forked from decipherindustries/signalk-calypso-ultrasonic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDECODE
26 lines (23 loc) · 1006 Bytes
/
DECODE
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
Bytes: 0-1 2-3 4 5 6 7 8-9
Ex. data: 0000 3F01 04 7C 00 00 0000
AABB CCDD EE FF GG HH IIJJ
Decode:
0-1. Wind speed: hex2dec(BB AA) / 100
2-3. Wind direction: hex2dec(DD CC)
4. Battery level: hex2dec(EE) * 10
5. Temp level: hex2dec(FF) - 100
6. Roll: hex2dec(GG) - 90
7. Pitch: hex2dec(HH) - 90
8-9. Compass: 360 - hex2dec(JJ II)
Ex.
0-1. hex2dec(00 00) => 0 / 100 => 0
2-3. hex2dec(01 3F) => 319 (degrees)
4. hex2dec(04) => 4 * 10 => 40%
5. hex2dec(7C) => 124 - 100 => 24 (degrees C)
6. hex2dec(00) => 0 - 90 => -90 (degrees)
7. hex2dec(00) => 0 - 90 => -90 (degrees)
8-9. 360 - hex2dec(00 00) => 360 - 0 => 360
Before calculating values:
- Check mode (characteristic 0xA001); 0 = sleep, 1 = low power, 2 = normal (set if required)
- Check wind check speed (characteristic 0xA002); 0x01, 0x04, 0x08 Hz (change if required)
- Check status of e-compass e/o (characteristic 0xA003); 0x01 = on, 0x00 = off. If off, don't transmit values roll, pitch, compass