1 Reply Latest reply on Sep 21, 2020 3:19 AM by PY_21

    How to pass a string over BLE

    user_3678521

      So I know how to sent a int over BLE, but now I want to sent a string but I can't seem to find out how.

       

      This is how I sent a int, that i can read from my app:

       

      for(;;)

          {

              /* https://www.youtube.com/watch?v=Aeip0hkc4YE*/

              cy_stc_ble_gatt_handle_value_pair_t serviceHandle;

              cy_stc_ble_gatt_value_t serviceData;

           

              serviceData.val = (uint8*)data;

              serviceData.len = 1;

           

              serviceHandle.attrHandle = CY_BLE_CUSTOM_SERVICE_DEVICE_OUTBOUND_CHAR_HANDLE;

              serviceHandle.value = serviceData;

           

              Cy_BLE_GATTS_WriteAttributeValueLocal(&serviceHandle);

              data[0]++;

              CyDelay(1000);

          }

       

      This counts up every second and I can read it.

       

      but if I want to sent a string how can I do that?? I tried somthing like this, but i only read the start letter 'M':

       

      ValStr = "Mads Sander Hoegstrup";

           

      serviceData.val = (uint8*) ValStr;

      serviceData.len = 1;

           

      serviceHandle.attrHandle = CY_BLE_CUSTOM_SERVICE_DEVICE_OUTBOUND_2_CHAR_HANDLE;

      serviceHandle.value = serviceData;

           

      Cy_BLE_GATTS_WriteAttributeValueLocal(&serviceHandle);