Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE HID does not work on Raspberry Pi #121

Closed
drewskoots opened this issue Mar 12, 2021 · 4 comments
Closed

BLE HID does not work on Raspberry Pi #121

drewskoots opened this issue Mar 12, 2021 · 4 comments

Comments

@drewskoots
Copy link

I'm trying to port this tutorial to my raspberry pi zero, but upon running the script I get the following error:

Traceback (most recent call last):
  File "code.py", line 22, in <module>
    hid = HIDService()
  File "/usr/local/lib/python3.7/dist-packages/adafruit_ble/services/standard/hid.py", line 324, in __init__
    super().__init__(report_map=hid_descriptor)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_ble/services/__init__.py", line 70, in __init__
    getattr(self, class_attr)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_ble/characteristics/__init__.py", line 142, in __get__
    return bleio_characteristic.value
  File "/usr/local/lib/python3.7/dist-packages/_bleio/characteristic.py", line 183, in value
    self.service.connection._bleak_client.read_gatt_char(self.uuid._bleak_uuid)
AttributeError: 'NoneType' object has no attribute '_bleak_client'

This seems to be pretty far down the stack, so I'm finding it very difficult to debug. Does anyone have any tips on what could be the issue? Is it a fundamental hardware issue or can I tweak the code to make it run on my raspi0. I'm not very well versed in BLE, so I was hoping someone with more expertise could maybe offer some insight. I'd greatly appreciate any help :)

@dhalbert
Copy link
Collaborator

dhalbert commented Mar 12, 2021

Are you trying to get the Rpi to act as an HID keyboard? The RPi, using adafruit-blinka-bleio, and bleak, can only act as a BLE central, and the HID code acts as a peripheral.

@drewskoots
Copy link
Author

Yes, the idea is that I would like the raspi to send a series of keypresses to my computer when I push a button. Preferably over bluetooth rather than over USB.

@dhalbert
Copy link
Collaborator

Unfortunately, the underlying bleak layer does not support that. It can't advertise, because it's a central only. See hbldh/bleak#81. We don't know of another underlying multi-platform library we can use that would be able to act as a peripheral.

Other people have wanted to do this, but I haven't found an example of an existing project.

@drewskoots
Copy link
Author

Ok, that's too bad. I definitely appreciate you helping me get a definitive answer here though. I'll see if I can achieve the same functionality with a different approach!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants