weliem / bluez_inc

A C library for Bluez (BLE) that hides all DBus communication. It doesn't get easier than this. This library can also be used in C++.
MIT License
84 stars 19 forks source link

User data on all top-level `bluez_inc` types? #27

Closed charlesnicholson closed 5 months ago

charlesnicholson commented 5 months ago

Thanks for bluez_inc, it's so much easier to work with than bluez / dbus :)

A lot of the bluez_inc callbacks just give you an Adapter * or a Device *, but in a system that manages more than one adapter / device, it's hard to know which one is which. So, I need to end up writing some globally-accessible thread-safe data structure that I can pass these pointers to in exchange for some of my application context.

If there were functions like

void binc_adapter_set_user_data(Adapter *adapter, void *user_data);
void *binc_adapter_get_user_data(Adapter *adapter);

and

void binc_device_set_user_data(Device *device, void *user_data);
void *binc_device_get_user_data(Device *device);

Then it would be trivial to load up the bluez_inc objects with a pointer to my application context, and retrieve it in the various bluez_inc callbacks.

charlesnicholson commented 5 months ago

(Also, if the implementation is as simple as I'm making it sound, I'd happily throw together a PR for this)

weliem commented 5 months ago

Feel free to raise a PR!

weliem commented 5 months ago

Thanks!