diff --git a/sonoff/xdrv_05_irremote.ino b/sonoff/xdrv_05_irremote.ino index ad48c5c8e..cb60f2af3 100644 --- a/sonoff/xdrv_05_irremote.ino +++ b/sonoff/xdrv_05_irremote.ino @@ -85,13 +85,9 @@ char* IrUint64toHex(uint64_t value, char *str, uint16_t bits) memmove(str + fill, str, len +1); memset(str, '0', fill); } - memmove(str + 2, str, strlen(str) +1); - str[0] = '0'; - str[1] = 'x'; return str; } - #ifdef USE_IR_RECEIVE /*********************************************************************************************\ * IR Receive @@ -132,10 +128,17 @@ void IrReceiveCheck(void) decode_results results; if (irrecv->decode(&results)) { - char hvalue[64]; - IrUint64toHex(results.value, hvalue, results.bits); // Get 64bit value as hex 0x00123456 + char hvalue[65]; // Max 256 bits + if (results.bits > 64) { + // This emulates IRutils resultToHexidecimal and may needs a larger IR_RCV_BUFFER_SIZE + uint32_t digits2 = results.bits / 8; + if (results.bits % 8) { digits2++; } + ToHex_P((unsigned char*)results.state, digits2, hvalue, sizeof(hvalue)); // Get n-bit value as hex 56341200 + } else { + IrUint64toHex(results.value, hvalue, results.bits); // Get 64bit value as hex 00123456 + } - AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_IRR "Echo %d, RawLen %d, Overflow %d, Bits %d, Value %s, Decode %d"), + AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_IRR "Echo %d, RawLen %d, Overflow %d, Bits %d, Value 0x%s, Decode %d"), irsend_active, results.rawlen, results.overflow, results.bits, hvalue, results.decode_type); unsigned long now = millis(); @@ -149,7 +152,7 @@ void IrReceiveCheck(void) if (Settings.flag.ir_receive_decimal) { ulltoa(results.value, svalue, 10); } else { - snprintf_P(svalue, sizeof(svalue), PSTR("\"%s\""), hvalue); + snprintf_P(svalue, sizeof(svalue), PSTR("\"0x%s\""), hvalue); } Response_P(PSTR("{\"" D_JSON_IRRECEIVED "\":{\"" D_JSON_IR_PROTOCOL "\":\"%s\",\"" D_JSON_IR_BITS "\":%d,\"" D_JSON_IR_DATA "\":%s"), GetTextIndexed(sirtype, sizeof(sirtype), iridx, kIrRemoteProtocols), results.bits, svalue); @@ -921,8 +924,8 @@ uint32_t IrRemoteCmndIrSendJson(void) int protocol_code = GetCommandCode(protocol_text, sizeof(protocol_text), protocol, kIrRemoteProtocols); char dvalue[64]; - char hvalue[64]; - AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %s (%s), repeat %d, protocol_code %d"), + char hvalue[20]; + AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %s (0x%s), repeat %d, protocol_code %d"), protocol_text, protocol, bits, ulltoa(data, dvalue, 10), IrUint64toHex(data, hvalue, bits), repeat, protocol_code); irsend_active = true; diff --git a/tools/decode-config.py b/tools/decode-config.py index cf4606506..67e21b3a6 100755 --- a/tools/decode-config.py +++ b/tools/decode-config.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -VER = '2.2.0031' +VER = '2.3.0032' """ decode-config.py - Backup/Restore Sonoff-Tasmota configuration data @@ -955,7 +955,40 @@ Setting_6_6_0_5['flag3'][0].update ({ 'tuya_dimmer_min_limit': ('