Merge branch 'master' into master

This commit is contained in:
Tom Fifield
2024-09-25 15:10:48 +08:00
committed by GitHub
87 changed files with 959 additions and 694 deletions

View File

@@ -21,6 +21,7 @@
#include "Default.h"
#include "serialization/JSON.h"
#include "serialization/MeshPacketSerializer.h"
#include <Throttle.h>
#include <assert.h>
const int reconnectMax = 5;
@@ -158,7 +159,22 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
meshtastic_MeshPacket *p = packetPool.allocCopy(*e.packet);
p->via_mqtt = true; // Mark that the packet was received via MQTT
if (p->from == 0 || p->from == nodeDB->getNodeNum()) {
LOG_INFO("Ignoring downlink message we originally sent.\n");
packetPool.release(p);
return;
}
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
if (moduleConfig.mqtt.encryption_enabled) {
LOG_INFO("Ignoring decoded message on MQTT, encryption is enabled.\n");
packetPool.release(p);
return;
}
if (p->decoded.portnum == meshtastic_PortNum_ADMIN_APP) {
LOG_INFO("Ignoring decoded admin packet.\n");
packetPool.release(p);
return;
}
p->channel = ch.index;
}
@@ -598,7 +614,7 @@ void MQTT::perhapsReportToMap()
if (!moduleConfig.mqtt.map_reporting_enabled || !(moduleConfig.mqtt.proxy_to_client_enabled || isConnectedDirectly()))
return;
if (millis() - last_report_to_map < map_publish_interval_msecs) {
if (Throttle::isWithinTimespanMs(last_report_to_map, map_publish_interval_msecs)) {
return;
} else {
if (map_position_precision == 0 || (localPosition.latitude_i == 0 && localPosition.longitude_i == 0)) {