Skip to content

Commit

Permalink
Fix #913 - Failed to execute LoRaWAN Command
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand committed Apr 16, 2024
1 parent f50c12a commit 95115c0
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ public async Task<HttpResponseMessage> ExecuteLoRaDeviceMessage(string deviceId,
ArgumentNullException.ThrowIfNull(deviceId, nameof(deviceId));
ArgumentNullException.ThrowIfNull(commandDto, nameof(commandDto));

// Convert the hex frame to a byte array
var hexFrame = Enumerable.Range(0, commandDto.Frame.Length / 2)
.Select(x => Convert.ToByte(commandDto.Frame.Substring(x * 2, 2), 16))
.ToArray();

// Convert the byte array to a base64 string
var rawPayload = Convert.ToBase64String(hexFrame);

var body = new LoRaCloudToDeviceMessage
{
RawPayload = Convert.ToBase64String(Encoding.UTF8.GetBytes(commandDto.Frame)),
RawPayload = rawPayload,
Fport = commandDto.Port,
Confirmed = commandDto.Confirmed
};
Expand Down

0 comments on commit 95115c0

Please sign in to comment.