omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Bluetooth Peripheral Identification and Filtering

    Pythonista
    ble bluetooth uuid
    3
    4
    2650
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dan.kouba
      dan.kouba last edited by dan.kouba

      Hello,

      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 uuid and name. In my research, I have found that uuid is generated randomly, and can both change at any time and is different between devices. Therefore, uuid is 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, name is 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:

      1. A dictionary containing advertising data of a specific peripheral (Link)
      2. The scanForPeripheralsWithServices:options: method (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!

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        I think your best bet is to use objc. The cb module is fairly limited.

        1 Reply Last reply Reply Quote 0
        • dan.kouba
          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?

          1 Reply Last reply Reply Quote 0
          • ccc
            ccc last edited by

            https://github.com/omz/Pythonista-Issues

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors