IoThon serverside code. The project expects a BLE gateway to send BLE advertisements via HTTP post. If the header of BLE data matches the encrypted RuuviTag data, advertisement is encoded into trinary and sent to the Tangle.
Git clone this repository, run npm install
, and run node index.js
.
The project expects data to be posted via HTTP in JSON format to port 5375. Example data:
[ { timestamp: '2017-12-28T12:33:38Z',
type: 'Unknown',
mac: 'D6A911ADA763',
bleName: '',
rssi: -29,
rawData: '02010415FF990403401713B9CC001CFFF804080BC50000000000' },
{ timestamp: '2017-12-28T12:33:38Z',
type: 'Unknown',
mac: 'D6A911ADA763',
bleName: '',
rssi: -39,
rawData: '02010415FF990403401713B9CC001CFFF804080BC50000000000' },
{ timestamp: '2017-12-28T12:33:40Z',
type: 'Unknown',
mac: 'D6A911ADA763',
bleName: '',
rssi: -40,
rawData: '02010415FF990403401712B9CB0020FFFC04000BC50000000000' } ]
Where
- timestamp is the gateway time at the time advertisement was received.
- type is the type of data as interpreted by the gateway, "Unknown" in our case.
- bleName is advertised name of beacon
- mac is MAC address of the BLE device
- rssi is signal strength
- rawData is the manufacturer specific data sent by beacon.
The data gets sent as 0-value IOTA transaction to address 999999999999999999999999999999999999999999999999999999999999999999FILTERAESIOTHON
if the data has header of 0201061BFF990406
.
root@flash-entry-playground:/var/www/html# node index.js
Express server listening on port 5375
Querying
getNodeInfo result { appName: 'IRI',
appVersion: '1.4.1.6',
jreAvailableProcessors: 8,
jreFreeMemory: 503035224,
jreVersion: '1.8.0_151',
jreMaxMemory: 11453595648,
jreTotalMemory: 1570766848,
latestMilestone: 'FGGAHBFPKUZIHTPTBRHTSWXEDPRRDQ9JNVGSUFLDEVMYDLLOWCJLTOQKNHJCZUFWGEFCVGVTBZJBA9999',
latestMilestoneIndex: 330724,
latestSolidSubtangleMilestone: 'FGGAHBFPKUZIHTPTBRHTSWXEDPRRDQ9JNVGSUFLDEVMYDLLOWCJLTOQKNHJCZUFWGEFCVGVTBZJBA9999',
latestSolidSubtangleMilestoneIndex: 330724,
neighbors: 9,
packetsQueueSize: 0,
time: 1516359010683,
tips: 5042,
transactionsToRequest: 11,
duration: 0 }
Received data
Locking
{ timestamp: '2017-12-28T20:01:09Z',
type: 'Unknown',
mac: 'EA17E9643A7A',
bleName: '',
rssi: -45,
rawData: '0201061BFF9904060CE179D269C643EBC81BC50E48DC949DA9519E5300000000' }
ODGAHDXCADTCGDHDPCADDDGADBGAWAUAVAABRAVAWARAWABBCCWAUADBUAVADBUACBICGAQAGAHDMDDDTCGADBGADCBDZCBDCDKDBDGAQAGAADPCRCGADBGAOBKBVAABOBCB9BYAXAKBABKBGAQAGAQC9DTCXBPCADTCGADBGAGAQAGAFDGDGDXCGADBRAYAZAQAGAFDPCKDNBPCHDPCGADBGAUAWAUAVAUA9BVALBPBPBCBCBUAYAUA9BUAMBOBVAABCBNBWA9BCBMB9BYAXAOBLBMBBBVALBMBZAUAOBYABBNBMBCBYACBNBKBCBZAVACBOBZAXAUAUAUAUAUAUAUAUAGAQD
Transfer in pipe
Received data
Received data
Received data
transactions sent! [ { hash: '9WVRCEPKDF9THOQMIUFPZEOTU9YINPGRQQIAWOGINRSKLLSBLUPPY9NXWQQCTLIEHFHPKE9IQCRU99999',
signatureMessageFragment: 'ODGAHDXCADTCGDHDPCADDDGADBGAWAUAVAABRAVAWARAWABBCCWAUADBUAVADBUACBICGAQAGAHDMDDDTCGADBGADCBDZCBDCDKDBDGAQAGAADPCRCGADBGAOBKBVAABOBCB9BYAXAKBABKBGAQAGAQC9DTCXBPCADTCGADBGAGAQAGAFDGDGDXCGADBRAYAZAQAGAFDPCKDNBPCHDPCGADBGAUAWAUAVAUA9BVALBPBPBCBCBUAYAUA9BUAMBOBVAABCBNBWA9BCBMB9BYAXAOBLBMBBBVALBMBZAUAOBYABBNBMBCBYACBNBKBCBZAVACBOBZAXAUAUAUAUAUAUAUAUAGAQD9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999',
address: '999999999999999999999999999999999999999999999999999999999999999999FILTERAESIOTHON',
value: 0,
obsoleteTag: 'C999HELLOIOTAFROMIOTHON9999',
timestamp: 1516359011,
currentIndex: 0,
lastIndex: 0,
bundle: 'IKALYJGZXXTVQRXBDRPSKLSGILNGFZKPTRTGRYFZIKWEWYGLO9AYDHRRKABXHUCGN9RLHILZJIZXKDPHA',
trunkTransaction: 'FGGAHBFPKUZIHTPTBRHTSWXEDPRRDQ9JNVGSUFLDEVMYDLLOWCJLTOQKNHJCZUFWGEFCVGVTBZJBA9999',
branchTransaction: 'RRHQYGRCAKAPYOQIVAGFDHGBGCJGFNJBKAGVTZIYPWNBROHDNCJ9MPGQARSVFQUCZMMJDVPYLOUMZ9999',
tag: '9999HELLOIOTAFROMIOTHON9999',
attachmentTimestamp: 1516359015277,
attachmentTimestampLowerBound: 0,
attachmentTimestampUpperBound: 12,
nonce: 'PCQZVITQKBBDHYC9FXTYILJZWWJ' } ]