Jump to content









Photo

​Decoding stream values

​decoding data stream

  • Please log in to reply
No replies to this topic

#1 syepes

syepes

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 11 February 2016 - 09:08 PM

Hello,

 
I am trying to evaluate if we could use Carriots for one of our projects.
One of the issues I am facing is that our devices are sending data encoded in hex, so we need to decode it once its received and extract the real data values.
 
I have more or less managed to make this work using the workaround mentioned in this post using a dummy reception Device+Rule+Listener that then sends the decoded/extracted info to the new device...
 
My main issue with this solution is that its receiving data twice and it's a bit messy.
String msg = context.data.msg; // "064022"
Float msg_bar = Integer.parseInt(msg.substring(0, 4), 16)/10.toFloat();  // 160.0
Float msg_volt = Integer.parseInt(msg.substring(4, 6), 16)/10.toFloat(); // 3.4

basicHttp.payload='{"protocol": "v2", "device": "dev@carriots", "at": "now", "data": {"bar": "' + msg_bar +  '","volt": "' + msg_volt + '"}}';

 

 

Does there currently exists a better way of achieving this?

 

 

Best regards and thanks is advance,

Sebastian

 






Also tagged with one or more of these keywords: ​decoding, data, stream

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users