Created
February 6, 2024 02:04
-
-
Save ccall48/657b789e91c068471322d2bf308325f7 to your computer and use it in GitHub Desktop.
Helium ChirpStack Mapper Flow
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": "ef6a48be18856f84", | |
"type": "tab", | |
"label": "Helium GPS Mapper", | |
"disabled": false, | |
"info": "", | |
"env": [] | |
}, | |
{ | |
"id": "21aa0b1687e13423", | |
"type": "function", | |
"z": "ef6a48be18856f84", | |
"name": "T1000 Chirp -> Helium Mapper", | |
"func": "let chirpstack = msg.payload;\n\n// au915 sb2 band plan\nlet channel = {\n 916.8: 0,\n 917: 1,\n 917.2: 2,\n 917.4: 3,\n 917.6: 4,\n 917.8: 5,\n 918: 6,\n 918.2: 7\n}\n\n// dummy init gps location data\nlet gps = {\n payload: {\n accuracy: 2,\n altitude: 2,\n latitude: 0,\n longitude: 0\n }\n}\n\n//Loop through status array and grab gps coords if they exist \nfor (let i = 0; i < chirpstack.object.messages[0].length; i++) {\n let data = chirpstack.object.messages[0];\n if (data[i].type === 'Longitude') {\n gps.payload.longitude = data[i].measurementValue;\n }\n if (data[i].type === 'Latitude') {\n gps.payload.latitude = data[i].measurementValue;\n }\n};\n\nlet modulation = chirpstack.txInfo.modulation.lora;\nlet hotspots = [];\n\nfor (let i = 0; i < chirpstack.rxInfo.length; i++) {\n let data = chirpstack.rxInfo[i]\n let spread = 'SF' + modulation.spreadingFactor + 'BW' + modulation.bandwidth;\n if (Object.hasOwn(data.metadata, 'gateway_id')) {\n let frequency = chirpstack.txInfo.frequency / 1000000;\n hotspots.push({\n channel: channel[frequency],\n frequency: frequency,\n id: data.metadata.gateway_id,\n lat: parseFloat(data.metadata.gateway_lat),\n long: parseFloat(data.metadata.gateway_long),\n name: data.metadata.gateway_name,\n reported_at: new Date(data.gwTime).getTime(),\n rssi: data.rssi,\n snr: data.snr,\n spreading: spread.slice(0, 8)\n })\n }\n};\n\nmsg.payload = {\n app_eui: \"T1000\",\n dev_eui: chirpstack.deviceInfo.devEui,\n devaddr: chirpstack.devAddr,\n fcnt: chirpstack.fCnt,\n decoded: gps,\n hotspots: hotspots,\n id: chirpstack.deduplicationId,\n name: chirpstack.deviceInfo.deviceName,\n payload: chirpstack.data,\n port: chirpstack.fPort,\n type: \"uplink\",\n reported_at: new Date(chirpstack.time).getTime()\n}\n\n// lets not send if there is no GPS coords or data was blank\nif (gps.payload.latitude === 0 || gps.payload.longitude === 0 || hotspots.length === 0 || chirpstack.data === \"\") {\n // do nothing...\n console.log('No data or GPS coords, die here...');\n} else {\n return msg;\n};\n", | |
"outputs": 1, | |
"timeout": 0, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 410, | |
"y": 140, | |
"wires": [ | |
[ | |
"cbabc7ba598025f2", | |
"79e673d7546bd0b5" | |
] | |
] | |
}, | |
{ | |
"id": "cbabc7ba598025f2", | |
"type": "http request", | |
"z": "ef6a48be18856f84", | |
"name": "mapper.helium", | |
"method": "POST", | |
"ret": "obj", | |
"paytoqs": "ignore", | |
"url": "https://mappers.helium.com/api/v1/ingest/uplink", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"insecureHTTPParser": false, | |
"authType": "", | |
"senderr": false, | |
"headers": [ | |
{ | |
"keyType": "other", | |
"keyValue": "Content-Type", | |
"valueType": "other", | |
"valueValue": "application/json" | |
} | |
], | |
"x": 740, | |
"y": 220, | |
"wires": [ | |
[ | |
"9630c53a5e141bc8" | |
] | |
] | |
}, | |
{ | |
"id": "9630c53a5e141bc8", | |
"type": "debug", | |
"z": "ef6a48be18856f84", | |
"name": "mapper.helium-debug", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"targetType": "msg", | |
"statusVal": "", | |
"statusType": "auto", | |
"x": 940, | |
"y": 220, | |
"wires": [] | |
}, | |
{ | |
"id": "d98269cccd0b8d24", | |
"type": "comment", | |
"z": "ef6a48be18856f84", | |
"name": "Helium Mapping HTTP Requests", | |
"info": "", | |
"x": 830, | |
"y": 100, | |
"wires": [] | |
}, | |
{ | |
"id": "79e673d7546bd0b5", | |
"type": "http request", | |
"z": "ef6a48be18856f84", | |
"name": "coveragemap", | |
"method": "POST", | |
"ret": "obj", | |
"paytoqs": "ignore", | |
"url": "https://integrations.ttnmapper.org/helium/v1", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"insecureHTTPParser": false, | |
"authType": "", | |
"senderr": false, | |
"headers": [ | |
{ | |
"keyType": "other", | |
"keyValue": "TTNMAPPERORG-USER", | |
"valueType": "other", | |
"valueValue": "[email protected]" | |
} | |
], | |
"x": 740, | |
"y": 280, | |
"wires": [ | |
[ | |
"c880e48c61da9109" | |
] | |
] | |
}, | |
{ | |
"id": "c880e48c61da9109", | |
"type": "debug", | |
"z": "ef6a48be18856f84", | |
"name": "coveragemap-debug", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"targetType": "msg", | |
"statusVal": "", | |
"statusType": "auto", | |
"x": 940, | |
"y": 280, | |
"wires": [] | |
}, | |
{ | |
"id": "5b3452d1247e4413", | |
"type": "function", | |
"z": "ef6a48be18856f84", | |
"name": "Tbeam Chirp -> Helium Mapper", | |
"func": "let chirpstack = msg.payload;\n\n// au915 sb2 band plan\nlet channel = {\n 916.8: 0,\n 917: 1,\n 917.2: 2,\n 917.4: 3,\n 917.6: 4,\n 917.8: 5,\n 918: 6,\n 918.2: 7\n}\n\n// dummy init gps location data\nlet gps = {\n payload: {\n accuracy: 2,\n altitude: 2,\n latitude: 0,\n longitude: 0\n }\n}\n\ngps.payload.latitude = chirpstack.object.latitude\ngps.payload.longitude = chirpstack.object.longitude\n\nlet modulation = chirpstack.txInfo.modulation.lora;\nlet hotspots = [];\n\nfor (let i = 0; i < chirpstack.rxInfo.length; i++) {\n let data = chirpstack.rxInfo[i]\n let spread = 'SF' + modulation.spreadingFactor + 'BW' + modulation.bandwidth;\n if (Object.hasOwn(data.metadata, 'gateway_id')) {\n let frequency = chirpstack.txInfo.frequency / 1000000;\n hotspots.push({\n channel: channel[frequency],\n frequency: frequency,\n id: data.metadata.gateway_id,\n lat: parseFloat(data.metadata.gateway_lat),\n long: parseFloat(data.metadata.gateway_long),\n name: data.metadata.gateway_name,\n reported_at: new Date(data.gwTime).getTime(),\n rssi: data.rssi,\n snr: data.snr,\n spreading: spread.slice(0, 8)\n })\n }\n};\n\nmsg.payload = {\n app_eui: \"TTGO Tbeam\",\n dev_eui: chirpstack.deviceInfo.devEui,\n devaddr: chirpstack.devAddr,\n fcnt: chirpstack.fCnt,\n decoded: gps,\n hotspots: hotspots,\n id: chirpstack.deduplicationId,\n name: chirpstack.deviceInfo.deviceName,\n payload: chirpstack.data,\n port: chirpstack.fPort,\n type: \"uplink\",\n reported_at: new Date(chirpstack.time).getTime()\n}\n\n// lets not send if there is no GPS coords or data was blank\nif (gps.payload.latitude === 0 || gps.payload.longitude === 0 || hotspots.length === 0 || chirpstack.data === \"\") {\n // do nothing...\n console.log('No data or GPS coords, die here...');\n} else {\n return msg;\n};\n", | |
"outputs": 1, | |
"timeout": 0, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 410, | |
"y": 200, | |
"wires": [ | |
[ | |
"cbabc7ba598025f2", | |
"79e673d7546bd0b5" | |
] | |
] | |
}, | |
{ | |
"id": "536faae02443c8fc", | |
"type": "function", | |
"z": "ef6a48be18856f84", | |
"name": "RAK7200 Chirp -> Helium Mapper", | |
"func": "let chirpstack = msg.payload;\n\n// au915 sb2 band plan\nlet channel = {\n 916.8: 0,\n 917: 1,\n 917.2: 2,\n 917.4: 3,\n 917.6: 4,\n 917.8: 5,\n 918: 6,\n 918.2: 7\n}\n\n// dummy init gps location data\nlet gps = {\n payload: {\n accuracy: 2,\n altitude: 2,\n latitude: 0,\n longitude: 0\n }\n}\n\nif (Object.hasOwn(chirpstack.object, 'gpsLocation')) {\n gps.payload.latitude = chirpstack.object.gpsLocation[1].latitude\n gps.payload.longitude = chirpstack.object.gpsLocation[1].longitude\n}\n\nlet modulation = chirpstack.txInfo.modulation.lora;\nlet hotspots = [];\n\nfor (let i = 0; i < chirpstack.rxInfo.length; i++) {\n let data = chirpstack.rxInfo[i]\n let spread = 'SF' + modulation.spreadingFactor + 'BW' + modulation.bandwidth;\n if (Object.hasOwn(data.metadata, 'gateway_id')) {\n let frequency = chirpstack.txInfo.frequency / 1000000;\n hotspots.push({\n channel: channel[frequency],\n frequency: frequency,\n // gw location sent as strings in metadata\n id: data.metadata.gateway_id,\n lat: parseFloat(data.metadata.gateway_lat),\n long: parseFloat(data.metadata.gateway_long),\n name: data.metadata.gateway_name,\n reported_at: new Date(data.gwTime).getTime(),\n rssi: data.rssi,\n snr: data.snr,\n spreading: spread.slice(0, 8)\n })\n }\n};\n\nmsg.payload = {\n app_eui: \"RAK7200\",\n dev_eui: chirpstack.deviceInfo.devEui,\n devaddr: chirpstack.devAddr,\n fcnt: chirpstack.fCnt,\n decoded: gps,\n hotspots: hotspots,\n id: chirpstack.deduplicationId,\n name: chirpstack.deviceInfo.deviceName,\n payload: chirpstack.data,\n port: chirpstack.fPort,\n type: \"uplink\",\n reported_at: new Date(chirpstack.time).getTime()\n}\n\n// lets not send if there is no GPS coords or data was blank\nif (gps.payload.latitude === 0 || gps.payload.longitude === 0 || hotspots.length === 0 || chirpstack.data === \"\") {\n // do nothing...\n console.log('No data or GPS coords, die here...');\n} else {\n return msg;\n};\n", | |
"outputs": 1, | |
"timeout": 0, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 400, | |
"y": 260, | |
"wires": [ | |
[ | |
"cbabc7ba598025f2", | |
"79e673d7546bd0b5" | |
] | |
] | |
}, | |
{ | |
"id": "0d21368886ff07b8", | |
"type": "function", | |
"z": "ef6a48be18856f84", | |
"name": "Browan Industrial -> Helium Mapper", | |
"func": "let chirpstack = msg.payload;\n\n// au915 sb2 band plan\nlet channel = {\n 916.8: 0,\n 917: 1,\n 917.2: 2,\n 917.4: 3,\n 917.6: 4,\n 917.8: 5,\n 918: 6,\n 918.2: 7\n}\n\n// dummy init gps location data\nlet gps = {\n payload: {\n accuracy: 2,\n altitude: 2,\n latitude: 0,\n longitude: 0\n }\n}\n\nif (chirpstack.object.GNSSerror === 0) {\n gps.payload.latitude = chirpstack.object.latitude\n gps.payload.longitude = chirpstack.object.longitude\n}\n\nlet modulation = chirpstack.txInfo.modulation.lora;\nlet hotspots = [];\n\nfor (let i = 0; i < chirpstack.rxInfo.length; i++) {\n let data = chirpstack.rxInfo[i]\n let spread = 'SF' + modulation.spreadingFactor + 'BW' + modulation.bandwidth;\n if (Object.hasOwn(data.metadata, 'gateway_id')) {\n let frequency = chirpstack.txInfo.frequency / 1000000;\n hotspots.push({\n channel: channel[frequency],\n frequency: frequency,\n // gw location sent as strings in metadata\n id: data.metadata.gateway_id,\n lat: parseFloat(data.metadata.gateway_lat),\n long: parseFloat(data.metadata.gateway_long),\n name: data.metadata.gateway_name,\n reported_at: new Date(data.gwTime).getTime(),\n rssi: data.rssi,\n snr: data.snr,\n spreading: spread.slice(0, 8)\n })\n }\n};\n\nmsg.payload = {\n app_eui: \"Browan\",\n dev_eui: chirpstack.deviceInfo.devEui,\n devaddr: chirpstack.devAddr,\n fcnt: chirpstack.fCnt,\n decoded: gps,\n hotspots: hotspots,\n id: chirpstack.deduplicationId,\n name: chirpstack.deviceInfo.deviceName,\n payload: chirpstack.data,\n port: chirpstack.fPort,\n type: \"uplink\",\n reported_at: new Date(chirpstack.time).getTime()\n}\n\n// lets not send if there is no GPS coords or data was blank\nif (gps.payload.latitude === 0 || gps.payload.longitude === 0 || hotspots.length === 0 || chirpstack.data === \"\") {\n // do nothing...\n console.log('No data or GPS coords, die here...');\n} else {\n return msg;\n};\n", | |
"outputs": 1, | |
"timeout": 0, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 390, | |
"y": 320, | |
"wires": [ | |
[ | |
"cbabc7ba598025f2", | |
"79e673d7546bd0b5" | |
] | |
] | |
}, | |
{ | |
"id": "b214d3338b0b368a", | |
"type": "function", | |
"z": "ef6a48be18856f84", | |
"name": "Yabby3 Chirp -> Helium Mapper", | |
"func": "let chirpstack = msg.payload;\n\n// au915 sb2 band plan\nlet channel = {\n 916.8: 0,\n 917: 1,\n 917.2: 2,\n 917.4: 3,\n 917.6: 4,\n 917.8: 5,\n 918: 6,\n 918.2: 7\n}\n\n// dummy init gps location data\nlet gps = {\n payload: {\n accuracy: 2,\n altitude: 2,\n latitude: 0,\n longitude: 0\n }\n}\n\n/*\n if fixed is not false we should have a heading and speed,\n confirm when i get back home.\n*/\nif (!chirpstack.object.isFixed) {\n gps.payload.latitude = chirpstack.object.latitude\n gps.payload.longitude = chirpstack.object.longitude\n gps.payload.heading = chirpstack.object.headingDeg\n gps.payload.speed = chirpstack.object.speedKmph\n}\n\nlet modulation = chirpstack.txInfo.modulation.lora;\nlet hotspots = [];\n\nfor (let i = 0; i < chirpstack.rxInfo.length; i++) {\n let data = chirpstack.rxInfo[i]\n let spread = 'SF' + modulation.spreadingFactor + 'BW' + modulation.bandwidth;\n if (Object.hasOwn(data.metadata, 'gateway_id')) {\n let frequency = chirpstack.txInfo.frequency / 1000000;\n hotspots.push({\n channel: channel[frequency],\n frequency: frequency,\n id: data.metadata.gateway_id,\n // gw location sent as strings in metadata\n lat: parseFloat(data.metadata.gateway_lat),\n long: parseFloat(data.metadata.gateway_long),\n name: data.metadata.gateway_name,\n reported_at: new Date(data.gwTime).getTime(),\n rssi: data.rssi,\n snr: data.snr,\n spreading: spread.slice(0, 8)\n })\n }\n};\n\nmsg.payload = {\n app_eui: \"Yabby3\",\n dev_eui: chirpstack.deviceInfo.devEui,\n devaddr: chirpstack.devAddr,\n fcnt: chirpstack.fCnt,\n decoded: gps,\n hotspots: hotspots,\n id: chirpstack.deduplicationId,\n name: chirpstack.deviceInfo.deviceName,\n payload: chirpstack.data,\n port: chirpstack.fPort,\n type: \"uplink\",\n reported_at: new Date(chirpstack.time).getTime()\n}\n\n// lets not send if there is no GPS coords or data was blank\nif (gps.payload.latitude === 0 || gps.payload.longitude === 0 || hotspots.length === 0 || chirpstack.data === \"\") {\n // do nothing...\n console.log('No data or GPS coords, die here...');\n} else {\n return msg;\n};\n", | |
"outputs": 1, | |
"timeout": 0, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"libs": [], | |
"x": 410, | |
"y": 380, | |
"wires": [ | |
[ | |
"cbabc7ba598025f2", | |
"79e673d7546bd0b5" | |
] | |
] | |
}, | |
{ | |
"id": "6475e56d1d76a49f", | |
"type": "comment", | |
"z": "ef6a48be18856f84", | |
"name": "MQTT TLS Connection", | |
"info": "", | |
"x": 140, | |
"y": 60, | |
"wires": [] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment