Skip to content

Commit

Permalink
updated transmit method
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekGn committed Jan 25, 2021
1 parent 6de9817 commit 64ec2fa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RfmOTA/RfmOTA/Ota/OtaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ private void SendRequest(IList<byte> request, [CallerMemberName] string memberNa
{
sw.Start();

_rfmUsb.Transmit(request, 1000);
_rfmUsb.Transmit(request);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion RfmOta/RfmOta/Rfm/IRfmUsb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal interface IRfmUsb : IDisposable
/// </summary>
/// <param name="data">The data to transmit</param>
/// <param name="timeout">The timeout in milliseconds to wait for a response</param>
void Transmit(IList<byte> data, int timeout);
void Transmit(IList<byte> data);
void SetDioMapping(Dio dio, DioMapping mapping);
}
}
24 changes: 22 additions & 2 deletions RfmOta/RfmOta/Rfm/RfmUsb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,29 @@ public IList<byte> TransmitReceive(IList<byte> data, int timeout)
} while (true);
}
///<inheritdoc/>
public void Transmit(IList<byte> data, int timeout)
public void Transmit(IList<byte> data)
{
SendCommand($"e-tx {BitConverter.ToString(data.ToArray()).Replace("-", string.Empty)} {timeout}");
int retries = RetryCount;

do
{
var response = SendCommand($"e-tx {BitConverter.ToString(data.ToArray()).Replace("-", string.Empty)}");

if (response.Contains("TX") || response.Contains("RX"))
{
if (retries == 0)
{
throw new RfmUsbTransmitException($"Packet transmission failed: [{response}]");
}

retries--;
}
else
{
break;
}

} while (true);
}
///<inheritdoc/>
public void SetDioMapping(Dio dio, DioMapping mapping)
Expand Down

0 comments on commit 64ec2fa

Please sign in to comment.