Bluetooth Peripheral Identification and Filtering
dan.kouba last edited by dan.kouba
I am working on an application that will connect to a bluetooth LE device (A Particle Boron) that I have written the firmware for. In my search to figure out how to connect to my peripheral device, I have discovered some limitations in the core bluetooth implementation in Pythonisa and wanted to bring this to the attention of the dev team.
When a peripheral is discovered, the two pieces of identifying information that are exposed from iOS's Core Bluetooth stack are
name. In my research, I have found that
uuidis generated randomly, and can both change at any time and is different between devices. Therefore,
uuidis out for identifying my device since I have no control over it. I then looked into using
name, but despite my best efforts I was unable to ever find my device when searching for the local name I put in the advertising data. Turns out,
nameis pulled from a cache if the device has ever identified itself under a name before to an iOS device. I have implemented a custom local name in the advertisement data which I was hoping to use as a filtering tool (as it is done in the heart rate monitor demo code in the Pythonista core bluetooth docs), but since it is only ever picking up the original cached name, this makes it useless as a filtering tool as well.
Now, I know the originally identified name of my hardware (e.g.
Boron-XXXXXX), but it is specific and unique to my hardware device, and any other hardware device I load my code onto will have its own unique name (e.g.
Boron-YYYYYY). Therefore, I cannot use it to find my class of devices unless I connect to every one with a specific prefix (
Boron-*) and inspect its services for the one I have implemented, which is slow and not sustainable in an environment in which multiple of these devices may exist.
I looked into the core bluetooth docs for iOS and two things are exposed that may solve this issue:
- A dictionary containing advertising data of a specific peripheral (Link)
Is there any way that these could be exposed through the Python wrapper for the CB module? It would be greatly helpful for my use case, and I'm sure others' as well. Let me know how I can make this happen!
JonB last edited by
I think your best bet is to use objc. The cb module is fairly limited.
dan.kouba last edited by
That's the reality of my specific situation at this time, but I was hoping to log this as a feature request. Not sure if there is a better venue for that?
ccc last edited by