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 registerForNotify not working (with workaround) #628
Comments
This register for notifications only on local esp32 device only: On arduino you still need this workaround. Its been added to this repository, but no new arduino version has been generated for some time and changes are not included yet. |
Thankyou chegewara, that makes sense. |
Unfortunatly the workaround isn't working on my device... I'm doing a manual reading of the characteristic to make sure measurement is working:
which results in this output:
all fine here. now i try to activate notification (with workaround)
output:
apparently (according to debug message) there is one last Notification work fine with nRF-Connect. |
@EBZ-Krisemendt I have one question, because logs shows that notification is received, are you trying to read characteristic value from within notificationCallback? If yes then it wont work, because for some reason (im guessing its some issue with semaphores) any action (read/write) called from notification callback is blocking whole app. You need to set some bool variable when you receive notification and in loop if variable is true then read characteristic. |
@chegewara to anwser your question: yes, i did indeed. changed it to a volatile bool "trigger" variable and now it works like a charm. thx very much. maybe this is worth noting in the comments within the example code to prevent others from falling in this pit. |
To be honest it was very annoying, i lost many hours before i found it by myself. |
Hi
I'm using v0.4.16 of the ESP32 BLE Arduino Library.
I have created a BLE server on an ESP32 board with 2 characteristics based on the BLE_notify example. This works as expected with the nRF Connect app on my phone: I can read values and get notifications.
I have created a BLE client on a second ESP32 board based on the BLE_client example, to connect to the server, register for notifications and output the value (on LEDs). This connects to the server and reads the initial value correctly. However this line does not work:
pRemoteCharacteristic->registerForNotify(notifyCallback);
I don't get an error, it just doesn't receive any notifications.
If I do the following, everything works fine:
The following code does not work either:
Is 'registerForNotify()' supposed to work when called without also writing to the descriptor manually?
If I first connect with the nRF Connect app, register for notifications, disconnect and reboot the client board, 'registerForNotify()' on its own works fine and receives the notifications. Simply connecting and disconnecting in nRF Connect didn't make it work, I had to register for the notifications.
I think there is something wrong with the server side of things, because I built a seperate project last week to display the output from a Speed/Cadence sensor, and only used 'registerForNotify()', and it works great.
I've attached the server code as a text file - can't upload an ino file.
BLE_server.txt
The text was updated successfully, but these errors were encountered: