Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Configured advertising duration and interval dont match up observed values for ble_app_eddystone example. Is this a bug?

I am using sdk15.2.0 with PCA10040 dev board.

In ble_app_eddystone example, the configured advertising interval and duration dont match the observed values.

I think I have found the reason why they dont match... Just want a confirmation from Nordic engineers weather I am correct or not.

Below code snippet is from es_app_config.h file 

As per the comment in the code, the values are in milli seconds.

In es_adv.c in get_adv_params() values from es_app_config.h are assigned to ble_gap_adv_params_t structure. Below code is from es_adv.c

Now if you check ble_gap_adv_params_t structure definition in ble_gap.h, the interval and duration values are not in milli seconds(read the comments).

Milli second macros from es_config.h should have been converted to respective count before use. This is the reason why configured and observed values don't match up.

Please confirm my understanding...

  • Hi,

    Yes, I can confirm that this is a bug.

    A fix could be to convert the interval from ms units to 625 us units in adv_start() in es_adv.c 

    Snippet:

    OR maybe better, in the get_adv_params() function.

    Snippet:

  • I would prefer doing it in get_adv_params(). Also, the same issue applies to p_adv_params->duration.

    I guess the snippet you posted is not from sdk15.2.0, because you have written p_adv_params->timeout and not p_adv_params->duration!

  • Yes, I agree, get_adv_params() would be the preferred place.

    I guess the snippet you posted is not from sdk15.2.0, because you have written p_adv_params->timeout and not p_adv_params->duration!

    Ah, that is correct, that snippet was based on SDK 14.2

  • There is another issue now.

    The spacing between two advertising intervals is not constant.

    These are my configurations in es_app_config.h...

    And this is what I observe with the changes that you suggested.

    This issue occurs in unmodified sdk15.2.0 as well. I checked that to be sure that my changes have not caused it.

    Any idea why this should happen?

    Also, APP_CFG_NON_CONN_ADV_TIMEOUT has no effect, I expected that non-connectable advertising should stop after the timeout but that didn't happen.

    Should I raise another question for this?

  • Hi

    There are too many timing related issues in ble_app_eddystone. Looks like the developer completely forgot about converting milli second values. es_app_config.h is confusing, the developer who wrote this should take a relook at this file. Here are a few that I can list...

    1. The macro APP_CONFIG_ADV_INTERVAL_MS_MAX has "_MS_" in it. I assumed this would be in milliseconds. But the value assigned to this macro is 16384. As per standard the max advertising interval is 10.24 sec. And all the while I was guessing if the standards have changed, it took me some time to realize that 16384 * 0.625 = 10240ms! 

    2. Apparently there is one more macro, MAX_ADV_INTERVAL, in the same file for the same purpose but not used anywhere! Again there is contradiction between the comment and macro name.

    3. If you change advertising interval from nRF Beacon for Eddystone app then again the advertising intervals go haywire. Looks like the milli sec values are not converted to interval counts.

    There are many such issue in this example, I may not be able to list them all. Can you request for a proper fix from the developer? Because if I do it I would need to spend more time and efforts in understanding the sdk code rather than writing my application.

    Usually your sdk code and examples are pretty awesome and rarely I find such issues with it but I wonder how this work got approved to be included in the release!

1 2 3