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

binc_application_set_char_updated_cb #55

Open abqjln opened 2 weeks ago

abqjln commented 2 weeks ago

Infrastructure is all there, but did not find this cb. Used to free temporary GByteArrays after binc_application_set_char_values.

Ex: when central/client requests a characteristic read , my server does GByteArray gbarray = g_byte_array_new(); g_byte_array_append( gbarray, &value, 1); binc_application_set_char_value(application, service_uuid, char_uuid, gbarray ); g_byte_array_free( gbarray, TRUE ); --> IF DO THIS Glib fails with g_atomic_ref_count_dec: assertion 'old_value > 0'

Putting the free in this cb frees only after the gbarray above is consumed.

weliem commented 2 weeks ago

You shouldn't do g_byte_array_free( gbarray, TRUE );. The library will free it once it is not needed anymore.

abqjln commented 1 week ago

Thank you!--that explains other issues I am having. My server has global structures with GByteArray elements to serve mullitple clients--the second client always fails, suspect due to having been freed. I will test. using local temporary GByteArrays.