Return the current tick as when the RF will be fully enabled (when MYNEWT_VAL_BLE_LL_RFMGMT_ENABLE_TIME is not defined). #1027
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Caveat: I am unfortunately not able to test this change on the current version of NimBLE, but the relevant code seems the identical to the version I know to be affected and fixed by this simple one-line change.
When
MYNEWT_VAL_BLE_LL_RFMGMT_ENABLE_TIME
is not defined insyscfg.h
, the functionble_ll_rfmgmt_enable_now()
is implemented as astatic inline
stub inble_ll_rfmgmt.h
.This stub always returns
0
, yet the function should return the "tick at which RF will be fully enabled".Returning a fixed value, rather than a tick value near to the current system tick, causes overflow issues. For example, in
ble_ll_adv_sm_start()
(ble_ll_adv.c
), this time is retrieved and a delta is calculated to check whether the advertising is trying to start before the RF would be ready:As this is not a tick time near to the current value (but instead, always 0), this calculation will overflow when the system timer is between 0x80000000-0xFFFFFFFF. This causes an incorrect, huge forward adjustment to be applied to the schedule.
The symptom is, for those configurations without
MYNEWT_VAL_BLE_LL_RFMGMT_ENABLE_TIME
who attempt to start advertising within a period of an odd multiple of 18.2 hours (half the 32-bit timer period) since the timer started: the advertising appears to silently fail.Alternatively, this function implementation could be moved into
ble_ll_rfmgmt.c
rather than the header; or all uses ofble_ll_rfmgmt_enable_now()
could be guarded with#if MYNEWT_VAL(BLE_LL_RFMGMT_ENABLE_TIME) > 0
/#endif
.