mirror of https://github.com/arendst/Tasmota.git
Merge pull request #6399 from s-hadinger/ir_hash
Rename "Data" to "Hash" and limit to 32 bits when receiving UNKNOWN IR protocol
This commit is contained in:
commit
33baadfafd
|
@ -2,6 +2,7 @@
|
||||||
* 6.6.0.12 20190910
|
* 6.6.0.12 20190910
|
||||||
* Redesign command Tariff to now default to 0 (=disabled) and allowing to set both Standard Time (ST) and Daylight Savings Time (DST) start hour
|
* Redesign command Tariff to now default to 0 (=disabled) and allowing to set both Standard Time (ST) and Daylight Savings Time (DST) start hour
|
||||||
* Commands Tariff1 22,23 = Tariff1 (Off-Peak) ST,DST Tariff2 (Standard) 6,7 = Tariff2 ST,DST Tariff9 0/1 = Weekend toggle (1 = Off-Peak during weekend)
|
* Commands Tariff1 22,23 = Tariff1 (Off-Peak) ST,DST Tariff2 (Standard) 6,7 = Tariff2 ST,DST Tariff9 0/1 = Weekend toggle (1 = Off-Peak during weekend)
|
||||||
|
* Change rename "Data" to "Hash" and limit to 32 bits when receiving UNKNOWN IR protocol (see DECODE_HASH from IRremoteESP8266)
|
||||||
*
|
*
|
||||||
* 6.6.0.11 20190907
|
* 6.6.0.11 20190907
|
||||||
* Change Settings crc calculation allowing short term backward compatibility
|
* Change Settings crc calculation allowing short term backward compatibility
|
||||||
|
|
|
@ -385,6 +385,7 @@
|
||||||
#define D_JSON_IR_BITS "Bits"
|
#define D_JSON_IR_BITS "Bits"
|
||||||
#define D_JSON_IR_DATA "Data"
|
#define D_JSON_IR_DATA "Data"
|
||||||
#define D_JSON_IR_DATALSB "DataLSB"
|
#define D_JSON_IR_DATALSB "DataLSB"
|
||||||
|
#define D_JSON_IR_HASH "Hash"
|
||||||
#define D_JSON_IR_RAWDATA "RawData"
|
#define D_JSON_IR_RAWDATA "RawData"
|
||||||
#define D_JSON_IR_REPEAT "Repeat"
|
#define D_JSON_IR_REPEAT "Repeat"
|
||||||
#define D_CMND_IRHVAC "IRHVAC"
|
#define D_CMND_IRHVAC "IRHVAC"
|
||||||
|
|
|
@ -129,6 +129,11 @@ void IrReceiveCheck(void)
|
||||||
|
|
||||||
if (irrecv->decode(&results)) {
|
if (irrecv->decode(&results)) {
|
||||||
char hvalue[65]; // Max 256 bits
|
char hvalue[65]; // Max 256 bits
|
||||||
|
|
||||||
|
iridx = results.decode_type;
|
||||||
|
if ((iridx < 0) || (iridx > 14)) { iridx = 0; } // UNKNOWN
|
||||||
|
|
||||||
|
if (iridx) {
|
||||||
if (results.bits > 64) {
|
if (results.bits > 64) {
|
||||||
// This emulates IRutils resultToHexidecimal and may needs a larger IR_RCV_BUFFER_SIZE
|
// This emulates IRutils resultToHexidecimal and may needs a larger IR_RCV_BUFFER_SIZE
|
||||||
uint32_t digits2 = results.bits / 8;
|
uint32_t digits2 = results.bits / 8;
|
||||||
|
@ -137,6 +142,9 @@ void IrReceiveCheck(void)
|
||||||
} else {
|
} else {
|
||||||
IrUint64toHex(results.value, hvalue, results.bits); // Get 64bit value as hex 00123456
|
IrUint64toHex(results.value, hvalue, results.bits); // Get 64bit value as hex 00123456
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
IrUint64toHex(results.value, hvalue, 32); // UNKNOWN is always 32 bits hash
|
||||||
|
}
|
||||||
|
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_IRR "Echo %d, RawLen %d, Overflow %d, Bits %d, Value 0x%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);
|
irsend_active, results.rawlen, results.overflow, results.bits, hvalue, results.decode_type);
|
||||||
|
@ -146,16 +154,19 @@ void IrReceiveCheck(void)
|
||||||
if (!irsend_active && (now - ir_lasttime > IR_TIME_AVOID_DUPLICATE)) {
|
if (!irsend_active && (now - ir_lasttime > IR_TIME_AVOID_DUPLICATE)) {
|
||||||
ir_lasttime = now;
|
ir_lasttime = now;
|
||||||
|
|
||||||
iridx = results.decode_type;
|
|
||||||
if ((iridx < 0) || (iridx > 14)) { iridx = 0; } // UNKNOWN
|
|
||||||
char svalue[64];
|
char svalue[64];
|
||||||
if (Settings.flag.ir_receive_decimal) {
|
if (Settings.flag.ir_receive_decimal) {
|
||||||
ulltoa(results.value, svalue, 10);
|
ulltoa(results.value, svalue, 10);
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("\"0x%s\""), hvalue);
|
snprintf_P(svalue, sizeof(svalue), PSTR("\"0x%s\""), hvalue);
|
||||||
}
|
}
|
||||||
ResponseTime_P(PSTR(",\"" D_JSON_IRRECEIVED "\":{\"" D_JSON_IR_PROTOCOL "\":\"%s\",\"" D_JSON_IR_BITS "\":%d,\"" D_JSON_IR_DATA "\":%s"),
|
ResponseTime_P(PSTR(",\"" D_JSON_IRRECEIVED "\":{\"" D_JSON_IR_PROTOCOL "\":\"%s\",\"" D_JSON_IR_BITS "\":%d"),
|
||||||
GetTextIndexed(sirtype, sizeof(sirtype), iridx, kIrRemoteProtocols), results.bits, svalue);
|
GetTextIndexed(sirtype, sizeof(sirtype), iridx, kIrRemoteProtocols), results.bits);
|
||||||
|
if (iridx) {
|
||||||
|
ResponseAppend_P(PSTR(",\"" D_JSON_IR_DATA "\":%s"), svalue);
|
||||||
|
} else {
|
||||||
|
ResponseAppend_P(PSTR(",\"" D_JSON_IR_HASH "\":%s"), svalue);
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings.flag3.receive_raw) {
|
if (Settings.flag3.receive_raw) {
|
||||||
ResponseAppend_P(PSTR(",\"" D_JSON_IR_RAWDATA "\":["));
|
ResponseAppend_P(PSTR(",\"" D_JSON_IR_RAWDATA "\":["));
|
||||||
|
|
|
@ -177,13 +177,18 @@ String sendIRJsonState(const struct decode_results &results) {
|
||||||
json += resultToHexidecimal(&results);
|
json += resultToHexidecimal(&results);
|
||||||
json += "\"";
|
json += "\"";
|
||||||
} else {
|
} else {
|
||||||
|
if (UNKNOWN != results.decode_type) {
|
||||||
json += ",\"" D_JSON_IR_DATA "\":";
|
json += ",\"" D_JSON_IR_DATA "\":";
|
||||||
|
} else {
|
||||||
|
json += ",\"" D_JSON_IR_HASH "\":";
|
||||||
|
}
|
||||||
if (Settings.flag.ir_receive_decimal) {
|
if (Settings.flag.ir_receive_decimal) {
|
||||||
char svalue[32];
|
char svalue[32];
|
||||||
ulltoa(results.value, svalue, 10);
|
ulltoa(results.value, svalue, 10);
|
||||||
json += svalue;
|
json += svalue;
|
||||||
} else {
|
} else {
|
||||||
char hvalue[64];
|
char hvalue[64];
|
||||||
|
if (UNKNOWN != results.decode_type) {
|
||||||
IrUint64toHex(results.value, hvalue, results.bits); // Get 64bit value as hex 0x00123456
|
IrUint64toHex(results.value, hvalue, results.bits); // Get 64bit value as hex 0x00123456
|
||||||
json += "\"";
|
json += "\"";
|
||||||
json += hvalue;
|
json += hvalue;
|
||||||
|
@ -191,6 +196,12 @@ String sendIRJsonState(const struct decode_results &results) {
|
||||||
IrUint64toHex(reverseBitsInBytes64(results.value), hvalue, results.bits); // Get 64bit value as hex 0x00123456, LSB
|
IrUint64toHex(reverseBitsInBytes64(results.value), hvalue, results.bits); // Get 64bit value as hex 0x00123456, LSB
|
||||||
json += hvalue;
|
json += hvalue;
|
||||||
json += "\"";
|
json += "\"";
|
||||||
|
} else { // UNKNOWN
|
||||||
|
IrUint64toHex(results.value, hvalue, 32); // Unknown is always 32 bits
|
||||||
|
json += "\"";
|
||||||
|
json += hvalue;
|
||||||
|
json += "\"";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
json += ",\"" D_JSON_IR_REPEAT "\":";
|
json += ",\"" D_JSON_IR_REPEAT "\":";
|
||||||
|
|
Loading…
Reference in New Issue