Publish hexdump to /data

This commit is contained in:
Gunnar Skjold
2025-12-01 10:25:28 +01:00
parent 7c85072106
commit 33f56c5135
3 changed files with 11 additions and 3 deletions

View File

@@ -841,7 +841,7 @@ bool HomeAssistantMqttHandler::publishRaw(uint8_t* raw, size_t length) {
snprintf_P(json, BufferSize, PSTR("{\"data\":\"%s\"}"), str.c_str());
char topic[192];
snprintf_P(topic, 192, PSTR("%s/debug"), mqttConfig.publishTopic);
snprintf_P(topic, 192, PSTR("%s/data"), mqttConfig.publishTopic);
bool ret = mqtt.publish(topic, json);
loop();
return ret;

View File

@@ -482,7 +482,7 @@ bool JsonMqttHandler::publishRaw(uint8_t* raw, size_t length) {
snprintf_P(json, BufferSize, PSTR("{\"data\":\"%s\"}"), str.c_str());
char topic[192];
snprintf_P(topic, 192, PSTR("%s/debug"), mqttConfig.publishTopic);
snprintf_P(topic, 192, PSTR("%s/data"), mqttConfig.publishTopic);
bool ret = mqtt.publish(topic, json);
loop();
return ret;

View File

@@ -397,7 +397,15 @@ uint8_t RawMqttHandler::getFormat() {
}
bool RawMqttHandler::publishRaw(uint8_t* raw, size_t length) {
return false;
if(topic.isEmpty() || !connected())
return false;
if(length <= 0 || length > BufferSize) return false;
String str = toHex(raw, length);
bool ret = mqtt.publish(topic + "/data", str);
loop();
return ret;
}
void RawMqttHandler::onMessage(String &topic, String &payload) {