3 Replies Latest reply on Nov 6, 2018 9:19 AM by psyu

    PSOC BLE transmit sint16 type value

    jitenderkumar_1515331

      Hi,

       

      Could you please provide a reference or example code where I can send sint16 type value from a BLE PSOC device.

       

      Currently I am sending uint16 type value successfully using the following code snippet –

       

      uint16 mydata = 25;

       

      UpdateBleServiceValue16(mydata, CYBLE_MYSERVICE_DATA_CHAR_HANDLE);

       

      void UpdateBleServiceValue8Array(uint16 mydata, uint16 attrHandle)

      {

      uint8 len = sizeof(mydata);

      static uint8 arrayData[2] = { 0x00, 0x00 };

      *(arrayData) = (mydata >> 8) & 0x00FF;

      arrayData[1] = mydata & 0x00FF;

       

      CYBLE_GATT_HANDLE_VALUE_PAIR_T pair = { { arrayData, len, len }, attrHandle };

      CyBle_GattsWriteAttributeValue( &pair, 0, &cyBle_connHandle, CYBLE_GATT_DB_LOCALLY_INITIATED );

      }

       

      But now I want to send value that can be negative as well i.e. I would like to send -25. How to make that possible?  CYBLE_GATT_HANDLE_VALUE_PAIR_T accepts only uint8 types.

       

      Alternate question is - Currently the data attribute is of type uint16, do I need to change it to sint16 in order to allow it to transmit negative values?

       

      Please help.

       

      Thanks

       

      Kind Regards,

       

      Jitender Kumar