Page 1 of 1

BT API support for C++

Posted: Mon Aug 26, 2024 6:36 pm
by x_arrange
Hi,

Dear IDF authors, this problem exists like since forever.

I wan't to write simple app on C++ but GAP/GATTS API doesn't support it. :cry:
I'm talking about event handlers.

Why esp_event_handler_register has custom arg parameter while neither esp_ble_gap_register_callback nor esp_ble_gatts_register_callback don't?

It's not so hard to add parameter and later call callback handler with it.
Please, add it in future releases

Re: BT API support for C++

Posted: Tue Aug 27, 2024 12:11 am
by ESP_Sprite
I agree that it's good practice to have some user pointer in callbacks in general terms, but is it really an issue here? Those callbacks you mention are system-wide (as in: you don't set the callbacks on an object or connection or whatever) so if the callback were to take a user pointer, that pointer would be exactly the same every time the callback would be called. In that case, the user pointer doesn't really add anything: you might as well use a global variable, and that saves the BT code from shuttling around the user pointer.