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

  • ?? sorry for nagging but i really need help with that and i am on a tight scheduled 

  • Hello Ziv,

    ziv123 said:
    hopefully we can resolve this before the end of this week 

    Yes, hopefully we will resolve this before the weekend.

    ziv123 said:
    thanks, it compiles now 

    That it good. Are you experiencing any unexpected behavior since switching to the advertising module?

    ziv123 said:

    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 ?

    Unfortunately no, none of the SDK examples currently use the advertising library - however, you could take a look at the "Usage" section of the library documentation to get started. You can also see the description of each config parameter here.
    Fortunately, the advdata structure and advertising module goes well together, there is no problem at all using both.

    ziv123 said:
    ... 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 

    Could you confirm for me that you are working with SDK 16, or if you have upgraded to SDK 17 since we last spoke about it?
    If you are using SDK 17 then you do not need to have two advertising data structures, you can just work with a single one.
    You do not need to provide scan response data.

    ziv123 said:
    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

    Are you saying that the code as you have shared it does nothing to change the advertising data, except if you include the commented part at the end?
    The advdata_update function handles the necessary encoding and configuration as well, please take a look in the advertising library source code.

    ziv123 said:

    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 ? 

    In short; yes, this is possible. You can either program the Dongle directly as you would have programmed a DK, or you can create a desktop application using the pc-ble-driver that controls the dongle. However, please open a new ticket for this subject if you require more information about this, as it is diverging from your initial ticket.

    Best regards,
    Karl

  • hi Karl

    Could you confirm for me that you are working with SDK 16

    yes, i checked the zip file i downloaded, and working with -> "nRF5_SDK_16.0.0_98a08e2.zip"

    Are you saying that the code as you have shared it does nothing to change the advertising data, except if you include the commented part at the end?

    YES, when using the commented lines instead of the advdata_update function then i see change in data in the nrf_connect_app on my cell phone. but when i am using the function as shown in the code i added i don't see a change in the data in the same app on my cell phone

    i will open a new topic on the dongle issue

    hope to read from you soon

    best regards

    Ziv

  • Hello again Ziv,

    ziv123 said:
    yes, i checked the zip file i downloaded, and working with -> "nRF5_SDK_16.0.0_98a08e2.zip"

    Great, thank you for confirming this.

    In SDK 16 you still need the two instances of the advertising struct, for the update function to work - as you have.
    The reason for this can be seen in the sd_ble_gap_adv_set_configure API reference.
    In SDK 17 this in handled by the advdata_update function internally.

    This might be a long-shot, but could you attempt to split the advdata buffers entirely?
    I do not know how they are initialized, so I say this to ensure that there are nothing shared between the buffers.

    ziv123 said:
    YES, when using the commented lines instead of the advdata_update function then i see change in data in the nrf_connect_app on my cell phone. but when i am using the function as shown in the code i added i don't see a change in the data in the same app on my cell phone

    Yes, I would expect the commented out lines to work on their own, as this is a sure-fire way of changing the advertising data.  

    ziv123 said:
    i will open a new topic on the dongle issue

    Great.

    Looking forward to resolving this issue together.

    Best regards,
    Karl

  • hi Karl 

    This might be a long-shot, but could you attempt to split the advdata buffers entirely?
    I do not know how they are initialized, so I say this to ensure that there are nothing shared between the buffers.

    what do you mean by split the advdata buffers entirely ? ??

    ble_advdata_t advdata[2];
    this is how they are first declaired

    static void advertising_init(void)
    {
        uint32_t      err_code;
        //ble_advdata_t advdata;
        uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
    
        //ble_advdata_manuf_data_t manuf_specific_data;
    
        manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
    
    #if defined(USE_UICR_FOR_MAJ_MIN_VALUES)
        // If USE_UICR_FOR_MAJ_MIN_VALUES is defined, the major and minor values will be read from the
        // UICR instead of using the default values. The major and minor values obtained from the UICR
        // are encoded into advertising data in big endian order (MSB First).
        // To set the UICR used by this example to a desired value, write to the address 0x10001080
        // using the nrfjprog tool. The command to be used is as follows.
        // nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val <your major/minor value>
        // For example, for a major value and minor value of 0xabcd and 0x0102 respectively, the
        // the following command should be used.
        // nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val 0xabcd0102
        uint16_t major_value = ((*(uint32_t *)UICR_ADDRESS) & 0xFFFF0000) >> 16;
        uint16_t minor_value = ((*(uint32_t *)UICR_ADDRESS) & 0x0000FFFF);
    
        uint8_t index = MAJ_VAL_OFFSET_IN_BEACON_INFO;
    
        m_beacon_info[index++] = MSB_16(major_value);
        m_beacon_info[index++] = LSB_16(major_value);
    
        m_beacon_info[index++] = MSB_16(minor_value);
        m_beacon_info[index++] = LSB_16(minor_value);
    #endif
    
    ///ziv addition:
      //  static uint8_t i = 4;
      //  if( i >= SET_VALUES_ARRAY )
      //  {
      //      i = 0;
      //  }
       // uint8_t idx = i++;
       m_beacon_info[12] = spin_angle[3];
       m_beacon_info[13] = (spin_direction[3] | speed[3]);
    
    // ziv addition end  
    
        manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
        manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;
    
        // Build and set advertising data.
        memset(&advdata[advdata_idx], 0, sizeof(advdata[advdata_idx]));
    
        advdata[advdata_idx].name_type             = BLE_ADVDATA_NO_NAME;//BLE_ADVDATA_SHORT_NAME;//BLE_ADVDATA_NO_NAME;
        advdata[advdata_idx].flags                 = flags;
        advdata[advdata_idx].p_manuf_specific_data = &manuf_specific_data;
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = 0;       // Never time out.
    
        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);
    }

    this is the advertising init func, in which i initiate only one of them, and after that, in the timer handler which i sent before i do this:

    advdata[advdata_next_idx] = advdata[advdata_idx];

    which to my understanding copies all the defines and configs of one instance to the other  (not sure it is semantically correct to say it but you understood i belive)

     

    best regards

    Ziv

Related