ESP32 as BLE Client and remote server notification

RisenRyzen
Posts: 2
Joined: Mon Dec 11, 2017 10:11 am

ESP32 as BLE Client and remote server notification

Postby RisenRyzen » Mon Dec 11, 2017 10:16 am

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?

-Rudy-
Posts: 31
Joined: Sun Feb 05, 2017 1:08 am

Re: ESP32 as BLE Client and remote server notification

Postby -Rudy- » Wed Dec 13, 2017 3:15 am

Take a look at https://github.com/nkolban/ESP32_BLE_Arduino and see if it does what you need.

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP32 as BLE Client and remote server notification

Postby chegewara » Wed Dec 13, 2017 6:49 am

You need to have some callback and nothing more, this is from BLE_client example:

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);
}
If code is good then it should works (tested yesterday).
https://github.com/nkolban/ESP32_BLE_Ar ... client.ino

RisenRyzen
Posts: 2
Joined: Mon Dec 11, 2017 10:11 am

Re: ESP32 as BLE Client and remote server notification

Postby RisenRyzen » Wed Dec 13, 2017 3:42 pm

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.

Looping40
Posts: 2
Joined: Mon Feb 19, 2018 8:08 am

Re: ESP32 as BLE Client and remote server notification

Postby Looping40 » Mon Feb 19, 2018 8:12 am

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

Who is online

Users browsing this forum: No registered users and 120 guests