NordicSemiconductor / IOS-nRF-Connect-Device-Manager

A mobile management library for devices supporting nRF Connect Device Manager.
https://www.nordicsemi.com/Software-and-tools/Software/nRF-Connect-SDK
Apache License 2.0
88 stars 40 forks source link

Fix: Wait for Write Without Response Buffer #116

Closed dinesharjani closed 1 year ago

dinesharjani commented 1 year ago

Core Bluetooth has a buffer when we give it Data to send / write with the writeValue API. Each Device has a different limit, but after 10 packets for sure, could be more, the API stops 'adding' or accepting Data, and so doesn't send it. There are other solutions for this, like a proper API callback for when you can send. We opted for a 'spinlock' solution of checking and waiting whether we can send. But we don't do it packet by packet, because it's too slow and CoreBluetooth is going to tell us every time that we should wait. So instead, we set a target of 10 writes, we wait for as many Connection Intervals as is necessary, and then keep writing. We get decent speed I'd say, and previous working use cases for DFU should not be affected.