Skip to content

registerForNotify BLEUUID("0x2902") ERROR: UUID value not 2, 4, 16 or 36 bytes #618

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

Closed
yuyi1005 opened this issue Aug 4, 2018 · 9 comments

Comments

@yuyi1005
Copy link

yuyi1005 commented Aug 4, 2018

I am using the example of the BLE_client collecting data from a BLE server, which supports only "notify" characteristic, but it crashes in registerForNotify().

I am using the latest code in esp32-snippets, and I have found the wrong point as follow.

BLERemoteCharacteristic.cpp
Line 504: BLERemoteDescriptor *desc = getDescriptor(BLEUUID("0x2902"));

length("0x2902") is always 6, which leads to the error "UUID value not 2, 4, 16 or 36 bytes".

Here is the log:

  • Found our characteristic
    [D][BLERemoteCharacteristic.cpp:484] registerForNotify(): >> registerForNotify(): Characteristic: uuid: 49535343-1e4d-4bd9-ba61-23c647249616, handle: 42 0x2a, props: broadcast: 0, read: 0, write_nr: 0, write: 0, notify: 1, indicate: 0, auth: 0
    [E][BLEUUID.cpp:115] BLEUUID(): ERROR: UUID value not 2, 4, 16 or 36 bytes
    [D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_REG_FOR_NOTIFY_EVT
    [D][BLERemoteCharacteristic.cpp:364] getDescriptor(): >> getDescriptor: uuid:
    [D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_REG_FOR_NOTIFY_EVT
    [D][BLERemoteCharacteristic.cpp:372] getDescriptor(): << getDescriptor: Not found
    [Guru Meditation Error: Core 1 panic'ed (LoadProhibited)
    . Exception was unhandled.
@chegewara
Copy link
Collaborator

Hi, i will check it but for now you can change it to:
BLERemoteDescriptor *desc = getDescriptor(BLEUUID((uint16_t)0x2902));

@yuyi1005
Copy link
Author

yuyi1005 commented Aug 6, 2018

Thanks! Now it can work most of the time, but yet there is a problem.

As I have five BLE servers to read data from by turns, I try to connect and disconnect for many times, but it stuck after a few minutes.

The log:

E (106920) BT_GATT: application already registered.
E (106920) BT_APPL: Register with GATT stack failed.
E (106981) BT_APPL: bta_gattc_process_api_open Failed, unknown client_if: 0

It seems that the program is stuck in:
BLEClient.cpp
Line 99: esp_err_t errRc = ::esp_ble_gattc_app_register(0);

@hetlelid
Copy link
Contributor

Should the cast fix from chegewara be implementet in the codebase?

@chegewara
Copy link
Collaborator

Could you try BLEUUID("2902")?

@hetlelid
Copy link
Contributor

hetlelid commented Sep 23, 2018

Did not work. see below. (cast fix works)

How do i check for the callbacks, there should be a loop somewhere?


BLERemoteDescriptor *desc = getDescriptor(BLEUUID("2902"));

Throws:

[D][BLERemoteCharacteristic.cpp:364] getDescriptor(): >> getDescriptor: uuid: 32303932-0000-1000-8000-00805f9b34fb [D][BLERemoteCharacteristic.cpp:372] getDescriptor(): << getDescriptor: Not found


BLERemoteDescriptor *desc = getDescriptor(BLEUUID((uint16_t)0x2902));

Throws:

[D][BLERemoteCharacteristic.cpp:364] getDescriptor(): >> getDescriptor: uuid: 00002902-0000-1000-8000-00805f9b34fb [D][BLERemoteCharacteristic.cpp:368] getDescriptor(): << getDescriptor: found

@chegewara
Copy link
Collaborator

Its taken literally, each digit is converted to ascii, which is wrong.

What do you mean check for callbacks? No, the isn't any loop.

@hetlelid
Copy link
Contributor

My BLE device can both serve READ and NOTIFY on the same characteristic. So its a bit confusing.
I mean, after i do the registerForNotify(), how to i display the value (content) coming from the notification packet?
pRemoteCharacteristic->readValue(); is for direct READ, do i use the same function for NOTIFY?
(Sorry, this is probably hijacking og the thread)

But back to the topic. Do you have any conserns about your uint16_t type cast fix?

@chegewara
Copy link
Collaborator

You can have registerForNotify() for each remote characteristic that is serving notify or indicate, and you can in addition setCallbacks() for each characteristic that can be read/write. You can also find examples about it.
https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLETests/SampleRead.cpp#L25-L46

@chegewara
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants