Bluetooth advertising timeout needs to be modified

I am creating proof of concept software using a nRF52840 Dev Kit.  The code is based on the Nordic UART Service example which uses Zephyr, but has been substantially modified to suit the application.

I use "bt_le_adv_start" to begin Bluetooth advertising.  All is working well except the Bluetooth Advertising stops after approx. 30 seconds.

I cannot find an API to use to change the advertising timeout; is there one?
Is it possible to change the timeout to "never"?

I've noticed that the Nordic SDK has functions which allow for changing of the timeout value; can I mix Zephyr API calls and Nordic SDK API calls?

The application may periodically change the advertised values.  If I change the advertised values using "bt_le_adv_update_data", does the timeout counter reset (and I get another 30 seconds)?

As a final, but less desirable option, I could stop the advertising, then re-start every 15 seconds.  Is there anything I should know about solving the problem this way?

-Craig Goldman

  • Edvin,

    That is an excellent suggestion.  There may be a one-day delay in getting this done, since I am committed to a meeting most of the day.

    -Craig

  • Testing done.

    I put a breakpoint in after "ad_is_limited(ad, ad_len)".  The function is returning 'true'.  When I examined the variable holding the advertising data, it looked wrong.

    I modified the code to follow your suggestion and used "BT_DATA_BYTES" macro to load the struct bt_data with the advertising flags.  RE-tested the code and Bluetooth no longer times out.

    Edvin, thank you for help.

    This case can be closed.

    -Craig

  • Hello Craig,

    Glad to hear it sorted out. I didn't test it, but I can't tell why it didn't work with your implementation of the ad[] struct. Perhaps there is something with the way the data parameter is set. It is the fact that the data variable inside ad[] is a pointer that is throwing you off, I think (at least it throws me off). 

    You can try doing something like this:

        uint8_t test_data[1] = {BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR};
        test_ad[0].type = BT_DATA_FLAGS;
        test_ad[0].data_len = 1u;
        test_ad[0].data = test_data;
        LOG_INF("test_ad[0] = 0x%02x", test_ad->data[0]);

    I tried the way that you did initially, and it printed "test_ad[0] = 01", which will trigger the timeout since 0x01 = BT_LE_AD_LIMITED (and also your flags will be wrong).

    Best regards,

    Edvin

Related