This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

advertising packets include gatt attribute data

Hi:

I want to include the Characteristic value in the advertising packet,for example the real time battery level,thus there is no need to  establish a connection between a central and a
peripheral,is it impossible?(the chip is nrf52832,sdk version nRF5_SDK_17.0.2_d674dde)

Currently I get the following clues:

Table 4-7. Service Data AD Type

Field Length in bytes Description
UUID 2, 4, or 16 The actual UUID identifying the data
The data associated with the service identified by the UUID
Service Data Variable

Table 4-6. Characteristic properties

Property Location Description
Broadcast Properties If set, allows this characteristic value to be placed in advertising packets, using the Service
Data AD Type (see
“GATT Attribute Data in Advertising Packets”)

According the two clues above ,enable the characteristic broadcast property and config the Service Data AD Type may achieve that goal,but the result is that the battery level does not appear in the advertising packet,is there anything wrong?

part of service data config code:

static ble_advdata_service_data_t adv;
static ble_advdata_manuf_data_t mna_data;
static uint8_t mdata[5]={9,5};

/**@brief Function for initializing the Advertising functionality.
*/
static void advertising_init(void)
{
ret_code_t err_code;
ble_advertising_init_t init;

adv.service_uuid=BLE_UUID_BATTERY_LEVEL_CHAR;//BLE_UUID_BATTERY_LEVEL_CHAR;//BLE_UUID_BATTERY_SERVICE;
adv.data.size=1;
adv.data.p_data=&m_bas.battery_level_last;

init.advdata.p_service_data_array=&adv;
init.advdata.service_data_count=1;

part of characteristic broadcast property code:

static ret_code_t battery_level_char_add(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init)
{
ret_code_t err_code;
ble_add_char_params_t add_char_params;
ble_add_descr_params_t add_descr_params;
uint8_t initial_battery_level;
uint8_t init_len;
uint8_t encoded_report_ref[BLE_SRV_ENCODED_REPORT_REF_LEN];

// Add battery level characteristic
initial_battery_level = p_bas_init->initial_batt_level;

memset(&add_char_params, 0, sizeof(add_char_params));
add_char_params.uuid = BLE_UUID_BATTERY_LEVEL_CHAR;
add_char_params.max_len = sizeof(uint8_t);
add_char_params.init_len = sizeof(uint8_t);
add_char_params.p_init_value = &initial_battery_level;
add_char_params.char_props.notify = p_bas->is_notification_supported;
add_char_params.char_props.read = 1;
add_char_params.char_props.broadcast = 1;
add_char_params.cccd_write_access = p_bas_init->bl_cccd_wr_sec;
add_char_params.read_access = p_bas_init->bl_rd_sec;

Has anyone used this feature? Please provide me with some help, thanks!

Parents
  • Hello!

    Yes this should be possible, it sounds like you want to use your peripheral unit as a beacon.

    Have you looked at the Beacon transmitter sample application?

    Best regards,

    Einar

  • Hi!

    Thank you for your reply,I just checked the Beacon project,it seems to broadcast fixed datas using the manufacturer AD type,but what I want to achieve is a dynamic broadcasting that the broadcast data follows the change of the characteristic attribute value.

    I know there is a way to dynamically update broadcast data using the function "ble_advertising_advdata_update()" ,but it requires application participation,does the softdevice supports automatic update of broadcast data according to the "add_char_params.char_props.broadcast = 1" ?

    And again am I misunderstanding the meaning of Service Data AD Type and Broadcast Property?

    thank you!

  • Hi

    Why would ble_advertising_advdata_update() not work for your application?

    Don't you just want to change the data in the advertisement, or am I misunderstanding?

    If I've misunderstood, can you please explain what you are trying to do?

    -Einar

  • Hi:

    yes,ble_advertising_advdata_update() it does work,but i do not  want to use it,I am looking for another possible way,for example using the “Broadcast property”,it said “If set, allows this characteristic value to be placed in advertising packets, using the Service Data AD Type”,so I think this might be a possible way.

    But I may have misunderstood the concept of “Broadcast property” and “Service Data AD Type”,if so,what is their meaning exactly,i want to figure it out,and are there any reference examples for these two concepts?

    Thanks again!

Reply
  • Hi:

    yes,ble_advertising_advdata_update() it does work,but i do not  want to use it,I am looking for another possible way,for example using the “Broadcast property”,it said “If set, allows this characteristic value to be placed in advertising packets, using the Service Data AD Type”,so I think this might be a possible way.

    But I may have misunderstood the concept of “Broadcast property” and “Service Data AD Type”,if so,what is their meaning exactly,i want to figure it out,and are there any reference examples for these two concepts?

    Thanks again!

Children
  • Hello!

    All of the characteristic property values, including "broadcast property" are only relevant if you are planning to establish a connection.

    These values are meant to give information about the characteristics you're sharing to the devices you connect to, so if you're planning to only broadcast these values will never be used.

    The "Service Data AD Type" is a formatting type for your advertising data. You can place data you want to broadcast in a data field like this, but you'll have to update it manually, for instance with ble_advertising_advdata_update().

    Hope this clears things up,

    Einar

  • Hi,

    Ok i got it, it helped me a lot,thank you!

    Best regards,

    Alan

Related