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,

    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 

  • hi Karl

    thanks, it compiles now 

    how ever, is there an example that uses the advertising library to get a better sense of needed configuration for the ble_advertising_t element ?

    if not, how should it be configured and will the 2 libraries work together ? 

    ... WELL i have tried to implement it but i see no change in the nrf scan app, and after looking some more to the function it's not clear to me why i need 2 instances since one is for scanned data and i am working with beacon 

    here my code, its a bit messy cause it's just to see its working , you can see the commented lines which do give change in data packets via nrf scan app

    static void data_update_timer_handler(void* p_context)
    {
        ret_code_t err_code;
        static uint8_t advdata_next_idx = 0;
    
        static uint8_t i = 0;
        if( i >= SET_VALUES_ARRAY )
        {
            i = 0;
        }
        uint8_t idx = i++;
        m_beacon_info[12] = spin_angle[idx];
        m_beacon_info[13] = (spin_direction[idx] | speed[idx]);
        NRF_LOG_INFO("%d",m_beacon_info[12]);
    
        manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
        manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;
    
        if(0 == advdata_idx ) advdata_next_idx = 1;
        else if( 1 == advdata_idx)  advdata_next_idx = 0;
        advdata[advdata_idx].p_manuf_specific_data = &manuf_specific_data;
        
        advdata[advdata_next_idx] = advdata[advdata_idx];
        ble_advertising_advdata_update(&ble_adv ,&advdata[advdata_next_idx], NULL /*&advdata[advdata_next_idx]*/);
        advdata_idx = advdata_next_idx;
    
    //    sd_ble_gap_adv_stop(m_adv_handle);
    //    err_code = ble_advdata_encode(&advdata[advdata_idx], 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);
    //    advdata_idx = advdata_next_idx;
    }
    #define EVERY_ONE_SECOND (200) // milli second
    APP_TIMER_DEF(data_change_timer);

    another thing, maybe i will open a new topic for that, regarding the nrf52840 dongle.. is it possible to program it to do the following via the nrf programmer (from the pc app):

    receive data via usb as uart and advertise it in a way that if no new data is arriving via uart the dongle keeps on advertising every 30ms (basically to receive data and update the advdata every time new data is received, or send each received mesage for several times in shortest intervals (30ms) unless new data arrives (also is it possible to program it to change some part of the data by itself each time it receives data from uart(meaning send the same data 10 times for instance, each time with one byte change in the data)

    that is instead of programming it via some development boards debugger ? 

    best regards

    Ziv

  • hopefully we can resolve this before the end of this week 

Related