Open rogerarchibald opened 2 days ago
In the Bluetooth logs, there is one write request that didn't get a write response from the peripheral. So this is likely the reason for the disconnect.
I don't think there is anything we can do about it in Bleak. The peripheral seems broken.
The peripheral works fine with the NRF Connect app.
The one write request that was sent twice is not common, looking at my logs it is normally written on the first attempt.
If I attempt to read prior to writing (i.e. immediately after the connection is made) the same disconnect problem occurs. In the BLE logs, there is not even an attempt to read: it just automatically disconnects.
Maybe there is something going on in my peripheral, but I can't see it from the sniffer.
It's also playing nice with simplePyBLE
With simplePyBLE are you doing write with response or write without response? Does the Bluetooth packet log look the same for both?
I'm not able to do Write Without Response using simplePyBLE...If I've got the peripheral set up as only write-without-response then the simplePyBLE crashes as soon as I try to send a write request: when this happens, I see nothing on the sniffer aside from the disconnect message. With my peripheral in this configuration, I can still write the characteristic OK using the NRF connect app.
When I change it back to write_with_response, everything looks solid.
I think the odd missed packet I was seeing previously was due to my debug setup: I had a Tag-Connect cable connected to my target board so I could print debug statements over SWO and the cable was routed right over my SOC/antenna. When I remove the cable I don't see any more repeat write requests.
bluetoothctl -v
) in case of Linux:Description
First off, I'm mainly an electronics guy and embedded developer so apologies in advance if I'm being ignorant here. I'm trying to develop a basic desktop app to get data from a BLE peripheral. I used the UART service example as a starting point for this. I have 4 characteristics in total: a read/notify status message, a write-only control value, a write-only enable characteristic and a read-only hour meter to count active time. I can write to the write characteristics without issue, but when I try to read or enable notifications on the status characteristic it immediately disconnects. If I watch the BLE packets with a sniffer, the read request doesn't happen: it just drops the connection. Likewise if I try to enable notifications, it just drops out right away.
I can read the hour meter characteristic without issue...I tried rearranging the characteristic declaration on my peripheral so that the status isn't the first characteristic in the GATT table to see if that might be the problem, but I get the same results.
I can read the characteristic with the NRF connect app as well as enable notifications and it seems to work normally. I'd appreciate if anybody might be able to point me towards the error of my ways here.
Here's the python in its entirety:
Here's the terminal output from the print statements: