mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-04 23:55:40 +00:00
Publish hexdump to /data
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user