Browse Source

Merge pull request #1324 from vtochq/patch-1

fix _ir_results checks for Raw mode
alexa
Xose Pérez 6 years ago
committed by GitHub
parent
commit
9d5f0e94b1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 16 deletions
  1. +6
    -16
      code/espurna/ir.ino

+ 6
- 16
code/espurna/ir.ino View File

@ -43,8 +43,6 @@ Raw messages:
Payload: 1000,1000,1000,1000,1000 Payload: 1000,1000,1000,1000,1000
| IR codes | | IR codes |
* To support long codes (Air Conditioneer) increase MQTT packet size -DMQTT_MAX_PACKET_SIZE=1200
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
*/ */
@ -91,7 +89,6 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload
} }
if (type == MQTT_MESSAGE_EVENT) { if (type == MQTT_MESSAGE_EVENT) {
String t = mqttMagnitude((char *) topic); String t = mqttMagnitude((char *) topic);
// Match topic // Match topic
@ -173,14 +170,6 @@ void _irMqttCallback(unsigned int type, const char * topic, const char * payload
DEBUG_MSG_P(PSTR("[IR] Raw IR output %d codes, repeat %d times on %d(k)Hz freq.\n"), count, _ir_repeat, _ir_freq); DEBUG_MSG_P(PSTR("[IR] Raw IR output %d codes, repeat %d times on %d(k)Hz freq.\n"), count, _ir_repeat, _ir_freq);
/*
DEBUG_MSG_P(PSTR("[IR] main codes: "));
for(int i = 0; i < count; i++) {
DEBUG_MSG_P(PSTR("%d,"),_ir_raw[i]);
}
DEBUG_MSG_P(PSTR("\n"));
*/
#if defined(IR_RX_PIN) #if defined(IR_RX_PIN)
_ir_receiver.disableIRIn(); _ir_receiver.disableIRIn();
#endif #endif
@ -364,12 +353,9 @@ void _irRXLoop() {
if (millis() - last_time < IR_DEBOUNCE) return; if (millis() - last_time < IR_DEBOUNCE) return;
last_time = millis(); last_time = millis();
// Check code
if (_ir_results.value < 1) return;
if (_ir_results.decode_type < 1) return;
if (_ir_results.bits < 1) return;
#if IR_USE_RAW #if IR_USE_RAW
// Check code
if (_ir_results.rawlen < 1) return;
char * payload; char * payload;
String value = ""; String value = "";
for (int i = 1; i < _ir_results.rawlen; i++) { for (int i = 1; i < _ir_results.rawlen; i++) {
@ -378,6 +364,10 @@ void _irRXLoop() {
} }
payload = const_cast<char*>(value.c_str()); payload = const_cast<char*>(value.c_str());
#else #else
// Check code
if (_ir_results.value < 1) return;
if (_ir_results.decode_type < 1) return;
if (_ir_results.bits < 1) return;
char payload[32]; char payload[32];
snprintf_P(payload, sizeof(payload), PSTR("%u:%lu:%u"), _ir_results.decode_type, (unsigned long) _ir_results.value, _ir_results.bits); snprintf_P(payload, sizeof(payload), PSTR("%u:%lu:%u"), _ir_results.decode_type, (unsigned long) _ir_results.value, _ir_results.bits);
#endif #endif


Loading…
Cancel
Save