Fix json output
This commit is contained in:
parent
127f1b56a3
commit
7511e68c91
1 changed files with 4 additions and 3 deletions
7
main.cpp
7
main.cpp
|
|
@ -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("\"Field\": " + std::to_string(static_cast<unsigned int>(state)));
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue