From d113c945b25c6ea213544cc4b5903c6c64ea7414 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sun, 3 Jan 2021 11:09:13 +0100 Subject: [PATCH 1/3] macsniff.cpp sanitizations --- src/macsniff.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/macsniff.cpp b/src/macsniff.cpp index 2ff27634..fb38d661 100644 --- a/src/macsniff.cpp +++ b/src/macsniff.cpp @@ -119,9 +119,7 @@ uint16_t mac_analyze(MacBuffer_t MacBuffer) { int8_t beaconID = isBeacon(macConvert(MacBuffer.mac)); if (beaconID >= 0) { ESP_LOGI(TAG, "Beacon ID#%d detected", beaconID); -#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) blink_LED(COLOR_WHITE, 2000); -#endif payload.reset(); payload.addAlarm(MacBuffer.rssi, beaconID); SendPayload(BEACONPORT); @@ -156,30 +154,22 @@ uint16_t mac_analyze(MacBuffer_t MacBuffer) { case MAC_SNIFF_WIFI: macs_wifi++; // increment Wifi MACs counter -#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) blink_LED(COLOR_GREEN, 50); -#endif break; -#if (BLECOUNTER) case MAC_SNIFF_BLE: macs_ble++; // increment BLE Macs counter -#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) blink_LED(COLOR_MAGENTA, 50); -#endif break; -#if (COUNT_ENS) case MAC_SNIFF_BLE_ENS: macs_ble++; // increment BLE Macs counter cwa_mac_add(hashedmac); // process ENS beacon -#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) blink_LED(COLOR_WHITE, 50); -#endif break; -#endif // COUNT_ENS -#endif // BLECOUNTER + default: + break; } // switch } // added From 41ab41566f30cd1496ad9571134343aea16c00a9 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sun, 3 Jan 2021 11:09:47 +0100 Subject: [PATCH 2/3] MAC container using DRAM --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 19ea3fef..3fb5c60b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -103,7 +103,7 @@ timesource_t timeSource = _unsynced; // container holding unique MAC address hashes with Memory Alloctor using PSRAM, // if present -std::set, Mallocator> macs; +DRAM_ATTR std::set, Mallocator> macs; // initialize payload encoder PayloadConvert payload(PAYLOAD_BUFFER_SIZE); From 399767e7ac3dcee1c9c5e8eaafa744a178b7777a Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sun, 3 Jan 2021 11:34:13 +0100 Subject: [PATCH 3/3] add MQTT nodered example --- README.md | 2 +- src/Node-RED/MQTT.json | 467 ++++++++++++++++++ .../Timeserver.json} | 0 src/{Timeserver => Node-RED}/timeserver.java | 0 4 files changed, 468 insertions(+), 1 deletion(-) create mode 100644 src/Node-RED/MQTT.json rename src/{Timeserver/Nodered-Timeserver.json => Node-RED/Timeserver.json} (100%) rename src/{Timeserver => Node-RED}/timeserver.java (100%) diff --git a/README.md b/README.md index 0f0c0529..8631a383 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ Paxcounter supports a battery friendly power saving mode. In this mode the devic # Time sync -Paxcounter can keep it's time-of-day synced with an external time source. Set *#define TIME_SYNC_INTERVAL* in paxcounter.conf to enable time sync. Supported external time sources are GPS, LORAWAN network time and LORAWAN application timeserver time. An on board DS3231 RTC is kept sycned as fallback time source. Time accuracy depends on board's time base which generates the pulse per second. Supported are GPS PPS, SQW output of RTC, and internal ESP32 hardware timer. Time base is selected by #defines in the board's hal file, see example in [**generic.h**](src/hal/generic.h). Bonus: If your LORAWAN network does not support network time, you can run a Node-Red timeserver application using the enclosed [**Timeserver code**](/src/Timeserver/Nodered-Timeserver.json). Configure MQTT nodes in Node-Red to the same LORAWAN application as paxocunter device is using. +Paxcounter can keep it's time-of-day synced with an external time source. Set *#define TIME_SYNC_INTERVAL* in paxcounter.conf to enable time sync. Supported external time sources are GPS, LORAWAN network time and LORAWAN application timeserver time. An on board DS3231 RTC is kept sycned as fallback time source. Time accuracy depends on board's time base which generates the pulse per second. Supported are GPS PPS, SQW output of RTC, and internal ESP32 hardware timer. Time base is selected by #defines in the board's hal file, see example in [**generic.h**](src/hal/generic.h). Bonus: If your LORAWAN network does not support network time, you can run a Node-Red timeserver application using the enclosed [**Timeserver code**](/src/Node-RED/Timeserver.json). Configure MQTT nodes in Node-Red for the LORAWAN application used by paxocunter device. # Wall clock controller diff --git a/src/Node-RED/MQTT.json b/src/Node-RED/MQTT.json new file mode 100644 index 00000000..4d2bde74 --- /dev/null +++ b/src/Node-RED/MQTT.json @@ -0,0 +1,467 @@ +[ + { + "id": "7bc3eb4f.fe4b64", + "type": "mqtt in", + "z": "c26229c6.2d1ae8", + "name": "Olimex", + "topic": "paxout/#", + "qos": "2", + "datatype": "utf8", + "broker": "bd56b04d.db0ff", + "x": 190, + "y": 160, + "wires": [ + [ + "d0276db6.83c46" + ] + ] + }, + { + "id": "4f59740b.296b7c", + "type": "debug", + "z": "c26229c6.2d1ae8", + "name": "data", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 1050, + "y": 280, + "wires": [] + }, + { + "id": "f10f8199.25183", + "type": "binary", + "z": "c26229c6.2d1ae8", + "name": "wifi", + "property": "payload", + "pattern": "l16, x16", + "x": 630, + "y": 100, + "wires": [ + [ + "800f5faa.15155" + ] + ] + }, + { + "id": "df4bdce5.dc219", + "type": "switch", + "z": "c26229c6.2d1ae8", + "name": "Ports", + "property": "topic", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "paxout/1", + "vt": "str" + }, + { + "t": "eq", + "v": "paxout/2", + "vt": "str" + }, + { + "t": "eq", + "v": "paxout/3", + "vt": "str" + }, + { + "t": "eq", + "v": "paxout/4", + "vt": "str" + }, + { + "t": "eq", + "v": "paxout/5", + "vt": "str" + }, + { + "t": "eq", + "v": "paxout/6", + "vt": "str" + }, + { + "t": "eq", + "v": "paxout/7", + "vt": "str" + }, + { + "t": "eq", + "v": "paxout/8", + "vt": "str" + }, + { + "t": "eq", + "v": "paxout/9", + "vt": "str" + }, + { + "t": "eq", + "v": "paxout/10", + "vt": "str" + }, + { + "t": "eq", + "v": "status", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 11, + "x": 370, + "y": 260, + "wires": [ + [ + "f10f8199.25183" + ], + [ + "e2974f79.55d5b" + ], + [ + "5f6987dd.b89378" + ], + [], + [ + "eaca83c4.5fcaf" + ], + [], + [], + [ + "7b6cbc9d.18fe44" + ], + [ + "d269537.4738fb" + ], + [ + "409e4762.71ff68" + ], + [ + "13fbfc5d.40dcc4" + ] + ] + }, + { + "id": "eaca83c4.5fcaf", + "type": "binary", + "z": "c26229c6.2d1ae8", + "name": "button", + "property": "payload", + "pattern": "b8 => button", + "x": 630, + "y": 280, + "wires": [ + [ + "a6037445.eb8ac8" + ] + ] + }, + { + "id": "409e4762.71ff68", + "type": "binary", + "z": "c26229c6.2d1ae8", + "name": "cwa", + "property": "payload", + "pattern": "l16 => cwa", + "x": 630, + "y": 140, + "wires": [ + [ + "2966fd1c.0b33d2" + ] + ] + }, + { + "id": "d0276db6.83c46", + "type": "base64", + "z": "c26229c6.2d1ae8", + "name": "Decode", + "action": "", + "property": "payload", + "x": 200, + "y": 260, + "wires": [ + [ + "df4bdce5.dc219" + ] + ] + }, + { + "id": "13fbfc5d.40dcc4", + "type": "binary", + "z": "c26229c6.2d1ae8", + "name": "Connection", + "property": "payload", + "pattern": "b8[19]|str(\"ascii\")", + "x": 650, + "y": 440, + "wires": [ + [ + "4f59740b.296b7c" + ] + ] + }, + { + "id": "800f5faa.15155", + "type": "ui_chart", + "z": "c26229c6.2d1ae8", + "name": "pax", + "group": "6838565d.06bf08", + "order": 1, + "width": 0, + "height": 0, + "label": "Pax [Wifi]", + "chartType": "line", + "legend": "false", + "xformat": "dd HH:mm", + "interpolate": "linear", + "nodata": "Noch keine Daten", + "dot": false, + "ymin": "", + "ymax": "", + "removeOlder": 1, + "removeOlderPoints": "", + "removeOlderUnit": "3600", + "cutout": 0, + "useOneColor": false, + "useUTC": false, + "colors": [ + "#1f77b4", + "#aec7e8", + "#ff7f0e", + "#2ca02c", + "#98df8a", + "#d62728", + "#ff9896", + "#9467bd", + "#c5b0d5" + ], + "outputs": 1, + "x": 810, + "y": 100, + "wires": [ + [] + ] + }, + { + "id": "2966fd1c.0b33d2", + "type": "ui_chart", + "z": "c26229c6.2d1ae8", + "name": "cwa", + "group": "6838565d.06bf08", + "order": 1, + "width": 0, + "height": 0, + "label": "CWA", + "chartType": "line", + "legend": "false", + "xformat": "dd HH:mm", + "interpolate": "linear", + "nodata": "", + "dot": false, + "ymin": "", + "ymax": "", + "removeOlder": 1, + "removeOlderPoints": "", + "removeOlderUnit": "3600", + "cutout": 0, + "useOneColor": false, + "useUTC": false, + "colors": [ + "#1f77b4", + "#aec7e8", + "#ff7f0e", + "#2ca02c", + "#98df8a", + "#d62728", + "#ff9896", + "#9467bd", + "#c5b0d5" + ], + "outputs": 1, + "x": 810, + "y": 140, + "wires": [ + [] + ] + }, + { + "id": "a6037445.eb8ac8", + "type": "ui_toast", + "z": "c26229c6.2d1ae8", + "position": "top right", + "displayTime": "3", + "highlight": "", + "sendall": true, + "outputs": 0, + "ok": "OK", + "cancel": "", + "raw": false, + "topic": "Button", + "name": "Popup", + "x": 810, + "y": 280, + "wires": [] + }, + { + "id": "b4478f8.f8b747", + "type": "mqtt out", + "z": "c26229c6.2d1ae8", + "name": "Olimex", + "topic": "paxin", + "qos": "", + "retain": "", + "broker": "bd56b04d.db0ff", + "x": 190, + "y": 480, + "wires": [] + }, + { + "id": "e2974f79.55d5b", + "type": "binary", + "z": "c26229c6.2d1ae8", + "name": "device status", + "property": "payload", + "pattern": "l16 => voltage,\nl64 => uptime,\nb8 => temperature,\nl32 => ram,\nb8 => reset0,\nb8 => reset1", + "x": 650, + "y": 200, + "wires": [ + [ + "4f59740b.296b7c" + ] + ] + }, + { + "id": "5f6987dd.b89378", + "type": "binary", + "z": "c26229c6.2d1ae8", + "name": "device config", + "property": "payload", + "pattern": "b8 => loradr,\nb8 => txPower,\nl16 => rssilimit,\nb8 => sendcycle,\nb8 => wifichancycle,\nb8 => blescantime,\nb8 => rgblum,\nb8 => configmask,\nb8 => payloadmask,\nb8z|str(\"ascii\") => version", + "x": 650, + "y": 240, + "wires": [ + [ + "4f59740b.296b7c" + ] + ] + }, + { + "id": "7b6cbc9d.18fe44", + "type": "binary", + "z": "c26229c6.2d1ae8", + "name": "battery", + "property": "payload", + "pattern": "l16 => voltage", + "x": 630, + "y": 360, + "wires": [ + [ + "4f59740b.296b7c" + ] + ] + }, + { + "id": "d269537.4738fb", + "type": "binary", + "z": "c26229c6.2d1ae8", + "name": "time", + "property": "payload", + "pattern": "l32 => unixtime", + "x": 630, + "y": 400, + "wires": [ + [ + "4f59740b.296b7c" + ] + ] + }, + { + "id": "ce0cb32b.b7b96", + "type": "base64", + "z": "c26229c6.2d1ae8", + "name": "Encode", + "action": "", + "property": "payload", + "x": 200, + "y": 420, + "wires": [ + [ + "b4478f8.f8b747" + ] + ] + }, + { + "id": "c246a129.eeb5e", + "type": "inject", + "z": "c26229c6.2d1ae8", + "name": "rcmd", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "paxin", + "payload": "[128, 129]", + "payloadType": "bin", + "x": 190, + "y": 360, + "wires": [ + [ + "ce0cb32b.b7b96" + ] + ] + }, + { + "id": "bd56b04d.db0ff", + "type": "mqtt-broker", + "name": "Shiftr.io", + "broker": "public.cloud.shiftr.io", + "port": "1883", + "clientid": "", + "usetls": false, + "compatmode": false, + "keepalive": "60", + "cleansession": true, + "birthTopic": "paxout/status", + "birthQos": "0", + "birthPayload": "on", + "closeTopic": "paxout/status", + "closeQos": "0", + "closePayload": "off", + "willTopic": "paxout/status", + "willQos": "0", + "willPayload": "unknown" + }, + { + "id": "6838565d.06bf08", + "type": "ui_group", + "name": "MQTT", + "tab": "ad5894fa.466c58", + "order": 1, + "disp": true, + "width": "6", + "collapse": false + }, + { + "id": "ad5894fa.466c58", + "type": "ui_tab", + "name": "Paxcounter", + "icon": "people", + "order": 4 + } +] \ No newline at end of file diff --git a/src/Timeserver/Nodered-Timeserver.json b/src/Node-RED/Timeserver.json similarity index 100% rename from src/Timeserver/Nodered-Timeserver.json rename to src/Node-RED/Timeserver.json diff --git a/src/Timeserver/timeserver.java b/src/Node-RED/timeserver.java similarity index 100% rename from src/Timeserver/timeserver.java rename to src/Node-RED/timeserver.java