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.
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
BT API support for C++
-
- Posts: 9833
- Joined: Thu Nov 26, 2015 4:08 am
Re: BT API support for C++
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.
Re: BT API support for C++
Generally you may be right. But using C++ code adds so much to readability and clearness fo code.
I want to wrap all BT function into a class where callback will be static member with class pointer passed to it as user parameter
as it can be easily done to all other APIs of ESP32.
Sadly, many years it remains as is
I want to wrap all BT function into a class where callback will be static member with class pointer passed to it as user parameter
as it can be easily done to all other APIs of ESP32.
Sadly, many years it remains as is
-
- Posts: 9833
- Joined: Thu Nov 26, 2015 4:08 am
Re: BT API support for C++
My point is, as there is only one BT subsystem, you may just as well implement your BT C++ class as a singleton. There's no need for a callback parameter that way.
Who is online
Users browsing this forum: No registered users and 77 guests