bjoernQ / bleps

A toy-level BLE peripheral stack
MIT License
55 stars 18 forks source link

Notifications stopping after a write when the client is Linux #32

Closed dzamlo closed 10 months ago

dzamlo commented 10 months ago

I have a very strange issue. On Linux, when I listen for notification on a characteristic, notifications works OK, but as soon as I write to any characteristics (even in a different service) they stop. Re-asking for notifications make them works again until the next write.

I've used both the btleplug library and the official bluer library.

If I use the ble_server example from esp32-nimble, it works as expected.

If I use the nRF Connect app on android as the client, it works as expected.

There is some strange interaction between the Linux Bluetooth stack and bleps.

dzamlo commented 10 months ago

I have identified that the issue is related to the value of self.src_handle becoming 3 in the AttributeServer.

If on line 144 of attribute_server.rs in do_work_with_notification I hard code 1 instead of self.src_handle, this fix the issue.

This change happen on line 235.

I'm wondering if the line

self.src_handle = handle;

should be

self.src_handle = src_handle;

Like for WriteReq, but as I don't understand much about BLE for the moment, I'm not sure.