This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Disconnected peripheral reconnects direct in iOS.

Hi, Got stuck on an issue that has come and gone and then working fine, and are now back again.

I use a nrf51 module with the led-button-service example (sdk 5.2). It's not using bondmgr, just scan for known or recently connected peripherals. I modified the example to have 4 characteristics and to wakeup each 60 seconds to sample ADC values. In the timer event I call start advertise, which is set to 6 seconds. After update-notify two of the characteristics value I disconnect from iOS (stop notifyValue on chars and cancel connection). I am using the iOS connect functions to restore state and connectPeripheral so it get started even i background mode.

Is there anything obvious I am missing?, I can see that the peripheral reconnects direct after I cancelConnection in iOS, and the only clue I got is that it does that for the same amount of time I have set the Advertising inteval to, in this case 6s.

Does the softdevice still advertise for connection attempt after it has passed the connected state? I have tried to stop advertise sd_ble_gap_stop(), but then it will not connect next time.

Thanks in advance!

Parents
  • Maybee iOS issue, cause the peripheral is still around for ca 6sec in my case (adv timout not affecting this 6s). Turned of notifying to just read, same prob. The cancelPeripheralConnection is non blocking, followed by issuing connectPeripheral on the current peripheral object, to the App, the connection is gone, but to iOS it could be active for other App etc. A workaround could be to wait and disconnect, but the background execution time windows might be gone for proper reconnect block call. I also tried to write to a characteristic to disconnect from the peripheral side, WithResponse that caused the valid parameters for on_write, but had weird connection and value update issues if disconnect in TX_READY event etc. I guess the best way would be to find some event when stack is ready to be closed. Tested some other posted solutions, but not quite got it working smothly. Any suggestions?

Reply
  • Maybee iOS issue, cause the peripheral is still around for ca 6sec in my case (adv timout not affecting this 6s). Turned of notifying to just read, same prob. The cancelPeripheralConnection is non blocking, followed by issuing connectPeripheral on the current peripheral object, to the App, the connection is gone, but to iOS it could be active for other App etc. A workaround could be to wait and disconnect, but the background execution time windows might be gone for proper reconnect block call. I also tried to write to a characteristic to disconnect from the peripheral side, WithResponse that caused the valid parameters for on_write, but had weird connection and value update issues if disconnect in TX_READY event etc. I guess the best way would be to find some event when stack is ready to be closed. Tested some other posted solutions, but not quite got it working smothly. Any suggestions?

Children
No Data
Related