steamclock / bluejay

A simple Swift framework for building reliable Bluetooth LE apps.
MIT License
1.09k stars 98 forks source link

Fix problems with timeouts on listens not working as expected with partial data received or data overflow #247

Closed nbrooke closed 3 years ago

nbrooke commented 3 years ago

For #240, #242

Summary of Problem:

There were a couple of rare error states that could happen if timeouts happened in the middle of a multi part listen, or if writeAndAssemble received more data than expected that were not being handled correctly (could fail to throw an error, could leave the bluetooth stack in a weird state where late operations would fail).

Proposed Solution:

Testing Completed and Required:

Verified the behaviour of all the failure modes for write and assemble inside another app. The error edge cases for this are strange enough that it is a little tricky to test them in the real world, writeAndAssemble can be tested artificially by lying about the expected amount of data, but its not clear how to verify the correct behaviour of listen and writeAndListen without hardware that causes the behaviour. The changes are relatively low risk though, given the the changes are identical to writeAndListen, which CAN be tested.