Bluetooth icon indicating copy to clipboard operation
Bluetooth copied to clipboard

Fix GATT Notifications

Open colemancda opened this issue 5 years ago • 5 comments

GATTServer should not be sending GATT notifications to the connected client that wrote the value.

  • [x] If the Peripheral wrote a new value, all connected clients should be notified.
  • [x] If a Central wrote a value, all connected centrals, except the one that wrote the value, should be notified.

colemancda avatar Jan 20 '19 22:01 colemancda

Initial work in https://github.com/PureSwift/Bluetooth/commit/ab33985b8621d122662be941b2a4f267cb80ba07 . Need to differentiate between:

  • [x] Write triggered by Peripheral (inform all Centrals)
  • [x] Write triggered by current Central (inform other Centrals)
  • [x] Write triggered by other Central (Inform this Central)

colemancda avatar Jan 20 '19 22:01 colemancda

Notifications for characteristics will not work for multiple characteristics with the same UUID in a service.

https://github.com/PureSwift/Bluetooth/blob/ab33985b8621d122662be941b2a4f267cb80ba07/Sources/GATTServer.swift#L280

colemancda avatar Jan 21 '19 01:01 colemancda

There seems to also be issues in the GATTClient implementation https://gist.github.com/wlisac/75650c0bc54ffb4a248b8aff306ff715

colemancda avatar Jan 21 '19 17:01 colemancda

I can confirm the there is an issue around GATTClient processing notifications. A peripheral receives and processes the subscribe request from the GATTClient and the unsubscribe request when the GATTClient is closed. Notifications sent by the peripheral are not being processed correctly by the GATTClient. Before I debug further I thought I’d ask if anyone else is actively working on this and if so what progress has been made?

sbrewin avatar Sep 01 '20 15:09 sbrewin

I am also getting this error Assertion failed: Invalid range: file /data/scanner/SwiftScanner/.build/checkouts/Bluetooth/Sources/BluetoothGATT/GATTClient.swift, line 470

Whenever I start a notify on characteristic. It doesn't happen every time but does once about 1 in 3 times.

justinmiller62 avatar Apr 27 '21 17:04 justinmiller62