Emulating Bluetooth LE Peripheral on Mac OS X Mavericks


This post documents some interesting Mac OS X Bluetooth LE peripheral examples I have found.

Arbitrary Bluetooth Peripheral

Clone example from https://github.com/sandeepmistry/osx-ble-peripheral.

An issue is that it duplicates peripheral services after Bluetooth is turned off/on. Calling removeAllServices of CBPeripheralManager, fixes that.

You can also use IOBluetoothDevice API to iterate through connected Central devices. We found situations when after starting the peripheral app, the central app running on an iPhone would not establish Bluetooth LE communication. We were able to use IOBluetoothDevice to force disconnect all connected devices at app start on the Mac, to skirt the issue.

Advertising an iBeacon

Clone example from https://github.com/mttrb/BeaconOSX. Appears on the LightBlue app, but need to actually use it as an iBeacon. Check author’s blog at http://www.blendedcocoa.com/blog/2013/11/02/mavericks-as-an-ibeacon/ for further details. On a side note, you can create an iBeacon using a Raspberry Pi and an off-the-shelf USB dongle.

4 thoughts on “Emulating Bluetooth LE Peripheral on Mac OS X Mavericks

      1.     for(IOBluetoothDevice *device in devices) {
                if(device && [device isConnected]){
                    [device closeConnection];
                }
            }
        

        Where, devices can be obtained by looking up recentDevices

            NSArray *devices = [IOBluetoothDevice recentDevices:5];
        

        Or, by using registerForConnectNotifications

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s