Time unit inconsistencies in GapScanningParams
- Dominant language
- C++
- Stars
- 81
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
GapScanningParams tries to expose the user to a comprehensible API to set different scan parameters such as scan window, scan interval, etc. The user can set the scan window and interval in terms of milliseconds, but internally these values get converted to units of 0.625 milliseconds. There are a few issues with the time units in the API:
1. The constructor is supposed to accept scan interval and window arguments in units of milliseconds and internally it converts them. However, the default is to set the arguments to [SCAN_INTERVAL_MAX](https://github.com/ARMmbed/ble/blob/develop/ble/GapScanningParams.h#L23) and [SCAN_WINDOW_MAX](https://github.com/ARMmbed/ble/blob/develop/ble/GapScanningParams.h#L25) that already are in units of 0.625ms.
2. The following `const` values are all in units of 0.625 milliseconds. This effectively makes them completely unusable since all the setter functions take arguments in milliseconds. Therefore, if you want to set the max possible interval then you need to compute `setInterval(SCAN_INTERVAL_MAX * 0.625)`:
- SCAN_INTERVAL_MIN
- SCAN_INTERVAL_MAX
- SCAN_WINDOW_MIN
- SCAN_WINDOW_MAX
3. Despite the majority of the API being in terms of milliseconds, the getter functions return scan window and timeout in units of 0.625ms rather than plain milliseconds.
Contributor guide
Research direction
Start with ble/GapScanningParams.h, especially the constructor, SCAN_INTERVAL_MIN/MAX, SCAN_WINDOW_MIN/MAX, and the interval, window, and timeout getters and setters. Audit the conversions and defaults so the public API consistently uses milliseconds, then verify the constants, constructor defaults, and getter results agree with that unit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100