Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn Windows laptop into iBeacon

I have a laptop with Bluetooth 4.0, or Bluetooth Low Energy if you will.

For testing purposes I'd like to turn this Windows 8 laptop into broadcasting a fake iBeacon UUID/MajorID/MinorID so I can test an App I wrote.

Is there any software available with which I can broadcast beacons? Or any API's or libraries with which I could (easily) write it myself?

Like this, but then for Windows: https://github.com/timd/MactsAsBeacon

An actual iBeacon is on its way here, but I'd love to already do some testing in the meanwhile.

like image 396
Bran van der Meer Avatar asked Dec 04 '22 05:12

Bran van der Meer


1 Answers

So, it is possible, but you need a Linux VM inside Windows 8. Here's a small guide.

Step 1: VirtualBox

  • Install VirtualBox and the VirtualBox Extention Pack, make sure they are the same version.
  • Create new Ubuntu Linux VM, mount an ubuntu installation CD, and install the OS. I used the server edition since a GUI would be unnecessary and slow everything down.
  • Make sure in the VM's settings the USB 2.0 controller is turned on, and you created a filter for your Bluetooth device.
  • Then start your VM and in the running VM window, enable sharing your bluetooth device: Menu Devices > USB Devices > select Bluetooth device.

Step 2: Linux

Run:

sudo apt-get install bluez
sudo hciconfig hci0 up
sudo hciconfig hci0 leadv 3
sudo hciconfig hci0 noscan
hciconfig

The last command should show UP RUNNING before you continue.

If you can't find the hci0 device, you probably have incorrect VM usb filter settings, or your device is in use by Windows. I found that disabling and enabling the device in the Windows Device Manager helped the VM recognize it. When you enabled sharing the bluetooth device from VirtualBox, the Device Manager should show a greyed-out bluetooth adapter when you've selected 'Shown hidden devices'.

Step 3: Assemble your broadcast command

  1. Generate a UUID: python -c 'import sys,uuid; sys.stdout.write(uuid.uuid4().hex)'
  2. The format of the command will be:
    1. hcitool -i hci0 cmd 0x08 0x0008
    2. 1E 02 01 1A 1A FF (iBeacon-specific flags)
    3. Company ID, 4C 00 is Apple
    4. 02 15 (iBeacon advertisement indicator)
    5. UUID: 16 pairs of 2 hex numbers, separated by spaces
    6. Major ID: 00 00
    7. Minor ID: 00 00
    8. Calibrated Tx power: C8 00, or short: C8

Your command should look something like this, replace the __ with your UUID:

sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ 00 00 00 00 C8

Step 4: Start broadcasting!

Example command:

sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8

If that command was succesful, it should keep transmitting. Grab your Android or iPhone device and install the iBeacon locate app to see if you can find your beacon broadcasted.

Happy app debugging!

Credits: a lot of the idea's were stolen from this article.

like image 189
Bran van der Meer Avatar answered Jan 11 '23 01:01

Bran van der Meer