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