Issue with BLECM_APP_EVT_ADV_TIMEOUT - callback fires every sec

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MiTo_1583836
Level 5
Level 5
50 likes received 25 likes received 10 likes received

I am using SDK 2.2.2/ BCM20737SoC and I found an issue with the advertisement duration/timeout that I cannot explain.

My goal is to set the highest possible value for timeout for a beacon design running with HIGH_UNDIRECTED_DISCOVERABLE. The goal is to limit the number of callbacks being called by the system. The parameter that controls the advertisement duration is called: .high_undirect_adv_duration. It is set at the very beginning when the application is launching. The type for this parameter is UINT16 so we should be able to hardcode a value of 0xFFFF (65535 seconds). This means the callback should be called every ~18h12 or so.

Also I register for the callback in my "create" function as follow:

bleprofile_regAppEvtHandler(BLECM_APP_EVT_ADV_TIMEOUT, xxxx_yyyy_advertisement_stopped);

Here is the problem experienced.

  • If I hardcode .high_undirect_adv_duration = 65535 (seconds) and run the application the callback fires every second.
  • If I hardcode  .high_undirect_adv_duration = 5 (seconds) and run the application, the callback fires properly every 5 seconds.

Doing some investigations I found the limit value being 32768. If I put  .high_undirect_adv_duration =32768 the callback is NOT called every second. If I put .high_undirect_adv_duration =32769 the callback is called every second.

I am not quite sure what is so special about the number 32768. It is currently the maximum value I can set for the advertisement duration.

I would like to hardcode the maximum value:  .high_undirect_adv_duration = 65535 with a callback calling after the 65535 seconds.

Thanks for feedback!

0 Likes
4 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

Adding jakewtorres​ on the applications team.

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

A few layers down the stack, the timeout values are cast as int16_t values. Meaning that when you input more than 32768, it overflows into the negative realm. And these are invalid arguments for a timer.

But this shouldn't cause too much of an issue. It's easily worked around by restarting advertisements on the advertisement stop callback. Just restart advertisements once with the duration at 32767 to achieve ~18 hours.

Jacob

0 Likes

Ok that's unfortunate, thank you for checking quickly really appreciate. I will work around in the code.

0 Likes

I'm unsure what your use-case is, but if you're trying to leave on advertisements for as long as possible, you can see mybeacon for an API to turn them on indefinitely--no timer initialization, no callbacks.

Jacob

0 Likes