Skip to content

Commit

Permalink
Fix setting of ConnectionSource field (#287)
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
josesimoes authored Dec 18, 2020
1 parent 6cf6b91 commit 3a7f936
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public async Task<bool> ConnectAsync(
int timeout,
bool force = false,
int attempts = 1,
ConnectionSource connectionSource = ConnectionSource.Unknown,
ConnectionSource requestedConnectionSource = ConnectionSource.Unknown,
bool requestCapabilities = true)
{
// setup linear back-off based on the parameters
Expand Down Expand Up @@ -264,7 +264,21 @@ public async Task<bool> ConnectAsync(
// update flag
IsConnected = true;
ConnectionSource = (reply == null || reply.Source == Commands.Monitor_Ping.c_Ping_Source_NanoCLR) ? ConnectionSource.nanoCLR : ConnectionSource.nanoBooter;
// update field
switch (reply.Source)
{
case Commands.Monitor_Ping.c_Ping_Source_NanoCLR:
ConnectionSource = ConnectionSource.nanoCLR;
break;
case Commands.Monitor_Ping.c_Ping_Source_NanoBooter:
ConnectionSource = ConnectionSource.nanoBooter;
break;
default:
ConnectionSource = ConnectionSource.Unknown;
break;
}
if (m_silent)
{
Expand Down Expand Up @@ -328,7 +342,7 @@ public async Task<bool> ConnectAsync(
TargetInfo = targetInfoPolicy.Execute(() => GetMonitorTargetInfo());
}
if (connectionSource != ConnectionSource.Unknown && connectionSource != ConnectionSource)
if (requestedConnectionSource != ConnectionSource.Unknown && requestedConnectionSource != ConnectionSource)
{
// update flag
IsConnected = false;
Expand Down Expand Up @@ -674,7 +688,20 @@ public Commands.Monitor_Ping.Reply GetConnectionSource()
var connectionSource = reply.Payload as Commands.Monitor_Ping.Reply;

// update field
ConnectionSource = (ConnectionSource)connectionSource.Source;
switch (connectionSource.Source)
{
case Commands.Monitor_Ping.c_Ping_Source_NanoCLR:
ConnectionSource = ConnectionSource.nanoCLR;
break;

case Commands.Monitor_Ping.c_Ping_Source_NanoBooter:
ConnectionSource = ConnectionSource.nanoBooter;
break;

default:
ConnectionSource = ConnectionSource.Unknown;
break;
}

return connectionSource;
}
Expand Down

0 comments on commit 3a7f936

Please sign in to comment.