Fix json output

This commit is contained in:
Carl Philipp Klemm 2026-03-29 23:07:03 +02:00
parent 127f1b56a3
commit 7511e68c91

View file

@ -44,11 +44,12 @@ static void send_sensor(TCPSocket* socket, uint8_t id, bool state)
lastState = state;
std::string json = "{ \"Type\": \"Sensor\", \"SensorType\": 254, ";
std::string json = "{ \"MessageType\": \"SensorUpdate\", \"Data\": [{ \"Type\": \"Sensor\", \"SensorType\": 254, ";
json.append("\"Id\": " + std::to_string(static_cast<unsigned int>(id)) + ", ");
json.append("\"Field\": " + std::to_string(static_cast<unsigned int>(state)));
json.append(" }\n");
json.append(" }] }\n");
std::string sendbuf(MSG_STRING + std::to_string(json.length()) + "\n" + json);
Log(Log::DEBUG)<<"Sending: \n"<<sendbuf;
socket->send(sendbuf.c_str(), sendbuf.size());
}