Reading WICED Sense Data from JavaScript

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi All,

Let me start by saying I know close to nothing about C/C++ (and I'm trying hard to understand the iOS source)..  With that said, I have gotten my WICED Sense kit to provide data.. I've figured out how to get the notifications from the sensors.. cool!  Also, I have not modified the firmware - so all sensors are active.

So now, from javascript the kit appears to be sending in an ArrayBuffer; but I'm having a hard time trying to figure out what data is what   Let me give you some examples...

let's say:  data = the WICED Sense Kit ArrayBuffer data

when I write out to my console log this:

kitData = new Uint8Array(data);

I get this:

kitData.length array is 19 and contains:

11, 76, 0, 225, 255, 31, 0, 142, 255, 202, 255, 181, 0, 223, 3, 138, 2, 251, 253

I can only assume that's the sensor data?!  Every 13th iteration, kitData shrinks down to a length of 7 and contains:

52, 155, 3, 210, 39, 247, 0

..again, assuming this is sensor data (probably temp, humidity, and pressure; as they are sent at less intervals because they change less).

if I used signed array:

kitData = new Int8Array(data);

array sizes are the same.. data is now signed..

11, 79, 0, -35, -1, 11, 0, -96, -2, 5, 0, -7, 1, -83, 6, 106, 3, -70, -3

52, -15, 1, -47, 39, -16, 0

..so I know from reading the blog that i need to read a bitmask from the packet to understand the subsequent data.  I noted that in all cases, the first position of the data being sent is "11" (when the array size is 19) and "52" (when the size is 7).

..anyone have any clues as to how I may decipher this incoming data from JavaScript?  Truly appreciate.

-Mike

0 Likes
1 Solution
Anonymous
Not applicable

Ok - I think I have it..  or at least a clue! 

the first int number in this example is 11:

11, 79, 0, -35, -1, 11, 0, -96, -2, 5, 0, -7, 1, -83, 6, 106, 3, -70, -3

11 in binary = 001011    // so if you follow the bits (right-to-left) and reference the bitmask documented OTA_Sensor_Packets.JPG

---------

1: accelerometer sensor data is included

1: gyro sensor data is included

0: humidity sensor data is not included

1: magnetometer sensor data is included

0: pressure sensor data is not included

0: temp sensor data is not included

similarly, 52 in binary = 110100  // again, right-to-left bitmask is:

---------

0: accelerometer sensor data is not included

0: gyro sensor data is not included

1: humidity sensor data is included

0: magnetometer sensor data is not included

1: pressure sensor data is included

1: temp sensor data is included

..so in theory, if I converted the first result from the data to binary, I can figure out the subsequent data being sent.

e.g.

(11).toString(2);        // 1011

I then need to build a structure for the subsequent data so I can read it..

-Mike

View solution in original post

7 Replies