diff options
Diffstat (limited to 'platformio/relayctl/src/mqtt.cpp')
-rw-r--r-- | platformio/relayctl/src/mqtt.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/platformio/relayctl/src/mqtt.cpp b/platformio/relayctl/src/mqtt.cpp index e1f70c3..0314c75 100644 --- a/platformio/relayctl/src/mqtt.cpp +++ b/platformio/relayctl/src/mqtt.cpp @@ -19,8 +19,8 @@ static const char MQTT_PASSWORD[] = DEFAULT_MQTT_PASSWORD; static const char MQTT_CLIENT_ID[] = DEFAULT_MQTT_CLIENT_ID; static const char MQTT_SECRET[HOME_SECRET_SIZE+1] = HOME_SECRET; -static const char TOPIC_STAT[] = "stat"; -static const char TOPIC_INITIAL_STAT[] = "stat1"; +static const char TOPIC_DIAGNOSTICS[] = "stat"; +static const char TOPIC_INITIAL_DIAGNOSTICS[] = "stat1"; static const char TOPIC_OTA_RESPONSE[] = "otares"; static const char TOPIC_RELAY_POWER[] = "power"; static const char TOPIC_ADMIN_OTA[] = "admin/ota"; @@ -45,7 +45,7 @@ MQTT::MQTT() { client.onConnect([&](bool sessionPresent) { PRINTLN("mqtt: connected"); - sendInitialStat(); + sendInitialDiagnostics(); subscribe(TOPIC_RELAY_POWER, 1); subscribe(TOPIC_ADMIN_OTA); @@ -174,36 +174,36 @@ uint16_t MQTT::subscribe(const String &topic, uint8_t qos) { return packetId; } -void MQTT::sendInitialStat() { +void MQTT::sendInitialDiagnostics() { auto cfg = config::read(); - InitialStatPayload stat{ + InitialDiagnosticsPayload stat{ .ip = wifi::getIPAsInteger(), .fw_version = FW_VERSION, .rssi = wifi::getRSSI(), .free_heap = ESP.getFreeHeap(), - .flags = StatFlags{ + .flags = DiagnosticsFlags{ .state = static_cast<uint8_t>(relay::getState() ? 1 : 0), .config_changed_value_present = 1, .config_changed = static_cast<uint8_t>(cfg.flags.node_configured || cfg.flags.wifi_configured ? 1 : 0) } }; - publish(TOPIC_INITIAL_STAT, reinterpret_cast<uint8_t*>(&stat), sizeof(stat)); - statStopWatch.save(); + publish(TOPIC_INITIAL_DIAGNOSTICS, reinterpret_cast<uint8_t*>(&stat), sizeof(stat)); + diagnosticsStopWatch.save(); } -void MQTT::sendStat() { - StatPayload stat{ +void MQTT::sendDiagnostics() { + DiagnosticsPayload stat{ .rssi = wifi::getRSSI(), .free_heap = ESP.getFreeHeap(), - .flags = StatFlags{ + .flags = DiagnosticsFlags{ .state = static_cast<uint8_t>(relay::getState() ? 1 : 0), .config_changed_value_present = 0, .config_changed = 0 } }; - publish(TOPIC_STAT, reinterpret_cast<uint8_t*>(&stat), sizeof(stat)); - statStopWatch.save(); + publish(TOPIC_DIAGNOSTICS, reinterpret_cast<uint8_t*>(&stat), sizeof(stat)); + diagnosticsStopWatch.save(); } uint16_t MQTT::sendOtaResponse(OTAResult status, uint8_t error_code) { @@ -237,7 +237,7 @@ void MQTT::handleRelayPowerPayload(const uint8_t *payload, uint32_t length) { PRINTLN("error: unexpected state value"); } - sendStat(); + sendDiagnostics(); } void MQTT::handleAdminOtaPayload(uint16_t packetId, const uint8_t *payload, size_t length, size_t index, size_t total) { |