fix some issues with authentication and bonding #69
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 a few issues with authentication and bonding.
In
PeripheralManager+G5.swift
writing to a characteristic that is not notifying should not throw and should return aData
object with zero bytes. Was previously failing a guard statement due tocharacteristic.value == nil
.AppDelegate.swift
was callingtransmitter.resumeScanning
onapplicationDidBecomeActive
. This causes undesired behaviour. For example the function is called when the user accepts the pairing request, causing the transmitter to immediately disconnect. This PR only callsresumeScanning
if!transmitter.stayConnected
.After sending a bond request message, the auth characteristic does not respond to any read or write commands. Consequently this line always throws with a timeout error. Also, since the auth characteristic is not notifying, there is no way to be informed whether the user has accepted the pairing request. In this change we no longer try to query the auth status after bonding; rather we progress immediately to control, and allow the first step in control to timeout after 15s rather than the default 2. The result is that the control step proceeds once the user accepts the pairing request. If the user doesn't accept the pairing request, the transmitter simply disconnects and we have another chance on the next transmitter wakeup.
Also fixes debug messages like "Re-connecting to known peripheral #### in 4640537203540230144s" (string format specifier).