You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i have the code where the mqtt json is subscribed and when passed through the function it correctly sends the 24 bit code
but when i send the json made by my code it results in incorrect 50 bit sending
code:
void modbusprocess(const String &jsonPayload) {
DynamicJsonDocument doc(11264);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
i have the code where the mqtt json is subscribed and when passed through the function it correctly sends the 24 bit code
but when i send the json made by my code it results in incorrect 50 bit sending
code:
void modbusprocess(const String &jsonPayload) {
DynamicJsonDocument doc(11264);
}
json creation code:
const char* getStateName(uint16_t state) {
return (state == 0x01) ? "OFF" : "ON";
}
const char* getModeName(uint16_t mode) {
Serial.printf("Mode: %d\n", mode);
switch (mode) {
case 0X03: return "AUTO";
case 0X06: return "COOL";
case 0X05: return "DRY";
default: return "UNK";
}
}
const char* getFanSpeed(uint16_t mode) {
return "HIG"; // You can change this dynamically later
}
const char* getSwingV(uint16_t mode) {
return "AUT"; // You can change this dynamically later
}
void sendACJson(uint16_t temp, uint16_t state, uint16_t mode) {
DynamicJsonDocument doc(11264);
JsonObject ir1 = doc["data"].createNestedObject("ir1");
//JsonObject ir1 = doc["data"].to();
ir1["brand"] = "COOLIX";
ir1["state"] = getStateName(state);
ir1["temp"] = temp;
ir1["mode"] = getModeName(mode);
ir1["fanspd"] = getFanSpeed(mode);
ir1["swingv"] = getSwingV(mode);
String output;
serializeJson(doc, output);
Serial.println("📤 Sending AC JSON:");
Serial.println(output);
modbusprocess(output); // Process the output string as needed
client.publish("UTIR/cmd/", output.c_str()); // If using MQTT
}
expected json:
{
"cid": 0,
"type": "ac",
"data": {
"ir1": {
"brand": "COOLIX",
"state": "ON",
"temp": 28,
"mode": "AUTO",
"fanspd": "LOW",
"swingv": "AUT"
}
}
}
Beta Was this translation helpful? Give feedback.
All reactions