added support for IR RC5

This commit is contained in:
KlausMu 2024-01-27 08:37:17 +01:00
parent abc134bf70
commit 54c0bd2f3d
2 changed files with 31 additions and 10 deletions

View file

@ -76,17 +76,37 @@ void executeCommandWithData(std::string command, commandData commandData, std::s
} }
case IR_SONY: { case IR_SONY: {
if (additionalPayload != "") {
// https://cplusplus.com/reference/string/stoull/
std::string::size_type sz = 0; // alias of size_t std::string::size_type sz = 0; // alias of size_t
const uint64_t data = std::stoull(additionalPayload, &sz, 0); uint64_t data;
// // https://stackoverflow.com/questions/42356939/c-convert-string-to-uint64-t if (commandData.commandPayloads.empty() && (additionalPayload == "")) {
// std::istringstream iss(additionalPayload); Serial.printf("execute: cannot send IR SONY, because both data and payload are empty\r\n");
// iss >> payload;
Serial.printf("execute: will send IR SONY, data %s (%" PRIu64 ")\r\n", additionalPayload.c_str(), data);
IrSender.sendSony(data, 15);
} else { } else {
Serial.printf("execute: cannot send IR SONY, because payload is empty\r\n"); if (additionalPayload != "") {
data = std::stoull(additionalPayload, &sz, 0);
} else {
auto current = commandData.commandPayloads.begin();
data = std::stoull(*current, &sz, 0);
}
Serial.printf("execute: will send IR SONY, data (%" PRIu64 ")\r\n", data);
IrSender.sendSony(data, 15);
}
break;
}
case IR_RC5: {
std::string::size_type sz = 0; // alias of size_t
uint64_t data;
if (commandData.commandPayloads.empty() && (additionalPayload == "")) {
Serial.printf("execute: cannot send IR RC5, because both data and payload are empty\r\n");
} else {
if (additionalPayload != "") {
data = std::stoull(additionalPayload, &sz, 0);
} else {
auto current = commandData.commandPayloads.begin();
data = std::stoull(*current, &sz, 0);
}
Serial.printf("execute: will send IR RC5, data (%" PRIu64 ")\r\n", data);
IrSender.sendRC5(IrSender.encodeRC5X(0x00, data));
} }
break; break;
} }

View file

@ -107,6 +107,7 @@ enum commandHandlers {
IR_NEC, IR_NEC,
IR_SAMSUNG, IR_SAMSUNG,
IR_SONY, IR_SONY,
IR_RC5,
#ifdef ENABLE_WIFI_AND_MQTT #ifdef ENABLE_WIFI_AND_MQTT
MQTT, MQTT,
#endif #endif