-
Notifications
You must be signed in to change notification settings - Fork 217
subscribe()/valueUpdated() not working #71
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
Comments
I had noticed the question raised about the failure to subscribe on the Arduino Forum and began to investigate. For what it's worth, I discovered that within this function BLERemoteCharacteristic::writeCccd(uint16_t value) it determines the number of descriptors with this call int numDescriptors = descriptorCount(); For some reason the Bluefruit device is returning 0. I ran the identical peripheral example using a BBC microbit and this correctly returns the value 2 (as in, there are two descriptors present for that characteristic 2901 and 2902). |
So would you say that it's a Nano33 BLE issue? Also I'm assuming you were able to subscribe on the BBC microbit. |
Yes, the Nano33 can subscribe to the BBC microbit as the Nano BLE central firmware can loop through the number of descriptors available from the BBC microbit and find 0x2902 to then apply the write value function. With Bluefruit, because number of descriptors is zero the Nano BLE central firmware bypasses and thus never updates the Bluefruit 0x2902. |
I see - any suggestions on how to fix the descriptorCount() function? Otherwise I'm going to order an ESP32 and be done with this :/. |
I've discovered that this is not as straightforward as one might think. I created a PSoC4 peripheral with the same GATT service + characteristics as the Bluefruit device but this time I did not implement the NOTIFY update functionality, just to see what happens (i.e. this should throw up an error). The ESP32 returns that all is OK, when it should not have done so - so in this case the ESP32 would have crashed or not received any values from NOTIFY. The nano BLE33 board (with ArduinoBLE library) interestingly finds the 2 descriptors (2901 and 2902) and says that it was able to update 2902 but then does not update the "fallback" option as the "if (_properties & (BLENotify | BLEIndicate))" was not true (with the Bluefruit device this was true but the cccd.writeValue must not return true for what ever reason).
|
Debug using BLE.debug(Serial) - nano BLE connecting with Bluefruit: Found f7:0f:7f:2d:4e:56 'Adafruit Bluefruit LE' 6e400001-b5a3-f393-e0a9-e50e24dcca9e |
I've found that within the writeValue function (BLERemoteDescriptor), the Bluefruit has resp[0] = 0x01, which triggers an error condition. Not sure what this means though. Trawling through that debug log I found that with the Bluefruit device we get: and with the BBC microbit device we get: |
Alright, so it seems that my issues are a combination of BlueFruit and ArduinoBLE incompatabilities. Debugging the library is unfortunately a bit past the scope of project, since it's due in a week. In general I would be interested in helping out however, so please let me know if there's anything you need me to do. |
Hi @willtmakinen78 and @Gerriko , Could you please try if this fix solves the issue? |
I am having the same issue with Nano RP4020. |
I've been using an Arduino Nano 33 BLE to communicate with my PC over the BlueFruit LE Friend's UART characteristic. Using the default ArduinoBLE library, I'm able to connect to the BlueFruit from the Nano33 as a central device, and write to the BlueFruit and have it show up in a serial terminal. I can get the Nano33 to read from the Bluefruit as well, by sending a Characteristic.read() request and a subsequent Charcterisitc.readValue() command. Subscribing to the rx characterisitic on the Nano33 is an issue, however, even though the Bluefruit's info page says that the rx characterisitc (address 0x0003) is capable of Notify. At first, Charcteristic.subscribe() would always return false, until I followed @gdsport's advice here and modified BLERemoteDescriptor.cpp. Now, although subscribe() returns true, Charcteristic.valueUpdated() always returns false, even when opening up a serial port to the BlueFruit and sending data with the UART service. This is the relevant Arduino code:
For reference, this is the modified code from BLERemoteDescriptor.cpp:
Any thoughts on what might be causing this?
Arduino IDE version 1.8.12 and ArduinoBLE version 1.1.2
The text was updated successfully, but these errors were encountered: