Hello!
I am having an intermittent issue, where I get an unexpected disconnect from our hardware peripheral (which uses the Nordic nrf8001 chip) about 1 out of 20 times.
The disconnect always happens at exactly the same place. Here is my connection sequence:
-
central.scanForPeripheralsWithServices([serviceUUIDUART], options: nil)
didDiscoverPeripheral -> look for matching name in advertisementData, if found continue with:
store a reference to peripheral as myPeripheral
central.connectPeripheral(peripheral, options: nil)
central.stopScan()
wait for didConnectPeripheral then call myPeripheral?.discoverServices([serviceUUIDUART])
Right here is where it fails, again about 1 out of 20 times.
I've posted my debug output log and the error code I receive in didDisconnectPeripheral.
This test is running in a loop, by the way, where we connect, discover services, send and receive data, then disconnect. Then we wait for, say, 6 second and start the loop over.
Has anyone else seen errors like this when connecting?
Found Peripheral 50000 <__NSConcreteUUID 0x1742250a0> 36DC3DDA-9384-D02F-BF95-12527501BB86
connected to peripheral <CBPeripheral: 0x1700f0d00, identifier = 36DC3DDA-9384-D02F-BF95-12527501BB86, name = 50000, state = connected>
my peripheral is <CBPeripheral: 0x1700f0d00, identifier = 36DC3DDA-9384-D02F-BF95-12527501BB86, name = 50000, state = connected>
going to discover services for Snail and VIU
disconnected from peripheral <CBPeripheral: 0x1700f0d00, identifier = 36DC3DDA-9384-D02F-BF95-12527501BB86, name = 50000, state = disconnected> for reasons Error Domain=CBErrorDomain Code=10 "The connection has failed unexpectedly." UserInfo=0x17426f980 {NSLocalizedDescription=The connection has failed unexpectedly.}
Thanks!
Justin