sdh: simplifications and improvements#388
Conversation
|
You can find the documentation preview for this PR here. |
b6616a3 to
9cf07f8
Compare
5fd1e4e to
749680f
Compare
|
|
||
| /* Helper macros to check for equality */ | ||
|
|
||
| #define _NRF_SDH_OBSERVER_PRIO_HIGHEST_HIGHEST 1 |
There was a problem hiding this comment.
don't use underscores for first character
| * If :option:`CONFIG_NRF_SDH_STR_TABLES` is enabled, returns the event name. | ||
| * Otherwise, returns the supplied integer as a string. | ||
| * | ||
| * @param evt A NRF_SOC_SVCS enumeration value. |
There was a problem hiding this comment.
@ before symbols links to it
There was a problem hiding this comment.
@nordicjm Can you please provide some context on this suggestion? Thanks.
| }; | ||
|
|
||
| if (sdh_enabled) { | ||
| (void) sd_softdevice_is_enabled(&sd_is_enabled); |
There was a problem hiding this comment.
| (void) sd_softdevice_is_enabled(&sd_is_enabled); | |
| (void)sd_softdevice_is_enabled(&sd_is_enabled); |
fix in whole PR
5032ba2 to
381bff5
Compare
|
Added changlog entries |
| SoftDevice handler | ||
| ################## | ||
|
|
||
| The SoftDevice handler is a library that handles SoftDevice initialization tasks, and pulls and dispatches the SoftDevice events to registered components. |
There was a problem hiding this comment.
Would be good with more skin on the bone, though I guess that can be added later as well.
| No changes since the latest nRF Connect SDK Bare Metal release. | ||
| * Removed: | ||
|
|
||
| * The ``NRF_SDH_BLE`` Kconfig option. |
There was a problem hiding this comment.
I think it should be like this:
| * The ``NRF_SDH_BLE`` Kconfig option. | |
| * The ``CONFIG_NRF_SDH_BLE`` Kconfig option. |
There was a problem hiding this comment.
I ended up dropping this commit
| LOG_MODULE_DECLARE(nrf_sdh, CONFIG_NRF_SDH_LOG_LEVEL); | ||
|
|
||
| const char *gap_evt_tostr(int evt) | ||
| const char *ble_evt_tostr(int evt) |
There was a problem hiding this comment.
| const char *ble_evt_tostr(int evt) | |
| const char *ble_evt_to_str(int evt) |
There was a problem hiding this comment.
echo on above, to_str is english, tostr is not a word
There was a problem hiding this comment.
This is corrected in b1bf672, though would be good to have it changed here as well.
|
@lemrey Please rebase :) |
b-gent
left a comment
There was a problem hiding this comment.
Approving for the changelog items but we will need more rst documentation before the release.
|
@nordicjm could you please have a look again? |
| * A SoftDevice observer has a defined priority, which determines the order with | ||
| * which the observer receives relevant events compared to other observers. | ||
| * | ||
| * Five priority levels are defined: highest, high, user, user low, lowest. |
There was a problem hiding this comment.
Nit:
| * Five priority levels are defined: highest, high, user, user low, lowest. | |
| * Five priority levels are defined: highest, high, user, user low, and lowest. |
Add a placeholder entry for sdh to be able to reference it in the changelog. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
It is more correct to use an SoC observer to do this, rather than doing it directly in nrf_sdh_soc (the stack observer). Make the feature optional, and leave it enabled by default. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Introduce an allowed set of priorities for observers, with validity checks. These are: HIGHEST, HIGH, USER, USER_LOW, LOWEST. These could be extended ala SYS_INIT to include a priority within a level, but it seemed a bit overkill for now. Each library or piece of code in the SDK shall have an hardcoded priority, because just changing the priority of one component would break the others. In general, a component's observer must have a lower priority than the observers in its dependencies. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Add GATTS and GATTC event strings to the table. Renamed gap_evt_tostr() to ble_evt_tostr() to reflect that it now can print all BLE events. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Add a Kconfig menu for clock configuration, to make the menu nicer. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Add a Kconfig menu for BLE configuration, to make the menu nicer. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Rework the functions in nrf_sdh_ble and nrf_sdh_soc that mapped BLE and SOC events to their stringified version to make them public and align their names. Instead of printing "unknown" if the event is not known, default to printing its numerical value in hexadecimal. That is also the default behavior if CONFIG_NRF_SDH_STR_TABLES is unset, and the table is not compiled. This is better than toggling the availability of the whole function, because we avoid conditional compilation around it. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Update the assert message at the end of the polling loops to print which kind of event we failed to pull, e.g. SoC or BLE. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
There is no reason for this API to be in this library. It could be added to a dedicated library later to avoid having to rely on DT macros to retrieve this information. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
There was a distinction between observers that could stop the SoftDevice state changes, and those that didn't. The former were called "request observers" and the latter "state observers". Since both observers are interested in the SoftDevice state, this commit merges the two, keeping only "state observers", for the purpose of simplifying things a bit. Now, state observers can return non-zero to these events: - NRF_SDH_STATE_EVT_ENABLE_PREPARE and - NRF_SDH_STATE_EVT_DISABLE_PREPARE to halt the state change. The return value from the observer is ignored for other events. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
These can return -EBUSY, which was missing. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
This patch moves the state observers into RAM and adds a new field `is_busy` that is used to maintain their busy state when a request to change the SoftDevice state is made. That is used to avoid sending the _PREPARE event multiple times to the same observer. The new function nrf_sdh_observer_ready() inspects the state of all observers and dispatches the events only to non-ready observers, differently from nrf_sdh_request_continue() which sent the events to all observers unconditionally instead. When the last observer makes itself ready, the SoftDevice state change takes place (from within nrf_sdh_observer_ready()). Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Use the native SoftDevice function sd_softdevice_is_enabled() instead. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Only check if the SoftDevice handler is suspended, not if the SoftDevice is enabled. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Rename an internal variable. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Remove these, and force users to put a semicolon themselves. Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
|
@nrfconnect/ncs-bm-test @nrfconnect/ncs-eris please have a look. |
|
Added documentation to #515 |
HIGHEST,HIGH,USER,USER_LOW,LOWESTRemove NRF_SDH_BLE (no longer configurable)nrf_sdh_app_ram_start_get(), unused and not usefulnrf_sdh_is_enabled()in favor of native SoftDevice functionnrf_sdh_request_continue()and addnrf_sdh_observer_ready().