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

Changing advertisement data in every packet

Hi,

I need to change advertisement data while advertising. The goal is to set new data for every packet. Firstly, I was trying to put new value like this, but it didn't work:

#... int COUNTER = 1; uint8_t data[] = "123456789123456"; #... // Enter main loop. for (;;) { COUNTER = COUNTER + 1; if (COUNTER == 14) COUNTER = 0; data[3] = (uint8_t) COUNTER; power_manage(); } (modified code from ble tutorial: devzone.nordicsemi.com/.../)

After that, I have read this post: devzone.nordicsemi.com/.../

As I understand now, I was changing memory and that did not make any effect on my advertising. In order to do so, I need to use sd_ble_gap_adv_data_set(). When I try to put it in main loop with COUNTER value as p_data it does not work and I have no idea what is wrong.

What should I change in order to make it work? How can I solve this problem? Are there any other approaches?

Parents
  • The solution here is to use radio notifications. You will have to change the advertisement packet every time the radio has been active, which typically is after every advertisement interval. You will have to setup a callback function in ble_radio_notification_init(…) that changes the advertisement packet.

    A user has uploaded his implementation of this solution here, where he switches between different eddystone-format advertising packets using the callback function eddystone_interleave(..).

  • Thank you, this is a very good option. I am looking forward for the link. I am using nRF51. For my application every packet is important and I need to count sent packets, give them kind of id and markers. I am not very clear what do you mean by puting data in the scan response packet. Right now, I don't have problems with packet size, but in other versions of application it may be an issue.

Reply
  • Thank you, this is a very good option. I am looking forward for the link. I am using nRF51. For my application every packet is important and I need to count sent packets, give them kind of id and markers. I am not very clear what do you mean by puting data in the scan response packet. Right now, I don't have problems with packet size, but in other versions of application it may be an issue.

Children
No Data
Related