Pairing to HID device with aioble #16093
Unanswered
kizmit99
asked this question in
Libraries & Drivers
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I suppose my questions really boil down to the following: Does the aioble library support pairing? If so, can anyone point me to an example showing how to do it? And, does aioble support concurrent connections to multiple devices?
My development experience has focused on Java (basically since its earliest releases, but primarily in the enterprise environment). I also have a decent amount of experience with C/C++, plus a smattering of experience in several other languages. My current project is interfacing a couple of BLE based VR-Ring controllers with an ESP32 family microcontroller. I have a working version of this interface running on the ESP32 written in C/C++ for the Arduino platform with the NimBLE library wrapper over the Espressif BLE library. As a learning experience I am trying to implement a similar interface running on MycroPython (v1.24.0) using the aoible library. I am not having much success and would appreciate any help folks have to offer...
The device I'm trying to connect to is a compliant HID device, but I am fine with not dealing with the HID Report Map. My working implementation basically does the following:
Initiate a scan
on AdvertisedDeviceCallback
Once scanning has provided a device of the correct name
on notifyCallback
I hope the above makes sense to anyone taking the time to read this :) I feel like providing the actual C code used to implement the above wouldn't add much to this discussion.
With the pseudo-code above you will notice that I never explicitly Pair with the device. However, when the HID_PROTOCOL_MODE characteristic is read, there is (apparently) something triggered behind the scenes that actually initiates and completes a pairing operation. If that read is not performed, the notification subscriptions fail.
So, when I try to connect with this device using aioble on MycroPython I'm following a similar pattern of scanning, connecting, getting the HID_SERVICE and looking up the Characteristics by UUID, but when I try to read from the characteristic I get a "GATTError: 271" thrown. The Nordic website shows a list of GATT errors and I find BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION defined as 0x010F (271 decimal). So I'm assuming I'm not getting an encrypted connection because I'm not actually paired with the device. Which leads to my original questions shown above. How do I initiate pairing with the aoible library?
My test code is shown here:
Note that I found this discussion topic: https://github.com/orgs/micropython/discussions/12674 which I believe is telling me that aoible does not support pairing and even if it did it would be complicated for me to connect to two devices at the same time anyway. Of course that discussion is directed towards the PICO implementation, and I'm running on ESP32 (in case that makes a difference).
Thank you in advance for any pointers.
Beta Was this translation helpful? Give feedback.
All reactions