Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern committed Aug 2, 2023
1 parent c223ae3 commit 2c3baa4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Meshtastic.Data;
using Meshtastic.Data.MessageFactories;
using Meshtastic.Protobufs;
using Meshtastic.Extensions;
using Microsoft.Extensions.Logging;

namespace Meshtastic.Cli.CommandHandlers;
Expand Down Expand Up @@ -31,8 +32,9 @@ await Connection.WriteToRadio(ToRadioMessageFactory.CreateMeshPacketMessage(mess
{
// if (packet?.PayloadVariantCase == FromRadio.PayloadVariantOneofCase.Packet &&
// packet.MeshPacket is not null)
Logger.LogInformation($"Received telemetry from device: {packet}");
return await Task.FromResult(true);
Logger.LogInformation($"Received packet from device: {packet}");
Logger.LogInformation(packet.GetPayload<Telemetry>()?.DeviceMetrics?.ToString() ?? "No telemetry data received");
return await Task.FromResult(false);
});
}
}
7 changes: 4 additions & 3 deletions Meshtastic/Data/MessageFactories/TelemetryMessageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ public TelemetryMessageFactory(DeviceStateContainer container, uint? dest = null

public MeshPacket CreateTelemetryPacket(uint channel = 0)
{
var telemetry = container!.FromRadioMessageLog
.Where(fromRadio => fromRadio.Packet.From == container.MyNodeInfo.MyNodeNum)
.First(fromRadio => fromRadio.GetPayload<Telemetry>()?.DeviceMetrics != null)?.GetPayload<Telemetry>()?.DeviceMetrics;
var telemetry = container?.FromRadioMessageLog
.Where(fromRadio => fromRadio.Packet?.From == container.MyNodeInfo?.MyNodeNum)
.FirstOrDefault(fromRadio => fromRadio.GetPayload<Telemetry>()?.DeviceMetrics != null)?.GetPayload<Telemetry>()?.DeviceMetrics;

return new MeshPacket()
{
Channel = channel,
Expand Down

0 comments on commit 2c3baa4

Please sign in to comment.