Merge branch 'master' into 2264-feature-check-for-low-heap-before-adding-to-nodedb-was-reboot-loop-heap-too-low

This commit is contained in:
Thomas Göttgens 2023-04-13 23:50:21 +02:00 committed by GitHub
commit a13775bd70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -349,13 +349,14 @@ void Power::readPowerStatus()
getMacAddr(dmac); // Get our hardware ID getMacAddr(dmac); // Get our hardware ID
char mac[18]; char mac[18];
sprintf(mac, "!%02x%02x%02x%02x", dmac[2], dmac[3], dmac[4], dmac[5]); sprintf(mac, "!%02x%02x%02x%02x", dmac[2], dmac[3], dmac[4], dmac[5]);
auto newHeap = memGet.getFreeHeap(); auto newHeap = memGet.getFreeHeap();
std::string heapTopic = "msh/2/heap/" + std::string(mac); std::string heapTopic = (*moduleConfig.mqtt.root ? moduleConfig.mqtt.root : "msh") + "/2/heap/" + std::string(mac);
std::string heapString = std::to_string(newHeap); std::string heapString = std::to_string(newHeap);
mqtt->pubSub.publish(heapTopic.c_str(), heapString.c_str(), false); mqtt->pubSub.publish(heapTopic.c_str(), heapString.c_str(), false);
// auto fragHeap = memGet.getHeapFragmentation(); // auto fragHeap = memGet.getHeapFragmentation();
auto wifiRSSI = WiFi.RSSI(); auto wifiRSSI = WiFi.RSSI();
heapTopic = "msh/2/wifi/" + std::string(mac); heapTopic = (*moduleConfig.mqtt.root ? moduleConfig.mqtt.root : "msh") + "/2/wifi/" + std::string(mac);
std::string wifiString = std::to_string(wifiRSSI); std::string wifiString = std::to_string(wifiRSSI);
mqtt->pubSub.publish(heapTopic.c_str(), wifiString.c_str(), false); mqtt->pubSub.publish(heapTopic.c_str(), wifiString.c_str(), false);
} }

View File

@ -19,10 +19,6 @@ const int reconnectMax = 5;
MQTT *mqtt; MQTT *mqtt;
std::string statusTopic = "/2/stat/";
std::string cryptTopic = "/2/c/"; // msh/2/c/CHANNELID/NODEID
std::string jsonTopic = "/2/json/"; // msh/2/json/CHANNELID/NODEID
static MemoryDynamic<meshtastic_ServiceEnvelope> staticMqttPool; static MemoryDynamic<meshtastic_ServiceEnvelope> staticMqttPool;
Allocator<meshtastic_ServiceEnvelope> &mqttPool = staticMqttPool; Allocator<meshtastic_ServiceEnvelope> &mqttPool = staticMqttPool;
@ -164,7 +160,7 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), pubSub(mqttClient), mqttQueue(MAX_
assert(!mqtt); assert(!mqtt);
mqtt = this; mqtt = this;
if (moduleConfig.mqtt.root) { if (*moduleConfig.mqtt.root) {
statusTopic = moduleConfig.mqtt.root + statusTopic; statusTopic = moduleConfig.mqtt.root + statusTopic;
cryptTopic = moduleConfig.mqtt.root + cryptTopic; cryptTopic = moduleConfig.mqtt.root + cryptTopic;
jsonTopic = moduleConfig.mqtt.root + jsonTopic; jsonTopic = moduleConfig.mqtt.root + jsonTopic;

View File

@ -69,6 +69,9 @@ class MQTT : private concurrency::OSThread
virtual int32_t runOnce() override; virtual int32_t runOnce() override;
private: private:
std::string statusTopic = "/2/stat/";
std::string cryptTopic = "/2/c/"; // msh/2/c/CHANNELID/NODEID
std::string jsonTopic = "/2/json/"; // msh/2/json/CHANNELID/NODEID
/** return true if we have a channel that wants uplink/downlink /** return true if we have a channel that wants uplink/downlink
*/ */
bool wantsLink() const; bool wantsLink() const;