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:
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.
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.
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.