This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myDecoder(args) | |
{ | |
var bytes = args.bytes; | |
var port = args.port; | |
var startFlag = bytes[0]; | |
var temperature; | |
var humidity; | |
if(startFlag != 0xAA) | |
{ | |
return {"Error" : "invalid start flag"}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function XYZDeviceDecoder(args) | |
{ | |
var bytes = args.bytes; | |
var port = args.fport; | |
var status = args.status; | |
var temperature = bytes[0] || bytes[1] << 8; | |
var humidity = bytes[2] || bytes[3] << 8; | |
//return {"temp" : 0, "humidity" : 1}; | |
return {"temperature" : temperature, "humidity" : humidity, "raw" : bytes, "port" : port, "status" : {"value" : 1, "context" : status}}; |