Parsing mDot-EVB Data/Payload
Home › Forums › Conduit: AEP Model › Parsing mDot-EVB Data/Payload
Tagged: mdot evb
- This topic has 4 replies, 4 voices, and was last updated 8 years ago by
Harald Rupp.
-
AuthorPosts
-
November 12, 2015 at 10:18 pm #9984
Patrick Phillips
ParticipantWe have mDot-EVB data running on our AEP. The msg: Object data looks like this:
11/12/2015, 11:07:59 PM[msg obj]
[msg] : (Object)
{ “chan”: 3, “cls”: 0, “codr”: “4/5”, “datr”: “SF9BW125”, “freq”: “902.9”, “lsnr”: “12.8”, “modu”: “LORA”, “rfch”: 0, “rssi”: -101, “seqn”: 604, “size”: 20, “timestamp”: “2015-11-13T04:07:58Z”, “tmst”: 757714236, “payload”:”\u000e\u0000\u0001\u000f\b\u0006\u0014\u0000\u0005\u0016\u000b\u0001l”, “eui”: “00:80:00:00:00:00:9d:09”, “_msgid”: “b7fe9163.48017” }Has anyone parsed and converted the “Payload” into keyed JSON pairs through a NodeRED function?
The first order of business would be to identify the \u sensor data sequence.We’ll need to do this before pushing it to a dashboard. Suggestions?
Thanks for all the MultiTech assistance!
Patrick
April 20, 2016 at 11:59 am #12222Chris Friedel
ParticipantHey Patrick!
I realize this is an ancient request, but I wanted to fill this out for anyone who might come after looking for this.
The definition of this packet is found at
Essentially, there is a byte that identifies what the next X bytes will represent, and then this repeats.
Each set of bytes after the identifier represents *one ore more* signed integers of some length. You’ll need to read that packet format above.
In node red, msg.payload from a LoRa node is a node.js buffer object. This object has easy byte[] to integer methods. HOWEVER, node.js buffers do not have an easy mechanism for reading 24 bit integers (which the dev board uses), so I ended up writing my own simple function.
msg.bitConverter = {
toSignedInt: function(bytes) {
var value = 0;var signBitMask = 128;
var fullBitMask = 255;
var noBitMask = 0;
var activeBitMask = noBitMask;
var signMultiplier = 1;
var signOffset = 0;if ((bytes[0] & signBitMask) == signBitMask)
{
activeBitMask = fullBitMask;
signMultiplier = -1;
signOffset = 1;
}for (dataIndex = 0; dataIndex < bytes.length; dataIndex++) {
//if the number is negative, perform two's complement, and then shift
//by MSB byte order
value +=
(
(bytes[dataIndex] ^ activeBitMask) <<
(8 * (bytes.length - (dataIndex + 1)))
);
}return (value + signOffset) * signMultiplier;
}
};
return msg;You can then call this function with a big endian byte array (that is to say, bytes[0] has the most significant byte, which by the way is how the dev board sends the data) of any length, and it will turn it into a signed integer equivalent.
You need to loop through the buffer consuming first the type identifier, and then the bytes representing the signed integer to follow. This implies your node-red code needs to have a definition of these different parts. For the LoRa demo report, this definition could look like this:
tags= [{tag:'lux', id:5, byteCount:2, valueCount:1},
{tag:'press', id:8, byteCount:3, valueCount:1},
{tag:'temp', id:11, byteCount:2, valueCount:1},
{tag:'3axis', id:14, byteCount:3, valueCount:3}];At some point I might pull an example of this out of our node-red app and make a bare bones example on the devhq app store. Keep a look out for something like “zedi lora dev board bare bones” or something to that effect.
I hope this helps someone out!
Cheers,
ChrisApril 20, 2016 at 12:46 pm #12225Chris Friedel
ParticipantHey, I’ve added a barebones example of this to devhq.
Please see our app:
“LoRa Dev Board to JSON Example”May 2, 2017 at 8:34 am #18875Sandoche Balakrichenan
ParticipantI added the javascript provided in the ftp link above. And on sending the message from EVB, i get the following error:
“TypeError: Cannot read property ‘replace’ of undefined”
May 3, 2017 at 5:29 am #18895Harald Rupp
ParticipantHi All,
Thanks Chris for the JSON Example, it works great.
I installed the “LoRa Dev Board to JSON Example” and switched the EVB Box to Survey GPS.
in this Mode, with the Code Example i could retrieve on the Pressure Data, when i want to add the GPS Coordinates the Array will stay empty.
I added
{name:’gps_lat’, id:’15’, byteCount:4, valueCount:4, scale:1/1000000}.Any idea, how i could parse the GPS Coordinates on the Conduit Device directly, because i dont want to download the Data File from the Box.
Thanks for an Hint
Harald
-
AuthorPosts
- You must be logged in to reply to this topic.