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

Advertizing multiple UUIDs (iBeacon)

Hi,

I want to advertise multiple UUIDs, one after another

Do I have to stop advertising, or is there a way, that I can update the struct in the background?

Currently we do it the following way:

  for ever {
        ble.init();
        change_mac(uids[i].mac); // patching the struct
        ble.stopAdvertising();
        set_payload(&ble, uids[i].bcn);  // accumulateAdvertisingPayload()
        ble.startAdvertising();
        nrf_delay_us(500*1000);     // Sleep for some time
    }
Parents
  • Hi.

    This is the correct way to change the advertisement packet.

    I do not know the contents of ble_init(), but it seems wrong to initialize something in a loop.

    The nrf_delay_us does not make the CPU sleep. It will "actively" to nothing (busy wait) for the set time. This will make your battery time lower. If you want to actually sleep and save power, use an app_timer with a 500 ms interval to do your tasks. Then call uint32_t err_code = sd_app_evt_wait(); in your main() loop.

Reply
  • Hi.

    This is the correct way to change the advertisement packet.

    I do not know the contents of ble_init(), but it seems wrong to initialize something in a loop.

    The nrf_delay_us does not make the CPU sleep. It will "actively" to nothing (busy wait) for the set time. This will make your battery time lower. If you want to actually sleep and save power, use an app_timer with a 500 ms interval to do your tasks. Then call uint32_t err_code = sd_app_evt_wait(); in your main() loop.

Children
Related