Skip to content

Conversation

thebookins
Copy link
Contributor

@thebookins thebookins commented Feb 17, 2018

This PR fixes a few issues with authentication and bonding.

  1. In PeripheralManager+G5.swift writing to a characteristic that is not notifying should not throw and should return a Data object with zero bytes. Was previously failing a guard statement due to characteristic.value == nil.

  2. AppDelegate.swift was calling transmitter.resumeScanning on applicationDidBecomeActive. 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 calls resumeScanning if !transmitter.stayConnected.

  3. 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).

@thebookins thebookins changed the title fix bonding and characteristic write when not notifying fix some issues with authentication and bonding Feb 17, 2018
ps2 added a commit that referenced this pull request Feb 18, 2018
@thebookins
Copy link
Contributor Author

Resolved with #70 and #73. Thanks @ps2!

@thebookins thebookins closed this Feb 22, 2018
@thebookins thebookins deleted the bonding branch May 12, 2018 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant