scratchfoundation / scratch-link

Device interoperability layer for Windows and MacOS
BSD 3-Clause "New" or "Revised" License
102 stars 83 forks source link

Cache all characteristics in all services once a peripheral is connected #155

Closed terado0618 closed 4 years ago

terado0618 commented 4 years ago

Resolves

Resolves #151

Proposed Changes

Reason for Changes

I encounter an annoying issue that read/write for each characteristic has a delay (approximately 1 second) on Windows. This delay is caused by service.GetCharacteristicsAsync(BluetoothCacheMode.Uncached) in BLESession#GetEndpoint() which takes 1 second on my development PC with a bluetooth adapter.

Avoid this, I would like to propose this PR to cache all characteristics once a peripheral is connected.

Fortunately this does not significantly increase duration on connecting phase to the peripheral.

Additional duration
micro:bit 1.9 s
LEGO BOOST 1.2 s