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

Change of ADV data in SDK 17

Hello 

We have an application that ADV every second and is based on SDK 14.

We are currently attempting to move to SDK 17. What I have noticed is that if I change and ADV data during advertisement by the help of new API function ble_advertising_advdata_update I see that there will be a delay of ±2 seconds (I see it in air trace) during which there will be no ADV at all.

Even when I configured ADV interval to be 100 milli and data rate change is 1 time at a second I see a delay of 2 seconds over the air until an updated data takes place.

The question is: Is that an expected behaviour? Is there any way to prevent this stop of ADV for 2 seconds?

Parents
  • Hello,

    We are currently attempting to move to SDK 17. What I have noticed is that if I change and ADV data during advertisement by the help of new API function ble_advertising_advdata_update I see that there will be a delay of ±2 seconds (I see it in air trace) during which there will be no ADV at all.

    This does sound strange. Is your call to ble_advertising_advdata_update returning any error codes at any point?
    The updating of advertising data can be done between every advertisement, and should take effect before the next advertising, or at worst before the second advertising.

    Even when I configured ADV interval to be 100 milli and data rate change is 1 time at a second I see a delay of 2 seconds over the air until an updated data takes place.

    How are you queueing the updating of the data, through a timer?

    Could you make sure that you have DEBUG defined in your preprocessor defines, like shown in the included image?

    1 - 2 seconds sounds like you application might be encountering an error and / or resetting. Could you verify if this occurs, that the device resets in this timespan?

    Looking forward to resolving this issue together!

    Best regards,
    Karl

  • Hello Karl

    I ma not hitting app_error_handler and do run with DEBUG (turned it on)

    The error code returned by the function ble_advertising_advdata_update is NRF_SUCCESS

    However I do see in the over the air behaviour a delay

    The timer is our internally implemented timer which expires every second and from the timer I call to the function 

    ble_advertising_advdata_update(&m_advertising, &advdata, NULL); (We do not need any scan response data)

    I override simply a data in the ble_advertising_init_t with the new one and call to the ble_advertising_advdata_update

    (To my understanding this shall be ok since soft device copies ADV data into internal buffer)

    Am I wrong?

  • Idid some more testing and as soon as mark out the call to the function:

    ble_advertising_advdata_update

    I am not hitting main. Otherwise I do have a reset(hitting main)

    It looks like a crash is within sd_ble_gap_adv_set_configure in the function ble_advertising_advdata_update

    What can cause a crash their?

Reply Children
  • Hello,

    KTM said:

    I override simply a data in the ble_advertising_init_t with the new one and call to the ble_advertising_advdata_update

    (To my understanding this shall be ok since soft device copies ADV data into internal buffer)

    Am I wrong?

    No, your understanding here is correct - because the ble_advertising_advdata_update function from SDK v.17 does the copying for you. If you were using an older SDK, such as v.16, you would have had to provide separate buffers for the updated data ( which you might have read other tickets about on the forum ), but this is not the case with SDK v.17.  

    KTM said:

    Idid some more testing and as soon as mark out the call to the function:

    ble_advertising_advdata_update

    I am not hitting main. Otherwise I do have a reset(hitting main)

    I am sorry, but I do not understand what you are saying here - you said in your previous reply that ble_advertising_advdata_update always returns NRF_SUCCESS, are you now seeing another error code returned?
    I suspect that the 1 - 2 second delay between updates is a result of a device reset, which again might be caused by an error cod ebeing returned somewhere.

    KTM said:
    It looks like a crash is within sd_ble_gap_adv_set_configure in the function ble_advertising_advdata_update

    How do you pinpoint this? Using error codes, or using breakpoints?
    Please be advised that you may not use breakpoints with a running SoftDevice. The breakpoints will halt the CPU, and the SoftDevice will be unable to perform its timing-critical tasks in time, before you release the CPU again, this will cause the SoftDevice to assert immediately upon leaving the breakpoint.
    Are you seeing anything written to your log before the crash? Could you also elaborate what exactly you mean when you say that it looks like it crashes?

    Looking forward to resolving this issue together!

    Best regards,
    Karl

  • I put a break point in the main on the first line.

    I hit it so I assume there was a reset due to some error

    This is a way I figure out that there is probably a device reset...

    Also within a function ble_advertising_advdata_update I put a point after sd_ble_gap_adv_set_configure call (i.e. on return) and never hit this line so I guess that the reset comes from sd_ble_gap_adv_set_configure

    How would you suggest to debug that?

  • KTM said:

    I put a break point in the main on the first line.

    I hit it so I assume there was a reset due to some error

    Breakpoints before having enabled the SoftDevice is fine - since it will not assert if it is not enabled and active.
    To clarify my last comment: you might very well use breakpoints to debug your application - the first part will behave as usual: when a breakpoint is encountered, the CPU is halted, and the debugger shows you the contents of different registers ol. at that time.
    However, the difference comes when the SoftDevice is active at this time, and thus does not get to run when it needs to in order to maintain a connection or other timing-critical obligations. This will cause the SoftDevice to assert the moment it is given back control of the CPU ( which happens as soon as you click "resume" on the debugger ). So, long story short: You may indeed use breakpoints, but it will cause the device to reset immediately when you leave an encountered breakpoint.

    KTM said:

    I hit it so I assume there was a reset due to some error

    This is a way I figure out that there is probably a device reset...

     When did you hit this breakpoint, did you hit it a first time when starting the application, and then again when attempting to update the advertising data?

    KTM said:
    Also within a function ble_advertising_advdata_update I put a point after sd_ble_gap_adv_set_configure call (i.e. on return) and never hit this line so I guess that the reset comes from sd_ble_gap_adv_set_configure

    As mentioned, this will work - you should encounter the breakpoint as usual - but the SoftDevice will assert immediately upon resuming the program.

    KTM said:
    How would you suggest to debug that?

    I would make sure that all SDK function that returns error codes are accounted for, and that their returned error values always is passed to an APP_ERROR_CHECK, to see if the code is anything other than NRF_SUCCESS.
    This way, you should see the exact error printed by your logger - along with which function that returned it - if an error different than NRF_SUCCESS is returned.
    Are you seeing anything at all being written to your logger when this behavior occurs?

    Best regards,
    Karl

  • did you hit this breakpoint, did you hit it a first time when starting the application, and then again when attempting to update the advertising data?

    Exactly

  • Then I must concur that it sounds like the device is resetting, most likely due to an error being generated in / by the update function.

    Karl Ylvisaker said:
    Are you seeing anything at all being written to your logger when this behavior occurs?

     
    Best regards,
    Karl

Related