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

Current solution to update packets while advertising for every packet

Hi,

I have seen this post, but it is quite old, so I would like to know what is the current solution to

  • update advertising packets while advertising, without stop and start again the transmission
  • update some bytes in my manufacturer data
  • update my packet for each new packet that i send.

I am currently using the ble_advertising library, with a NRF52 BLE kit on Eclipse. 

  • Hi Karl. Well, with my program, I cannot check which version it is for now, but I think that I am on SDK 15. I I have decided to evolve from SDK15 to 16 because it seems to me that the ble_advertising_advdata_update is not working on SDK15. I have begun, but for now, I have a lot of mistakes. Is this function working on SDK15 ? 

  • Ok, so finally I am working with SDK15. My function is working well: 

    static void Update_data(void)
    {
    	ret_code_t err_code;
    	ble_advdata_manuf_data_t manuf_specific_data;
    	ble_advdata_t advdata;
    
    	if(counter>255) counter = 0;
    	m_beacon_info[0] = (uint8_t)counter;
    	counter++;
    
        memset(&advdata, 0, sizeof(advdata));
    
        advdata.name_type               = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance      = false; //AKR
        // adv manuf specific data //AKR
        manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
        manuf_specific_data.data.p_data = m_beacon_info;
        manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;
        advdata.p_manuf_specific_data   = &manuf_specific_data;
    
        //Encoding of the data to be updated after
        err_code = ble_advdata_encode(&advdata, m_advertising.adv_data.adv_data.p_data, &m_advertising.adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        //Updating of the encoded data
    	err_code = ble_advertising_advdata_update(&m_advertising, &m_advertising.adv_data, true);
    	APP_ERROR_CHECK(err_code);
    
    }
    

    To easily use the ble_advertising_advdata,update from SDK15, I have used the ble_encode function. Now I can see that my frames are updated with the NRF sniffer app tool. What I want now, is to update my frame for each frame that I send. Do youknow how can I do that ?

  • Hello again,

    Beldramma said:
    I have decided to evolve from SDK15 to 16
    Beldramma said:
    Ok, so finally I am working with SDK15.

    Did you here mean to say that you finally is working with SDK 16, or have I misunderstood you? 
    Keep in mind that the advdata_update function was introduced in SDK v.15.2.0, and is not present in < v.15.2.0.

    Beldramma said:
    To easily use the ble_advertising_advdata,update from SDK15, I have used the ble_encode function.

    You should not have to encode the data prior to sending it to the advdata_update function, since that is done within the update function itself. Are you saying that the advdata_function did not work as expected, until you provided it with already encoded advdata?

    Beldramma said:
    Now I can see that my frames are updated with the NRF sniffer app tool.

    I am happy that your advertising is behaving as expected!

    Beldramma said:
    What I want now, is to update my frame for each frame that I send. Do youknow how can I do that ?

    To do this you would have to call the update function with new data every time an advertisment is made.
    Be advised that packets may be corrupted or lost on the way depending on the environment, so if you are only advertising some data once, certain datapoints may never reach the central.

    Best regards,
    Karl

  • Did you here mean to say that you finally is working with SDK 16, or have I misunderstood you? 
    Keep in mind that the advdata_update function was introduced in SDK v.15.2.0, and is not present in < v.15.2.0.

    No I am working on SDK 15.2. So I have the first version of the ble_advertising_advdata_update, and I need to encode the data myself. 

    To do this you would have to call the update function with new data every time an advertisment is made.
    Be advised that packets may be corrupted or lost on the way depending on the environment, so if you are only advertising some data once, certain datapoints may never reach the central.

    Do you know how to do that ? I am trying to use the ble_radio_notification_init to update my data each time. Theorically, after each new sending, this interruption will be activated and will call an function that here is Radio_handler. I am using it, but it seems to me that it doesn't work very well, because I have not oonly one incrementation of my byte between each packet but few incrementations. 

    Here is my code : 

    void Radio_handler(bool radio_evt)
    {
        if (radio_evt)
        {
            Update_data(); //Toggle the status of the LED on each radio notification event
        }
    }
    void radio_notification_handler_init(void)
    {
    	ret_code_t err_code;
    	err_code = ble_radio_notification_init(APP_IRQ_PRIORITY_LOW, NRF_RADIO_NOTIFICATION_DISTANCE_5500US, Radio_handler);
    	APP_ERROR_CHECK(err_code);
    }

    I don't know what is the problem for now.

  • Hello again,

    Beldramma said:
    No I am working on SDK 15.2. So I have the first version of the ble_advertising_advdata_update, and I need to encode the data myself. 

    Yes, my mistake. I was checking the source code of the SDK v.16, I see now that you must call encode before calling the SDK v.15.2 advdata_update version, my apologies for any confusion this might have caused.

    Beldramma said:
    Do you know how to do that ? I am trying to use the ble_radio_notification_init to update my data each time. Theorically, after each new sending, this interruption will be activated and will call an function that here is Radio_handler. I am using it, but it seems to me that it doesn't work very well, because I have not oonly one incrementation of my byte between each packet but few incrementations. 

    For this you will need radio notifications, for further detail on this please see my colleagues reply to this ticket.

    Let me know if anything should still be unclear!

    Best regards,
    Karl

Related