labapart / gattlib

Library to access GATT information from BLE (Bluetooth Low Energy) devices
http://labapart.com/
461 stars 161 forks source link

gattlib_write_char_by_handle stalls #31

Open mweal-ed opened 7 years ago

mweal-ed commented 7 years ago

I'm not sure if this is a problem in gattlib or the underlying bluez/kernel drivers, but it seems like about 1 in 5000 writes stall - stuck in the __while ( write_completed == FALSE )__ loop. Looking at the HCI traces in wireshark the write never made it down to the the hci device. I have tried this both on Ubuntu 16.04.2 LTS and Raspberry Pi 3, both with the same results.

I have tried changing gattlib_write_char_by_handle to use gatt_write_cmd instead of gatt_write_char, and the write still gets dropped.

Do you have any suggestions on what might be causing this problem (or where I should start looking)?

mweal-ed commented 7 years ago

I have been looking into this further and I believe the problem may have something to do with a conflict/race condition between "g_main_loop_run" in the "connection_thread" and the various "g_main_context_iteration" calls.

Note sure, but still looking, any help would be appreciated.

mweal-ed commented 7 years ago

fix in pull request #33