diff --git a/examples/simple_repeater/Cellularmqtt.h b/examples/simple_repeater/Cellularmqtt.h index 58c1031d..517e31c8 100644 --- a/examples/simple_repeater/Cellularmqtt.h +++ b/examples/simple_repeater/Cellularmqtt.h @@ -100,6 +100,10 @@ struct TelemetryData { char apn[40]; char oper[24]; bool mqtt_connected; + // Routing settings (v1.8+) + uint8_t loop_detect; // 0=off, 1=minimal, 2=moderate, 3=strict + uint8_t path_hash_mode; // 0=1-byte, 1=2-byte, 2=3-byte + uint8_t flood_max; // max flood hop count (0-64) }; // --------------------------------------------------------------------------- diff --git a/examples/simple_repeater/cellularmqtt.cpp b/examples/simple_repeater/cellularmqtt.cpp index c3aaee82..15f2bf3a 100644 --- a/examples/simple_repeater/cellularmqtt.cpp +++ b/examples/simple_repeater/cellularmqtt.cpp @@ -1124,19 +1124,24 @@ restart: xSemaphoreGive(_telemetryMutex); } - char json[400]; + static const char* loopLabels[] = { "off", "minimal", "moderate", "strict" }; + const char* loopStr = td.loop_detect <= 3 ? loopLabels[td.loop_detect] : "off"; + + char json[512]; snprintf(json, sizeof(json), "{\"uptime\":%lu,\"batt_mv\":%d,\"batt_pct\":%d,\"temp\":%.1f," "\"csq\":%d,\"bars\":%d,\"neighbors\":%d," "\"freq\":%.3f,\"bw\":%.1f,\"sf\":%d,\"cr\":%d,\"tx\":%d," "\"name\":\"%s\",\"ip\":\"%s\",\"oper\":\"%s\",\"apn\":\"%s\"," - "\"heap\":%d}", + "\"heap\":%d," + "\"loop_detect\":\"%s\",\"path_hash_mode\":%d,\"flood_max\":%d}", td.uptime_secs, td.battery_mv, td.battery_pct, td.temperature / 10.0f, _csq, getSignalBars(), td.neighbor_count, td.freq, td.bw, td.sf, td.cr, td.tx_power, td.node_name, _ipAddr, _operator, _apn, - ESP.getFreeHeap()); + ESP.getFreeHeap(), + loopStr, td.path_hash_mode, td.flood_max); mqttPublish(_topicTelem, json); lastTelem = millis(); diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index fcd70605..e8a87733 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -246,6 +246,9 @@ void loop() { strncpy(td.oper, cellularMQTT.getOperator(), sizeof(td.oper) - 1); td.mqtt_connected = cellularMQTT.isConnected(); td.neighbor_count = 0; // TODO: expose from MyMesh + td.loop_detect = p->loop_detect; + td.path_hash_mode = p->path_hash_mode; + td.flood_max = p->flood_max; cellularMQTT.updateTelemetry(td); lastTelemUpdate = millis(); @@ -299,6 +302,9 @@ void loop() { strncpy(td.node_name, p->node_name, sizeof(td.node_name) - 1); td.mqtt_connected = wifiMQTT.isConnected(); td.neighbor_count = 0; + td.loop_detect = p->loop_detect; + td.path_hash_mode = p->path_hash_mode; + td.flood_max = p->flood_max; wifiMQTT.updateTelemetry(td); lastTelemUpdate = millis(); diff --git a/examples/simple_repeater/wifimqtt.cpp b/examples/simple_repeater/wifimqtt.cpp index 71dd2beb..71ad5bf0 100644 --- a/examples/simple_repeater/wifimqtt.cpp +++ b/examples/simple_repeater/wifimqtt.cpp @@ -373,19 +373,24 @@ void WiFiMQTT::publishQueuedResponses() { void WiFiMQTT::publishTelemetry() { _rssi = WiFi.RSSI(); - char json[400]; + static const char* loopLabels[] = { "off", "minimal", "moderate", "strict" }; + const char* loopStr = _telemetry.loop_detect <= 3 ? loopLabels[_telemetry.loop_detect] : "off"; + + char json[512]; snprintf(json, sizeof(json), "{\"uptime\":%lu,\"batt_mv\":%d,\"batt_pct\":%d,\"temp\":%.1f," "\"rssi\":%d,\"bars\":%d,\"neighbors\":%d," "\"freq\":%.3f,\"bw\":%.1f,\"sf\":%d,\"cr\":%d,\"tx\":%d," "\"name\":\"%s\",\"ip\":\"%s\",\"ssid\":\"%s\"," - "\"heap\":%d}", + "\"heap\":%d," + "\"loop_detect\":\"%s\",\"path_hash_mode\":%d,\"flood_max\":%d}", _telemetry.uptime_secs, _telemetry.battery_mv, _telemetry.battery_pct, _telemetry.temperature / 10.0f, _rssi, getSignalBars(), _telemetry.neighbor_count, _telemetry.freq, _telemetry.bw, _telemetry.sf, _telemetry.cr, _telemetry.tx_power, _telemetry.node_name, _ipAddr, _config.networks[_activeNetwork].ssid, - ESP.getFreeHeap()); + ESP.getFreeHeap(), + loopStr, _telemetry.path_hash_mode, _telemetry.flood_max); _mqttClient.publish(_topicTelem, json); } diff --git a/examples/simple_repeater/wifimqtt.h b/examples/simple_repeater/wifimqtt.h index ae3bf055..c6db4424 100644 --- a/examples/simple_repeater/wifimqtt.h +++ b/examples/simple_repeater/wifimqtt.h @@ -103,6 +103,10 @@ struct TelemetryData { uint8_t tx_power; char node_name[32]; bool mqtt_connected; + // Routing settings (v1.8+) + uint8_t loop_detect; // 0=off, 1=minimal, 2=moderate, 3=strict + uint8_t path_hash_mode; // 0=1-byte, 1=2-byte, 2=3-byte + uint8_t flood_max; // max flood hop count (0-64) }; // ---------------------------------------------------------------------------