After disconnected, when user click the connect button again, there was an error The device must be opened first. This happens because the port object was already disconnected and will throw this error when a disconnect is called on a disconnected port.
No device selection dialog was offered when this happened.
Adding a line port=null after port.disconnect() just like the the rgb example fixed the error message and a device selection dialog will be offered each time
On console example, when a user disconnect the
port
, theport
object was not deleted like the rgb example https://github.com/webusb/arduino/blob/fab0eca52a6ea813e97607a75270bec1399dc77a/demos/rgb/rgb.js#L50After disconnected, when user click the
connect
button again, there was an errorThe device must be opened first
. This happens because theport
object was already disconnected and will throw this error when a disconnect is called on a disconnectedport
.No device selection dialog was offered when this happened.
Adding a line
port=null
afterport.disconnect()
just like the the rgb example fixed the error message and a device selection dialog will be offered each timeHope this helps.
JP