ble advertizing data update dynamically in the prigram

Hi

I want to update the ble advertising data in my program. In nrf5340 the bt_le_adv_start() command should run only once in the main program.

Is it possible to change the advertising data of ble device in broadcast non connectable mode by bt_data_bytes() or bt_data() commands or

any other means. Its also preferable to use extended mode to be able to use 256 bytes of data while broadcasting.

Thank you in advance for your support.

Best regards.

Parents
  • Hello,

    I have not tested it yet, but there is a function called bt_le_adv_update_data(). I am not sure whether you need to stop the adverting using bt_le_adv_stop() before updating the data or not. Check the return value from bt_le_adv_update to see whether it succeeds without stopping the advertising data.

    Best regards,

    Edvin

  • Hi

    I have tested it on my custom board. It worked without the need of using bt_le_adv_stop().

    But I have another question yet. I want to use the ble radio in extended mode to be able to

    transfer more than just 32 bytes.

    Again thank you for your supports.

    Best regards,

    Saeed

  • You can ad a scan response packet in bt_le_adv_start():

    int bt_le_adv_start(const struct bt_le_adv_param *param,
    		    const struct bt_data *ad, size_t ad_len,
    		    const struct bt_data *sd, size_t sd_len);

    The parameters *sd and sd_len is the scan response data, which gives you another 31 bytes. If you need even more, then you need to look into bt_le_ext_adv_create(). In fact, you will find a lot of the possibilities by looking at the bluetooth.h file found in NCS\zephyr\include\bluetooth\bluetooth.h.

    Best regards,

    Edvin

  • Hi

    Thank you very much for your guidance. But let me discus another question.

    Actually I want to attach the serial port receiving data to ad area field of my advertising device. Should

    I use BT_DATA_BYTES()? As far as I tried only static constant data can be used in this function.

    How could I change the ad data dynamically in the program.?

Reply Children
Related