mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-19 16:29:31 +00:00
Remove MQTT JSON for all but NRF52_USE_JSON target
This commit is contained in:
parent
6d8be13266
commit
bb1b05d18a
@ -19,8 +19,11 @@
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
#include "Default.h"
|
||||
|
||||
#if NRF52_USE_JSON
|
||||
#include "serialization/JSON.h"
|
||||
#include "serialization/MeshPacketSerializer.h"
|
||||
#endif
|
||||
#include <Throttle.h>
|
||||
#include <assert.h>
|
||||
|
||||
@ -52,6 +55,7 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
|
||||
meshtastic_ServiceEnvelope e = meshtastic_ServiceEnvelope_init_default;
|
||||
|
||||
if (moduleConfig.mqtt.json_enabled && (strncmp(topic, jsonTopic.c_str(), jsonTopic.length()) == 0)) {
|
||||
#if NRF52_USE_JSON
|
||||
// check if this is a json payload message by comparing the topic start
|
||||
char payloadStr[length + 1];
|
||||
memcpy(payloadStr, payload, length);
|
||||
@ -135,6 +139,7 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
|
||||
LOG_ERROR("JSON received payload on MQTT but not a valid JSON");
|
||||
}
|
||||
delete json_value;
|
||||
#endif
|
||||
} else {
|
||||
if (length == 0) {
|
||||
LOG_WARN("Empty MQTT payload received, topic %s!", topic);
|
||||
@ -234,11 +239,15 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), mqttQueue(MAX_MQTT_QUEUE)
|
||||
|
||||
if (*moduleConfig.mqtt.root) {
|
||||
cryptTopic = moduleConfig.mqtt.root + cryptTopic;
|
||||
#if NRF52_USE_JSON
|
||||
jsonTopic = moduleConfig.mqtt.root + jsonTopic;
|
||||
#endif
|
||||
mapTopic = moduleConfig.mqtt.root + mapTopic;
|
||||
} else {
|
||||
cryptTopic = "msh" + cryptTopic;
|
||||
#if NRF52_USE_JSON
|
||||
jsonTopic = "msh" + jsonTopic;
|
||||
#endif
|
||||
mapTopic = "msh" + mapTopic;
|
||||
}
|
||||
|
||||
@ -705,6 +714,7 @@ void MQTT::perhapsReportToMap()
|
||||
}
|
||||
}
|
||||
|
||||
#if NRF52_USE_JSON
|
||||
bool MQTT::isValidJsonEnvelope(JSONObject &json)
|
||||
{
|
||||
// if "sender" is provided, avoid processing packets we uplinked
|
||||
@ -715,6 +725,7 @@ bool MQTT::isValidJsonEnvelope(JSONObject &json)
|
||||
(json.find("type") != json.end()) && json["type"]->IsString() && // should specify a type
|
||||
(json.find("payload") != json.end()); // should have a payload
|
||||
}
|
||||
#endif
|
||||
|
||||
bool MQTT::isPrivateIpAddress(const char address[])
|
||||
{
|
||||
|
@ -5,7 +5,9 @@
|
||||
#include "concurrency/OSThread.h"
|
||||
#include "mesh/Channels.h"
|
||||
#include "mesh/generated/meshtastic/mqtt.pb.h"
|
||||
#if NRF52_USE_JSON
|
||||
#include "serialization/JSON.h"
|
||||
#endif
|
||||
#if HAS_WIFI
|
||||
#include <WiFiClient.h>
|
||||
#if !defined(ARCH_PORTDUINO)
|
||||
@ -117,9 +119,10 @@ class MQTT : private concurrency::OSThread
|
||||
// Check if we should report unencrypted information about our node for consumption by a map
|
||||
void perhapsReportToMap();
|
||||
|
||||
#if NRF52_USE_JSON
|
||||
// returns true if this is a valid JSON envelope which we accept on downlink
|
||||
bool isValidJsonEnvelope(JSONObject &json);
|
||||
|
||||
#endif
|
||||
/// Determines if the given address is a private IPv4 address, i.e. not routable on the public internet.
|
||||
/// These are the ranges: 127.0.0.1, 10.0.0.0-10.255.255.255, 172.16.0.0-172.31.255.255, 192.168.0.0-192.168.255.255.
|
||||
bool isPrivateIpAddress(const char address[]);
|
||||
|
Loading…
Reference in New Issue
Block a user