not receiving BLE notifications on pycom fipy
-
Hello,
I am trying to receive bluetooth NOTIFY messages using the FiPy.
The script I am running is as follows:
from network import Bluetooth def mycb(chr): print("Callback succesful!") bt = Bluetooth() if not bt.isscanning(): #scan for devices bt.start_scan(-1) while True: adv = bt.get_adv() if adv and adv.mac == b"my_dev_mac": try: conn = bt.connect(adv.mac) services = conn.services() for service in services: if service.uuid() == b'my_serv_uuid': chars = service.characteristics() for char in chars: if char.uuid() == b'my_char_uuid': char.callback(trigger = Bluetooth.CHAR_NOTIFY_EVENT, handler=mycb)Using a different app (nRF on android) I can see the NOTIFYs being transmitted, so it's certain they are being transmitted. Reading and writing values also works fine, however the callback does not seem to work.
What am I missing?
Sincerely,
Robert -
@Robert-N have you checked that you actually get the service and characteristic and that the callback is correctly installed?
-
@jcaron I am certain the services and characteristics are being transmitted, as I can read them. I am not quite sure what you mean by "callback being correctly installed", do I need to install the callback seperately? Is this not something that works out of the box?
-
@Robert-N I mean, are you sure ˋchar.callback` is actually called? Add a trace there to make sure that happens. Just to make sure it’s not some stupid typo or something that prevents it from being executed.
-
@jcaron I am sure that the callback works, I have gotten into the callback when using the nRF connect app as a server and sending notifications with that server. However after further tracing, it seems that I cannot properly subscribe to the NOTIFY characteristic. To subscribe for notifications it seems that you have to send a value to the descriptor, not the characteristic as I have been trying. The same problem got mentioned here: https://github.com/pycom/pycom-micropython-sigfox/issues/37, although it is still not clear how to write to the descriptor. Is there any way to write to the descriptor?
-
@Robert-N have you had any success with notify egen connecting a pycom board as a client to a server (sensor) or is this not possible?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login