Tuesday, August 9, 2016

Random WordPress notes


  1. To make sure no one can access your plugin files directly, add this line at the very top of your plugin code:
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  2. To validate the the contents of the form request came from the current site and not somewhere else, use nonce field

Random JavaScript notes

  1. name or id of any HTML element cannot be same as the name of the JS function that element is used to call.
    e.g. <input name="foo" id="foo" onclick "foo()" /> 
  2. Consider using 'map', 'filter' and 'reduce'; instead of loops

Making Bluetooth headset work with Windows 7 (64 bit)

I recently bought a Bluetooth headset (iBall Pulse BT4), which I wanted to use on my PC. Obviously I also bought a plug-n-play USB Bluetooth adapter, thinking all I need to do is plug it into the USB port and turn on my new headset. But as you may have guessed, things proved to be little trickier than I thought.

The thing was working fine with my phone. So it had no problem pairing with any device which had in-built Bluetooth. It was also being detected and installed (added) on the PC. But no matter what I did, it wasn't ready to pair with BT adapter attached to my PC.

Then began endless session of trying Windows troubleshoot (yes, I did try that), trying to find the solution on Internet, contacting the tech support etc. Soon I learnt that the cheap BT dongle I was using had Bluetooth version 2.0, which was no good for audio streaming. So I bough another dongle, this time a version 4.0. But still there was no luck.

Also, most common solution I found online, for "Bluetooth peripheral device driver not found" error, didn't work. It asked to go to Device Manager > Bluetooth, right click on Bluetooth Peripheral Device > Update Driver > Browse my computer for driver software > Let me pick from a list of device drivers on my computer, and then selecting Microsoft generic driver.

Then after getting my friend to help and frustration of couple of days, suddenly that thing worked! But being very bad at remembering things (that's why the name of the blog), I could not figure out exactly what, out of dozens of things I had tried recently, had made it work.

But then, for some deep ultra-technical reason (called my fuck-up), I had to format and re-install Windows on my machine. I took this chance and kept record of what I did this time to make the headset work again. And now, I present it to you.

I am not an expert at all. It is just what I did. It worked for me. Don't know about you. Good luck if you are trying to do it the same way as I did.

Here's what I have:
Motherboard: Asus
OS: Windows 7 (64 bit)
BT Headset: iBall Pulse BT4
BT USB Adapter: Bluetooth CSR 4.0 Dongle

What I did:
  1. Created System Repair Disk
  2. Created System Restore Point
  3. Installed CSR BT Dongle using CD which came with it
  4. Downloaded and installed Lenovo Bluetooth drivers (yes, Lenovo. Asus drivers won't work)
    https://download.lenovo.com/ibmdl/pub/pc/pccbbs/thinkcentre_drivers/c2blt01us17.exe
  5. Disconnected my wired headsets from PC. Audio streaming won't go to USB port if any other audio devices are already connected.
  6. Added headset using Add Device in Devices and Printers (fairly simple process)
  7. Allowed Windows Updates (Install only the drivers not found on my PC)
  8. In Devices and Printers right click on iBall Pulse > Properties > Hardware > Advanced Audio Distribution Profile (Sink) > Properties > Change Settings > Driver > Update Driver
  9. Driver was downloaded and installed
  10. Restarted the headset, unplugged and plugged the BT dongle again
  11. Ta-da! It paired successfully.
Sometimes, when I switch off the headset or BT adapter or the PC, I have problem with pairing. Then I go back to iBall Pulse > Properties > Hardware > iBall Pulse (Stereo Audio) > Properties > Change Settings > Driver > Roll Back Driver, and then Update Driver again. (EDIT: Before trying this, try UPDATE 1. That method is far more simple and faster than this one.)

I haven't tested this for any other PC/headset combination. Hopefully you won't break anything while trying this. Have fun.

UPDATE 1: Now when the headset won't pair with bluetooth dongle, I do the following:
Switch OFF the headset, remove the dongle, switch ON the headset and insert dongle again (in this specific order).
[if the above mentioned method does not work, try the method given below.]
Go to Devices and Printers. It shows an icon for iBall Pulse bluetooth headset (if dongle is connected and headset is ON in pairing mode). Right click on it and click Remove device. Confirm and let it remove. Then keep bluetooth dongle and headset ON in pairing mode and click Add a device. Pop up window should show headset icon. Double-click to add it and let the install finish. Sometimes it will pair instantly. If not, simply switch OFF the headset, remove the dongle, switch ON the headset and insert dongle again (in this specific order).

UPDATE 2: I have noticed that it often causes problem if I switch ON the headset after I have inserted the dongle. So when starting, first switch ON the headset and then insert the dongle. Also, when removing, it is better to switch OFF the headset first and then remove the dongle.

UPDATE 3: If you pair the headset with some other device, then it also may cause problems when you try to pair with your PC again.