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

beacon advertise interval

hello Nordic

i am working with nrf52832, sdk 6.0, softdevice s132 v7.0

i read around the forum that i can advertise a beacon packet every 20 ms 

but in the ble_app_beacon example the interval for the advertisement is written to be minimum 100ms ?? so where did that 20 ms go ?

however, since i don't know how to change the data of the message while advertising i put a timer handler that stops the advertise, update the data and start it again.

i put the timer to go every 50 ms and the advertisement interval every 50 ms i put a pin toggle every time i receive a ble from the address i am filtering..

1. the time is not fixed, maybe some messages are lost or maybe not sent, i don't know 

2. the intervals are larger then 50 ms .. more to the 100 ms  when they are sometimes fixed 

can you advice on this matter ?

i need to be sending changeable data in a beacon at list 30 times in one second

best regards

Ziv

  • Hello Ziv,

    i read around the forum that i can advertise a beacon packet every 20 ms 

    but in the ble_app_beacon example the interval for the advertisement is written to be minimum 100ms ?? so where did that 20 ms go ?

    I am not sure I follow your train of thoughts here - the lowest possible advertising interval is indeed 20 ms, but the beacon example provided in the SDK uses an advertising interval of between 100 and 200 ms, this is correct.
    The reason for this is that beacons do not usually transfer a whole lot of data, and as such it is more power efficient to not advertise with the lowest possible interval. You may of course change this in your own application, to use the 20 ms advertising interval.

    however, since i don't know how to change the data of the message while advertising i put a timer handler that stops the advertise, update the data and start it again.

    If you are using the advertising module you may instead use the _advdata_update function.
    However, the _advdata_update function has a known issue, which requires that you have two adv_data instances that you alternate between passing to update and updating.
    That is to say: you may not pass a single advdata instance to advertising start, update the same advdata instance and then provide it as the argument to _advdata_update.
    Instead, you will have to have two advdata instances, where you pass one as the argument to the _advdata_update function, and then you may update the other advdata instance, before calling _advdata_update again with the most recently updated(not currently in use) advdata instance.

    1. the time is not fixed, maybe some messages are lost or maybe not sent, i don't know 

    Advertisements are transfers without acknowledgments, and they may indeed be lost sometimes - there are no retransmissions because there is never any acknowledgements. This can happen more often if the devices are far apart, and if they are operating in a 2.4 GHz noisy environment. The time can not be completely fixed either, due to the random 10 ms delay that is added before every advertisement. This is part of the BLE specification and can not be removed.

    2. the intervals are larger then 50 ms .. more to the 100 ms  when they are sometimes fixed 

    Please elaborate on the exact timings you are seeing. How are you measuring this by the way, only the toggling pin, or do you also use the BLE Sniffer tool

    i need to be sending changeable data in a beacon at list 30 times in one second

    This is possible using beacon advertisements, since with a 20 ms advertising interval your worst case will be 30 ms between each advertisement, which again means that you will get more than 30 packets per second.
    However, you will need to keep in mind that advertisement packets may be lost. This is the biggest drawback of using advertisements to transfer data, and also what makes advertisement data transfer infeasible if you need to make sure every packet is received.
    In the latter case, you will need to establish a connection to ensure that every packet is received.

    Please let me know if anything still should be unclear,
     
    Best regards,
    Karl

  • hi Karl

    good to read from you 

    the thing i actually have to design is

    1. a software for 150 units that receive data (specific for each of them) from one broadcasting unit that is connected to a pc

    2. dLL for the beacon broadcasting gateway or dongle or whatever that is connected to the pc which is running some python app (will need some help with that later)

    regarding the first part:

    • I have no power saving issues since power will be given to all units all the time
    • I was going for broadcasting and beacon to avoid making connection with each unit which i think will take a lot of time on Acks and reconnecting with a different unit every time. I would have sent one big message to all units ,if it was possible, and maybe send it multiple times in a second just to make sure every unit got it.
    • So i was toggling myself between working on an extended beacon broadcast, to checking how much data i can transfer in the 31 byte message and how many times i can transfer it ,so that if one 31 byte message can contain data for 10 units, i have to see that i can send the message to all 150 units every one second
    You may of course change this in your own application, to use the 20 ms advertising interval.

    can i also control the scan interval, and if so how and is there some issues i need to take under consideration when doing that ?

    Instead, you will have to have two advdata instances, where you pass one as the argument to the _advdata_update function, and then you may update the other advdata instance, before calling _advdata_update again with the most recently updated(not currently in use) advdata instance.

    i could not find any _advdata_update function in the ble_advdata.h file. if or when i find the function you are referring to then do i need to stop the advertising and restart it like in the following code, and update in the middle or i can only update advdata in the timer handler and the broadcasting continue in its interval ?:

    sd_ble_gap_adv_stop(m_adv_handle);
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
        err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
        APP_ERROR_CHECK(err_code);

    This can happen more often if the devices are far apart, and if they are operating in a 2.4 GHz noisy environment

    if i am using the ADDRESS FILTER:

        err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_ADDR_FILTER, m_target_periph_addr); // Ziv
        APP_ERROR_CHECK(err_code);
    
        // Setting filters for scanning.
        err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_ADDR_FILTER, false); // Ziv
        APP_ERROR_CHECK(err_code);

    does it change something regarding noises or every message from any device is received and read all the way anyway  and only then is filtered ?

    How are you measuring this by the way

    i toggle a pin in the case of ' NRF_BLE_SCAN_EVT_FILTER_MATCH '  in the ' scan_event_handler(...) '

    i look at the pin in the scope in a 50ms for each square 

    Regarding the second thing:

    if you can recommend a gateway or a device, gateway or other that connects to a pc via usb and comes with a convenient API so i can wrap it and supply the customer with an easy API for the data needed to be transferred to all the 150 units via bl, that would be great. 

    i read some about the nrf52840 dongle but someone wrote that it has a lot of over had regarding softdevice and serialization if i recall and actually recommend using a designated device (for us price of such device is not an issue)

    hope to read from you soon 

    best regards

    Ziv

  • Hello Ziv,

    I understand. That is a lot of units to control, but if you are broadcasting an instruction then all the devices within range will indeed get the advertisement, no problem.
    I would recommend sending it multiple times, to increase the probability that every other unit receives the advertisement.
    The longer the advertisement, the bigger the chance of it being affected 

    ziv123 said:
    can i also control the scan interval, and if so how and is there some issues i need to take under consideration when doing that ?

    Yes, you may change the scan interval too.
    The scan interval should be at minimum advertising interval + 10 ms. Increasing scan interval might allow you to receive more packets, but it will require more power.

    ziv123 said:
    i could not find any _advdata_update function in the ble_advdata.h file.

    My apologies, I should have written out the entire function name - ble_advertising_advdata_update.

    ziv123 said:
    if or when i find the function you are referring to then do i need to stop the advertising and restart it like in the following code, and update in the middle or i can only update advdata in the timer handler and the broadcasting continue in its interval

    If you are using the ble_advertising_advdata_update function then you do not need to stop, update and start advertising again. Then you may only call the _advdata_update function as part of your timer callback, yes. However, keep in mind the double advdata instance you will need to keep alternating between, like I explained in my previous comment.
    If you do not do this, then the ble_advertising_advdata_update function will not work.

    ziv123 said:
    does it change something regarding noises or every message from any device is received and read all the way anyway  and only then is filtered ?

    Unfortunately, filters does nothing to improve on interference from 2.4 GHz noise in the environment.
    You are correct that every message is received and read, and then the filters are applied after that.

    ziv123 said:
    if you can recommend a gateway or a device, gateway or other that connects to a pc via usb and comes with a convenient API so i can wrap it and supply the customer with an easy API for the data needed to be transferred to all the 150 units via bl, that would be great. 

    The nRF52840 dongle is well suited for this.
    You might want to take a look at the pc-ble-driver when you are going to work on this device.

    ziv123 said:
    i read some about the nrf52840 dongle but someone wrote that it has a lot of over had regarding softdevice and serialization if i recall and actually recommend using a designated device (for us price of such device is not an issue)

    I do not understand what you mean by that the nRF52840 dongle is not a designated device, please elaborate.
    The device ( regardless of if it is a dongle or not ) will need a BLE stack either way to be able to communicate using BLE - the SoftDevice is a great and convenient BLE stack implementation that is readily available for all Nordic products.

    Best regards,
    Karl

  • hi Karl

    I would recommend sending it multiple times, to increase the probability that every other unit receives the advertisement.

    that was my plan though in one 31 bytes packet i can have a data for 10 units, so i need to broadcast at least 15 messages like this in a second and preferably at least 2 times for each message -> 30 messages per second, i know that in theory i can broadcast every 20ms and that should be enough but from checking in the scope on the pin toggle i saw it was less stable in those intervals (we discussed this already i think) 

    Unfortunately, filters does nothing to improve on interference from 2.4 GHz noise in the environment.
    You are correct that every message is received and read, and then the filters are applied after that.

    what about whitelist ? does it work better, if i want all units to read only from a certain address ? if so, how is it done on both sides ?

    The nRF52840 dongle is well suited for this.

    It is not clear to me if i can use the dongle nrf52840 as it is without programing it, just sending serial data and have some AT command list that i can operate it through that. So at the moment i am wondering if i should use a bll654 (it has a nrf52840 soc) which comes programed already and no special installations are required (it is more expensive i know), but i don't know to what extent i can control it through the AT commands, like setting broadcast intervals and use of all the 31 bytes of data to my needs without having fixed big headers... or if i use the nrf52840 dongle and program it and download all necessary dependencies, softdevice and more stuff that i briefly saw in the github link you add  

    so, anyway, at the moment i am starting to work on writing a python app that will identify one of this usbs and send serial data to it (for haps there is already a written code for that in the softdevice for the nrf52840 dongle, i don't know) 

    so any advice on that matter will be helpful and maybe i would make a better decision on where to invest until the dongles arrive :)

    best regards

    Ziv

  • hi Karl

    hope all is all right cause you kind of vanished 

    anyway .. i still have all the questions i posted but i also need to think on another metter:

    till now the project was to send data from one unit to 150 units in the area and beacon can solve this, 

    but now, i also need to transfer data back from the 150 units to the device connected to the pc, and that seams to be a little bit more complicated .. 

    can you advice on that matter? what are the options, cons and prunes ?

    best regards

    Ziv

Related