"decode frame"
Bootstrap 3.3.0 Snippet by PeterElsys

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<div class="col-md-4">
<input class="form-control input-md" type="text" id="inputData" name="inputData" value="123">
</div>
</div>
<div class="row">
<div class="col-md-4">
<a href="#" id="convert" class="btn btn-sm btn-info"><span class="glyphicon glyphicon-refresh"></span> Convert</a>
</div>
</div>
<div class="row">
<div class="col-md-4">
<textarea class="form-control" id="result" name="textarea" rows="10"></textarea>
</div>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
______ _ _______ _______
| ____| | / ____\ \ / / ____|
| |__ | | | (___ \ \_/ / (___
| __| | | \___ \ \ / \___ \
| |____| |____ ____) | | | ____) |
|______|______|_____/ |_| |_____/
ELSYS simple payload decoder.
Use it as it is or remove the bugs :)
www.elsys.se
peter@elsys.se
*/
const TYPE_TEMP =0x01; //temp 2 bytes -3276.8°C -->3276.7°C
const TYPE_RH =0x02; //Humidity 1 byte 0-100%
const TYPE_ACC =0x03; //acceleration 3 bytes X,Y,Z -128 --> 127 +/-63=1G
const TYPE_LIGHT =0x04; //Light 2 bytes 0-->65535 Lux
const TYPE_MOTION =0x05; //No of motion 1 byte 0-255
const TYPE_CO2 =0x06; //Co2 2 bytes 0-65535 ppm
const TYPE_VDD =0x07; //VDD 2byte 0-65535mV
const TYPE_ANALOG1 =0x08; //VDD 2byte 0-65535mV
const TYPE_GPS =0x09; //3bytes lat 3bytes long binary
const TYPE_PULSE1 =0x0A; //2bytes relative pulse count
function bin16dec(bin) {
var num=bin&0xFFFF;
if (0x8000 & num)
num = - (0x010000 - num);
return num;
}
function bin8dec(bin) {
var num=bin&0xFF;
if (0x80 & num)
num = - (0x0100 - num);
return num;
}
function hexToBytes(hex) {
for (var bytes = [], c = 0; c < hex.length; c += 2)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: