Hi all,
I'm working with a peripheral that will connect to an ios 7 device through a BLE connection. Once connected, the device will function as a GATT client and subscribe to ANCS (I saw a developer video that claimed that if you subscribe to ANCS, then ios should manager automatically reconnecting for you, but it was unclear how bonding was involved in this). The device connects, initiates bonding, and the device appears to successfully bond. It shows up as connected and paired in the phone list of Bluetooth devices. The problem I'm running into though, is that if the connection is lost (device disables bluetooth, goes out of range, phone/device turned off, etc.), I can't get the device to reconnect. For example, I have my device and phone paired. I turn the device off so the connection is lost, then turn it back on.
When the connection is lost, I get the following logs from the phone:
securityd[86] <Error>: SecErrorGetOSStatus unknown error domain: com.apple.security.sos.error for error: The operation couldnt be completed. (com.apple.security.sos.error error 2 - Public Key not available - failed to register before call)
securityd[86] <Error>: securityd_xpc_dictionary_handler sbd[119] DeviceInCircle The operation couldnt be completed. (com.apple.security.sos.error error 2 - Public Key not available - failed to register before call)
profiled[137] <Notice>: (Note ) profiled: Service stopping.
BTLEServer[135] <Notice>: (Note ) Peripheral "My Device #123" is now disconnected: Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly." UserInfo=0x16e91900 {NSLocalizedDescription=The connection has timed out unexpectedly.}
BTLEServer[135] <Notice>: (Note ) Connecting peripheral "My Device #123"...
Now though, if I turn my device back on, so it is broadcasting advertising data again, I should expect the iphone to automatically reconnect to the device, but it does not. Furthermore, if I try to connect to the device from the phone, it will not work. The phone gets the waiting icon, but otherwise does nothing until it pops up a connection unsuccessful message. There doesn't seem to be any logs associated with this connect attempt, and my LE packet sniffer does not see any data passed either. At this point, the only way to connect the device again is to select the "Forget this device" option, refresh the list, and then re-pair.
I've been trying to debug and see if there is something wrong with how my device handles the bonding process, but on a LE sniffer, I see the full SMP auth process, from Security and Pairing Requests, to both slave and master Signing Information packets, and I don't see anything wrong with it. No failure or error packets.
During the bonding process, looking at the iphone debug logs, I get the following error logs repeatedly (about 25-30 times):
securityd[86] <Error>: SecErrorGetOSStatus unknown error domain: com.apple.security.sos.error for error: The operation couldnt be completed. (com.apple.security.sos.error error 2 - Public Key not available - failed to register before call)
securityd[86] <Error>: securityd_xpc_dictionary_handler sbd[119] DeviceInCircle The operation couldnt be completed. (com.apple.security.sos.error error 2 - Public Key not available - failedto register before call)
That seems to be highly suspicious, but as the SMP packets passing back and forth between my device and the iphone all look to be fine, I haven't been able to figure out what is going wrong.
So, the questions I have for the list:
Has anyone successfully paired a device over BLE such that it will automatically reconnect without using an app?
Has anyone seen these errors I'm getting, and might know why I'm getting them, how to fix them, or if they are even a problem?