How to measure water in a reservoir

Dependencies:   Cayenne-MQTT-mbed Cayenne-LPP

Committer:
wamae
Date:
Fri Mar 08 11:34:56 2019 +0000
Revision:
0:7bfeb237e600
working code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wamae 0:7bfeb237e600 1 /**
wamae 0:7bfeb237e600 2 * > const ttn = require('ttn')
wamae 0:7bfeb237e600 3 * > var app; ttn.application('YOUR_APP', 'YOUR_KEY').then(a=>app=a)
wamae 0:7bfeb237e600 4 * > var d; app.devices().then(de=>d=de)
wamae 0:7bfeb237e600 5 * > d
wamae 0:7bfeb237e600 6 */
wamae 0:7bfeb237e600 7
wamae 0:7bfeb237e600 8 var devices =[
wamae 0:7bfeb237e600 9 { appId: '12345678909876543',
wamae 0:7bfeb237e600 10 devId: 'hc_sr04_2',
wamae 0:7bfeb237e600 11 latitude: 0.3956° S,
wamae 0:7bfeb237e600 12 longitude: 36.9622° E,
wamae 0:7bfeb237e600 13 altitude: 7723,
wamae 0:7bfeb237e600 14 description: 'water level system',
wamae 0:7bfeb237e600 15 fCntUp: 0,
wamae 0:7bfeb237e600 16 fCntDown: 0,
wamae 0:7bfeb237e600 17 disableFCntCheck: true,
wamae 0:7bfeb237e600 18 uses32BitFCnt: true,
wamae 0:7bfeb237e600 19 activationConstraints: 'local',
wamae 0:7bfeb237e600 20 usedDevNoncesList: [],
wamae 0:7bfeb237e600 21 usedAppNoncesList: [],
wamae 0:7bfeb237e600 22 lastSeen: 0,
wamae 0:7bfeb237e600 23 appEui: '70B3D57ED0010386',
wamae 0:7bfeb237e600 24 devEui: '00D76350D629D861',
wamae 0:7bfeb237e600 25 appKey: '00000000000000000000000000000000',
wamae 0:7bfeb237e600 26 appSKey: '8833967FB940B18EDD461ADE38905F2A',
wamae 0:7bfeb237e600 27 nwkSKey: '7B2C6805B56D7B055FA31CF21F0326D2',
wamae 0:7bfeb237e600 28 devAddr: '26011EE8',
wamae 0:7bfeb237e600 29 attributes: {} }]
wamae 0:7bfeb237e600 30
wamae 0:7bfeb237e600 31
wamae 0:7bfeb237e600 32 console.log(devices.map((d) => {
wamae 0:7bfeb237e600 33 var id = d.devId.match(/(\d+)/)[0];
wamae 0:7bfeb237e600 34 return `static uint32_t DEVADDR_${id} = 0x${d.devAddr};
wamae 0:7bfeb237e600 35 static uint8_t NWKSKEY_${id}[] = { ${d.nwkSKey.split(/(..)/).filter(f=>!!f).map(f=>'0x'+f).join(', ')} };
wamae 0:7bfeb237e600 36 static uint8_t APPSKEY_${id}[] = { ${d.appSKey.split(/(..)/).filter(f=>!!f).map(f=>'0x'+f).join(', ')} };`
wamae 0:7bfeb237e600 37 }).join('\n\n'));