Skip to content

Commit

Permalink
Clean up some straggler NRF52 json
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern authored and fifieldt committed Dec 21, 2024
1 parent df63423 commit 6eaacd1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/mqtt/MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
#include <WiFi.h>
#endif
#include "Default.h"
#if !defined(ARCH_NRF52) || NRF52_USE_JSON
#include "serialization/JSON.h"
#include "serialization/MeshPacketSerializer.h"
#endif
#include <Throttle.h>
#include <assert.h>
#include <pb_decode.h>
Expand Down Expand Up @@ -119,6 +121,7 @@ inline void onReceiveProto(char *topic, byte *payload, size_t length)
router->enqueueReceivedMessage(p.release());
}

#if !defined(ARCH_NRF52) || NRF52_USE_JSON
// returns true if this is a valid JSON envelope which we accept on downlink
inline bool isValidJsonEnvelope(JSONObject &json)
{
Expand Down Expand Up @@ -204,6 +207,7 @@ inline void onReceiveJson(byte *payload, size_t length)
LOG_DEBUG("JSON ignore downlink message with unsupported type");
}
}
#endif

/// Determines if the given IPAddress is a private IPv4 address, i.e. not routable on the public internet.
bool isPrivateIpAddress(const IPAddress &ip)
Expand Down Expand Up @@ -248,6 +252,7 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)

// check if this is a json payload message by comparing the topic start
if (moduleConfig.mqtt.json_enabled && (strncmp(topic, jsonTopic.c_str(), jsonTopic.length()) == 0)) {
#if !defined(ARCH_NRF52) || NRF52_USE_JSON
// parse the channel name from the topic string
// the topic has been checked above for having jsonTopic prefix, so just move past it
char *channelName = topic + jsonTopic.length();
Expand All @@ -261,6 +266,7 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
return;
}
onReceiveJson(payload, length);
#endif
return;
}

Expand Down Expand Up @@ -748,4 +754,4 @@ void MQTT::perhapsReportToMap()

// Update the last report time
last_report_to_map = millis();
}
}
4 changes: 3 additions & 1 deletion src/mqtt/MQTT.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "concurrency/OSThread.h"
#include "mesh/Channels.h"
#include "mesh/generated/meshtastic/mqtt.pb.h"
#if !defined(ARCH_NRF52) || NRF52_USE_JSON
#include "serialization/JSON.h"
#endif
#if HAS_WIFI
#include <WiFiClient.h>
#if !defined(ARCH_PORTDUINO)
Expand Down Expand Up @@ -127,4 +129,4 @@ class MQTT : private concurrency::OSThread

void mqttInit();

extern MQTT *mqtt;
extern MQTT *mqtt;

0 comments on commit 6eaacd1

Please sign in to comment.