Modify broadcast data

hello:

  In nrf5,the content of this struct variable can be easily modified to change the advertising data even during advertising,just like this:

ble_gap_adv_data_t m_adv_data =
{
.adv_data =
{
.p_data = ADV_DATA,
.len = ADV_DATA_LENGTH
},
.scan_rsp_data =
{
.p_data = NULL,
.len = 0
}
};

void update_exp_info(uint16_t exp_count, uint16_t exp_spend_time_ms){
m_adv_data.adv_data.p_data[EXP_COUNT_OFFSET] = exp_count % 256;
m_adv_data.adv_data.p_data[EXP_COUNT_OFFSET + 1] = exp_count / 256;
m_adv_data.adv_data.p_data[EXP_TIME_MS_OFFSET] = exp_spend_time_ms % 256;
m_adv_data.adv_data.p_data[EXP_TIME_MS_OFFSET + 1] = exp_spend_time_ms / 256;
}

Is there a similar method in NCS? Or how can the broadcast data be easily modified (during the broadcasting process) in NCS?

Looking forward to your help.

Parents Reply Children
  • Hello, thank you very much for your response.
    I am developing based on the example "multiple adv sets," which broadcasts two advertisements simultaneously. I noticed that the function you provided does not pass a pointer to a specific advertisement.
    If I want to update the data of a specific advertisement in the multiple advertising sets, how should I proceed?
    I look forward to your reply.

  • Hi Allen and thank you for your patience. 

    I think the best is to use bt_le_ext_adv_set_data as this will allow you specify which advertisement to update

    Regards

    Runar

  • Thank you, I have already tried your suggestion, and it does work.

    However, my work involves studying the delay in Bluetooth neighbor discovery, so I need to know the exact time from the start of advertising to when the advertisement packet is scanned by the scanning device. The method I am using is to record the time when the antenna starts and write it into the advertisement packet, so the broadcast packet will carry the time it was sent. When the receiver receives the packet, it will know when the packet was sent. Therefore, I need to modify the content of the advertisement packet in the radio_notification. However, it seems that this function cannot be called inside the radio notification, and the error message is as follows:

    *** Booting nRF Connect SDK v2.5.0 ***
    I: SoftDevice Controller build revision:
    I: c5 93 ba a9 14 4d 8d 05 |.....M..
    I: 30 4e 9b 92 d7 71 1e e8 |0N...q..
    I: aa 02 50 3c |..P<
    I: HW Platform: Nordic Semiconductor (0x0002)
    I: HW Variant: nRF52x (0x0002)
    I: Firmware: Standard Bluetooth controller (0x00) Version 197.47763 Build 2370639017
    I: Identity: DD:78:A1:BA:18:E4 (random)
    I: HCI: version 5.4 (0x0d) revision 0x1102, manufacturer 0x0059
    I: LMP: version 5.4 (0x0d) subver 0x1102
    Created adv: 0x20001d30
    ASSERTION FAIL @ WEST_TOPDIR/zephyr/kernel/sem.c:128
    E: r0/a1: 0x00000004 r1/a2: 0x00000080 r2/a3: 0x20007380
    E: r3/a4: 0x00000001 r12/ip: 0x20005060 r14/lr: 0x0002b977
    E: xpsr: 0x61000025
    E: Faulting instruction address (r15/pc): 0x0003139e
    E: >>> ZEPHYR FATAL ERROR 4:

    Do you have any good suggestions?

  • I have to say I'm honestly not sure if you can change the package within the radio notification. I will ask internally 

    I'm just wondering if it would not be better to toggle a pin on both the sender and receiver and use a scope to measure the time between two devices. 

    Regards

    Runar

  • Thank you,I'll try your suggestion. Also, if there is a way to modify the packet within the radio, please let me know.

Related