scratchfoundation / scratch-link

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

Micro bit disconnect shortly after connection #52

Closed BryceLTaylor closed 6 years ago

BryceLTaylor commented 6 years ago

Once you connect a micro bit it should stay connected.

When I first connected the micro bit it showed the successfully connected message and then became disconnected. An error appeared in the console.

microbitdisconnect

Repro steps: This project already had the EV3 extension added I then added the micro bit extension Then I connected the micro bit A second or two later it disconnected I reset the micro bit and reconnected and it worked after that

I couldn't reproduce it, I just wanted to give some info on how it happened the one time I saw it.

BryceLTaylor commented 6 years ago

I have seen this a few times now. I can't seem to keep it connected now.

BryceLTaylor commented 6 years ago

@thisandagain had it working just fine on a micro bit on another machine (Microsoft Surface). I'm seeing this on the Dell Latitude E5570 and the micro bit named TIGAG.

cwillisf commented 6 years ago

Here's the code causing the exception. The call to ToArray() is throwing System.ArgumentException with the message "The specified buffer index is not within the buffer capacity."

switch (readResult.Status)
{
    case GattCommunicationStatus.Success:
        return EncodingHelpers.EncodeBuffer(readResult.Value.ToArray(), encoding);

I suspect this means that the micro:bit firmware is returning an empty or invalid characteristic value in response to the read -- maybe a firmware bug? Still, Scratch Link shouldn't react this way.