mirror of https://github.com/arendst/Tasmota.git
Add possibility to receive more then 64 bits to IRremote
Add possibility to receive more then 64 bits to IRremote. May still need change of IR_RCV_BUFFER_SIZE (#6286)
This commit is contained in:
parent
9af67a5278
commit
b04bf63446
|
@ -85,13 +85,9 @@ char* IrUint64toHex(uint64_t value, char *str, uint16_t bits)
|
||||||
memmove(str + fill, str, len +1);
|
memmove(str + fill, str, len +1);
|
||||||
memset(str, '0', fill);
|
memset(str, '0', fill);
|
||||||
}
|
}
|
||||||
memmove(str + 2, str, strlen(str) +1);
|
|
||||||
str[0] = '0';
|
|
||||||
str[1] = 'x';
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_IR_RECEIVE
|
#ifdef USE_IR_RECEIVE
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* IR Receive
|
* IR Receive
|
||||||
|
@ -132,10 +128,17 @@ void IrReceiveCheck(void)
|
||||||
decode_results results;
|
decode_results results;
|
||||||
|
|
||||||
if (irrecv->decode(&results)) {
|
if (irrecv->decode(&results)) {
|
||||||
char hvalue[64];
|
char hvalue[65]; // Max 256 bits
|
||||||
IrUint64toHex(results.value, hvalue, results.bits); // Get 64bit value as hex 0x00123456
|
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);
|
irsend_active, results.rawlen, results.overflow, results.bits, hvalue, results.decode_type);
|
||||||
|
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
|
@ -149,7 +152,7 @@ void IrReceiveCheck(void)
|
||||||
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("\"%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"),
|
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);
|
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);
|
int protocol_code = GetCommandCode(protocol_text, sizeof(protocol_text), protocol, kIrRemoteProtocols);
|
||||||
|
|
||||||
char dvalue[64];
|
char dvalue[64];
|
||||||
char hvalue[64];
|
char hvalue[20];
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %s (%s), repeat %d, protocol_code %d"),
|
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);
|
protocol_text, protocol, bits, ulltoa(data, dvalue, 10), IrUint64toHex(data, hvalue, bits), repeat, protocol_code);
|
||||||
|
|
||||||
irsend_active = true;
|
irsend_active = true;
|
||||||
|
|
Loading…
Reference in New Issue