Hi: First post
I have an issue where I'm using the ESP32 as an BLE CLIENT connecting to a BLE sensor from Nordic.
According to Nordic, If I want to receive notifications from a changed characteristic I should write 1 to the CCC (2902).
Anyway, I can connect, list the characteristics and see if they support notify or not, but using:
pRemoteCharacteristic->registerForNotify( notifyCallback );
doesn't do anything. So I suppose that the notification enabling doesn't work or I'm missing something, namely the 1 write to the CCC.
Any ideas to where I can debug this?
ESP32 as BLE Client and remote server notification
-
- Posts: 2
- Joined: Mon Dec 11, 2017 10:11 am
Re: ESP32 as BLE Client and remote server notification
Take a look at https://github.com/nkolban/ESP32_BLE_Arduino and see if it does what you need.
Re: ESP32 as BLE Client and remote server notification
You need to have some callback and nothing more, this is from BLE_client example:
If code is good then it should works (tested yesterday).
https://github.com/nkolban/ESP32_BLE_Ar ... client.ino
Code: Select all
static void notifyCallback(
BLERemoteCharacteristic* pBLERemoteCharacteristic,
uint8_t* pData,
size_t length,
bool isNotify) {
Serial.print("Notify callback for characteristic ");
Serial.print(pBLERemoteCharacteristic->getUUID().toString().c_str());
Serial.print(" of data length ");
Serial.println(length);
}
https://github.com/nkolban/ESP32_BLE_Ar ... client.ino
-
- Posts: 2
- Joined: Mon Dec 11, 2017 10:11 am
Re: ESP32 as BLE Client and remote server notification
Thanks for the answers, and Yes I'm using the BLE_client examples from ESP32 BLE arduino.
My issue is that the callback is never called.
It's worth mentioning that the advertising UUID is different to the service UUID where I connect to, so I needed a little modification, namely scan for one UUID and after connection to the BLE device server, connect to a specific service and then get the temperature characteristic.
This works without any issue, since I've also added a lot of debug messages to the ESP32 BLE Arduino code, and it seems that everything is working as it should, but, after registering for the notification for that specific characteristic, the callback is never fired.
My issue is that the callback is never called.
It's worth mentioning that the advertising UUID is different to the service UUID where I connect to, so I needed a little modification, namely scan for one UUID and after connection to the BLE device server, connect to a specific service and then get the temperature characteristic.
This works without any issue, since I've also added a lot of debug messages to the ESP32 BLE Arduino code, and it seems that everything is working as it should, but, after registering for the notification for that specific characteristic, the callback is never fired.
Re: ESP32 as BLE Client and remote server notification
Hello
I had the same isue. Fixed with this:
const uint8_t v[]={0x1,0x0};
pRemoteCharacteristic->registerForNotify(notifyCallback);
pRemoteCharacteristic->getDescriptor(BLEUUID((uint16_t)0x2902))->writeValue((uint8_t*)v,2,true);
Regards
I had the same isue. Fixed with this:
const uint8_t v[]={0x1,0x0};
pRemoteCharacteristic->registerForNotify(notifyCallback);
pRemoteCharacteristic->getDescriptor(BLEUUID((uint16_t)0x2902))->writeValue((uint8_t*)v,2,true);
Regards
Who is online
Users browsing this forum: No registered users and 117 guests