Data packets format

Started by Lensdigital, September 10, 2015, 04:35:27 PM

Lensdigital

Quick question. What format pockets received by Raspberry Pi should be?  I wasn't able to find this information in the Raspberry Pi Gateway guide, which by the way easy to follow (fantastic job Felix!).
To clarify, I'm asking about string format. From the example code it looks like you are using [] between different fields as separators?
I just want to test if Pi is listening to arduino and adds a node.
Tried sending command like this, but nothing appeared in the nodes list:
Serial.print ("#[0][44]33,28,90[RX_RSSI:-88]");

Felix

They are space delimited, here's an example:

[99] F:70.15 H:30 [RSSI:-80]

This is received from node 99, with 2 metrics (temp and humidity), with RSSI -80.
Note that all metrics you pass through must match a definition in metrics.js otherwise they are discarded (non matching, unknown).

Lensdigital

#2
Quote from: Felix on September 11, 2015, 07:45:08 AM
They are space delimited, here's an example:

[99] F:70.15 H:30 [RSSI:-80]

This is received from node 99, with 2 metrics (temp and humidity), with RSSI -80.
Note that all metrics you pass through must match a definition in metrics.js otherwise they are discarded (non matching, unknown).
Fantastic! Thank you so much! I'm now seeing node automatically registered, this is so cool! :)
Also it looks like line break was also needed at the end (wasn't working with Serial.print, but ok with Serial.println ).

Just one strange thing, when I send this line: [99] F:70.15 H:30 [RSSI:-80], it shows temperature as 0.7...
I changed it to C:20 and it shows up correctly. Is it something defined in the metrics.js?

Edit: I think I found a small bug in the metrics.js file.
I changed FH line (line 106) from this:
FH : { name:'F', regexp:/F\:(-?\d+)/i, value:'', valuation:function(value) {return value/100;}, unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature' }},


To this:
FH : { name:'FH', regexp:/FH\:(-?\d+)/i, value:'', valuation:function(value) {return value/100;}, unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature' }},


and it started to work :)

Felix

Actually that's intentional because the prefixes of the metrics entries have to be unique but the metrics themselves in the regex can have the same prefix.
Note that the return value is "processed" ie divided by 100 so that's why you're seeing that effect. By default the temperature returned from WeatherShield is returned as hundreds, so it has to be divided by 100 to yield the decimal value. But it's up to you how you want to interpret your own data...

Lensdigital

Quote from: Felix on September 11, 2015, 12:16:52 PM
Actually that's intentional because the prefixes of the metrics entries have to be unique but the metrics themselves in the regex can have the same prefix.
Note that the return value is "processed" ie divided by 100 so that's why you're seeing that effect. By default the temperature returned from WeatherShield is returned as hundreds, so it has to be divided by 100 to yield the decimal value. But it's up to you how you want to interpret your own data...
Ah I see, thanks!