From 4d620f2345532054af4af3f4130651079d092bfc Mon Sep 17 00:00:00 2001 From: Matthias Goebl Date: Thu, 27 Dec 2018 20:12:09 +0100 Subject: [PATCH 1/8] Add option for RX pin pullup in IRMQTTServer.ino --- examples/IRMQTTServer/IRMQTTServer.ino | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/IRMQTTServer/IRMQTTServer.ino b/examples/IRMQTTServer/IRMQTTServer.ino index 38a099b51..316ab64c1 100644 --- a/examples/IRMQTTServer/IRMQTTServer.ino +++ b/examples/IRMQTTServer/IRMQTTServer.ino @@ -190,6 +190,7 @@ // GPIO the IR RX module is connected to/controlled by. GPIO 14 = D5. // Comment this out to disable receiving/decoding IR messages entirely. #define IR_RX 14 // <=- CHANGE_ME (optional) +#define IR_RX_PULLUP false const uint16_t kHttpPort = 80; // The TCP port the HTTP server is listening on. // Name of the device you want in mDNS. // NOTE: Changing this will change the MQTT path too unless you override it @@ -381,7 +382,11 @@ void handleRoot() { "Last message sent: " + String(lastSendSucceeded ? "Ok" : "FAILED") + " (" + timeSince(lastSendTime) + ")
" #ifdef IR_RX - "IR Recv GPIO: " + String(IR_RX) + "
" + "IR Recv GPIO: " + String(IR_RX) + +#if IR_RX_PULLUP + " (pullup)" +#endif // IR_RX_PULLUP + "
" "Total IR Received: " + String(irRecvCounter) + "
" "Last IR Received: " + lastIrReceived + " (" + timeSince(lastIrReceivedTime) + ")
" @@ -1112,6 +1117,9 @@ void setup(void) { irsend.begin(); offset = irsend.calibrate(); #if IR_RX +#if IR_RX_PULLUP + pinMode(IR_RX, INPUT_PULLUP); +#endif // IR_RX_PULLUP #if DECODE_HASH // Ignore messages with less than minimum on or off pulses. irrecv.setUnknownThreshold(kMinUnknownSize); From b1bdd7dedbdbc3b4738585bc15428571dafc45c7 Mon Sep 17 00:00:00 2001 From: Matthias Goebl Date: Thu, 27 Dec 2018 21:46:31 +0100 Subject: [PATCH 2/8] Send whole buffer for received raw messages in IRMQTTServer.ino --- examples/IRMQTTServer/IRMQTTServer.ino | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/IRMQTTServer/IRMQTTServer.ino b/examples/IRMQTTServer/IRMQTTServer.ino index 316ab64c1..515419b52 100644 --- a/examples/IRMQTTServer/IRMQTTServer.ino +++ b/examples/IRMQTTServer/IRMQTTServer.ino @@ -1291,6 +1291,20 @@ void loop(void) { lastIrReceivedTime = millis(); lastIrReceived = String(capture.decode_type) + "," + resultToHexidecimal(&capture); + if (capture.decode_type == -1) { + lastIrReceived += ";"; + for (uint16_t i = 1; i < capture.rawlen; i++) { + uint32_t usecs; + for (usecs = capture.rawbuf[i] * kRawTick; usecs > UINT16_MAX; + usecs -= UINT16_MAX) { + lastIrReceived += uint64ToString(UINT16_MAX); + lastIrReceived += ",0,"; + } + lastIrReceived += uint64ToString(usecs, 10); + if (i < capture.rawlen - 1) + lastIrReceived += ","; + } + } // If it isn't an AC code, add the bits. if (!hasACState(capture.decode_type)) lastIrReceived += "," + String(capture.bits); From aaed840b71abe062a030b10a0644d0db4fc40cae Mon Sep 17 00:00:00 2001 From: Matthias Goebl Date: Fri, 28 Dec 2018 09:17:06 +0100 Subject: [PATCH 3/8] Make sending the whole buffer optional. Add comments to increase MQTT_MAX_PACKET_SIZE. Fix using the enum value for UNKNOWN type. --- examples/IRMQTTServer/IRMQTTServer.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/IRMQTTServer/IRMQTTServer.ino b/examples/IRMQTTServer/IRMQTTServer.ino index 515419b52..9eecab8d3 100644 --- a/examples/IRMQTTServer/IRMQTTServer.ino +++ b/examples/IRMQTTServer/IRMQTTServer.ino @@ -26,7 +26,7 @@ * o Install the following libraries via Library Manager * - WiFiManager (https://github.com/tzapu/WiFiManager) (Version >= 0.14) * - PubSubClient (https://pubsubclient.knolleary.net/) - * o You MUST change to have the following (or larger) value: + * o You MUST change to have the following (or larger, particularly for REPORT_RAW_UNKNOWNS) value: * #define MQTT_MAX_PACKET_SIZE 512 * - PlatformIO IDE: * If you are using PlatformIO, this should already been done for you in @@ -151,6 +151,7 @@ // Change to 'true'/'false' if you do/don't want these features or functions. #define USE_STATIC_IP false // Change to 'true' if you don't want to use DHCP. #define REPORT_UNKNOWNS false // Report inbound IR messages that we don't know. +#define REPORT_RAW_UNKNOWNS false // Report the whole buffer. MQTT_MAX_PACKET_SIZE of 1024 or more recommended. #define MQTT_ENABLE true // Whether or not MQTT is used at all. // 'kHtmlUsername' & 'kHtmlPassword' are used by the following two items: #define FIRMWARE_OTA true // Allow remote update of the firmware via http. @@ -1291,7 +1292,8 @@ void loop(void) { lastIrReceivedTime = millis(); lastIrReceived = String(capture.decode_type) + "," + resultToHexidecimal(&capture); - if (capture.decode_type == -1) { +#if REPORT_RAW_UNKNOWNS + if (capture.decode_type == UNKNOWN) { lastIrReceived += ";"; for (uint16_t i = 1; i < capture.rawlen; i++) { uint32_t usecs; @@ -1305,6 +1307,7 @@ void loop(void) { lastIrReceived += ","; } } +#endif // REPORT_RAW_UNKNOWNS // If it isn't an AC code, add the bits. if (!hasACState(capture.decode_type)) lastIrReceived += "," + String(capture.bits); From 293833d6344f59b0e9bc854bd205a34a4e595549 Mon Sep 17 00:00:00 2001 From: David Conran Date: Sat, 29 Dec 2018 01:10:18 +1000 Subject: [PATCH 4/8] Fix travis config (#591) Try to fix some travis issues. - Upgrade to newer arduino package. - Breaking changes because of esp8266 core v2.5 - CpuFrequency -> xtal - FlashSize -> eesz --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4331425e9..30c266e4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,14 @@ language: c env: - - BD=esp8266:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M3M - - BD=esp8266:esp8266:d1_mini:CpuFrequency=80,FlashSize=4M3M + - BD=esp8266:esp8266:nodemcuv2:xtal=80,eesz=4M3M + - BD=esp8266:esp8266:d1_mini:xtal=80,eesz=4M3M before_install: - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16" - sleep 3 - export DISPLAY=:1.0 - - wget http://downloads.arduino.cc/arduino-1.8.2-linux64.tar.xz - - tar xf arduino-1.8.2-linux64.tar.xz - - sudo mv arduino-1.8.2 /usr/local/share/arduino + - wget http://downloads.arduino.cc/arduino-1.8.8-linux64.tar.xz + - tar xf arduino-1.8.8-linux64.tar.xz + - sudo mv arduino-1.8.8 /usr/local/share/arduino - sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino - wget https://raw.githubusercontent.com/google/styleguide/gh-pages/cpplint/cpplint.py install: From c79c951ae89693a990a38046ff6ea6a197a2252d Mon Sep 17 00:00:00 2001 From: Matthias Goebl Date: Thu, 27 Dec 2018 20:12:09 +0100 Subject: [PATCH 5/8] Add option for RX pin pullup in IRMQTTServer.ino --- examples/IRMQTTServer/IRMQTTServer.ino | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/IRMQTTServer/IRMQTTServer.ino b/examples/IRMQTTServer/IRMQTTServer.ino index 38a099b51..316ab64c1 100644 --- a/examples/IRMQTTServer/IRMQTTServer.ino +++ b/examples/IRMQTTServer/IRMQTTServer.ino @@ -190,6 +190,7 @@ // GPIO the IR RX module is connected to/controlled by. GPIO 14 = D5. // Comment this out to disable receiving/decoding IR messages entirely. #define IR_RX 14 // <=- CHANGE_ME (optional) +#define IR_RX_PULLUP false const uint16_t kHttpPort = 80; // The TCP port the HTTP server is listening on. // Name of the device you want in mDNS. // NOTE: Changing this will change the MQTT path too unless you override it @@ -381,7 +382,11 @@ void handleRoot() { "Last message sent: " + String(lastSendSucceeded ? "Ok" : "FAILED") + " (" + timeSince(lastSendTime) + ")
" #ifdef IR_RX - "IR Recv GPIO: " + String(IR_RX) + "
" + "IR Recv GPIO: " + String(IR_RX) + +#if IR_RX_PULLUP + " (pullup)" +#endif // IR_RX_PULLUP + "
" "Total IR Received: " + String(irRecvCounter) + "
" "Last IR Received: " + lastIrReceived + " (" + timeSince(lastIrReceivedTime) + ")
" @@ -1112,6 +1117,9 @@ void setup(void) { irsend.begin(); offset = irsend.calibrate(); #if IR_RX +#if IR_RX_PULLUP + pinMode(IR_RX, INPUT_PULLUP); +#endif // IR_RX_PULLUP #if DECODE_HASH // Ignore messages with less than minimum on or off pulses. irrecv.setUnknownThreshold(kMinUnknownSize); From 190061b9199d54b286a54d34e051a05573c03b83 Mon Sep 17 00:00:00 2001 From: Matthias Goebl Date: Thu, 27 Dec 2018 21:46:31 +0100 Subject: [PATCH 6/8] Send whole buffer for received raw messages in IRMQTTServer.ino --- examples/IRMQTTServer/IRMQTTServer.ino | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/IRMQTTServer/IRMQTTServer.ino b/examples/IRMQTTServer/IRMQTTServer.ino index 316ab64c1..515419b52 100644 --- a/examples/IRMQTTServer/IRMQTTServer.ino +++ b/examples/IRMQTTServer/IRMQTTServer.ino @@ -1291,6 +1291,20 @@ void loop(void) { lastIrReceivedTime = millis(); lastIrReceived = String(capture.decode_type) + "," + resultToHexidecimal(&capture); + if (capture.decode_type == -1) { + lastIrReceived += ";"; + for (uint16_t i = 1; i < capture.rawlen; i++) { + uint32_t usecs; + for (usecs = capture.rawbuf[i] * kRawTick; usecs > UINT16_MAX; + usecs -= UINT16_MAX) { + lastIrReceived += uint64ToString(UINT16_MAX); + lastIrReceived += ",0,"; + } + lastIrReceived += uint64ToString(usecs, 10); + if (i < capture.rawlen - 1) + lastIrReceived += ","; + } + } // If it isn't an AC code, add the bits. if (!hasACState(capture.decode_type)) lastIrReceived += "," + String(capture.bits); From a9b4056f82b2c7e943774ae1c79642bfc00fc912 Mon Sep 17 00:00:00 2001 From: Matthias Goebl Date: Fri, 28 Dec 2018 09:17:06 +0100 Subject: [PATCH 7/8] Make sending the whole buffer optional. Add comments to increase MQTT_MAX_PACKET_SIZE. Fix using the enum value for UNKNOWN type. --- examples/IRMQTTServer/IRMQTTServer.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/IRMQTTServer/IRMQTTServer.ino b/examples/IRMQTTServer/IRMQTTServer.ino index 515419b52..9eecab8d3 100644 --- a/examples/IRMQTTServer/IRMQTTServer.ino +++ b/examples/IRMQTTServer/IRMQTTServer.ino @@ -26,7 +26,7 @@ * o Install the following libraries via Library Manager * - WiFiManager (https://github.com/tzapu/WiFiManager) (Version >= 0.14) * - PubSubClient (https://pubsubclient.knolleary.net/) - * o You MUST change to have the following (or larger) value: + * o You MUST change to have the following (or larger, particularly for REPORT_RAW_UNKNOWNS) value: * #define MQTT_MAX_PACKET_SIZE 512 * - PlatformIO IDE: * If you are using PlatformIO, this should already been done for you in @@ -151,6 +151,7 @@ // Change to 'true'/'false' if you do/don't want these features or functions. #define USE_STATIC_IP false // Change to 'true' if you don't want to use DHCP. #define REPORT_UNKNOWNS false // Report inbound IR messages that we don't know. +#define REPORT_RAW_UNKNOWNS false // Report the whole buffer. MQTT_MAX_PACKET_SIZE of 1024 or more recommended. #define MQTT_ENABLE true // Whether or not MQTT is used at all. // 'kHtmlUsername' & 'kHtmlPassword' are used by the following two items: #define FIRMWARE_OTA true // Allow remote update of the firmware via http. @@ -1291,7 +1292,8 @@ void loop(void) { lastIrReceivedTime = millis(); lastIrReceived = String(capture.decode_type) + "," + resultToHexidecimal(&capture); - if (capture.decode_type == -1) { +#if REPORT_RAW_UNKNOWNS + if (capture.decode_type == UNKNOWN) { lastIrReceived += ";"; for (uint16_t i = 1; i < capture.rawlen; i++) { uint32_t usecs; @@ -1305,6 +1307,7 @@ void loop(void) { lastIrReceived += ","; } } +#endif // REPORT_RAW_UNKNOWNS // If it isn't an AC code, add the bits. if (!hasACState(capture.decode_type)) lastIrReceived += "," + String(capture.bits); From a26bc4ef8b74ed132a1d84259632f965448e73e9 Mon Sep 17 00:00:00 2001 From: Matthias Goebl Date: Sat, 29 Dec 2018 22:16:55 +0100 Subject: [PATCH 8/8] Fixed too long lines with comments --- examples/IRMQTTServer/IRMQTTServer.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/IRMQTTServer/IRMQTTServer.ino b/examples/IRMQTTServer/IRMQTTServer.ino index 9eecab8d3..1c02e591c 100644 --- a/examples/IRMQTTServer/IRMQTTServer.ino +++ b/examples/IRMQTTServer/IRMQTTServer.ino @@ -26,7 +26,8 @@ * o Install the following libraries via Library Manager * - WiFiManager (https://github.com/tzapu/WiFiManager) (Version >= 0.14) * - PubSubClient (https://pubsubclient.knolleary.net/) - * o You MUST change to have the following (or larger, particularly for REPORT_RAW_UNKNOWNS) value: + * o You MUST change to have the following (or larger) value: + * (with REPORT_RAW_UNKNOWNS 1024 or more is recommended) * #define MQTT_MAX_PACKET_SIZE 512 * - PlatformIO IDE: * If you are using PlatformIO, this should already been done for you in @@ -151,7 +152,8 @@ // Change to 'true'/'false' if you do/don't want these features or functions. #define USE_STATIC_IP false // Change to 'true' if you don't want to use DHCP. #define REPORT_UNKNOWNS false // Report inbound IR messages that we don't know. -#define REPORT_RAW_UNKNOWNS false // Report the whole buffer. MQTT_MAX_PACKET_SIZE of 1024 or more recommended. +#define REPORT_RAW_UNKNOWNS false // Report the whole buffer, recommended: + // MQTT_MAX_PACKET_SIZE of 1024 or more #define MQTT_ENABLE true // Whether or not MQTT is used at all. // 'kHtmlUsername' & 'kHtmlPassword' are used by the following two items: #define FIRMWARE_OTA true // Allow remote update of the firmware via http.