Level measurement using range finder and lora technology

Dependencies:   Cayenne-LPP SDBlockDevice

Committer:
wamae
Date:
Wed Jun 26 10:35:50 2019 +0000
Revision:
0:f930f0440fd5
better copy

Who changed what in which revision?

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