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

Set data type for Notify

Hello.
I am sending data from the multi-roll BLE module to the central BLE module using Notify.
Currently, only the sample project HRValue is sent.

The data related to transmission is HRValue.
ble_hrs_scan_device_send (& m_hrs, HRValue);
I send it with the above code.

The data when receiving is as follows.
typedef struct
{
    uint16_t hr_value; / ** <Heart Rate Value. * /
    uint8_t rr_intervals_cnt; / ** <Number of RR intervals. * /
    uint16_t rr_intervals [BLE_HRS_C_RR_INTERVALS_MAX_CNT]; / ** <RR intervals. * /
} ble_hrm_t;


I would like to send character string data in addition to HRValue. In that case, is it correct to add character string data to the received data structure?
Please let me know if there is any other way.
Thank you.

SoftDevice: S132
IDE: SES
BLE Device: NRF52832
SDK version: 15.30
Central project: ble_peripheral⇒ble_app_hrs_c
multirole project: experimental⇒ble_app_multirole_lesc

Parents Reply
  • All services and characteristics that use a 16-bit UUID are assigned numbers that should be used only as specified by the service and profile as specified by BT. If you want to send proprietary data, then refer to for instance ble_app_blinky that show how you can add vendor specific UUID's (128-bit) that can be used for vendor specific generic usage.

Children
  • thank you for the advice.
    I'm looking at the project "ble_app_blinky" and "ble_app_blinky_c" now. These two send the button state as data. The receiving side (ble_app_blinky_c) found that the following data is defined on "ble_lbs_c.h".

    / ** @ brief Structure containing the Button value received from the peer. * /
    typedef struct
    {
        uint8_t button_state; / ** <Button Value. * /
    } ble_button_t;

    On the other hand, on the sending side (ble_app_blinky), the data to be sent is only the state of the button, so the data is not defined and is directly entered in the sending parameter.
    uint32_t ble_lbs_on_button_change (uint16_t conn_handle, ble_lbs_t * p_lbs, uint8_t button_state)
    {
        ble_gatts_hvx_params_t params;
        uint16_t len ​​= sizeof (button_state);

        memset (& params, 0, sizeof (params));
        params.type = BLE_GATT_HVX_NOTIFICATION;
        params.handle = p_lbs-> button_char_handles.value_handle;
        params.p_data = & button_state;
        params.p_len = & len;

        return sd_ble_gatts_hvx (conn_handle, & params);
    }

    How are the data relationships established between the two?
    Also, when configuring your own data on this project, is it configured on the “ble_button_t” on the central side (ble_app_blinky_c)? On the peripheral side (ble_app_blinky), should I create a new data structure at the following location in the "ble_lbs.h" part?

    / ** @ brief LED Button Service structure.This structure contains various status information for the service. * /
    struct ble_lbs_s
    {
        uint16_t service_handle; / ** <Handle of LED Button Service (as provided by the BLE stack).
        ble_gatts_char_handles_t led_char_handles; / ** <Handles related to the LED Characteristic. * /
        ble_gatts_char_handles_t button_char_handles; / ** <Handles related to the Button Characteristic. * /
        uint8_t uuid_type; / ** <UUID type for the LED Button Service. * /
        ble_lbs_led_write_handler_t led_write_handler; / ** <Event handler to be called when the LED Characteristic is written. * /
    };

  • You are completely free to change this as you see fit.

    The BLE softdevice will transmit/receive any data "as-is" with no modification. The application simply provide a connection handle, a pointer to a buffer, and a length field. The softdevice will then transmit and receive this generic data over BLE.

    As long as you are not using a standardized BLE profile (heart rate, glucose, fitness...), then you are free to struct and cast this data as you best see fit for your requirements. It is entirely up to you.

    You may find this useful:
    https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-services-a-beginners-tutorial
    https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-characteristics-a-beginners-tutorial

  • With reference to the tutorial, I was able to send my own data from the customization service. Thank you.
    Next, we will work to integrate with existing services and send 2D array data.

Related