diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 2c5c80c70..6f2e91046 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -2,13 +2,16 @@ * Add 16 timers using commands Timer and Timers (#1091) * Add commands Timer 0 to clear timer and Timer 1..16 to copy timer * Add optional Timer configuration webpage to be enabled in user_config.h with define USE_TIMERS_WEB + * Add hexadecimal Data entry to command IrSend using 0x notation (#1290, #2314) * Add Domoticz Battery and RSSI Quality (#1604) * Add Home Assistant MQTT Discovery for Buttons and change SetOption19 response (#2277) * Add support for SGP30 gas and air quality sensor (#2307) * Add multiple color entry support for command Led like Led2 120000 001200 000012 setting led2 as Red, Led3 as Green and Led4 as Blue (#2303) + * Add hexadecimal RGB color entry on RGBCW leds (#2304) * Change webpage parameter communication * Change Timer parameter Device to more obvious Output * Change max number of commands in Backlog from 15 to 30 and ignore commands overflowing + * Change user_config_override usage by providing user_config_override_sample.h (#2228) * Change MQTT response topic for Energy changes from ENERGY to SENSOR (#2229, #2251) * Change default Reset configuration time from 4 seconds to 40 seconds on Button hold (#2268) * diff --git a/sonoff/xdrv_01_light.ino b/sonoff/xdrv_01_light.ino index 2c9b04890..9230c1529 100644 --- a/sonoff/xdrv_01_light.ino +++ b/sonoff/xdrv_01_light.ino @@ -991,11 +991,10 @@ boolean LightColorEntry(char *buffer, uint8_t buffer_length) light_entry_color[i++] = atoi(str); } } -// entry_type = (light_subtype == i) ? 2 : 0; // Decimal entry_type = 2; // Decimal } - else if ((2 * light_subtype) == buffer_length) { // Hexadecimal entry - for (byte i = 0; i < light_subtype; i++) { + else if (((2 * light_subtype) == buffer_length) || (buffer_length > 3)) { // Hexadecimal entry + for (byte i = 0; i < buffer_length / 2; i++) { strlcpy(scolor, buffer + (i *2), 3); light_entry_color[i] = (uint8_t)strtol(scolor, &p, 16); } diff --git a/sonoff/xdrv_02_irremote.ino b/sonoff/xdrv_02_irremote.ino index 94f57baae..896faa37a 100644 --- a/sonoff/xdrv_02_irremote.ino +++ b/sonoff/xdrv_02_irremote.ino @@ -284,26 +284,25 @@ boolean IrSendCommand() uint32_t bits = 0; uint32_t data = 0; - for (uint16_t i = 0; i <= sizeof(dataBufUc); i++) { - dataBufUc[i] = toupper(XdrvMailbox.data[i]); - } + UpperCase(dataBufUc, XdrvMailbox.data); if (!strcasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_IRSEND))) { if (XdrvMailbox.data_len) { StaticJsonBuffer<128> jsonBuf; - JsonObject &ir_json = jsonBuf.parseObject(dataBufUc); - if (!ir_json.success()) { + JsonObject &root = jsonBuf.parseObject(dataBufUc); + if (!root.success()) { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRSEND "\":\"" D_JSON_INVALID_JSON "\"}")); // JSON decode failed } else { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_IRSEND "\":\"" D_JSON_DONE "\"}")); - protocol = ir_json[D_JSON_IR_PROTOCOL]; - bits = ir_json[D_JSON_IR_BITS]; - data = ir_json[D_JSON_IR_DATA]; + char parm_uc[10]; + protocol = root[UpperCase_P(parm_uc, PSTR(D_JSON_IR_PROTOCOL))]; + bits = root[UpperCase_P(parm_uc, PSTR(D_JSON_IR_BITS))]; + data = strtoul(root[UpperCase_P(parm_uc, PSTR(D_JSON_IR_DATA))], NULL, 0); if (protocol && bits && data) { int protocol_code = GetCommandCode(protocol_text, sizeof(protocol_text), protocol, kIrRemoteProtocols); - snprintf_P(log_data, sizeof(log_data), PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %d, protocol_code %d"), - protocol_text, protocol, bits, data, protocol_code); + snprintf_P(log_data, sizeof(log_data), PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %u (0x%lX), protocol_code %d"), + protocol_text, protocol, bits, data, data, protocol_code); AddLog(LOG_LEVEL_DEBUG); switch (protocol_code) {