Skip to content

Commit

Permalink
Allow specifying channel index in JSON field "channel" for downlink
Browse files Browse the repository at this point in the history
Still requires JSON message to be published to channel named "mqtt"
  • Loading branch information
GUVWAF committed Feb 8, 2024
1 parent c46d2d1 commit 7d87cba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mqtt/MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
// construct protobuf data packet using TEXT_MESSAGE, send it to the mesh
meshtastic_MeshPacket *p = router->allocForSending();
p->decoded.portnum = meshtastic_PortNum_TEXT_MESSAGE_APP;
p->channel = sendChannel.index;
if (json.find("channel") != json.end() && json["channel"]->IsNumber() &&
(json["channel"]->AsNumber() < channels.getNumChannels()))
p->channel = json["channel"]->AsNumber();
if (json.find("to") != json.end() && json["to"]->IsNumber())
p->to = json["to"]->AsNumber();
if (jsonPayloadStr.length() <= sizeof(p->decoded.payload.bytes)) {
Expand Down Expand Up @@ -95,7 +97,9 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
// construct protobuf data packet using POSITION, send it to the mesh
meshtastic_MeshPacket *p = router->allocForSending();
p->decoded.portnum = meshtastic_PortNum_POSITION_APP;
p->channel = sendChannel.index;
if (json.find("channel") != json.end() && json["channel"]->IsNumber() &&
(json["channel"]->AsNumber() < channels.getNumChannels()))
p->channel = json["channel"]->AsNumber();
if (json.find("to") != json.end() && json["to"]->IsNumber())
p->to = json["to"]->AsNumber();
p->decoded.payload.size =
Expand Down

0 comments on commit 7d87cba

Please sign in to comment.