Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for RX pin pullup and send whole buffer for received raw messages in IRMQTTServer.ino #589

Merged
merged 9 commits into from
Dec 30, 2018
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
29 changes: 27 additions & 2 deletions examples/IRMQTTServer/IRMQTTServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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 <PubSubClient.h> to have the following (or larger) value:
* o You MUST change <PubSubClient.h> to have the following (or larger, particularly for REPORT_RAW_UNKNOWNS) value:
matgoebl marked this conversation as resolved.
Show resolved Hide resolved
* #define MQTT_MAX_PACKET_SIZE 512
* - PlatformIO IDE:
* If you are using PlatformIO, this should already been done for you in
Expand Down Expand Up @@ -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.
matgoebl marked this conversation as resolved.
Show resolved Hide resolved
#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.
Expand Down Expand Up @@ -190,6 +191,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
Expand Down Expand Up @@ -381,7 +383,11 @@ void handleRoot() {
"Last message sent: " + String(lastSendSucceeded ? "Ok" : "FAILED") +
" <i>(" + timeSince(lastSendTime) + ")</i><br>"
#ifdef IR_RX
"IR Recv GPIO: " + String(IR_RX) + "<br>"
"IR Recv GPIO: " + String(IR_RX) +
#if IR_RX_PULLUP
" (pullup)"
#endif // IR_RX_PULLUP
"<br>"
"Total IR Received: " + String(irRecvCounter) + "<br>"
"Last IR Received: " + lastIrReceived +
" <i>(" + timeSince(lastIrReceivedTime) + ")</i><br>"
Expand Down Expand Up @@ -1112,6 +1118,9 @@ void setup(void) {
irsend.begin();
offset = irsend.calibrate();
#if IR_RX
#if IR_RX_PULLUP
pinMode(IR_RX, INPUT_PULLUP);
matgoebl marked this conversation as resolved.
Show resolved Hide resolved
#endif // IR_RX_PULLUP
#if DECODE_HASH
// Ignore messages with less than minimum on or off pulses.
irrecv.setUnknownThreshold(kMinUnknownSize);
Expand Down Expand Up @@ -1283,6 +1292,22 @@ void loop(void) {
lastIrReceivedTime = millis();
lastIrReceived = String(capture.decode_type) + "," +
resultToHexidecimal(&capture);
#if REPORT_RAW_UNKNOWNS
if (capture.decode_type == UNKNOWN) {
lastIrReceived += ";";
for (uint16_t i = 1; i < capture.rawlen; i++) {
matgoebl marked this conversation as resolved.
Show resolved Hide resolved
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 += ",";
}
}
#endif // REPORT_RAW_UNKNOWNS
// If it isn't an AC code, add the bits.
if (!hasACState(capture.decode_type))
lastIrReceived += "," + String(capture.bits);
Expand Down