Fixed handling cancelled bonding for read/write operations #597
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #552, again.
Write and read requests trigger bonding when sent using an unsecured link to a protected attribute. If bonding fails, e.g. it's cancelled, there are 2 things happening:
onCharacteristicRead
callback. This will be ignored.In both cases, the bond state broadcast receiver gets transition
BOND-BONDING
->BOND_NONE
. This PR adds a code to fail awaiting request of write/read type.If no GATT operation is performed withing 3 seconds after bonding fails, the device gets disconnected (Android disconnects, not the library). However, if there is any GATT operation enqueued and will be executed, the phone continues as if nothing happened. It can trigger bonding again and again. At some point, if bonding state changed to
BOND_NONE
, call to a protected attribute will generate status 5 (BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION
). This means, that Android will not try to bond again, and the request is getting failed immediately.