This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using hvx_params to send string data?

Have been following the nordic tutorial to update characteristic value using hvx_params. Currently the structure for hvx_params is as follows:

    /**@brief GATT HVx parameters. */
typedef struct
{
  uint16_t          handle;             /**< Characteristic Value Handle. */
  uint8_t           type;               /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
  uint16_t          offset;             /**< Offset within the attribute value. */
  uint16_t          *p_len;              /**< Length in bytes to be written, length in bytes written after successful return. */
  uint8_t           *p_data;             /**< Actual data content, use NULL to use the current attribute value. */
} ble_gatts_hvx_params_t;

And in the tutorial, the data to be updated is done by

hvx_params.p_data = (uint8_t*)new_value;

where p_data is in int. However, I want to pass string as the characteristic value to notify an android app using BLE.

My question is, is it possible to do so by changing the structure to:

char           *p_data; 

and also change to

new_value = "Hello there!";
hvx_params.p_data = new_value;

where new_value is in char* (a string).

If this is the wrong method, what should I do to pass string via BLE to the android app using notifications?

Thank you.

Related