Created
August 21, 2019 13:32
-
-
Save dexterlabora/9272a4bee34034e13c5892edf6adb4d2 to your computer and use it in GitHub Desktop.
A simulation of WiFi and BLE probes and MQTT communication network.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "c100fe2a.cb152", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Broker", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "payload", | |
| "x": 350, | |
| "y": 80, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "2d4f4be6.545f04", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Device: AAAA-AAAA-AAAA", | |
| "func": "\nmsg.device = {\n serial: \"AAAA-AAAA-AAAA\",\n name: \"Lobby\",\n tags: [\"Floor-01\", \"Guest\"]\n}\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 580, | |
| "y": 180, | |
| "wires": [ | |
| [ | |
| "a2445d05.bc6f" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "c831ce49.33e98", | |
| "type": "inject", | |
| "z": "90fbc492.9c31f8", | |
| "name": "AP 1", | |
| "topic": "", | |
| "payload": "", | |
| "payloadType": "date", | |
| "repeat": "", | |
| "crontab": "", | |
| "once": false, | |
| "onceDelay": 0.1, | |
| "x": 110, | |
| "y": 180, | |
| "wires": [ | |
| [ | |
| "cafd49a5.43b1c8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "d04bdc6a.9a0ab", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "WiFi Clients", | |
| "func": "msg.clients = [\n \"50:dc:e7:98:4f:5e\",\n \"3c:5c:c4:f0:99:06\",\n \"3c:da:2a:f0:89:3e\",\n \"18:fe:34:ed:8b:ea\",\n \"04:03:d6:55:a8:34\",\n \"98:18:88:00:e6:fe\",\n \"18:fe:34:fc:5a:7f\",\n \"64:16:66:35:a8:3b\",\n \"5c:cf:7f:83:c1:99\",\n \"24:18:1d:ae:4c:71\"\n];\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 530, | |
| "y": 400, | |
| "wires": [ | |
| [ | |
| "2e5b037d.84cd5c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "cafd49a5.43b1c8", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Network: N_1111111111111", | |
| "func": "\nmsg.network = {\n id: \"N_1111111111111\",\n name: \"Branch-01\"\n}\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 320, | |
| "y": 180, | |
| "wires": [ | |
| [ | |
| "2d4f4be6.545f04" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "9ce3e99a.077288", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Broker", | |
| "info": "", | |
| "x": 90, | |
| "y": 40, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "d01c443e.e40dd8", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "BLE Clients", | |
| "func": "msg.clients = [\n \"bb:dc:e7:98:4f:5e\",\n \"bb:5c:c4:f0:99:06\",\n \"bb:da:2a:f0:89:3e\",\n \"bb:fe:34:ed:8b:ea\",\n \"bb:03:d6:55:a8:34\",\n \"bb:18:88:00:e6:fe\",\n \"bb:fe:34:fc:5a:7f\",\n \"bb:16:66:35:a8:3b\",\n \"bb:cf:7f:83:c1:99\",\n \"bb:18:1d:ae:4c:71\"\n];\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 530, | |
| "y": 440, | |
| "wires": [ | |
| [ | |
| "2e5b037d.84cd5c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "74498671.f7d1a8", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "MOCK Payload", | |
| "func": "function getRandomInt(max) {\n return Math.floor(Math.random() * Math.floor(max));\n}\n\nconst networkId = msg.network.id;\nconst deviceSerial = msg.device.serial;\nconst device = msg.device;\nconst radio = msg.radio;\nconst service = msg.service;\nconst clientMacs = msg.clients;\n\n\nvar Mock = function(mac) {\n const _date = new Date();\n this.date = _date;\n const _now = _date.toISOString();\n // range of -30 to -90 and possibility of \"disconnected\"\n const _rssi = -90 + getRandomInt(60);\n \n this.rssi = _rssi;\n this.ts = _now;\n this.clientMac = mac;\n};\n\nconst mock = clientMacs.map(c => new Mock(c));\n \nmsg.payload = mock;\n\n\n\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 460, | |
| "y": 580, | |
| "wires": [ | |
| [ | |
| "8ba3301e.7d72d" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "bb34263f.083858", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Radio: wifi", | |
| "func": "msg.radio = \"wifi\";\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 350, | |
| "y": 400, | |
| "wires": [ | |
| [ | |
| "d04bdc6a.9a0ab" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "5edccf23.e3352", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Radio: ble", | |
| "func": "msg.radio = \"ble\"\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 340, | |
| "y": 440, | |
| "wires": [ | |
| [ | |
| "d01c443e.e40dd8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "7a96033f.829b7c", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Service: rssi-old", | |
| "func": "msg.service = \"rssi\"\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 280, | |
| "y": 580, | |
| "wires": [ | |
| [ | |
| "74498671.f7d1a8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "d40b07e0.afa878", | |
| "type": "mqtt out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "topic": "", | |
| "qos": "", | |
| "retain": "", | |
| "broker": "cac9920e.f8df8", | |
| "x": 750, | |
| "y": 760, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "3bf5db2b.951b34", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Service: count", | |
| "func": "msg.service = \"count\"\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 280, | |
| "y": 620, | |
| "wires": [ | |
| [ | |
| "1b1ecfea.a5aad" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "1b1ecfea.a5aad", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "MOCK Payload", | |
| "func": "function getRandomInt(max) {\n return Math.floor(Math.random() * Math.floor(max));\n}\n\nconst networkId = msg.network.id;\nconst deviceSerial = msg.device.serial;\nconst device = msg.device;\nconst radio = msg.radio;\nconst service = msg.service;\nconst clientMacs = msg.clients;\n\n\nvar Mock = function(clients) {\n const _date = new Date();\n const _now = _date.toISOString();\n const _count = clients.length;\n \n this.ts = _now;\n this.networkId = networkId;\n this.serial = deviceSerial;\n this.count = _count;\n};\n\nconst mock = new Mock(clientMacs);\n \nmsg.payload = mock;\n\n\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 460, | |
| "y": 620, | |
| "wires": [ | |
| [ | |
| "4147e5c3.b8415c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "a2445d05.bc6f", | |
| "type": "link out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "AP1", | |
| "links": [ | |
| "c32822f5.22b11" | |
| ], | |
| "x": 735, | |
| "y": 180, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "c32822f5.22b11", | |
| "type": "link in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "WiFi Clients", | |
| "links": [ | |
| "a2445d05.bc6f", | |
| "44193069.324bf", | |
| "e1413630.c4e2b8", | |
| "4178ccd.8cbe934", | |
| "4b924381.22a80c" | |
| ], | |
| "x": 75, | |
| "y": 420, | |
| "wires": [ | |
| [ | |
| "c862a3d1.90bf4" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "8b11e3d5.70476", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Access Points", | |
| "info": "", | |
| "x": 110, | |
| "y": 140, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "207c9ed1.6a7af2", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Device: BBBB-BBBB-BBBB", | |
| "func": "\nmsg.device = {\n serial: \"BBBB-BBBB-BBBB\",\n name: \"Reception\",\n tags: [\"Floor-01\", \"Guest\"]\n}\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 580, | |
| "y": 240, | |
| "wires": [ | |
| [ | |
| "4178ccd.8cbe934" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "f2c5c2b3.5f0e5", | |
| "type": "inject", | |
| "z": "90fbc492.9c31f8", | |
| "name": "AP 2", | |
| "topic": "", | |
| "payload": "", | |
| "payloadType": "date", | |
| "repeat": "", | |
| "crontab": "", | |
| "once": false, | |
| "onceDelay": 0.1, | |
| "x": 110, | |
| "y": 240, | |
| "wires": [ | |
| [ | |
| "e5eadc6e.c1e7f" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "e5eadc6e.c1e7f", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Network: N_1111111111111", | |
| "func": "\nmsg.network = {\n id: \"N_1111111111111\",\n name: \"Branch-01\"\n}\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 320, | |
| "y": 240, | |
| "wires": [ | |
| [ | |
| "207c9ed1.6a7af2" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "baf9515b.f18f", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Device: CCCC-CCCC-CCCC", | |
| "func": "\nmsg.device = {\n serial: \"CCCC-CCCC-CCCC\",\n name: \"Elevators\",\n tags: [\"Floor-01\", \"Guest\"]\n}\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 580, | |
| "y": 300, | |
| "wires": [ | |
| [ | |
| "4b924381.22a80c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "eded4166.0fdaa", | |
| "type": "inject", | |
| "z": "90fbc492.9c31f8", | |
| "name": "AP 3", | |
| "topic": "", | |
| "payload": "", | |
| "payloadType": "date", | |
| "repeat": "", | |
| "crontab": "", | |
| "once": false, | |
| "onceDelay": 0.1, | |
| "x": 110, | |
| "y": 300, | |
| "wires": [ | |
| [ | |
| "8fb297b1.bda5d8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "8fb297b1.bda5d8", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Network: N_222222222222", | |
| "func": "\nmsg.network = {\n id: \"N_222222222222\",\n name: \"Branch-02\"\n}\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 320, | |
| "y": 300, | |
| "wires": [ | |
| [ | |
| "baf9515b.f18f" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "4178ccd.8cbe934", | |
| "type": "link out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "AP2", | |
| "links": [ | |
| "c32822f5.22b11" | |
| ], | |
| "x": 735, | |
| "y": 240, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "4b924381.22a80c", | |
| "type": "link out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "AP3", | |
| "links": [ | |
| "c32822f5.22b11" | |
| ], | |
| "x": 735, | |
| "y": 300, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "b92171ed.90117", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Radios and Clients", | |
| "info": "", | |
| "x": 130, | |
| "y": 360, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "1786a7cb.5452f8", | |
| "type": "link out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Radios and Clients", | |
| "links": [ | |
| "9a7cbc6a.1bfd7" | |
| ], | |
| "x": 735, | |
| "y": 480, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "9a7cbc6a.1bfd7", | |
| "type": "link in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "links": [ | |
| "1786a7cb.5452f8" | |
| ], | |
| "x": 60, | |
| "y": 600, | |
| "wires": [ | |
| [ | |
| "3bf5db2b.951b34", | |
| "e44a77e2.ec3308" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "1edb4527.23556b", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Services and Mock", | |
| "info": "", | |
| "x": 130, | |
| "y": 540, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "8ba3301e.7d72d", | |
| "type": "link out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Services and Mock: rssi", | |
| "links": [ | |
| "ad9f7c37.95c95" | |
| ], | |
| "x": 735, | |
| "y": 580, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "3d9da352.8d9c3c", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Publish Data to Topic", | |
| "info": "", | |
| "x": 140, | |
| "y": 720, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "ad9f7c37.95c95", | |
| "type": "link in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "links": [ | |
| "8ba3301e.7d72d", | |
| "4147e5c3.b8415c" | |
| ], | |
| "x": 75, | |
| "y": 760, | |
| "wires": [ | |
| [ | |
| "e37a0428.ec6238" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "2e5b037d.84cd5c", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Client MAC Randomizer", | |
| "func": "// Adjust Random Settings Here\nconst clientAddMax = 0;\nconst clientRemoveMax = 0;\n\n\n\n\n// collect existing clients from state\nflow.set('clientMacs', msg.clients);\nvar clientContext = flow.get('clientMacs');\n\n// random client MAC address generator\nvar RandomClient = function(){\n return \"XX:XX:XX:XX:XX:XX\".replace(/X/g, function() {\n return \"0123456789ABCDEF\".charAt(Math.floor(Math.random() * 16))\n });\n}\n\n// add random clients\nconst clientsToAdd = Math.floor(Math.random() * clientAddMax)\nfor (let c = 0; c < clientsToAdd; c++){\n clientContext.push(RandomClient()) \n}\n\n// remove random clients\nconst clientsToRemove = Math.floor(Math.random() * clientRemoveMax)\nfor (let c = 0; c < clientsToRemove; c++){\n clientContext.pop() \n}\n\n// remember state\nflow.set('clientMacs', clientContext);\n\nmsg.clients = clientContext;\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 570, | |
| "y": 480, | |
| "wires": [ | |
| [ | |
| "1786a7cb.5452f8", | |
| "cc07faf5.bb7b58" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "8643560b.888df8", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Workflows", | |
| "info": "", | |
| "x": 100, | |
| "y": 860, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "6cbe0189.df43a", | |
| "type": "mqtt in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "#", | |
| "topic": "#", | |
| "qos": "2", | |
| "broker": "cac9920e.f8df8", | |
| "x": 150, | |
| "y": 940, | |
| "wires": [ | |
| [ | |
| "3caac59.d4c7d3a" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "4318f354.888a6c", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Sub #", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "payload", | |
| "x": 830, | |
| "y": 940, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "3caac59.d4c7d3a", | |
| "type": "json", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "property": "payload", | |
| "action": "", | |
| "pretty": false, | |
| "x": 650, | |
| "y": 940, | |
| "wires": [ | |
| [ | |
| "4318f354.888a6c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "151baaac.7e8fe5", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Subscribe ALL", | |
| "info": "", | |
| "x": 160, | |
| "y": 900, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "e61d03e1.b1fff", | |
| "type": "mqtt in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "merakimr/N_1111111111111/+/wifi/count", | |
| "topic": "merakimr/N_1111111111111/+/wifi/count", | |
| "qos": "2", | |
| "broker": "cac9920e.f8df8", | |
| "x": 260, | |
| "y": 1040, | |
| "wires": [ | |
| [ | |
| "53090390.3cb11c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "72d39704.37bc48", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Sub WiFi Client Count", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "payload", | |
| "x": 780, | |
| "y": 1040, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "53090390.3cb11c", | |
| "type": "json", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "property": "payload", | |
| "action": "", | |
| "pretty": false, | |
| "x": 530, | |
| "y": 1040, | |
| "wires": [ | |
| [ | |
| "72d39704.37bc48" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "e5cd6388.4a029", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Subscribe: to all APs in a network, listing only WiFi client count", | |
| "info": "", | |
| "x": 310, | |
| "y": 1000, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "cc07faf5.bb7b58", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "clients", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "clients", | |
| "x": 710, | |
| "y": 440, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "e37a0428.ec6238", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Topic: `merakimr/${networkId}/${deviceSerial}/${radio}/${service}`", | |
| "func": "const networkId = msg.network.id;\nconst deviceSerial = msg.device.serial;\nconst radio = msg.radio;\nconst service = msg.service;\n\n\nmsg.topic = `merakimr/${networkId}/${deviceSerial}/${radio}/${service}`;\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 360, | |
| "y": 760, | |
| "wires": [ | |
| [ | |
| "d40b07e0.afa878" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "93108d5a.44f2f", | |
| "type": "mqtt out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "topic": "", | |
| "qos": "", | |
| "retain": "", | |
| "broker": "cac9920e.f8df8", | |
| "x": 750, | |
| "y": 820, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "f45ed708.746df8", | |
| "type": "link in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Topic: clients", | |
| "links": [ | |
| "5e0b93f6.ae9b3c", | |
| "62493ba.ad73fc4" | |
| ], | |
| "x": 75, | |
| "y": 820, | |
| "wires": [ | |
| [ | |
| "5465a667.0339a8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "5465a667.0339a8", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Topic: `merakimr/${networkId}/${deviceSerial}/${radio}/${service}/${clientId}`", | |
| "func": "const networkId = msg.network.id;\nconst deviceSerial = msg.device.serial;\nconst device = msg.device;\nconst radio = msg.radio;\nconst service = msg.service;\n//const clientMacs = msg.clients;\nconst clientId = msg.payload.clientMac || clientId;\n\n\nmsg.topic = `merakimr/${networkId}/${deviceSerial}/${radio}/${service}/${clientId}`\n\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 390, | |
| "y": 820, | |
| "wires": [ | |
| [ | |
| "93108d5a.44f2f" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "4147e5c3.b8415c", | |
| "type": "link out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Services and Mock: Count", | |
| "links": [ | |
| "ad9f7c37.95c95" | |
| ], | |
| "x": 735, | |
| "y": 620, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "e44a77e2.ec3308", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Service: rssi", | |
| "func": "msg.service = \"rssi\"\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 270, | |
| "y": 660, | |
| "wires": [ | |
| [ | |
| "b3dbae13.8052b" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "5e0b93f6.ae9b3c", | |
| "type": "link out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Services and Mock: Clients", | |
| "links": [ | |
| "f45ed708.746df8" | |
| ], | |
| "x": 735, | |
| "y": 660, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "b3dbae13.8052b", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "MOCK Payload", | |
| "func": "function getRandomInt(max) {\n return Math.floor(Math.random() * Math.floor(max));\n}\n\nconst networkId = msg.network.id;\nconst deviceSerial = msg.device.serial;\nconst txPower = msg.txPower;\nconst device = msg.device;\nconst radio = msg.radio;\nconst service = msg.service;\nconst clientMacs = msg.clients;\n\n\n\nvar Mock = function(mac) {\n const _date = new Date();\n this.date = _date;\n const _now = _date.toISOString();\n // range of -30 to -90 and possibility of \"disconnected\"\n const _rssi = -90 + getRandomInt(60);\n this.rssi = _rssi;\n this.txPower = txPower;\n this.ts = _now;\n this.clientMac = mac;\n this.deviceSerial = deviceSerial;\n};\n\nconst mock = clientMacs.map(c => new Mock(c));\n \nmsg.payload = mock;\n\n\n\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 460, | |
| "y": 660, | |
| "wires": [ | |
| [ | |
| "8dd832c0.831b9" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "8dd832c0.831b9", | |
| "type": "split", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "splt": "\\n", | |
| "spltType": "str", | |
| "arraySplt": 1, | |
| "arraySpltType": "len", | |
| "stream": false, | |
| "addname": "", | |
| "x": 610, | |
| "y": 660, | |
| "wires": [ | |
| [ | |
| "5e0b93f6.ae9b3c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "b008d71c.66a0f8", | |
| "type": "mqtt in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "merakimr/N_1111111111111/+/wifi/rssi/#", | |
| "topic": "merakimr/N_1111111111111/+/wifi/rssi/#", | |
| "qos": "2", | |
| "datatype": "auto", | |
| "broker": "cac9920e.f8df8", | |
| "x": 260, | |
| "y": 1260, | |
| "wires": [ | |
| [ | |
| "f9cd9001.dd155" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "492e4aea.b43594", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Sub WiFi RSSI - Clients", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "payload", | |
| "x": 770, | |
| "y": 1260, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "f9cd9001.dd155", | |
| "type": "json", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "property": "payload", | |
| "action": "", | |
| "pretty": false, | |
| "x": 530, | |
| "y": 1260, | |
| "wires": [ | |
| [ | |
| "492e4aea.b43594" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "524599c5.f9f128", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Subscribe: to all APs in a network, listing all WiFi client rssi - WITH CLIENT IN TOPIC", | |
| "info": "", | |
| "x": 370, | |
| "y": 1220, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "b2908032.7f27c", | |
| "type": "mqtt in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "merakimr/+/YYYY-YYYY-YYYY/wifi/rssi/24:18:1d:ae:4c:71", | |
| "topic": "merakimr/+/YYYY-YYYY-YYYY/wifi/rssi/24:18:1d:ae:4c:71", | |
| "qos": "2", | |
| "datatype": "auto", | |
| "broker": "cac9920e.f8df8", | |
| "x": 310, | |
| "y": 1380, | |
| "wires": [ | |
| [ | |
| "7e8002f1.be268c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "b48ed2a9.02e76", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Sub WiFi RSSI - One Client", | |
| "active": true, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "payload", | |
| "x": 760, | |
| "y": 1380, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "7e8002f1.be268c", | |
| "type": "json", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "property": "payload", | |
| "action": "", | |
| "pretty": false, | |
| "x": 590, | |
| "y": 1420, | |
| "wires": [ | |
| [ | |
| "b48ed2a9.02e76", | |
| "f9dfa5b8.5588a8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "43be4d14.1e3254", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Subscribe: to all APs in all networks, listing only one WiFi client rssi - WITH CLIENT IN TOPIC", | |
| "info": "", | |
| "x": 400, | |
| "y": 1340, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "645be8b3.6717c8", | |
| "type": "mqtt in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "merakimr/N_1111111111111/+/wifi/rssi/#", | |
| "topic": "merakimr/N_1111111111111/+/wifi/rssi/#", | |
| "qos": "2", | |
| "datatype": "auto", | |
| "broker": "cac9920e.f8df8", | |
| "x": 260, | |
| "y": 1500, | |
| "wires": [ | |
| [ | |
| "7ba32c39.16bb34" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "3b1d849.a52a27c", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Sub WiFi RSSI - All Clients", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "payload", | |
| "x": 760, | |
| "y": 1500, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "7ba32c39.16bb34", | |
| "type": "json", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "property": "payload", | |
| "action": "", | |
| "pretty": false, | |
| "x": 530, | |
| "y": 1500, | |
| "wires": [ | |
| [ | |
| "3b1d849.a52a27c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "e4667539.051438", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Subscribe: to all APs in a network, listing only one WiFi client rssi - WITH ALL CLIENTs IN TOPIC", | |
| "info": "", | |
| "x": 410, | |
| "y": 1460, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "e8a47cee.da2fe", | |
| "type": "mqtt in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "merakimr/N_1111111111111/+/ble/count", | |
| "topic": "merakimr/N_1111111111111/+/ble/count", | |
| "qos": "2", | |
| "broker": "cac9920e.f8df8", | |
| "x": 260, | |
| "y": 1140, | |
| "wires": [ | |
| [ | |
| "a48b2477.449c08" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "f6a804f2.c513e8", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Sub BLE Client Count", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "payload", | |
| "x": 780, | |
| "y": 1140, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "a48b2477.449c08", | |
| "type": "json", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "property": "payload", | |
| "action": "", | |
| "pretty": false, | |
| "x": 530, | |
| "y": 1140, | |
| "wires": [ | |
| [ | |
| "f6a804f2.c513e8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "650dcc6e.f87dd4", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Subscribe: to all APs in a network, listing only BLE client count", | |
| "info": "", | |
| "x": 310, | |
| "y": 1100, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "85d73acf.fd75b8", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Count Packet Size", | |
| "func": "msg.payload = JSON.stringify(msg.payload).length;\nnode.status({fill:\"green\",shape:\"ring\",text:msg.payload});\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 510, | |
| "y": 1960, | |
| "wires": [ | |
| [ | |
| "390810de.c5161" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "390810de.c5161", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Packet Size", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "true", | |
| "x": 790, | |
| "y": 1960, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "4c3503e2.88ba1c", | |
| "type": "mqtt in", | |
| "z": "90fbc492.9c31f8", | |
| "name": "merakimr/+/AAAA-AAAA-AAAA/wifi/rssi/#", | |
| "topic": "merakimr/+/AAAA-AAAA-AAAA/wifi/rssi/#", | |
| "qos": "2", | |
| "datatype": "auto", | |
| "broker": "cac9920e.f8df8", | |
| "x": 220, | |
| "y": 2020, | |
| "wires": [ | |
| [ | |
| "85d73acf.fd75b8", | |
| "e44fdd23.01994", | |
| "779629cd.276918", | |
| "5601d76d.d31478" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "e44fdd23.01994", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Total Count Packet Size", | |
| "func": "var count = context.get('count') || 0;\nvar packet = JSON.stringify(msg.payload).length;\ncount += packet\nnode.status({fill:\"green\",shape:\"ring\",text:Math.round(count/1000) + \"kb\"});\ncontext.set('count', count);\nmsg.payload = count\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 530, | |
| "y": 2020, | |
| "wires": [ | |
| [ | |
| "7596c3bc.62fc2c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "7596c3bc.62fc2c", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Total Packet Size", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "payload", | |
| "x": 770, | |
| "y": 2020, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "779629cd.276918", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Total Packets", | |
| "func": "var packets = context.get('packets') || 0;\npackets++\nnode.status({fill:\"green\",shape:\"ring\",text:packets});\ncontext.set('packets', packets);\nmsg.payload = packets\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 500, | |
| "y": 2080, | |
| "wires": [ | |
| [ | |
| "1d01423e.e6515e" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "1d01423e.e6515e", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Total Packets", | |
| "active": false, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "payload", | |
| "x": 780, | |
| "y": 2080, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "a0464f96.01dc", | |
| "type": "comment", | |
| "z": "90fbc492.9c31f8", | |
| "name": "Analysis", | |
| "info": "", | |
| "x": 120, | |
| "y": 1900, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "c862a3d1.90bf4", | |
| "type": "function", | |
| "z": "90fbc492.9c31f8", | |
| "name": "txPower", | |
| "func": "function getRandomInt(max) {\n return Math.floor(Math.random() * Math.floor(max));\n}\n\nmsg.txPower = 14 - getRandomInt(2);\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 180, | |
| "y": 420, | |
| "wires": [ | |
| [ | |
| "bb34263f.083858", | |
| "5edccf23.e3352" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "f9dfa5b8.5588a8", | |
| "type": "link out", | |
| "z": "90fbc492.9c31f8", | |
| "name": "sub - wifi clients", | |
| "links": [ | |
| "8db1148e.7e65b8", | |
| "3299552f.0b8fea" | |
| ], | |
| "x": 695, | |
| "y": 1420, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "5601d76d.d31478", | |
| "type": "debug", | |
| "z": "90fbc492.9c31f8", | |
| "name": "", | |
| "active": true, | |
| "tosidebar": true, | |
| "console": false, | |
| "tostatus": false, | |
| "complete": "false", | |
| "x": 340, | |
| "y": 2160, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "2c366672.d40bca", | |
| "type": "mosca in", | |
| "z": "90fbc492.9c31f8", | |
| "mqtt_port": 1883, | |
| "mqtt_ws_port": 8080, | |
| "name": "", | |
| "username": "", | |
| "password": "", | |
| "dburl": "", | |
| "x": 120, | |
| "y": 80, | |
| "wires": [ | |
| [ | |
| "c100fe2a.cb152" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "cac9920e.f8df8", | |
| "type": "mqtt-broker", | |
| "z": "", | |
| "name": "localhost (mosca)", | |
| "broker": "localhost", | |
| "port": "1883", | |
| "clientid": "", | |
| "usetls": false, | |
| "compatmode": true, | |
| "keepalive": "60", | |
| "cleansession": true, | |
| "birthTopic": "", | |
| "birthQos": "0", | |
| "birthPayload": "", | |
| "closeTopic": "", | |
| "closeQos": "0", | |
| "closePayload": "", | |
| "willTopic": "", | |
| "willQos": "0", | |
| "willPayload": "" | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment