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

Parents
  • 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

  • hi Karl

    i am jumping a little bit from one question to another, sorry for that but i finely talked with directly with the client and i have some questions:

    1. if i work with a beacon, what's the safe interval in which a 31 byte message can be transfered, how much time for receiving and how much time till the next time i can send the message? same wuestion for a 255 byte of data message ? 

    i read somewhere that i can send a message every 20 ms but when i checked it with a scope it was not very stable.. i think we talked about it before actually but i am not sure.. need to look

    2. if want to create a connection with lets say 20 units, how much time from when the message is advertised till connection is established with a unit and how much time from a data message is sent to the ACK received from the field unit ? also, how much time from data message sent to the field unit till i can send the next data message to that unit

    i would also like to understand if possible what is the meaning of nrf52840 maintaining 20 connections.. does it mean it keeps a live connection with all 20 units how much time will it take to send a message to all units ?

    one more thing, if i use a different device with larger antenna will it help to get more stable and sure communication, how will it benefit the communication with the units ? 

    one more, can a device be in a scan mode for beacon from other device and advertise its own beacon at the same time ? or do i have to stop advertising -> go to scan and then back to advertise ?

    best regards

    Ziv

  • Hello Ziv,

    ziv123 said:
    i am jumping a little bit from one question to another, sorry for that but i finely talked with directly with the client and i have some questions

    No problem. However, in order to keep the forum tidy I would ask that you create a new ticket if you should have any followup questions to this comment, since the questions now have diverged from the original "beacon advertising interval" ticket questions.

    ziv123 said:
    1. if i work with a beacon, what's the safe interval in which a 31 byte message can be transfered, how much time for receiving and how much time till the next time i can send the message? same wuestion for a 255 byte of data message ? 

    The minimum advertising interval that you may configure is as mentioned 20 ms. In addition, there will be added a random 0 - 10 ms delay on top of this, which means that the worst case if 30 ms between every advertisement. These requirements are the same for the 255 byte message ( assuming you are referring to extended advertising here ).
    To see how long time different sized payloads take to transfer, please have a look at our online power profiler for the nrf52 series.
    As you can see from the online power profiler a non-connectable advertisement of 31 bytes will take 376 us to complete for each advertising channel.

    ziv123 said:
    i read somewhere that i can send a message every 20 ms but when i checked it with a scope it was not very stable.. i think we talked about it before actually but i am not sure.. need to look

    Yes, we have already spoken about this. The reason why this is not stable is the 0 - 10 ms randomly added delay. The delay is part of the BLE specification and can not be omitted.

    ziv123 said:

    2. if want to create a connection with lets say 20 units, how much time from when the message is advertised till connection is established with a unit and how much time from a data message is sent to the ACK received from the field unit ? also, how much time from data message sent to the field unit till i can send the next data message to that unit

    i would also like to understand if possible what is the meaning of nrf52840 maintaining 20 connections.. does it mean it keeps a live connection with all 20 units how much time will it take to send a message to all units ?



    You may indeed hold up to 20 concurrent connections. Please see this ticket for more detail.
    You can use the online power profiler to see how long each transfer will take, depending on the size of the transmission.
    The time till first ACK from an advertisement is hard to estimate precisely since it depends on a lot of factors, but please see this ticket for a discussion of the time to establish a connection.

    ziv123 said:
    one more thing, if i use a different device with larger antenna will it help to get more stable and sure communication, how will it benefit the communication with the units ? 

    A larger / higher power antenna will decrease the chance of packet loss, which in turn may speed up data transfer.
    The necessity of this will depend on the environment / conditions your devices are in. If there is a lot of obstacles and interference, etc.

    ziv123 said:
    one more, can a device be in a scan mode for beacon from other device and advertise its own beacon at the same time ? or do i have to stop advertising -> go to scan and then back to advertise ?

    Are you asking if a device can alternate between being a central and a peripheral?
    If so, the answer is yes. This is demonstrated in the experimental multirole examples in the SDK that I mentioned earlier.

    Best regards,
    Karl

  • hi Karl 

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

    when writing this function in the app_ble_beacon example i get undefined reference error 

    may be you know why ?

    best regards

    Ziv

  • Hello Ziv,

    ziv123 said:
    when writing this function in the app_ble_beacon example i get undefined reference error

    Please be specific about the error messages you are seeing. Is it an undefined reference error to ble_advertising.h?
    In that case, you will need to make sure that you have included ble_advertising.h and the path /SDK/components/BLE/ble_advertising in your pre-processor defines.

    If this is not the include error in question, please elaborate.

    Best regards,
    Karl

  • the argument of this function are unknown in the app_ble_example 10040, peripheral.

    " unknown type name 'ble_advertising_t'; did you mean 'ble_version_t'? "

    " implicit declaration of function 'ble_advertising_advdata_update' [-Wimplicit-function-declaration] "

    best regards

    Ziv

Reply Children
  • Hi Ziv,

    Again, the more specific and detailed your answers are, the easier it will be to help you resolve this issue.
    From the two lines you included in your last comment, I would recommend that you check out your SES project settings, especially the preprocessor defines. Ensure that they include the path I gave you in my previous comment. Then, check that you have added the source file to your project files, and included the header file.

    Looking forward to resolving this issue.

    Best regards,
    Karl

  • hi Karl

    the path you mentioned is in the pre compiled file

    i also copy the line cause i am not sure the pic is clear:

    c_user_include_directories="../../../config;../../../../../../components;../../../../../../components/ble/ble_advertising;

    so its not that or maybe it needs to be called from some other place ?

    also added the following:

    <file file_name="../../../../../../components/ble/ble_advertising.c" />

    still same result 

    best regards

    Ziv

  • Hello Ziv,

    ziv123 said:
    so its not that or maybe it needs to be called from some other place ?

    Yes, it seems the paths are added correctly. How did you go about adding the paths by the way, did you insert them into this file directly? Could you also specify the exact name of the file you now have copied snippets from?

    Are you working with armgcc and Makefiles directly, or are you using an IDE like Segger Embedded Studios?
    If I know this then I can provide more detailed instructions on how to add paths and source files to your 
    Just to make sure - have you made sure to include ble_advertising.h in your main file?

    Best regards,
    Karl

  • hi Karl

    ok, there is progress, yes adding #include .. is important 

    however, the  ble_advertising.h is not called, i think, because BLE_ADVERTISING is not set

    #if NRF_MODULE_ENABLED(BLE_ADVERTISING)
    #include "ble_advdata.h"
    #include "ble_advertising.h"
    #include "nrf_soc.h"
    #include "nrf_log.h"
    #include "sdk_errors.h"
    #include "nrf_sdh_ble.h"

    but again, why it would not be configured in a build in beacon example ???  

    and anyway, where is the right place to define it if that's the solution ?

    best regards

    Ziv

  • Hello Ziv,

    ziv123 said:
    however, the  ble_advertising.h is not called, i think, because BLE_ADVERTISING is not set
    ziv123 said:
    where is the right place to define it if that's the solution ?

    That could very well be the case. If so, please check that BLE_ADVERTISING_ENABLED is defined to 1 in the sdk_config.
    Please try this, and see if the undefined reference error is resolved.

    ziv123 said:
    but again, why it would not be configured in a build in beacon example ???  

    The Beacon example from the SDK does not use the advertising library - it uses the ble_advdata library and direct calls to the SoftDevice API.

    Best regards,
    Karl 

Related