Skip to content

Commit b1522c4

Browse files
committed
feat(api): ✨ generalize MQTT message type handling
Expanded MQTT message processing to handle all types ending with "DisplayPropertyUpload" or containing "HeartBeatReport" (case-insensitive), instead of only specific hardcoded types. This improves flexibility and supports a broader range of message types.
1 parent 0ede3a3 commit b1522c4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/EcoFlow.Mqtt.Api/Services/InternalMqttApi.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Ecoflow.Corebiz.Mqtt.Proto.Common;
2-
using Ecoflow.EnergyStorageModule.Proto.Pd335BmsBp;
32
using EcoFlow.Mqtt.Api.Extensions;
43
using EcoFlow.Mqtt.Api.Models;
54
using EcoFlow.Mqtt.Api.Session;
@@ -136,8 +135,11 @@ private Task OnApplicationMessageReceived(MqttApplicationMessageReceivedEventArg
136135
foreach (var header in headers.Decrypted)
137136
{
138137
var message = header.Pdata.AsEcoFlowMessage(header.CmdFunc, header.CmdId);
138+
var messageName = message.GetType().Name;
139139

140-
if (message is BMSHeartBeatReport)
140+
if (messageName.EndsWith("DisplayPropertyUpload", StringComparison.OrdinalIgnoreCase))
141+
nodes.Add(message.ToJson());
142+
else if (messageName.Contains("HeartBeatReport", StringComparison.OrdinalIgnoreCase))
141143
nodes.Add(message.ToJson());
142144
else
143145
Console.WriteLine($"⚠️ Unsupported binary message received from {serialNumber}: {message.ToStringWithTitle()}");

0 commit comments

Comments
 (0)