scratchfoundation / scratch-link

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

BLE connection allows 'discover' during discovery state #91

Open evhan55 opened 5 years ago

evhan55 commented 5 years ago

While a BLE socket is open over Scratch Link, it is possible to send multiple 'discover' requests on a single socket session (i.e. during an existing discovery state). While over a BT socket, attempting to do so returns an error: {"code":-32601,"message":"Method Not Found","data":"Cannot call discover in discovery state"}.

The Scratch Link documentation states that Scratch Link automatically handles scan renewal during discovery, and may terminate discovery if too much time has elapsed. This suggests that discovery should only be requested once per Scratch Link session, and that the observed BT behavior is correct.

Therefore, BLE should possibly also return an error when multiple 'discover' requests are sent on a single session.

See https://github.com/LLK/scratch-vm/issues/1671#issuecomment-432731064

This was tested with:

Scratch Link 1.1.2 1b61617
macOS Version 10.14 (Build 18A391)