2 Replies Latest reply on Dec 4, 2014 4:15 PM by userc_8763

    WICED Sense Notification and Characteristic values, e.g. Temp


      Comments for Android App developers (based in experience):

      Mentioned already, BLE supports max. 4 Notifications (where we can subscribe to). Here, the WICED Sense uses just two Notifications (see the document "Sensor Data Format").

      (OK, maybe reasonable to do because so we can get all 6 sensor values with just two Notifications. If we would have for every sensor an own Notification (which is actually the standard way to do) - we would have a limitation to decide which maximal four).

       

      It results in following:

      a) Even BLE supports well-known UUIDs for Temperature, Pressure characteristics etc. - they are not used here. All sensor values are encoded as proprietary data format. Therefore, you cannot use any BLE data types, e.g. FLOAT, SFLOAT etc. You have to decode all sensor values by your own. (BLE supports a nice FLOAT format where even degC or degF can be encoded - not used here, it makes it harder and losing flexibility).

      b) Also not using the UUID for a temperature characteristic results in "Unknown Service" and "Unknow Characteristic",

       

      What the "Sensor Data Format" doc does not tell you:

      I) The bytes come as Big Endian! So, a Notification as Java byte[] value comes as: 0x34 0xXX 0xXX (Hum) 0xXX 0xXX (Pressure) 0x09 0x01 (Temp)

      II) The value (example) 0x0901 is d'2305

      III) I think it should mean: 2 bytes BigEndian degC * 100 (we have two factional digits, not just one with *10).
           Therefore, if you convert Temp value into floating decimal - divide by 100, not 10, and watch out for the big endian when doing on

           a little endian platform (Android ARM CPU for instance where your app is running)

       

      The "Code Snippet" there with the struct I do not understand completely. What are all these bits?
      Is my interpretation right?:
      1) The first byte in the Characterstic value (sent via Notification) is a bit encoded field which tells us if a sensor value is present or not (6 or 2 byte fields have valid data or not, but they are always transmitted).

      2) Does it mean we can have all combinations, not just starting with 0x0B or 0x34? It can be also 0x01, 0x3F?

      3) 0x3F we might not see because all the sensor datas are always split into two Notifications?
      4) Is the set of values always constant, what is inside 1st and 2nd Notification?
          Means: Humidity, Pressur and Temp. come always in 2nd Indication, not in first, but the first byte bit field gives us indication
          which values are valid inside packet?

      OK, this might make sense, e.g. if we disable a sensor in WICED Sense device and related value is transmitted as 0 (or garbage).
      So, it means, we have to decode first byte always because a sensor value can be missing on Notification data packet.

       

       

      VictorZ_46 userc_4357

        • 1. Re: Notification and Characteristic values, e.g. Temp

          Sorry, I have to correct myself:

           

          Temp value coming as *10 is correct!

          The value comes as big endian. I see value[] as 0x01 15 which is d'277, divided by 10: it looks a correct 27.7 degC value.
          (surprise: the device is much hotter then my ambient temperature  ;-)   )

           

          But it remains Big Endian - confirmed.

          1 of 1 people found this helpful
          • 2. Re: Notification and Characteristic values, e.g. Temp


            Is there any example on how to access the values of variables  (mX,mY,mZ) of GyroFragment class shown below or basically I do I access the gyro related information from the sensor?

             

             

            public class GyroFragment extends Fragment implements

             

            OnClickListener, Animated {

             

             

            private void updateTextWidgets() {

            mRawX.setText(getString(R.string.raw_x, String.format("%.1f", mX)));

            mRawY.setText(getString(R.string.raw_y, String.format("%.1f", mY)));

            mRawZ.setText(getString(R.string.raw_z, String.format("%.1f", mZ)));

            }

            .

            .

            }

             

            Nilesh