diff --git a/.checkpatch.conf b/.checkpatch.conf index e793f667fcf3..f920c4fb0186 100644 --- a/.checkpatch.conf +++ b/.checkpatch.conf @@ -22,6 +22,7 @@ --ignore MULTISTATEMENT_MACRO_USE_DO_WHILE --exclude ext --exclude samples/matter/.*/src +--exclude applications/matter_weather_station/src --exclude samples/openthread/cli/harness --exclude modules/tfm/tfm/boards/src --exclude modules/tfm/tfm/boards/common diff --git a/.github/labeler.yml b/.github/labeler.yml index 01c4557c5fc5..7c905cc18642 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -46,7 +46,6 @@ - "tests/subsys/net/**/*" "CI-all-test": - - "west.yml" - "**/*partition_manager*/**/*" - "**/*partition_manager*" @@ -181,19 +180,24 @@ - "samples/matter/**/*" "CI-find-my-test": - - "include/bluetooth/**/*" - - "include/dfu/**/*" - - "include/nfc/**/*" - - "include/dk_buttons_and_leds.h" - - "include/event_manager.h" - - "lib/dk_buttons_and_leds/**/*" - - "subsys/bootloader/**/*" - - "subsys/bluetooth/**/*" - - "subsys/dfu/dfu_target/**/*" - - "subsys/event_manager/**/*" - - "subsys/nfc/**/*" - - "subsys/partition_manager/**/*" - - "modules/mcuboot/**/*" + - any: + - "include/dfu/**/*" + - "include/nfc/**/*" + - "include/dk_buttons_and_leds.h" + - "include/event_manager.h" + - "lib/dk_buttons_and_leds/**/*" + - "subsys/bootloader/**/*" + - "subsys/dfu/dfu_target/**/*" + - "subsys/event_manager/**/*" + - "subsys/nfc/**/*" + - "subsys/partition_manager/**/*" + - "modules/mcuboot/**/*" + - any: + - "include/bluetooth/**/*" + - "!include/bluetooth/mesh/**/*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" -"no-changelog": - - "!doc/nrf/releases/release-notes-latest.rst" +"changelog-entry-required": + - "!doc/nrf/releases/release-notes-changelog.rst" diff --git a/.github/workflows/contribs.yml b/.github/workflows/contribs.yml index 4cf1f0a0400e..67dc5ed61e27 100644 --- a/.github/workflows/contribs.yml +++ b/.github/workflows/contribs.yml @@ -15,9 +15,14 @@ jobs: command: 'external' messages: | Thank you for your contribution! - It seems you are not a member of the nrfconnect GitHub organization. - At this time we are not accepting external contributions, but this may change soon. - Please visit https://devzone.nordicsemi.com/ to raise any issues you found or ask for help. + It seems you are not a member of the nrfconnect GitHub organization. External contributions are handled as follows: + Large contributions, affecting multiple subsystems for example, may be rejected if they are complex, may introduce regressions due to lack of test coverage, or if they are not consistent with the architecture of nRF Connect SDK. + PRs will be run in our continuous integration (CI) test system. + If CI passes, PRs will be tagged for review and merged on successful completion of review. You may be asked to make some modifications to your contribution during review. + If CI fails, PRs may be rejected or may be tagged for review and rework. + PRs that become outdated due to other changes in the repository may be rejected or rework requested. + External contributions will be prioritized for review based on the relevance to current development efforts in nRF Connect SDK. Bug fix PRs will be prioritized. + You may raise issues or ask for help from our Technical Support team by visiting https://devzone.nordicsemi.com/. | The author of this pull request has now been added to the nrfconnect GitHub organization. labels: 'external' diff --git a/.github/workflows/manifest.yml b/.github/workflows/manifest.yml index 32e1e1366991..e2ed904ee8d5 100644 --- a/.github/workflows/manifest.yml +++ b/.github/workflows/manifest.yml @@ -22,12 +22,26 @@ jobs: fetch-depth: 0 - name: Manifest - uses: zephyrproject-rtos/action-manifest@v1.1.0 + uses: oyvindronningstad/action-manifest@module-labels with: github-token: ${{ secrets.GITHUB_TOKEN }} manifest-path: 'west.yml' checkout-path: 'ncs/nrf' label-prefix: 'manifest-' verbosity-level: '1' - labels: 'manifest' + + # Add one label per line. 'manifest' always adds the label 'manifest'. + # 'CI-all-test:zephyr;nrfxlib,' adds the 'CI-all-test' label when the + # zephyr module or the nrfxlib module is changed. Each line is comma- + # separated. + labels: > + manifest, + CI-all-test:zephyr;nrfxlib, + CI-tfm-test:trusted-firmware-m;tfm-mcuboot, + CI-boot-dfu-test:mcuboot;mcumgr, + CI-matter-test:matter, + CI-find-my-test:find-my, + CI-homekit-test:homekit, + CI-thread-test:openthread, + CI-crypto-test:mbedtls;mbedtls-nrf dnm-labels: 'DNM' diff --git a/.github/workflows/oss-history.yml b/.github/workflows/oss-history.yml index 718bcc583ac1..919e55bfb38d 100644 --- a/.github/workflows/oss-history.yml +++ b/.github/workflows/oss-history.yml @@ -21,7 +21,7 @@ jobs: run: | west init -l ncs/nrf cd ncs - west update zephyr + west update zephyr mcuboot trusted-firmware-m git -C zephyr remote add upstream https://github.com/zephyrproject-rtos/zephyr - name: Check OSS history diff --git a/CODEOWNERS b/CODEOWNERS index 881f3d0d39d0..063f1eb1412d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -21,6 +21,7 @@ /applications/asset_tracker_v2/ @simensrostad @jtguggedal @jhn-nordic @coderbyheart /applications/connectivity_bridge/ @jtguggedal @nordic-auko /applications/machine_learning/ @pdunaj +/applications/matter_weather_station/ @Damian-Nordic @kkasperczyk-no /applications/nrf_desktop/ @pdunaj /applications/pelion_client/ @pdunaj /applications/serial_lte_modem/ @junqingzou @lats1980 @rlubos @@ -115,12 +116,13 @@ Kconfig* @tejlmand /samples/profiler/ @pdunaj @pizi-nordic /samples/peripheral/radio_test/ @kapi-no /samples/peripheral/lpuart/ @nordic-krch +/samples/peripheral/802154_phy_test/ @czeslawmakarski /samples/tfm/tfm_hello_world/ @oyvindronningstad /samples/zigbee/ @tomchy @sebastiandraus /samples/CMakeLists.txt @tejlmand /samples/nrf5340/netboot/ @hakonfam /samples/nrf5340/multiprotocol_rpmsg/ @hubertmis -/scripts/ @mbolivar @tejlmand +/scripts/ @mbolivar-nordic @tejlmand /scripts/hid_configurator/ @pdunaj /scripts/tools-versions-*.txt @tejlmand @asle-nordic @grho @shanta-14 /share/zephyrbuild-package/ @tejlmand diff --git a/Kconfig.nrf b/Kconfig.nrf index d3d2ab5e3fe7..cdc4430778ab 100644 --- a/Kconfig.nrf +++ b/Kconfig.nrf @@ -24,8 +24,8 @@ config MBEDTLS_LIBRARY_NRF_SECURITY endchoice # This is a temporary solution to whitelist -# BOARD_THINGY91_NRF9160NS in compliance -config BOARD_THINGY91_NRF9160NS +# BOARD_THINGY91_NRF9160_NS in compliance +config BOARD_THINGY91_NRF9160_NS bool # nRF Connect SDK needs a larger default stacks in certain configurations diff --git a/applications/asset_tracker/Kconfig b/applications/asset_tracker/Kconfig index b2d14223aea0..81d6d1f4e866 100644 --- a/applications/asset_tracker/Kconfig +++ b/applications/asset_tracker/Kconfig @@ -207,10 +207,10 @@ config ACCEL_TRIGGER config FLIP_INPUT int "Button or switch number to simulate flip" - range 1 4 if BOARD_NRF9160DK_NRF9160NS - range 1 1 if BOARD_THINGY91_NRF9160NS - default 3 if BOARD_NRF9160DK_NRF9160NS - default 1 if BOARD_THINGY91_NRF9160NS + range 1 4 if BOARD_NRF9160DK_NRF9160_NS + range 1 1 if BOARD_THINGY91_NRF9160_NS + default 3 if BOARD_NRF9160DK_NRF9160_NS + default 1 if BOARD_THINGY91_NRF9160_NS help Button or switch number to use for simulating a board flip event. @@ -232,7 +232,7 @@ endif config ACCEL_INVERTED bool "Accelerometer inverted" - default y if BOARD_THINGY91_NRF9160NS + default y if BOARD_THINGY91_NRF9160_NS help Enable if the accelerometer is mounted with the top side facing down when the board itself is in normal position. @@ -258,8 +258,8 @@ config CLOUD_BUTTON config CLOUD_BUTTON_INPUT int "Set button sensor button number" - range 1 4 if BOARD_NRF9160DK_NRF9160NS - range 1 1 if BOARD_THINGY91_NRF9160NS + range 1 4 if BOARD_NRF9160DK_NRF9160_NS + range 1 1 if BOARD_THINGY91_NRF9160_NS default 1 config CLOUD_CONNECT_RETRY_DELAY @@ -388,10 +388,10 @@ config TEMP_TRIGGER config TEMP_SIM_BUTTON int "Button or switch to trigger 'data ready' event" - range 1 4 if BOARD_NRF9160DK_NRF9160NS - range 1 1 if BOARD_THINGY91_NRF9160NS - default 3 if BOARD_NRF9160DK_NRF9160NS - default 1 if BOARD_THINGY91_NRF9160NS + range 1 4 if BOARD_NRF9160DK_NRF9160_NS + range 1 1 if BOARD_THINGY91_NRF9160_NS + default 3 if BOARD_NRF9160DK_NRF9160_NS + default 1 if BOARD_THINGY91_NRF9160_NS help Button or switch number to use for triggering a 'data ready' event. @@ -415,14 +415,14 @@ endif # ENVIRONMENT_SENSORS menuconfig LIGHT_SENSOR bool "Light sensor" - select BH1749 if BOARD_THINGY91_NRF9160NS - default y if BOARD_THINGY91_NRF9160NS + select BH1749 if BOARD_THINGY91_NRF9160_NS + default y if BOARD_THINGY91_NRF9160_NS if LIGHT_SENSOR config LIGHT_SENSOR_DEV_NAME string "Light sensor device name" - default "BH1749" if BOARD_THINGY91_NRF9160NS + default "BH1749" if BOARD_THINGY91_NRF9160_NS config LIGHT_SENSOR_DATA_SEND_INTERVAL int "Interval in seconds for sending light sensor data" diff --git a/applications/asset_tracker/README.rst b/applications/asset_tracker/README.rst index 9819973bdbb4..7f6028d7e8c4 100644 --- a/applications/asset_tracker/README.rst +++ b/applications/asset_tracker/README.rst @@ -101,7 +101,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns, nrf9160dk_nrf9160ns + :rows: thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -216,7 +216,7 @@ Alternatively, use the command line tool ``menuconfig`` or configure the options .. external_antenna_note_start .. note:: - For nRF9160 DK v0.15.0 and later, set the :option:`CONFIG_NRF9160_GPS_ANTENNA_EXTERNAL` option to ``y`` when building the application to achieve the best external antenna performance. + For nRF9160 DK v0.15.0 and later, set the :kconfig:`CONFIG_NRF9160_GPS_ANTENNA_EXTERNAL` option to ``y`` when building the application to achieve the best external antenna performance. .. external_antenna_note_end @@ -289,7 +289,7 @@ This application uses the following |NCS| libraries and drivers: * :ref:`lte_lc_readme` * |NCS| modules abstracted via the LwM2M carrier OS abstraction layer (:file:`lwm2m_os.h`) -.. include:: /lib/bin/lwm2m_carrier/doc/app_integration.rst +.. include:: /libraries/bin/lwm2m_carrier/app_integration.rst :start-after: lwm2m_osal_mod_list_start :end-before: lwm2m_osal_mod_list_end diff --git a/applications/asset_tracker/prj_thingy91_nrf9160ns.conf b/applications/asset_tracker/prj_thingy91_nrf9160_ns.conf similarity index 100% rename from applications/asset_tracker/prj_thingy91_nrf9160ns.conf rename to applications/asset_tracker/prj_thingy91_nrf9160_ns.conf diff --git a/applications/asset_tracker/sample.yaml b/applications/asset_tracker/sample.yaml index 9ccc271835f0..3e5a94026e1b 100644 --- a/applications/asset_tracker/sample.yaml +++ b/applications/asset_tracker/sample.yaml @@ -3,5 +3,5 @@ sample: tests: applications.asset_tracker: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns qemu_x86 + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns qemu_x86 tags: ci_build diff --git a/applications/asset_tracker/src/main.c b/applications/asset_tracker/src/main.c index 830cb1c9c979..c074e95b7d0d 100644 --- a/applications/asset_tracker/src/main.c +++ b/applications/asset_tracker/src/main.c @@ -21,6 +21,9 @@ #endif /* CONFIG_NRF_MODEM_LIB */ #include #include +#if defined(CONFIG_AGPS) +#include +#endif #include #if defined(CONFIG_NRF_CLOUD_AGPS) #include @@ -479,6 +482,36 @@ static void send_cell_pos_request(struct k_work *work) } #endif /* CONFIG_NRF_CLOUD_CELL_POS */ +#if defined(CONFIG_AGPS) +/* Converts the A-GPS data request from GPS driver to GNSS API format. */ +static void agps_request_convert( + struct nrf_modem_gnss_agps_data_frame *dest, + const struct gps_agps_request *src) +{ + dest->sv_mask_ephe = src->sv_mask_ephe; + dest->sv_mask_alm = src->sv_mask_alm; + dest->data_flags = 0; + if (src->utc) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST; + } + if (src->klobuchar) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST; + } + if (src->nequick) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST; + } + if (src->system_time_tow) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST; + } + if (src->position) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_POSITION_REQUEST; + } + if (src->integrity) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST; + } +} +#endif + static void send_agps_request(struct k_work *work) { ARG_UNUSED(work); @@ -494,8 +527,12 @@ static void send_agps_request(struct k_work *work) (k_uptime_get() - last_request_timestamp) < AGPS_UPDATE_PERIOD) { LOG_WRN("A-GPS request was sent less than 1 hour ago"); } else { + struct nrf_modem_gnss_agps_data_frame request; + + agps_request_convert(&request, &agps_request); + LOG_INF("Sending A-GPS request"); - err = gps_agps_request_send(agps_request, GPS_SOCKET_NOT_PROVIDED); + err = agps_request_send(request, AGPS_SOCKET_NOT_PROVIDED); if (err) { LOG_ERR("Failed to request A-GPS data, error: %d", err); } else { @@ -1569,8 +1606,7 @@ void cloud_event_handler(const struct cloud_backend *const backend, } #if defined(CONFIG_AGPS) - err = gps_process_agps_data(evt->data.msg.buf, - evt->data.msg.len); + err = agps_cloud_data_process(evt->data.msg.buf, evt->data.msg.len); #if defined(CONFIG_NRF_CLOUD_PGPS) if (!err) { LOG_INF("A-GPS data processed"); diff --git a/applications/asset_tracker/src/ui/Kconfig b/applications/asset_tracker/src/ui/Kconfig index 9e8effe93816..d8864d72a6b2 100644 --- a/applications/asset_tracker/src/ui/Kconfig +++ b/applications/asset_tracker/src/ui/Kconfig @@ -16,15 +16,15 @@ menu "User Interface" config UI_LED_USE_PWM bool "Use PWM to control LEDs" - default y if BOARD_THINGY91_NRF9160NS - select PWM if BOARD_THINGY91_NRF9160NS - select PWM_0 if BOARD_THINGY91_NRF9160NS + default y if BOARD_THINGY91_NRF9160_NS + select PWM if BOARD_THINGY91_NRF9160_NS + select PWM_0 if BOARD_THINGY91_NRF9160_NS if UI_LED_USE_PWM config UI_LED_PWM_DEV_NAME string "PWM device name for RGB LED" - default "PWM_0" if BOARD_THINGY91_NRF9160NS + default "PWM_0" if BOARD_THINGY91_NRF9160_NS config UI_LED_PWM_FREQUENCY int "LED PWM frequency" @@ -33,33 +33,33 @@ config UI_LED_PWM_FREQUENCY config UI_LED_RED_PIN int "Red LED pin number" - default 29 if BOARD_THINGY91_NRF9160NS + default 29 if BOARD_THINGY91_NRF9160_NS config UI_LED_GREEN_PIN int "Green LED pin number" - default 30 if BOARD_THINGY91_NRF9160NS + default 30 if BOARD_THINGY91_NRF9160_NS config UI_LED_BLUE_PIN int "Blue LED pin number" - default 31 if BOARD_THINGY91_NRF9160NS + default 31 if BOARD_THINGY91_NRF9160_NS endif # UI_LED_USE_PWM config UI_BUZZER bool "Enable buzzer" - default y if BOARD_THINGY91_NRF9160NS - select PWM if BOARD_THINGY91_NRF9160NS - select PWM_1 if BOARD_THINGY91_NRF9160NS + default y if BOARD_THINGY91_NRF9160_NS + select PWM if BOARD_THINGY91_NRF9160_NS + select PWM_1 if BOARD_THINGY91_NRF9160_NS if UI_BUZZER config UI_BUZZER_PWM_DEV_NAME string "PWM device name for buzzer" - default "PWM_1" if BOARD_THINGY91_NRF9160NS + default "PWM_1" if BOARD_THINGY91_NRF9160_NS config UI_BUZZER_PIN int "Buzzer pin number" - default 28 if BOARD_THINGY91_NRF9160NS + default 28 if BOARD_THINGY91_NRF9160_NS config UI_BUZZER_MIN_FREQUENCY int "Minimum buzzer frequency" @@ -73,31 +73,31 @@ endif # UI_BUZZER config UI_NMOS bool "Enable NMOS control" - default y if BOARD_THINGY91_NRF9160NS - select PWM if BOARD_THINGY91_NRF9160NS - select PWM_2 if BOARD_THINGY91_NRF9160NS + default y if BOARD_THINGY91_NRF9160_NS + select PWM if BOARD_THINGY91_NRF9160_NS + select PWM_2 if BOARD_THINGY91_NRF9160_NS if UI_NMOS config UI_NMOS_PWM_DEV_NAME string "PWM device name for buzzer" - default "PWM_2" if BOARD_THINGY91_NRF9160NS + default "PWM_2" if BOARD_THINGY91_NRF9160_NS config UI_NMOS_1_PIN int "NMOS 1 pin" - default 13 if BOARD_THINGY91_NRF9160NS + default 13 if BOARD_THINGY91_NRF9160_NS config UI_NMOS_2_PIN int "NMOS 2 pin" - default 14 if BOARD_THINGY91_NRF9160NS + default 14 if BOARD_THINGY91_NRF9160_NS config UI_NMOS_3_PIN int "NMOS 3 pin" - default 15 if BOARD_THINGY91_NRF9160NS + default 15 if BOARD_THINGY91_NRF9160_NS config UI_NMOS_4_PIN int "NMOS 4 pin" - default 16 if BOARD_THINGY91_NRF9160NS + default 16 if BOARD_THINGY91_NRF9160_NS endif # UI_NMOS diff --git a/applications/asset_tracker/src/ui/buzzer.c b/applications/asset_tracker/src/ui/buzzer.c index b31960d99bcb..1fd96777cc17 100644 --- a/applications/asset_tracker/src/ui/buzzer.c +++ b/applications/asset_tracker/src/ui/buzzer.c @@ -63,9 +63,7 @@ static void buzzer_disable(void) pwm_out(0, 0); #ifdef CONFIG_PM_DEVICE - int err = pm_device_state_set(pwm_dev, - PM_DEVICE_STATE_SUSPEND, - NULL, NULL); + int err = pm_device_state_set(pwm_dev, PM_DEVICE_STATE_SUSPEND); if (err) { LOG_ERR("PWM disable failed"); } @@ -79,9 +77,7 @@ static int buzzer_enable(void) atomic_set(&buzzer_enabled, 1); #ifdef CONFIG_PM_DEVICE - err = pm_device_state_set(pwm_dev, - PM_DEVICE_STATE_ACTIVE, - NULL, NULL); + err = pm_device_state_set(pwm_dev, PM_DEVICE_STATE_ACTIVE); if (err) { LOG_ERR("PWM enable failed"); return err; diff --git a/applications/asset_tracker/src/ui/led_pwm.c b/applications/asset_tracker/src/ui/led_pwm.c index 66d4c1124365..057e706595db 100644 --- a/applications/asset_tracker/src/ui/led_pwm.c +++ b/applications/asset_tracker/src/ui/led_pwm.c @@ -188,9 +188,7 @@ int ui_leds_init(void) void ui_leds_start(void) { #ifdef CONFIG_PM_DEVICE - int err = pm_device_state_set(leds.pwm_dev, - PM_DEVICE_STATE_ACTIVE, - NULL, NULL); + int err = pm_device_state_set(leds.pwm_dev, PM_DEVICE_STATE_ACTIVE); if (err) { LOG_ERR("PWM enable failed"); } @@ -202,9 +200,7 @@ void ui_leds_stop(void) { k_work_cancel_delayable_sync(&leds.work, &leds.work_sync); #ifdef CONFIG_PM_DEVICE - int err = pm_device_state_set(leds.pwm_dev, - PM_DEVICE_STATE_SUSPEND, - NULL, NULL); + int err = pm_device_state_set(leds.pwm_dev, PM_DEVICE_STATE_SUSPEND); if (err) { LOG_ERR("PWM disable failed"); } diff --git a/applications/asset_tracker/src/ui/nmos.c b/applications/asset_tracker/src/ui/nmos.c index d1ad5ab32371..5ecc607fc767 100644 --- a/applications/asset_tracker/src/ui/nmos.c +++ b/applications/asset_tracker/src/ui/nmos.c @@ -89,9 +89,7 @@ static void nmos_pwm_disable(uint32_t nmos_idx) return; } - int err = pm_device_state_set(pwm_dev, - PM_DEVICE_STATE_SUSPEND, - NULL, NULL); + int err = pm_device_state_set(pwm_dev, PM_DEVICE_STATE_SUSPEND); if (err) { LOG_WRN("PWM disable failed"); } @@ -113,9 +111,7 @@ static int nmos_pwm_enable(size_t nmos_idx) return 0; } - err = pm_device_state_set(pwm_dev, - PM_DEVICE_STATE_ACTIVE, - NULL, NULL); + err = pm_device_state_set(pwm_dev, PM_DEVICE_STATE_ACTIVE); if (err) { LOG_ERR("PWM enable failed"); return err; diff --git a/applications/asset_tracker_v2/README.rst b/applications/asset_tracker_v2/README.rst index 4d9efd83eb06..26136c637e1d 100644 --- a/applications/asset_tracker_v2/README.rst +++ b/applications/asset_tracker_v2/README.rst @@ -214,7 +214,7 @@ The application supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns, nrf9160dk_nrf9160ns + :rows: thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -285,7 +285,7 @@ Check and configure the following configuration options for the application: .. option:: CONFIG_ASSET_TRACKER_V2_APP_VERSION - Configuration for providing the application version - The application publishes its version number as a part of the static device data. The default value for the application version is ``0.0.0-development``. To configure the application version, set :option:`CONFIG_ASSET_TRACKER_V2_APP_VERSION` to the desired version. + The application publishes its version number as a part of the static device data. The default value for the application version is ``0.0.0-development``. To configure the application version, set :kconfig:`CONFIG_ASSET_TRACKER_V2_APP_VERSION` to the desired version. .. option:: CONFIG_CLOUD_CLIENT_ID_USE_CUSTOM - Configuration for enabling the use of custom cloud client ID @@ -293,7 +293,7 @@ Check and configure the following configuration options for the application: .. option:: CLOUD_CLIENT_ID - Configuration for providing a custom cloud client ID - This application configuration sets a custom client ID for the respective cloud. For setting a custom client ID, you need to set :option:`CONFIG_CLOUD_CLIENT_ID_USE_CUSTOM` to ``y``. + This application configuration sets a custom client ID for the respective cloud. For setting a custom client ID, you need to set :kconfig:`CONFIG_CLOUD_CLIENT_ID_USE_CUSTOM` to ``y``. .. _default_config_values: @@ -335,17 +335,17 @@ You can set the mandatory library-specific Kconfig options in the :file:`prj.con Configurations for AWS IoT library ---------------------------------- -* :option:`CONFIG_AWS_IOT_BROKER_HOST_NAME` -* :option:`CONFIG_AWS_IOT_SEC_TAG` +* :kconfig:`CONFIG_AWS_IOT_BROKER_HOST_NAME` +* :kconfig:`CONFIG_AWS_IOT_SEC_TAG` Configurations for Azure IoT Hub library ---------------------------------------- -* :option:`CONFIG_AZURE_IOT_HUB_DPS_HOSTNAME` -* :option:`CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE` -* :option:`CONFIG_AZURE_IOT_HUB_SEC_TAG` -* :option:`CONFIG_AZURE_FOTA_SEC_TAG` +* :kconfig:`CONFIG_AZURE_IOT_HUB_DPS_HOSTNAME` +* :kconfig:`CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE` +* :kconfig:`CONFIG_AZURE_IOT_HUB_SEC_TAG` +* :kconfig:`CONFIG_AZURE_FOTA_SEC_TAG` .. note: The nRF Cloud library does not require any library-specific Kconfig options to be set. @@ -355,15 +355,15 @@ Optional library configurations You can add the following optional configurations to configure the heap or to provide additional information such as APN to the modem for registering with an LTE network: -* :option:`CONFIG_HEAP_MEM_POOL_SIZE` - Configures the size of the heap that is used by the application when encoding and sending data to the cloud. More information can be found in :ref:`memory_allocation`. -* :option:`CONFIG_PDN_DEFAULTS_OVERRIDE` - Used for manual configuration of the APN. Set the option to ``y`` to override the default PDP context configuration. -* :option:`CONFIG_PDN_DEFAULT_APN` - Used for manual configuration of the APN. An example is ``apn.example.com``. +* :kconfig:`CONFIG_HEAP_MEM_POOL_SIZE` - Configures the size of the heap that is used by the application when encoding and sending data to the cloud. More information can be found in :ref:`memory_allocation`. +* :kconfig:`CONFIG_PDN_DEFAULTS_OVERRIDE` - Used for manual configuration of the APN. Set the option to ``y`` to override the default PDP context configuration. +* :kconfig:`CONFIG_PDN_DEFAULT_APN` - Used for manual configuration of the APN. An example is ``apn.example.com``. The application supports Assisted GPS. To set the source of the A-GPS data, set the following options: -* :option:`CONFIG_AGPS_SRC_SUPL` - Sets the external SUPL Client library as A-GPS data source. See the documentation on :ref:`supl_client_lib`. -* :option:`CONFIG_AGPS_SRC_NRF_CLOUD` - Sets nRF Cloud as A-GPS data source. You must set nRF Cloud as the firmware cloud backend. +* :kconfig:`CONFIG_AGPS_SRC_SUPL` - Sets the external SUPL Client library as A-GPS data source. See the documentation on :ref:`supl_client_lib`. +* :kconfig:`CONFIG_AGPS_SRC_NRF_CLOUD` - Sets nRF Cloud as A-GPS data source. You must set nRF Cloud as the firmware cloud backend. Configuration files =================== @@ -377,8 +377,8 @@ The application contains examples of Kconfig overlays. The following configuration files are available in the application folder: * :file:`prj.conf` - Configuration file common for all build targets -* :file:`boards/thingy91_nrf9160ns.conf` - Configuration file specific for Thingy:91. This file is automatically merged with the :file:`prj.conf` file when you build for the ``thingy91_nrf9160ns`` build target. -* :file:`boards/nrf9160dk_nrf9160ns.conf` - Configuration file specific for nRF9160 DK. This file is automatically merged with the :file:`prj.conf` file when you build for the ``nrf9160dk_nrf9160ns`` build target. +* :file:`boards/thingy91_nrf9160_ns.conf` - Configuration file specific for Thingy:91. This file is automatically merged with the :file:`prj.conf` file when you build for the ``thingy91_nrf9160_ns`` build target. +* :file:`boards/nrf9160dk_nrf9160_ns.conf` - Configuration file specific for nRF9160 DK. This file is automatically merged with the :file:`prj.conf` file when you build for the ``nrf9160dk_nrf9160_ns`` build target. * :file:`overlay-low-power.conf` - Configuration file that achieves the lowest power consumption by disabling features that consume extra power like LED control and logging. * :file:`overlay-debug.conf` - Configuration file that adds additional verbose logging capabilities to the application * :file:`boards//led_state_def.h` - Header file that describes the LED behavior of the CAF LEDs module. @@ -406,7 +406,7 @@ Also, the device must be provisioned and configured with the certificates accord .. external_antenna_note_start .. note:: - For nRF9160 DK v0.15.0 and later, set the :option:`CONFIG_NRF9160_GPS_ANTENNA_EXTERNAL` option to ``y`` when building the application to achieve the best external antenna performance. + For nRF9160 DK v0.15.0 and later, set the :kconfig:`CONFIG_NRF9160_GPS_ANTENNA_EXTERNAL` option to ``y`` when building the application to achieve the best external antenna performance. .. external_antenna_note_end @@ -415,9 +415,9 @@ Building with overlays To build with Kconfig overlay, it must be based to the build system, as shown in the following example: -``west build -b nrf9160dk_nrf9160ns -- -DOVERLAY_CONFIG=overlay-low-power.conf`` +``west build -b nrf9160dk_nrf9160_ns -- -DOVERLAY_CONFIG=overlay-low-power.conf`` -The above command will build for nRF9160 DK using the configurations found in :file:`overlay-low-power.conf`, in addition to the configurations found in :file:`prj_nrf9160dk_nrf9160ns.conf`. +The above command will build for nRF9160 DK using the configurations found in :file:`overlay-low-power.conf`, in addition to the configurations found in :file:`prj_nrf9160dk_nrf9160_ns.conf`. If some options are defined in both files, the options set in the overlay take precedence. Testing @@ -624,7 +624,7 @@ Following are some features that rely on dynamically allocated memory, using the * Event manager events * Encoding of the data that will be sent to cloud -You can configure the heap memory by using the :option:`CONFIG_HEAP_MEM_POOL_SIZE`. +You can configure the heap memory by using the :kconfig:`CONFIG_HEAP_MEM_POOL_SIZE`. The data management module that encodes data destined for cloud is the biggest consumer of heap memory. Therefore, when adjusting buffer sizes in the data management module, you must also adjust the heap accordingly. This avoids the problem of running out of heap memory in worst-case scenarios. diff --git a/applications/asset_tracker_v2/boards/nrf9160dk_nrf9160ns.conf b/applications/asset_tracker_v2/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from applications/asset_tracker_v2/boards/nrf9160dk_nrf9160ns.conf rename to applications/asset_tracker_v2/boards/nrf9160dk_nrf9160_ns.conf diff --git a/applications/asset_tracker_v2/boards/nrf9160dk_nrf9160ns.overlay b/applications/asset_tracker_v2/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from applications/asset_tracker_v2/boards/nrf9160dk_nrf9160ns.overlay rename to applications/asset_tracker_v2/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/applications/asset_tracker_v2/boards/nrf9160dk_nrf9160ns/led_state_def.h b/applications/asset_tracker_v2/boards/nrf9160dk_nrf9160_ns/led_state_def.h similarity index 100% rename from applications/asset_tracker_v2/boards/nrf9160dk_nrf9160ns/led_state_def.h rename to applications/asset_tracker_v2/boards/nrf9160dk_nrf9160_ns/led_state_def.h diff --git a/applications/asset_tracker_v2/boards/thingy91_nrf9160ns.conf b/applications/asset_tracker_v2/boards/thingy91_nrf9160_ns.conf similarity index 100% rename from applications/asset_tracker_v2/boards/thingy91_nrf9160ns.conf rename to applications/asset_tracker_v2/boards/thingy91_nrf9160_ns.conf diff --git a/applications/asset_tracker_v2/boards/thingy91_nrf9160ns.overlay b/applications/asset_tracker_v2/boards/thingy91_nrf9160_ns.overlay similarity index 100% rename from applications/asset_tracker_v2/boards/thingy91_nrf9160ns.overlay rename to applications/asset_tracker_v2/boards/thingy91_nrf9160_ns.overlay diff --git a/applications/asset_tracker_v2/boards/thingy91_nrf9160ns/led_state_def.h b/applications/asset_tracker_v2/boards/thingy91_nrf9160_ns/led_state_def.h similarity index 100% rename from applications/asset_tracker_v2/boards/thingy91_nrf9160ns/led_state_def.h rename to applications/asset_tracker_v2/boards/thingy91_nrf9160_ns/led_state_def.h diff --git a/applications/asset_tracker_v2/sample.yaml b/applications/asset_tracker_v2/sample.yaml index 092261d7ba43..6e950a82199b 100644 --- a/applications/asset_tracker_v2/sample.yaml +++ b/applications/asset_tracker_v2/sample.yaml @@ -3,11 +3,11 @@ sample: tests: applications.asset_tracker_v2.nrf_cloud: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns tags: ci_build applications.asset_tracker_v2.aws: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns extra_configs: - CONFIG_AWS_IOT_BROKER_HOST_NAME="example-hostname.aws.com" - CONFIG_AWS_IOT_SEC_TAG=42 @@ -31,7 +31,7 @@ tests: tags: ci_build applications.asset_tracker_v2.azure: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns extra_configs: - CONFIG_AZURE_IOT_HUB_DPS_HOSTNAME="global.azure-devices-provisioning.net" - CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE="IDSCOPE" diff --git a/applications/asset_tracker_v2/src/modules/Kconfig.sensor_module b/applications/asset_tracker_v2/src/modules/Kconfig.sensor_module index 246fdcb1873b..13372960a15a 100644 --- a/applications/asset_tracker_v2/src/modules/Kconfig.sensor_module +++ b/applications/asset_tracker_v2/src/modules/Kconfig.sensor_module @@ -6,7 +6,7 @@ menuconfig SENSOR_MODULE bool "Sensor module" - select EXTERNAL_SENSORS if BOARD_THINGY91_NRF9160NS + select EXTERNAL_SENSORS if BOARD_THINGY91_NRF9160_NS default y if SENSOR_MODULE diff --git a/applications/asset_tracker_v2/src/modules/cloud_module.c b/applications/asset_tracker_v2/src/modules/cloud_module.c index aa1c841b5feb..3e90737b0f6d 100644 --- a/applications/asset_tracker_v2/src/modules/cloud_module.c +++ b/applications/asset_tracker_v2/src/modules/cloud_module.c @@ -10,6 +10,9 @@ #include #include #include +#if defined(CONFIG_AGPS) +#include +#endif #if defined(CONFIG_NRF_CLOUD_AGPS) #include @@ -224,7 +227,7 @@ static void agps_data_handle(const uint8_t *buf, size_t len) int err; #if defined(CONFIG_AGPS) - err = gps_process_agps_data(buf, len); + err = agps_cloud_data_process(buf, len); if (err) { LOG_WRN("Unable to process agps data, error: %d", err); #if defined(CONFIG_NRF_CLOUD_PGPS) @@ -259,6 +262,36 @@ static void agps_data_handle(const uint8_t *buf, size_t len) (void)err; } +#if defined(CONFIG_AGPS) +/* Converts the A-GPS data request from GPS driver to GNSS API format. */ +static void agps_request_convert( + struct nrf_modem_gnss_agps_data_frame *dest, + const struct gps_agps_request *src) +{ + dest->sv_mask_ephe = src->sv_mask_ephe; + dest->sv_mask_alm = src->sv_mask_alm; + dest->data_flags = 0; + if (src->utc) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST; + } + if (src->klobuchar) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST; + } + if (src->nequick) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST; + } + if (src->system_time_tow) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST; + } + if (src->position) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_POSITION_REQUEST; + } + if (src->integrity) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST; + } +} +#endif + static void agps_data_request_handle(struct gps_agps_request *incoming_request) { int err; @@ -269,7 +302,11 @@ static void agps_data_request_handle(struct gps_agps_request *incoming_request) memcpy(&agps_request, incoming_request, sizeof(agps_request)); #if defined(CONFIG_AGPS) - err = gps_agps_request_send(agps_request, GPS_SOCKET_NOT_PROVIDED); + struct nrf_modem_gnss_agps_data_frame request; + + agps_request_convert(&request, &agps_request); + + err = agps_request_send(request, AGPS_SOCKET_NOT_PROVIDED); if (err) { LOG_WRN("Failed to request A-GPS data, error: %d", err); LOG_WRN("This is expected to fail if we are not in a connected state"); diff --git a/applications/asset_tracker_v2/src/modules/ui_module.c b/applications/asset_tracker_v2/src/modules/ui_module.c index c1fda06e2968..124de07e5b9b 100644 --- a/applications/asset_tracker_v2/src/modules/ui_module.c +++ b/applications/asset_tracker_v2/src/modules/ui_module.c @@ -195,7 +195,7 @@ static void button_handler(uint32_t button_states, uint32_t has_changed) EVENT_SUBMIT(ui_module_event); } -#if defined(CONFIG_BOARD_NRF9160DK_NRF9160NS) +#if defined(CONFIG_BOARD_NRF9160DK_NRF9160_NS) if (has_changed & button_states & DK_BTN2_MSK) { struct ui_module_event *ui_module_event = diff --git a/applications/connectivity_bridge/README.rst b/applications/connectivity_bridge/README.rst index be407a433fbb..fc6813ff9327 100644 --- a/applications/connectivity_bridge/README.rst +++ b/applications/connectivity_bridge/README.rst @@ -9,7 +9,7 @@ Connectivity bridge The Connectivity bridge application demonstrates the bridge functionality for the Thingy:91 hardware. -Additionally, the application also provides an option of adding the bluetooth functionality by making use of the :ref:`nus_service_readme`. +Additionally, the application also provides an option of adding the Bluetooth® functionality by making use of the :ref:`nus_service_readme`. Overview ******** @@ -32,7 +32,7 @@ See :ref:`thingy91_serialports` for information on the baud rate configuration f The application adds the functionality of a USB Mass Storage device, which contains several utility files such as a :file:`README.txt` file. -The application also provides a Bluetooth LE UART Service, which can be enabled by the option ``CONFIG_BRIDGE_BLE_ENABLE``. +The application also provides a Bluetooth® LE UART Service, which can be enabled by the option ``CONFIG_BRIDGE_BLE_ENABLE``. This service can be used for a wireless connection to one of the UART interfaces in the following way: .. list-table:: diff --git a/applications/connectivity_bridge/src/modules/uart_handler.c b/applications/connectivity_bridge/src/modules/uart_handler.c index 89aaa65db4c0..f3a60a85482f 100644 --- a/applications/connectivity_bridge/src/modules/uart_handler.c +++ b/applications/connectivity_bridge/src/modules/uart_handler.c @@ -243,8 +243,8 @@ static void set_uart_power_state(uint8_t dev_idx, bool active) #if UART_SET_PM_STATE const struct device *dev = devices[dev_idx]; int err; - uint32_t current_state; - uint32_t target_state; + enum pm_device_state current_state; + enum pm_device_state target_state; target_state = active ? PM_DEVICE_STATE_ACTIVE : PM_DEVICE_STATE_SUSPEND; @@ -258,7 +258,7 @@ static void set_uart_power_state(uint8_t dev_idx, bool active) return; } - err = pm_device_state_set(dev, target_state, NULL, NULL); + err = pm_device_state_set(dev, target_state); if (err) { LOG_ERR("device_set_power_state: %d", err); return; diff --git a/applications/machine_learning/README.rst b/applications/machine_learning/README.rst index 357c90554a42..73b12f390395 100644 --- a/applications/machine_learning/README.rst +++ b/applications/machine_learning/README.rst @@ -89,7 +89,7 @@ The figure visualizes relations between Event Manager, modules, drivers, and lib Since the application architecture is uniform and the code is shared, the set of modules in use depends on configuration. In other words, not all of the modules need to be enabled for a given reference design. -For example, the :ref:`caf_ble_state` and :ref:`caf_ble_adv` modules are not enabled if the configuration does not use Bluetooth. +For example, the :ref:`caf_ble_state` and :ref:`caf_ble_adv` modules are not enabled if the configuration does not use Bluetooth®. See :ref:`nrf_machine_learning_app_internal_modules` for detailed information about every module used by the nRF Machine Learning application. @@ -348,10 +348,10 @@ After programming the application, perform the following steps to test the nRF M After the mode is switched, the LED color changes to red and the LED starts blinking very slowly. #. Program the :ref:`central_uart` sample to a compatible development kit, for example the nRF52840 Development Kit. Turn on the programmed device. - After a brief delay the Bluetooth connection between the sample and the Thingy:52 is established. + After a brief delay the Bluetooth® connection between the sample and the Thingy:52 is established. The Thingy:52 forwards the sensor readouts over NUS. The LED on the Thingy:52 starts to blink rapidly. -#. Connect to the Bluetooth Central UART sample with a terminal emulator (for example, PuTTY). +#. Connect to the Bluetooth® Central UART sample with a terminal emulator (for example, PuTTY). See :ref:`putty` for the required settings. #. Observe the sensor readouts represented as comma-separated values. Every line represents a single sensor readout. @@ -464,7 +464,7 @@ The nRF Machine Learning application also uses the following dedicated applicati ``ei_data_forwarder_bt_nus`` The module forwards the sensor readouts over NUS to the connected Bluetooth Central. - The sensor data is forwarded only if the connection is secured and connection interval is within the limit defined by :option:`CONFIG_BT_PERIPHERAL_PREF_MAX_INT` and :option:`CONFIG_BT_PERIPHERAL_PREF_MAX_INT`. + The sensor data is forwarded only if the connection is secured and connection interval is within the limit defined by :kconfig:`CONFIG_BT_PERIPHERAL_PREF_MAX_INT` and :kconfig:`CONFIG_BT_PERIPHERAL_PREF_MAX_INT`. ``ei_data_forwarder_uart`` The module forwards the sensor readouts over UART. diff --git a/samples/matter/weather_station/CMakeLists.txt b/applications/matter_weather_station/CMakeLists.txt similarity index 84% rename from samples/matter/weather_station/CMakeLists.txt rename to applications/matter_weather_station/CMakeLists.txt index 31281251b916..cefa71c77354 100644 --- a/samples/matter/weather_station/CMakeLists.txt +++ b/applications/matter_weather_station/CMakeLists.txt @@ -7,24 +7,18 @@ cmake_minimum_required(VERSION 3.13.1) if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE release) + set(CMAKE_BUILD_TYPE ZDebug) endif() -set(CONF_FILE "prj_${CMAKE_BUILD_TYPE}.conf") - -option(BUILD_WITH_DFU "Build target with Device Firmware Upgrade support" ON) -if(BUILD_WITH_DFU) - list(INSERT OVERLAY_CONFIG 0 ${CMAKE_CURRENT_SOURCE_DIR}/../common/config/overlay-dfu_support.conf) - list(INSERT OVERLAY_CONFIG 0 ${CMAKE_CURRENT_SOURCE_DIR}/../common/config/overlay-dfu_nrf53_extension.conf) - set(mcuboot_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/child_image/mcuboot_${CMAKE_BUILD_TYPE}.conf) - set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/thingy53_nrf5340_cpuapp/pm_static.yml) -endif() +set(CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/prj_${CMAKE_BUILD_TYPE}.conf) +set(mcuboot_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/mcuboot_${CMAKE_BUILD_TYPE}.conf) +set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml) find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) project(matter-weather-station) -set(COMMON_ROOT ${CMAKE_CURRENT_LIST_DIR}/../common) +set(COMMON_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../samples/matter/common) set(NLIO_ROOT ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/third_party/nlio/repo) include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake) @@ -39,6 +33,7 @@ target_sources(app PRIVATE src/gen/callback-stub.cpp ${COMMON_ROOT}/src/thread_util.cpp ${COMMON_ROOT}/src/led_widget.cpp + ${COMMON_ROOT}/src/dfu_over_smp.cpp ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/util/DataModelHandler.cpp ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/reporting/reporting-default-configuration.cpp ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/reporting/reporting.cpp diff --git a/applications/matter_weather_station/README.rst b/applications/matter_weather_station/README.rst new file mode 100644 index 000000000000..545f3d968130 --- /dev/null +++ b/applications/matter_weather_station/README.rst @@ -0,0 +1,257 @@ +.. _matter_weather_station_app: + +Thingy:53: Matter weather station +################################# + +.. contents:: + :local: + :depth: 2 + +This Matter weather station application demonstrates the usage of the :ref:`Matter ` application layer to build a weather station device. +Such a device lets you remotely gather different kinds of data using the device sensors, such as temperature, air pressure, and relative humidity. +The device works as a Matter accessory device, meaning it can be paired and controlled remotely over a Matter network built on top of a low-power, 802.15.4 Thread network. +You can use this application as a reference for creating your own application. + +.. note:: + The Matter protocol is in an early development stage and must be treated as an experimental feature. + +Requirements +************ + +The application supports the following development kits: + +.. table-from-rows:: /includes/sample_board_rows.txt + :header: heading + :rows: thingy53_nrf5340_cpuapp + +To commission the weather station device and control it remotely through a Thread network, you also need a Matter controller device :ref:`configured on PC or smartphone ` (which requires additional hardware depending on which setup you choose). +The recommended way of getting measurement values is using the mobile Matter controller application that comes with a neat graphical interface, performs measurements automatically and visualizes the data. + +To program the Thingy:53 device, you need the external J-Link programmer. +If you own an nRF5340 DK that has an onboard J-Link programmer, you can also use it for this purpose. + +.. note:: + |matter_gn_required_note| + +Overview +******** + +The application uses a single button for controlling the device state. +The weather station device is periodically performing temperature, air pressure, and relative humidity measurements. +The measurement results are stored in the device memory and can be read using the Matter controller. +The controller communicates with the weather station device over the Matter protocol using Zigbee Cluster Library (ZCL). +The library describes data measurements within the proper clusters that correspond to the measurement type. + +The application uses MCUboot secure bootloader and SMP protocol for performing over-the-air Device Firmware Upgrade using Bluetooth® LE. +For information about how to upgrade the device firmware using a PC or a mobile, see the :ref:`matter_weather_station_app_dfu` section. + +.. _matter_weather_station_network_mode: + +Remote testing in a network +=========================== + +By default, the Matter accessory device has Thread disabled, and it must be paired with the Matter controller over Bluetooth LE to get configuration from it if you want to use the device within a Thread network. +To do this, the device must be made discoverable over Bluetooth LE. + +The Bluetooth LE advertising starts automatically upon the device startup, but only for a predefined period of time (15 minutes by default). +If the Bluetooth LE advertising times out, you can re-enable it manually using **Button 1**. + +Additionally, the controller must get the commissioning information from the Matter accessory device and provision the device into the network. +For details, see the `Testing`_ section. + +.. _matter_weather_station_app_build_types: + +Matter weather station build types +================================== + +The Matter weather station application does not use a single :file:`prj.conf` file. +Configuration files are provided for different build types and they are located in the `configuration/thingy53_nrf5340_cpuapp` directory. + +.. include:: /gs_modifying.rst + :start-after: build_types_overview_start + :end-before: build_types_overview_end + +Before you start testing the application, you can select one of the build types supported by Matter weather station application, depending on the building method. +This application supports the following build types: + +* ``ZDebug`` -- Debug version of the application - can be used to enable additional features for verifying the application behavior, such as logs or command-line shell. +* ``ZRelease`` -- Release version of the application - can be used to enable only the necessary application functionalities to optimize its performance. + +.. note:: + `Selecting a build type`_ is optional. + The ``ZDebug`` build type is used by default if no build type is explicitly selected. + +Configuration +************* + +|config| + +User interface +************** + +LED 1: + Shows the overall state of the device and its connectivity. + The following states are possible: + + * Short flash on (green color, 50 ms on/950 ms off) - The device is in the unprovisioned (unpaired) state and is not advertising over Bluetooth LE. + * Short flash on (blue color, 50 ms on/950 ms off) - The device is in the unprovisioned (unpaired) state, but is advertising over Bluetooth LE. + * Rapid even flashing (blue color, 100 ms on/100 ms off) - The device is in the unprovisioned state and a commissioning application is connected through Bluetooth LE. + * Short flash on (purple color, 50 ms on/950 ms off) - The device is fully provisioned and has Thread enabled. + +Button 1: + Used during the commissioning procedure. + Depending on how long you press the button: + + * If pressed for 6 seconds, it initiates the factory reset of the device. + Releasing the button within the 6-second window cancels the factory reset procedure. + * If pressed for less than 3 seconds, it starts the NFC tag emulation, enables Bluetooth LE advertising for the predefined period of time (15 minutes by default), and makes the device discoverable over Bluetooth LE. + +USB port: + Used for getting logs from the device or communicating with it through the command-line interface. + It is enabled only for the debug configuration of a application. + See the `Selecting a build type`_ section to learn how to select the debug configuration. + +NFC port with antenna attached: + Used for obtaining the commissioning information from the Matter accessory device to start the commissioning procedure. + +Building and running +******************** + +.. |sample path| replace:: :file:`applications/matter_weather_station` + +.. include:: /includes/build_and_run.txt + +Selecting a build type +====================== + +Before you start testing the application, you can select one of the :ref:`matter_weather_station_app_build_types`, depending on your building method. + +Selecting a build type in SES +----------------------------- + +.. include:: /gs_modifying.rst + :start-after: build_types_selection_ses_start + :end-before: build_types_selection_ses_end + +Selecting a build type from command line +---------------------------------------- + +.. include:: /gs_modifying.rst + :start-after: build_types_selection_cmd_start + :end-before: For example, you can replace the + +For example, you can replace the *selected_build_type* variable to build the ``ZRelease`` firmware for PCA20053 by running the following command in the project directory: + +.. parsed-literal:: + :class: highlight + + west build -b thingy53_nrf5340_cpuapp -d build_thingy53_nrf5340_cpuapp -- -DCMAKE_BUILD_TYPE=ZRelease + +The ``build_thingy53_nrf5340_cpuapp`` parameter specifies the output directory for the build files. + +.. note:: + If the selected board does not support the selected build type, the build is interrupted. + For example, if the ``ZDebugWithShell`` build type is not supported by the selected board, the following notification appears: + + .. code-block:: console + + Configuration file for build type ZDebugWithShell is missing. + +Testing +======= + +.. note:: + The testing procedure assumes you are using the mobile Matter controller application. + You can also obtain the measurement values using the PC command-line-based Matter controller and invoking the read commands manually. + To see how to send read commands from the PC Matter controller, read the `Working with Python Controller`_ guide in the Matter documentation. + +After programming the application, perform the following steps to test the Matter weather station application on the Thingy:53 with the mobile Matter controller application: + +1. Turn on the Thingy:53. + The application starts in an unprovisioned state. + The advertising over Bluetooth LE and DFU start automatically, and **LED 1** starts blinking blue (short flash on). +#. Commission the device into a Thread network by following the guides linked on the :ref:`ug_matter_configuring` page for the mobile Matter controller. + As part of this procedure, you will complete the following steps: + + * Configure Thread Border Router. + * Build and install the mobile Matter controller. + * Commission the device. + * Send Matter commands. + + During the commissioning procedure, **LED 1** of the Matter device starts blinking blue (rapid even flashing). + This indicates that the device is connected over Bluetooth LE, but does not yet have full Thread network connectivity. + + .. note:: + To start commissioning, the controller must get the commissioning information from the Matter accessory device. + The data payload, which includes the device discriminator and setup PIN code, is encoded and shared using an NFC tag. + When using the debug configuration, you can also get this type of information from the USB interface logs. + + Once the commissioning is complete and the device has full Thread connectivity, **LED 1** starts blinking purple (short flash on). +#. Read sensor measurements in Android CHIPTool: + + a. In the Android CHIPTool application main menu, tap the :guilabel:`SENSOR CLUSTERS` button to open the sensor measurements section. + This section contains text boxes to enter :guilabel:`Device ID` and :guilabel:`Endpoint ID`, a drop-down menu with available measurements and two buttons, :guilabel:`READ` and :guilabel:`WATCH`. + + .. figure:: /images/chiptool_sensor_cluster.gif + :alt: Sensor cluster section selection + + Sensor cluster section selection + + On this image, :guilabel:`Device ID` has the value ``5`` and :guilabel:`Endpoint ID` has the value ``1``. + #. Select one of the available measurement types from the drop-down menu. + #. Enter one of the following values for :guilabel:`Endpoint ID`, depending on the selected measurement type: + + * 1 - Temperature measurement + * 2 - Relative humidity measurement + * 3 - Air pressure measurement + + #. Tap the :guilabel:`READ` button to read and display the single measurement value. + + .. figure:: /images/chiptool_temperature_read.gif + :alt: Single temperature measurement read + + Single temperature measurement read + + #. Tap the :guilabel:`WATCH` button to start watching measurement changes in a continuous way and display values on a chart. + + .. figure:: /images/chiptool_temperature_watch.gif + :alt: Continuous temperature measurement watch + + Continuous temperature measurement watch + + The vertical axis represents the measurement values and the horizontal axis represents the current time. + #. Change the displayed measurement by selecting a different measurement type from the drop-down list and entering the corresponding :guilabel:`Endpoint ID` value. + + .. figure:: /images/chiptool_relative_humidity.gif + :alt: Relative humidity measurement type selection + + Relative humidity measurement type selection + +.. _matter_weather_station_app_dfu: + +Updating the device firmware +============================ + +.. note:: + Device Firmware Upgrade feature is under development and currently it is possible to update only the application core image. + Network core image update is not yet available. + +To update the device firmware, complete the steps listed for the selected method in the `Performing Device Firmware Upgrade in Matter device`_ tutorial. + +Dependencies +************ + +This application uses the Matter library, which includes the |NCS| platform integration layer: + +* `Matter`_ + +In addition, the application uses the following |NCS| components: + +* :ref:`dk_buttons_and_leds_readme` +* :ref:`nfc_uri` +* :ref:`lib_nfc_t2t` + +The application depends on the following Zephyr libraries: + +* :ref:`zephyr:logging_api` +* :ref:`zephyr:kernel_api` diff --git a/applications/matter_weather_station/child_image/multiprotocol_rpmsg_ZDebug.conf b/applications/matter_weather_station/child_image/multiprotocol_rpmsg_ZDebug.conf new file mode 100644 index 000000000000..8b53fef45668 --- /dev/null +++ b/applications/matter_weather_station/child_image/multiprotocol_rpmsg_ZDebug.conf @@ -0,0 +1,8 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# TODO: remove increasing connection interval after fixing MPSL driver blocking issues +CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 diff --git a/applications/matter_weather_station/child_image/multiprotocol_rpmsg_ZRelease.conf b/applications/matter_weather_station/child_image/multiprotocol_rpmsg_ZRelease.conf new file mode 100644 index 000000000000..8b53fef45668 --- /dev/null +++ b/applications/matter_weather_station/child_image/multiprotocol_rpmsg_ZRelease.conf @@ -0,0 +1,8 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# TODO: remove increasing connection interval after fixing MPSL driver blocking issues +CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 diff --git a/samples/matter/weather_station/child_image/mcuboot_debug.conf b/applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/mcuboot_ZDebug.conf similarity index 98% rename from samples/matter/weather_station/child_image/mcuboot_debug.conf rename to applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/mcuboot_ZDebug.conf index 897427cd07be..c6dad4985b00 100644 --- a/samples/matter/weather_station/child_image/mcuboot_debug.conf +++ b/applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/mcuboot_ZDebug.conf @@ -13,6 +13,7 @@ CONFIG_PM=n CONFIG_MAIN_STACK_SIZE=10240 CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" +CONFIG_BOOT_UPGRADE_ONLY=y CONFIG_BOOT_MAX_IMG_SECTORS=2048 CONFIG_BOOT_SIGNATURE_TYPE_RSA=y diff --git a/samples/matter/weather_station/child_image/mcuboot_release.conf b/applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/mcuboot_ZRelease.conf similarity index 98% rename from samples/matter/weather_station/child_image/mcuboot_release.conf rename to applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/mcuboot_ZRelease.conf index 897427cd07be..c6dad4985b00 100644 --- a/samples/matter/weather_station/child_image/mcuboot_release.conf +++ b/applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/mcuboot_ZRelease.conf @@ -13,6 +13,7 @@ CONFIG_PM=n CONFIG_MAIN_STACK_SIZE=10240 CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h" +CONFIG_BOOT_UPGRADE_ONLY=y CONFIG_BOOT_MAX_IMG_SECTORS=2048 CONFIG_BOOT_SIGNATURE_TYPE_RSA=y diff --git a/samples/matter/weather_station/configuration/thingy53_nrf5340_cpuapp/pm_static.yml b/applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/pm_static.yml similarity index 100% rename from samples/matter/weather_station/configuration/thingy53_nrf5340_cpuapp/pm_static.yml rename to applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/pm_static.yml diff --git a/samples/matter/weather_station/prj_debug.conf b/applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/prj_ZDebug.conf similarity index 58% rename from samples/matter/weather_station/prj_debug.conf rename to applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/prj_ZDebug.conf index b0e54e7c208e..3cb1961d6eae 100644 --- a/samples/matter/weather_station/prj_debug.conf +++ b/applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/prj_ZDebug.conf @@ -20,6 +20,7 @@ CONFIG_NET_SOCKETS_POLL_MAX=5 CONFIG_NET_L2_OPENTHREAD=y CONFIG_OPENTHREAD_MTD=y +CONFIG_OPENTHREAD_MTD_SED=y CONFIG_OPENTHREAD_FTD=n CONFIG_OPENTHREAD_SLAAC=y CONFIG_OPENTHREAD_MTD_NETDIAG=y @@ -27,6 +28,7 @@ CONFIG_OPENTHREAD_MANUAL_START=y CONFIG_OPENTHREAD_THREAD_STACK_SIZE=6144 CONFIG_OPENTHREAD_NUM_MESSAGE_BUFFERS=64 +CONFIG_OPENTHREAD_POLL_PERIOD=1000 CONFIG_OPENTHREAD_PANID=4660 CONFIG_OPENTHREAD_CHANNEL=15 CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread" @@ -35,6 +37,7 @@ CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" # Enable Bluetooth Low Energy CONFIG_BT=y CONFIG_BT_PERIPHERAL=y +CONFIG_BT_GATT_DYNAMIC_DB=y CONFIG_BT_DEVICE_APPEARANCE=0 CONFIG_BT_DEVICE_NAME_DYNAMIC=y CONFIG_BT_DEVICE_NAME_MAX=15 @@ -48,7 +51,6 @@ CONFIG_BT_MAX_PAIRED=0 CONFIG_BT_BONDABLE=n CONFIG_BT_TINYCRYPT_ECC=n CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY=y -CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 # Use NFC to share commissioning information CONFIG_CHIP_NFC_COMMISSIONING=y @@ -93,19 +95,28 @@ CONFIG_OBERON_MBEDTLS_AES_C=n CONFIG_DK_LIBRARY=y CONFIG_DK_LIBRARY_INVERT_LEDS=n -# Configure RTT logging and shell -CONFIG_USE_SEGGER_RTT=y -CONFIG_UART_CONSOLE=n +# Configure UART logging and shell CONFIG_LOG=y -CONFIG_LOG_MODE_DEFERRED=y -CONFIG_LOG_BACKEND_UART=n -CONFIG_LOG_BACKEND_RTT=n -CONFIG_LOG_STRDUP_BUF_COUNT=32 +CONFIG_LOG_BACKEND_UART=y +CONFIG_LOG_STRDUP_BUF_COUNT=48 CONFIG_LOG_STRDUP_MAX_STRING=100 +CONFIG_LOG_BUFFER_SIZE=2048 CONFIG_SHELL=y -CONFIG_SHELL_LOG_BACKEND=y -CONFIG_SHELL_BACKEND_SERIAL=n -CONFIG_SHELL_BACKEND_RTT=y +CONFIG_SHELL_LOG_BACKEND=n + +# Enable USB CDC ACM +CONFIG_USB=y +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_DEVICE_PRODUCT="Thingy:53 Matter Weather" +CONFIG_USB_DEVICE_VID=0x1915 +CONFIG_USB_DEVICE_PID=0x530D +CONFIG_USB_CDC_ACM=y +CONFIG_USB_UART_CONSOLE=y +CONFIG_USB_CDC_ACM_DEVICE_NAME="CDC_ACM" +CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0" +CONFIG_UART_LINE_CTRL=y +CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0" +CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51 # Configure Thingy:53 sensors CONFIG_I2C=y @@ -118,3 +129,40 @@ CONFIG_INIT_STACKS=y CONFIG_HW_STACK_PROTECTION=y CONFIG_THREAD_NAME=y CONFIG_MPU_STACK_GUARD=y + +######################################################### +# Bootloader and Device Firmware Upgrade related settings + +CONFIG_BOOTLOADER_MCUBOOT=y + +# QSPI configuration +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 + +# External flash memory configuration +CONFIG_PM_EXTERNAL_FLASH=y +CONFIG_PM_EXTERNAL_FLASH_DEV_NAME="MX25R64" +CONFIG_PM_EXTERNAL_FLASH_SIZE=0x800000 +CONFIG_PM_EXTERNAL_FLASH_BASE=0 + +# MCU Manager and SMP configuration +CONFIG_MCUMGR=y +CONFIG_MCUMGR_CMD_IMG_MGMT=y +CONFIG_MCUMGR_CMD_OS_MGMT=y +CONFIG_MCUMGR_SMP_BT=y +CONFIG_MCUMGR_SMP_BT_AUTHEN=n +CONFIG_MCUMGR_BUF_COUNT=6 + +# Increase BT MTU and RX buffer for big size DFU messages +CONFIG_BT_L2CAP_TX_MTU=260 +CONFIG_BT_BUF_ACL_RX_SIZE=264 + +# Increase system workqueue size, as SMP is processed within it +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2800 + +# TODO: Temporary fix until multi-image support allowing to update net core will be available: NCSDK-9502. +CONFIG_NRF53_UPGRADE_NETWORK_CORE=n + +# TODO: Temporary workaround to fix net core Spinel response timeout: KRKNWK-10930 +CONFIG_NRF_802154_SER_DEFAULT_RESPONSE_TIMEOUT=1000 diff --git a/samples/matter/weather_station/prj_release.conf b/applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/prj_ZRelease.conf similarity index 67% rename from samples/matter/weather_station/prj_release.conf rename to applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/prj_ZRelease.conf index 06600db8e33c..e11219481f72 100644 --- a/samples/matter/weather_station/prj_release.conf +++ b/applications/matter_weather_station/configuration/thingy53_nrf5340_cpuapp/prj_ZRelease.conf @@ -20,6 +20,7 @@ CONFIG_NET_SOCKETS_POLL_MAX=5 CONFIG_NET_L2_OPENTHREAD=y CONFIG_OPENTHREAD_MTD=y +CONFIG_OPENTHREAD_MTD_SED=y CONFIG_OPENTHREAD_FTD=n CONFIG_OPENTHREAD_SLAAC=y CONFIG_OPENTHREAD_MTD_NETDIAG=y @@ -27,6 +28,7 @@ CONFIG_OPENTHREAD_MANUAL_START=y CONFIG_OPENTHREAD_THREAD_STACK_SIZE=6144 CONFIG_OPENTHREAD_NUM_MESSAGE_BUFFERS=64 +CONFIG_OPENTHREAD_POLL_PERIOD=1000 CONFIG_OPENTHREAD_PANID=4660 CONFIG_OPENTHREAD_CHANNEL=15 CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread" @@ -35,6 +37,7 @@ CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" # Enable Bluetooth Low Energy CONFIG_BT=y CONFIG_BT_PERIPHERAL=y +CONFIG_BT_GATT_DYNAMIC_DB=y CONFIG_BT_DEVICE_APPEARANCE=0 CONFIG_BT_DEVICE_NAME_DYNAMIC=y CONFIG_BT_DEVICE_NAME_MAX=15 @@ -48,7 +51,6 @@ CONFIG_BT_MAX_PAIRED=0 CONFIG_BT_BONDABLE=n CONFIG_BT_TINYCRYPT_ECC=n CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY=y -CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 # Use NFC to share commissioning information CONFIG_CHIP_NFC_COMMISSIONING=y @@ -112,3 +114,40 @@ CONFIG_BME680=y CONFIG_MAIN_STACK_SIZE=8192 CONFIG_INIT_STACKS=y CONFIG_HW_STACK_PROTECTION=y + +######################################################### +# Bootloader and Device Firmware Upgrade related settings + +CONFIG_BOOTLOADER_MCUBOOT=y + +# QSPI configuration +CONFIG_NORDIC_QSPI_NOR=y +CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 +CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16 + +# External flash memory configuration +CONFIG_PM_EXTERNAL_FLASH=y +CONFIG_PM_EXTERNAL_FLASH_DEV_NAME="MX25R64" +CONFIG_PM_EXTERNAL_FLASH_SIZE=0x800000 +CONFIG_PM_EXTERNAL_FLASH_BASE=0 + +# MCU Manager and SMP configuration +CONFIG_MCUMGR=y +CONFIG_MCUMGR_CMD_IMG_MGMT=y +CONFIG_MCUMGR_CMD_OS_MGMT=y +CONFIG_MCUMGR_SMP_BT=y +CONFIG_MCUMGR_SMP_BT_AUTHEN=n +CONFIG_MCUMGR_BUF_COUNT=6 + +# Increase BT MTU and RX buffer for big size DFU messages +CONFIG_BT_L2CAP_TX_MTU=260 +CONFIG_BT_BUF_ACL_RX_SIZE=264 + +# Increase system workqueue size, as SMP is processed within it +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2800 + +# TODO: Temporary fix until multi-image support allowing to update net core will be available: NCSDK-9502. +CONFIG_NRF53_UPGRADE_NETWORK_CORE=n + +# TODO: Temporary workaround to fix net core Spinel response timeout: KRKNWK-10930 +CONFIG_NRF_802154_SER_DEFAULT_RESPONSE_TIMEOUT=1000 diff --git a/samples/matter/weather_station/sample.yaml b/applications/matter_weather_station/sample.yaml similarity index 67% rename from samples/matter/weather_station/sample.yaml rename to applications/matter_weather_station/sample.yaml index f83fdb6ffd95..3cf27a2fc2ef 100644 --- a/samples/matter/weather_station/sample.yaml +++ b/applications/matter_weather_station/sample.yaml @@ -1,8 +1,8 @@ sample: name: Matter Weather Station - description: Matter Weather Station example + description: Matter Weather Station application tests: - matter.weather_station: + applications.matter_weather_station: build_only: true platform_allow: thingy53_nrf5340_cpuapp integration_platforms: diff --git a/samples/matter/weather_station/src/app_event.h b/applications/matter_weather_station/src/app_event.h similarity index 64% rename from samples/matter/weather_station/src/app_event.h rename to applications/matter_weather_station/src/app_event.h index 2bb80bc649c7..d826d70b6db7 100644 --- a/samples/matter/weather_station/src/app_event.h +++ b/applications/matter_weather_station/src/app_event.h @@ -7,7 +7,14 @@ #pragma once struct AppEvent { - enum class Type { kButtonPush, kButtonRelease, kTimer }; + enum class Type { + kButtonPush, + kButtonRelease, + kTimer, +#ifdef CONFIG_MCUMGR_SMP_BT + kStartSMPAdvertising +#endif + }; using Handler = void (*)(AppEvent *); diff --git a/samples/matter/weather_station/src/app_task.cpp b/applications/matter_weather_station/src/app_task.cpp similarity index 84% rename from samples/matter/weather_station/src/app_task.cpp rename to applications/matter_weather_station/src/app_task.cpp index 1002364657d7..e214a5296fcf 100644 --- a/samples/matter/weather_station/src/app_task.cpp +++ b/applications/matter_weather_station/src/app_task.cpp @@ -16,20 +16,6 @@ #include #include -/* MCUMgr BT FOTA includes */ -#ifdef CONFIG_MCUMGR_CMD_OS_MGMT -#include "os_mgmt/os_mgmt.h" -#endif -#ifdef CONFIG_MCUMGR_CMD_IMG_MGMT -#include "img_mgmt/img_mgmt.h" -#endif -#ifdef CONFIG_MCUMGR_SMP_BT -#include -#endif -#ifdef CONFIG_BOOTLOADER_MCUBOOT -#include -#endif - #include #include #include @@ -47,6 +33,7 @@ enum class LedState { kAlive, kAdvertisingBle, kConnectedBle, kProvisioned }; constexpr size_t kAppEventQueueSize = 10; constexpr size_t kFactoryResetTriggerTimeoutMs = 3000; constexpr size_t kFactoryResetCompleteTimeoutMs = 3000; +constexpr size_t kMeasurementsIntervalMs = 250; constexpr uint8_t kTemperatureMeasurementEndpointId = 1; constexpr int16_t kTemperatureMeasurementAttributeMaxValue = 0x7fff; constexpr int16_t kTemperatureMeasurementAttributeMinValue = 0x954d; @@ -62,6 +49,8 @@ constexpr int16_t kPressureMeasurementAttributeInvalidValue = 0x8000; K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); k_timer sFunctionTimer; +k_timer sMeasurementsTimer; +bool sMeasurementTrigger; FunctionTimerMode sFunctionTimerMode = FunctionTimerMode::kDisabled; LEDWidget sRedLED; @@ -100,35 +89,27 @@ int AppTask::Init() return -1; } -#ifdef CONFIG_BOOTLOADER_MCUBOOT - /* Check if the image is run in the REVERT mode and eventually - confirm it to prevent reverting on the next boot. */ - if (mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT) { - if (boot_write_img_confirmed()) { - LOG_ERR("Confirming firmware image failed, it will be reverted on the next boot."); - } else { - LOG_INF("New firmware image confirmed."); - } - } - - /* Register SMP service for software update purpose */ - os_mgmt_register_group(); - img_mgmt_register_group(); - img_mgmt_set_upload_cb(SoftwareUpdateConfirmationHandler, NULL); - smp_bt_register(); +#ifdef CONFIG_MCUMGR_SMP_BT + GetDFUOverSMP().Init(RequestSMPAdvertisingStart); + GetDFUOverSMP().ConfirmNewImage(); + GetDFUOverSMP().StartServer(); #endif - /* Initialize timer */ + /* Initialize timers */ k_timer_init( &sFunctionTimer, [](k_timer *) { sAppTask.PostEvent(AppEvent::Type::kTimer, FunctionTimerHandler); }, nullptr); + k_timer_init( + &sMeasurementsTimer, + [](k_timer *) { sAppTask.PostEvent(AppEvent::Type::kTimer, MeasurementsTimerHandler); }, nullptr); + k_timer_start(&sMeasurementsTimer, K_MSEC(kMeasurementsIntervalMs), K_NO_WAIT); /* Init ZCL Data Model and start server */ InitServer(); ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); -#ifdef CONFIG_CHIP_NFC_COMMISSIONING +#if defined(CONFIG_CHIP_NFC_COMMISSIONING) || defined(CONFIG_MCUMGR_SMP_BT) PlatformMgr().AddEventHandler(AppTask::ChipEventHandler, 0); #endif @@ -137,13 +118,11 @@ int AppTask::Init() void AppTask::OpenPairingWindow() { - /* Start BLE advertising despite having Thread provisioned only in case of supporting for DFU over BLE. */ -#ifndef CONFIG_BOOTLOADER_MCUBOOT + /* Don't allow on starting Matter service BLE advertising after Thread provisioning. */ if (ConnectivityMgr().IsThreadProvisioned()) { - LOG_INF("NFC Tag emulation and BLE advertisement not started - device is commissioned to a Thread network."); + LOG_INF("NFC Tag emulation and Matter service BLE advertisement not started - device is commissioned to a Thread network."); return; } -#endif if (ConnectivityMgr().IsBLEAdvertisingEnabled()) { LOG_INF("BLE Advertisement is already enabled"); @@ -184,7 +163,11 @@ int AppTask::StartApp() PlatformMgr().UnlockChipStack(); } - UpdateClusterState(); + if (sMeasurementTrigger) { + sMeasurementTrigger = false; + UpdateClusterState(); + } + UpdateLedState(); } } @@ -204,13 +187,13 @@ void AppTask::PostEvent(AppEvent::Type type, AppEvent::Handler handler) PostEvent(&event); } -int AppTask::SoftwareUpdateConfirmationHandler(uint32_t offset, uint32_t size, void *arg) +#ifdef CONFIG_MCUMGR_SMP_BT +void AppTask::RequestSMPAdvertisingStart(void) { - /* For now just print update progress and confirm data chunk without any additional checks. */ - LOG_INF("Software update progress %d B / %d B", offset, size); - - return 0; + sAppTask.PostEvent(AppEvent::Type::kStartSMPAdvertising, + [](AppEvent *) { GetDFUOverSMP().StartBLEAdvertising(); }); } +#endif void AppTask::DispatchEvent(AppEvent *event) { @@ -263,6 +246,12 @@ void AppTask::FunctionTimerHandler(AppEvent *) } } +void AppTask::MeasurementsTimerHandler(AppEvent *) +{ + sMeasurementTrigger = true; + k_timer_start(&sMeasurementsTimer, K_MSEC(kMeasurementsIntervalMs), K_NO_WAIT); +} + void AppTask::UpdateClusterState() { struct sensor_value sTemperature, sPressure, sHumidity; @@ -393,20 +382,31 @@ void AppTask::UpdateLedState() sRedLED.Animate(); } -#ifdef CONFIG_CHIP_NFC_COMMISSIONING void AppTask::ChipEventHandler(const ChipDeviceEvent *event, intptr_t /* arg */) { - if (event->Type == DeviceEventType::kCHIPoBLEAdvertisingChange) { - if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Started) { - if (NFCMgr().IsTagEmulationStarted()) { - LOG_INF("NFC Tag emulation is already started"); - } else { - ShareQRCodeOverNFC( - chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); - } - } else if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped) { - NFCMgr().StopTagEmulation(); + if (event->Type != DeviceEventType::kCHIPoBLEAdvertisingChange) + return; + + if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped) { +#ifdef CONFIG_CHIP_NFC_COMMISSIONING + NFCMgr().StopTagEmulation(); +#endif +#ifdef CONFIG_MCUMGR_SMP_BT + /* After CHIPoBLE advertising stop, start advertising SMP in case Thread is enabled or there are no + * active CHIPoBLE connections (exclude the case when CHIPoBLE advertising is stopped on the connection + * time) */ + if (GetDFUOverSMP().IsEnabled() && + (ConnectivityMgr().IsThreadProvisioned() || ConnectivityMgr().NumBLEConnections() == 0)) + sAppTask.RequestSMPAdvertisingStart(); +#endif + } +#ifdef CONFIG_CHIP_NFC_COMMISSIONING + else if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Started) { + if (NFCMgr().IsTagEmulationStarted()) { + LOG_INF("NFC Tag emulation is already started"); + } else { + ShareQRCodeOverNFC(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); } } -} #endif +} diff --git a/samples/matter/weather_station/src/app_task.h b/applications/matter_weather_station/src/app_task.h similarity index 82% rename from samples/matter/weather_station/src/app_task.h rename to applications/matter_weather_station/src/app_task.h index 178d6fd76709..c7a42e3c72ba 100644 --- a/samples/matter/weather_station/src/app_task.h +++ b/applications/matter_weather_station/src/app_task.h @@ -10,6 +10,10 @@ #include +#ifdef CONFIG_MCUMGR_SMP_BT +#include "dfu_over_smp.h" +#endif + struct k_timer; class AppTask { @@ -28,11 +32,14 @@ class AppTask { void OpenPairingWindow(); void DispatchEvent(AppEvent *event); - static int SoftwareUpdateConfirmationHandler(uint32_t offset, uint32_t size, void *arg); +#ifdef CONFIG_MCUMGR_SMP_BT + static void RequestSMPAdvertisingStart(void); +#endif static void ButtonStateHandler(uint32_t buttonState, uint32_t hasChanged); static void ButtonPushHandler(AppEvent *event); static void ButtonReleaseHandler(AppEvent *event); static void FunctionTimerHandler(AppEvent *event); + static void MeasurementsTimerHandler(AppEvent *event); static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent *event, intptr_t arg); static AppTask sAppTask; diff --git a/samples/matter/weather_station/src/chip_project_config.h b/applications/matter_weather_station/src/chip_project_config.h similarity index 100% rename from samples/matter/weather_station/src/chip_project_config.h rename to applications/matter_weather_station/src/chip_project_config.h diff --git a/samples/matter/weather_station/src/gen/CHIPClientCallbacks.cpp b/applications/matter_weather_station/src/gen/CHIPClientCallbacks.cpp similarity index 100% rename from samples/matter/weather_station/src/gen/CHIPClientCallbacks.cpp rename to applications/matter_weather_station/src/gen/CHIPClientCallbacks.cpp diff --git a/samples/matter/weather_station/src/gen/CHIPClientCallbacks.h b/applications/matter_weather_station/src/gen/CHIPClientCallbacks.h similarity index 100% rename from samples/matter/weather_station/src/gen/CHIPClientCallbacks.h rename to applications/matter_weather_station/src/gen/CHIPClientCallbacks.h diff --git a/samples/matter/weather_station/src/gen/CHIPClusters.cpp b/applications/matter_weather_station/src/gen/CHIPClusters.cpp similarity index 100% rename from samples/matter/weather_station/src/gen/CHIPClusters.cpp rename to applications/matter_weather_station/src/gen/CHIPClusters.cpp diff --git a/samples/matter/weather_station/src/gen/CHIPClusters.h b/applications/matter_weather_station/src/gen/CHIPClusters.h similarity index 100% rename from samples/matter/weather_station/src/gen/CHIPClusters.h rename to applications/matter_weather_station/src/gen/CHIPClusters.h diff --git a/samples/matter/weather_station/src/gen/IMClusterCommandHandler.cpp b/applications/matter_weather_station/src/gen/IMClusterCommandHandler.cpp similarity index 100% rename from samples/matter/weather_station/src/gen/IMClusterCommandHandler.cpp rename to applications/matter_weather_station/src/gen/IMClusterCommandHandler.cpp diff --git a/samples/matter/weather_station/src/gen/af-gen-event.h b/applications/matter_weather_station/src/gen/af-gen-event.h similarity index 100% rename from samples/matter/weather_station/src/gen/af-gen-event.h rename to applications/matter_weather_station/src/gen/af-gen-event.h diff --git a/samples/matter/weather_station/src/gen/attribute-size.cpp b/applications/matter_weather_station/src/gen/attribute-size.cpp similarity index 100% rename from samples/matter/weather_station/src/gen/attribute-size.cpp rename to applications/matter_weather_station/src/gen/attribute-size.cpp diff --git a/samples/matter/weather_station/src/gen/callback-stub.cpp b/applications/matter_weather_station/src/gen/callback-stub.cpp similarity index 100% rename from samples/matter/weather_station/src/gen/callback-stub.cpp rename to applications/matter_weather_station/src/gen/callback-stub.cpp diff --git a/samples/matter/weather_station/src/gen/callback.h b/applications/matter_weather_station/src/gen/callback.h similarity index 100% rename from samples/matter/weather_station/src/gen/callback.h rename to applications/matter_weather_station/src/gen/callback.h diff --git a/samples/matter/weather_station/src/gen/chip-zcl-zpro-codec-api.h b/applications/matter_weather_station/src/gen/chip-zcl-zpro-codec-api.h similarity index 100% rename from samples/matter/weather_station/src/gen/chip-zcl-zpro-codec-api.h rename to applications/matter_weather_station/src/gen/chip-zcl-zpro-codec-api.h diff --git a/samples/matter/weather_station/src/gen/encoder.cpp b/applications/matter_weather_station/src/gen/encoder.cpp similarity index 100% rename from samples/matter/weather_station/src/gen/encoder.cpp rename to applications/matter_weather_station/src/gen/encoder.cpp diff --git a/samples/matter/weather_station/src/gen/endpoint_config.h b/applications/matter_weather_station/src/gen/endpoint_config.h similarity index 100% rename from samples/matter/weather_station/src/gen/endpoint_config.h rename to applications/matter_weather_station/src/gen/endpoint_config.h diff --git a/samples/matter/weather_station/src/gen/gen_config.h b/applications/matter_weather_station/src/gen/gen_config.h similarity index 100% rename from samples/matter/weather_station/src/gen/gen_config.h rename to applications/matter_weather_station/src/gen/gen_config.h diff --git a/samples/matter/weather_station/src/gen/gen_tokens.h b/applications/matter_weather_station/src/gen/gen_tokens.h similarity index 100% rename from samples/matter/weather_station/src/gen/gen_tokens.h rename to applications/matter_weather_station/src/gen/gen_tokens.h diff --git a/samples/matter/weather_station/src/main.cpp b/applications/matter_weather_station/src/main.cpp similarity index 56% rename from samples/matter/weather_station/src/main.cpp rename to applications/matter_weather_station/src/main.cpp index 4655ed9fd40d..31d522daea1c 100644 --- a/samples/matter/weather_station/src/main.cpp +++ b/applications/matter_weather_station/src/main.cpp @@ -8,8 +8,13 @@ #include +#ifdef CONFIG_USB +#include +#endif + #include #include +#include LOG_MODULE_REGISTER(app); @@ -20,6 +25,13 @@ int main() int ret = 0; CHIP_ERROR err = CHIP_NO_ERROR; +#ifdef CONFIG_USB + err = chip::System::MapErrorZephyr(usb_enable(NULL)); + if (err != CHIP_NO_ERROR) { + goto exit; + } +#endif + err = chip::Platform::MemoryInit(); if (err != CHIP_NO_ERROR) { LOG_ERR("Platform::MemoryInit() failed"); @@ -47,11 +59,32 @@ int main() goto exit; } - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); +#ifdef CONFIG_OPENTHREAD_MTD_SED + err = ConnectivityMgr().SetThreadDeviceType( + ConnectivityManager::kThreadDeviceType_SleepyEndDevice); + if (err != CHIP_NO_ERROR) { + LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed"); + goto exit; + } + + ConnectivityManager::ThreadPollingConfig pollingConfig; + pollingConfig.Clear(); + pollingConfig.ActivePollingIntervalMS = CONFIG_OPENTHREAD_POLL_PERIOD; + pollingConfig.InactivePollingIntervalMS = CONFIG_OPENTHREAD_POLL_PERIOD; + + err = ConnectivityMgr().SetThreadPollingConfig(pollingConfig); + if (err != CHIP_NO_ERROR) { + LOG_ERR("ConnectivityMgr().SetThreadPollingConfig() failed"); + goto exit; + } +#else + err = ConnectivityMgr().SetThreadDeviceType( + ConnectivityManager::kThreadDeviceType_MinimalEndDevice); if (err != CHIP_NO_ERROR) { LOG_ERR("ConnectivityMgr().SetThreadDeviceType() failed"); goto exit; } +#endif ret = GetAppTask().StartApp(); if (ret != 0) { diff --git a/samples/matter/weather_station/src/weather-station.zap b/applications/matter_weather_station/src/weather-station.zap similarity index 100% rename from samples/matter/weather_station/src/weather-station.zap rename to applications/matter_weather_station/src/weather-station.zap diff --git a/samples/matter/weather_station/thingy53_nrf5340_cpuapp.overlay b/applications/matter_weather_station/thingy53_nrf5340_cpuapp.overlay similarity index 100% rename from samples/matter/weather_station/thingy53_nrf5340_cpuapp.overlay rename to applications/matter_weather_station/thingy53_nrf5340_cpuapp.overlay diff --git a/applications/nrf_desktop/README.rst b/applications/nrf_desktop/README.rst index 62e1582dc803..7d1b8050f25a 100644 --- a/applications/nrf_desktop/README.rst +++ b/applications/nrf_desktop/README.rst @@ -7,7 +7,7 @@ nRF Desktop :local: :depth: 2 -The nRF Desktop is a reference design of a Human Interface Device (HID) that is connected to a host through Bluetooth LE or USB, or both. +The nRF Desktop is a reference design of a Human Interface Device (HID) that is connected to a host through Bluetooth® Low Energy or USB, or both. Depending on the configuration, this application can work as desktop mouse, gaming mouse, keyboard, or connection dongle. .. tip:: @@ -145,11 +145,11 @@ The following threads are kept running in the application: * System workqueue thread * Logger thread (on debug :ref:`build types `) * Shell thread (on :ref:`build types ` with shell enabled) - * Threads related to Bluetooth LE (the exact number depends on the selected Link Layer) + * Threads related to Bluetooth® LE (the exact number depends on the selected Link Layer) * Application-related threads * Motion sensor thread (running only on mouse) * Settings loading thread (enabled by default only on keyboard) - * QoS data sampling thread (running only if Bluetooth LE QoS feature is enabled) + * QoS data sampling thread (running only if Bluetooth® LE QoS feature is enabled) Most of the application activity takes place in the context of the system work queue thread, either through scheduled work objects or through the event manager callbacks (executed from the system workqueue thread). Because of this, the application does not need to handle resource protection. @@ -169,7 +169,7 @@ The application uses dynamic allocation to: When configuring HEAP, make sure that the values for the following options match the typical event size and the system needs: -* :option:`CONFIG_HEAP_MEM_POOL_SIZE` - The size must be big enough to handle the worst possible use case for the given device. +* :kconfig:`CONFIG_HEAP_MEM_POOL_SIZE` - The size must be big enough to handle the worst possible use case for the given device. .. important:: The nRF Desktop uses ``k_heap`` as the backend for dynamic allocation. @@ -414,7 +414,7 @@ When it is connected through USB, charging of the rechargeable batteries starts. Dongle USB ~~~~~~~~~~ -The nRF Desktop dongle works as a bridge between the devices connected through standard Bluetooth LE or Low Latency Packet Mode and the host connected through USB. +The nRF Desktop dongle works as a bridge between the devices connected through standard Bluetooth® Low Energy or Low Latency Packet Mode and the host connected through USB. It receives data wirelessly from the connected peripherals and forwards the data to the host. The nRF Desktop dongle is powered directly through USB. @@ -694,7 +694,7 @@ For example, LEDs are turned off and advertising is stopped. Moving the mouse or pressing any button wakes up the device and turns on the disabled functionalities. -You can define the amount of time after which the peripherals are suspended or powered off in :option:`CONFIG_CAF_POWER_MANAGER_TIMEOUT`. +You can define the amount of time after which the peripherals are suspended or powered off in :kconfig:`CONFIG_CAF_POWER_MANAGER_TIMEOUT`. By default, this period is set to 120 seconds. .. important:: @@ -760,7 +760,7 @@ After building the application with or without :ref:`specifying the build type < .. note:: You can manually start the scanning for new peripheral devices by pressing the **SW1** button on the dongle for a short time. This might be needed if the dongle does not connect with all the peripherals before timeout. - The scanning is interrupted after the amount of time predefined in :option:`CONFIG_DESKTOP_BLE_SCAN_DURATION_S`, because it negatively affects the performance of already connected peripherals. + The scanning is interrupted after the amount of time predefined in :kconfig:`CONFIG_DESKTOP_BLE_SCAN_DURATION_S`, because it negatively affects the performance of already connected peripherals. #. Move the mouse and press any key on the keyboard. The input is reflected on the host. @@ -953,7 +953,7 @@ To use the nRF Desktop application with your custom board: a. Ensure that the Bluetooth role is properly configured. For mouse, it should be configured as peripheral. #. Update the configuration related to peer control. - You can also disable the peer control using the :option:`CONFIG_DESKTOP_BLE_PEER_CONTROL` option. + You can also disable the peer control using the :kconfig:`CONFIG_DESKTOP_BLE_PEER_CONTROL` option. Peer control details are described in the :ref:`nrf_desktop_ble_bond` documentation. Refer to the :ref:`nrf_desktop_bluetooth_guide` section and Zephyr's :ref:`zephyr:bluetooth` page for more detailed information about the Bluetooth configuration. @@ -1158,8 +1158,8 @@ Since the nRF Desktop application uses the partition manager when the bootloader .. important:: By default, Zephyr does not use the code partition defined in the DTS files. - It is only used if :option:`CONFIG_USE_DT_CODE_PARTITION` is enabled. - If this option is disabled, the code is loaded at the address defined by :option:`CONFIG_FLASH_LOAD_OFFSET` and can spawn for :option:`CONFIG_FLASH_LOAD_SIZE` (or for the whole flash if the load size is set to zero). + It is only used if :kconfig:`CONFIG_USE_DT_CODE_PARTITION` is enabled. + If this option is disabled, the code is loaded at the address defined by :kconfig:`CONFIG_FLASH_LOAD_OFFSET` and can spawn for :kconfig:`CONFIG_FLASH_LOAD_SIZE` (or for the whole flash if the load size is set to zero). Because the nRF Desktop application depends on the DTS layout only for configurations without the bootloader, only the settings partition is relevant in such cases and other partitions are ignored. @@ -1209,13 +1209,13 @@ The nRF Desktop devices come in the following types: * Peripheral devices (mouse or keyboard) - * Support only the Bluetooth Peripheral role (:option:`CONFIG_BT_PERIPHERAL`). + * Support only the Bluetooth Peripheral role (:kconfig:`CONFIG_BT_PERIPHERAL`). * Handle only one Bluetooth LE connection at a time. * Use more than one Bluetooth local identity. * Central devices (dongle) - * Support only the Bluetooth Central role (:option:`CONFIG_BT_CENTRAL`). + * Support only the Bluetooth Central role (:kconfig:`CONFIG_BT_CENTRAL`). * Handle multiple Bluetooth LE connections simultaneously. * Use only one Bluetooth local identity (the default one). @@ -1237,12 +1237,12 @@ Configuration options This section describes the most important Bluetooth Kconfig options common for all nRF Desktop devices. For detailed information about every option, see the Kconfig help. -* :option:`CONFIG_BT_MAX_PAIRED` +* :kconfig:`CONFIG_BT_MAX_PAIRED` * nRF Desktop central: The maximum number of paired devices is greater than or equal to the maximum number of simultaneously connected peers. * nRF Desktop peripheral: The maximum number of paired devices is equal to the number of peers plus one, where the one additional paired device slot is used for erase advertising. -* :option:`CONFIG_BT_ID_MAX` +* :kconfig:`CONFIG_BT_ID_MAX` * nRF Desktop central: The device uses only one Bluetooth local identity, that is the default one. * nRF Desktop peripheral: The number of Bluetooth local identities must be equal to the number of peers plus two. @@ -1251,7 +1251,7 @@ For detailed information about every option, see the Kconfig help. * The other additional local identity is the default local identity, which is unused, because it cannot be reset after removing the bond. Without the identity reset, the previously bonded central could still try to reconnect after being removed from Bluetooth bonds on the peripheral side. -* :option:`CONFIG_BT_MAX_CONN` +* :kconfig:`CONFIG_BT_MAX_CONN` * nRF Desktop central: Set the option to the maximum number of simultaneously connected devices. * nRF Desktop peripheral: The default value (one) is used. @@ -1267,22 +1267,22 @@ Link Layer configuration options The nRF Desktop devices use one of the following Link Layers: -* :option:`CONFIG_BT_LL_SW_SPLIT` +* :kconfig:`CONFIG_BT_LL_SW_SPLIT` This Link Layer does not support the Low Latency Packet Mode (LLPM) and has a lower memory usage, so it can be used by memory-limited devices. -* :option:`CONFIG_BT_LL_SOFTDEVICE` +* :kconfig:`CONFIG_BT_LL_SOFTDEVICE` This Link Layer does support the Low Latency Packet Mode (LLPM). - If you opt for this Link Layer and enable the :option:`CONFIG_BT_CTLR_LLPM`, the :option:`CONFIG_CAF_BLE_USE_LLPM` is also enabled by default and can be configured further: + If you opt for this Link Layer and enable the :kconfig:`CONFIG_BT_CTLR_LLPM`, the :kconfig:`CONFIG_CAF_BLE_USE_LLPM` is also enabled by default and can be configured further: - * When :option:`CONFIG_CAF_BLE_USE_LLPM` is enabled, set the value for :option:`CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT` to ``3000``. + * When :kconfig:`CONFIG_CAF_BLE_USE_LLPM` is enabled, set the value for :kconfig:`CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT` to ``3000``. This is required by the nRF Desktop central and helps avoid scheduling conflicts with Bluetooth Link Layer. Such conflicts could lead to a drop in HID input report rate or a disconnection. Setting the value to ``3000`` also enables the nRF Desktop central to exchange data with up to 2 standard Bluetooth LE peripherals during every connection interval (every 7.5 ms). - * When :option:`CONFIG_CAF_BLE_USE_LLPM` is disabled, the device will use only standard Bluetooth LE connection parameters with the lowest available connection interval of 7.5 ms. + * When :kconfig:`CONFIG_CAF_BLE_USE_LLPM` is disabled, the device will use only standard Bluetooth LE connection parameters with the lowest available connection interval of 7.5 ms. - If the LLPM is disabled and more than 2 simultaneous Bluetooth connections are supported (:option:`CONFIG_BT_MAX_CONN`), you can set the value for :option:`CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT` to ``2500``. + If the LLPM is disabled and more than 2 simultaneous Bluetooth connections are supported (:kconfig:`CONFIG_BT_MAX_CONN`), you can set the value for :kconfig:`CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT` to ``2500``. With this value, the nRF Desktop central is able to exchange the data with up to 3 Bluetooth LE peripherals during every 7.5-ms connection interval. Using the value of ``3000`` for more than 2 simultaneous Bluetooth LE connections will result in a lower HID input report rate. @@ -1306,7 +1306,7 @@ Optionally, you can also enable the following module: The module can be used only with the SoftDevice Link Layer. .. note:: - The nRF Destkop devices enable :option:`CONFIG_BT_SETTINGS`. + The nRF Destkop devices enable :kconfig:`CONFIG_BT_SETTINGS`. When this option is enabled, the application is responsible for calling the :c:func:`settings_load` function - this is handled by the :ref:`nrf_desktop_settings_loader`. .. _nrf_desktop_bluetooth_guide_peripheral: @@ -1320,7 +1320,7 @@ The HID over GATT profile specification requires Bluetooth Peripherals to define * HID Service - Handled in the :ref:`nrf_desktop_hids`. * Battery Service - Handled in the :ref:`nrf_desktop_bas`. -* Device Information Service - Implemented in Zephyr and enabled with :option:`CONFIG_BT_DIS`. +* Device Information Service - Implemented in Zephyr and enabled with :kconfig:`CONFIG_BT_DIS`. It can be configured using Kconfig options with the ``CONFIG_BT_DIS`` prefix. The nRF Desktop peripherals must also define a dedicated GATT Service, which is used to provide the following information: @@ -1399,25 +1399,25 @@ The nRF Desktop application can use one of the following bootloaders: Configuring the B0 bootloader ----------------------------- -To enable the B0 bootloader, select the :option:`CONFIG_SECURE_BOOT` Kconfig option. +To enable the B0 bootloader, select the :kconfig:`CONFIG_SECURE_BOOT` Kconfig option. The B0 bootloader requires the following options enabled: -* :option:`CONFIG_SB_SIGNING_KEY_FILE` - Required for providing the signature used for image signing and verification. -* :option:`CONFIG_FW_INFO` - Required for the application versioning information. -* :option:`CONFIG_FW_INFO_FIRMWARE_VERSION` - Enable this option to set the version of the application after you enabled :option:`CONFIG_FW_INFO`. -* :option:`CONFIG_BUILD_S1_VARIANT` - Required for the build system to be able to construct the application binaries for both application's slots in flash memory. +* :kconfig:`CONFIG_SB_SIGNING_KEY_FILE` - Required for providing the signature used for image signing and verification. +* :kconfig:`CONFIG_FW_INFO` - Required for the application versioning information. +* :kconfig:`CONFIG_FW_INFO_FIRMWARE_VERSION` - Enable this option to set the version of the application after you enabled :kconfig:`CONFIG_FW_INFO`. +* :kconfig:`CONFIG_BUILD_S1_VARIANT` - Required for the build system to be able to construct the application binaries for both application's slots in flash memory. Configuring the MCUboot bootloader ---------------------------------- -To enable the MCUboot bootloader, select the :option:`CONFIG_BOOTLOADER_MCUBOOT` Kconfig option. +To enable the MCUboot bootloader, select the :kconfig:`CONFIG_BOOTLOADER_MCUBOOT` Kconfig option. Configure the MCUboot bootloader with the following options: * ``CONFIG_BOOT_SIGNATURE_KEY_FILE`` - This option defines the path to the private key that is used to sign the application and that is used by the bootloader to verify the application signature. The key must be defined only in the MCUboot bootloader configuration file. -* :option:`CONFIG_IMG_MANAGER` and :option:`CONFIG_MCUBOOT_IMG_MANAGER` - These options allow the application to manage the DFU image. +* :kconfig:`CONFIG_IMG_MANAGER` and :kconfig:`CONFIG_MCUBOOT_IMG_MANAGER` - These options allow the application to manage the DFU image. Enable both of them only for configurations that support :ref:`background DFU `. For these configurations, the :ref:`nrf_desktop_dfu` uses the provided API to request firmware upgrade and confirm the running image. @@ -1448,7 +1448,7 @@ The update image is generated in the build directory when building the firmware .. note:: By default, the build process for the B0 bootloader will construct an image for the first slot (slot 0 or S0). - To ensure that application is built for both slots, select the :option:`CONFIG_BUILD_S1_VARIANT` Kconfig option. + To ensure that application is built for both slots, select the :kconfig:`CONFIG_BUILD_S1_VARIANT` Kconfig option. When this option is selected, the :file:`zephyr/dfu_application.zip` contains both images. The update tool checks if the currently running image runs from either slot 0 or slot 1. diff --git a/applications/nrf_desktop/configuration/nrf52810dmouse_nrf52810/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf52810dmouse_nrf52810/app_ZDebug.conf index d5c675bcbc49..aa38de4d219c 100644 --- a/applications/nrf_desktop/configuration/nrf52810dmouse_nrf52810/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf52810dmouse_nrf52810/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52820dongle_nrf52820/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf52820dongle_nrf52820/app_ZDebug.conf index 3bd43d1a07ef..af5c99df85de 100644 --- a/applications/nrf_desktop/configuration/nrf52820dongle_nrf52820/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf52820dongle_nrf52820/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52833dk_nrf52833/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf52833dk_nrf52833/app_ZDebug.conf index 90969121d2e1..d36a0d93c693 100644 --- a/applications/nrf_desktop/configuration/nrf52833dk_nrf52833/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf52833dk_nrf52833/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52833dk_nrf52833/app_ZDebugWithShell.conf b/applications/nrf_desktop/configuration/nrf52833dk_nrf52833/app_ZDebugWithShell.conf index 0c0095465594..79990e3cf752 100644 --- a/applications/nrf_desktop/configuration/nrf52833dk_nrf52833/app_ZDebugWithShell.conf +++ b/applications/nrf_desktop/configuration/nrf52833dk_nrf52833/app_ZDebugWithShell.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebug.conf index 01305ff62786..4378bfb55995 100644 --- a/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebugMCUBoot.conf b/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebugMCUBoot.conf index 10f79d05eb68..10f46fb922b6 100644 --- a/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebugMCUBoot.conf +++ b/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebugMCUBoot.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebugWithShell.conf b/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebugWithShell.conf index 7afa64d54ff5..2422383f2d80 100644 --- a/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebugWithShell.conf +++ b/applications/nrf_desktop/configuration/nrf52833dongle_nrf52833/app_ZDebugWithShell.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug.conf index 3f51a3af6d7c..c11d75a988e4 100644 --- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugB0.conf b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugB0.conf index ccc994dabd90..e352a8bd9bee 100644 --- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugB0.conf +++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugB0.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugMCUBootQSPI.conf b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugMCUBootQSPI.conf index 36e28280cb6b..d4cfc075b555 100644 --- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugMCUBootQSPI.conf +++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugMCUBootQSPI.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugMCUBootSMP.conf b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugMCUBootSMP.conf index 903f78626f80..120071f3cce9 100644 --- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugMCUBootSMP.conf +++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugMCUBootSMP.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugWithShell.conf b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugWithShell.conf index 642d8da906ce..27f10c2b2793 100644 --- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugWithShell.conf +++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebugWithShell.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug_dongle.conf b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug_dongle.conf index 8e485db098f0..146f7b6de8e4 100644 --- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug_dongle.conf +++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug_dongle.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug_keyboard.conf b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug_keyboard.conf index 7e4bfe3c086d..7aa505193d59 100644 --- a/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug_keyboard.conf +++ b/applications/nrf_desktop/configuration/nrf52840dk_nrf52840/app_ZDebug_keyboard.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug.conf index 4550d725e1fb..c68dd20a6921 100644 --- a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug3BLEconn.conf b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug3BLEconn.conf index d046dc883e0e..24658e14b223 100644 --- a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug3BLEconn.conf +++ b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug3BLEconn.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug4LLPMconn.conf b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug4LLPMconn.conf index 2b10191788b1..636c7954ee0b 100644 --- a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug4LLPMconn.conf +++ b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebug4LLPMconn.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugB0.conf b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugB0.conf index eaba560dafa4..9e61e0101fe0 100644 --- a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugB0.conf +++ b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugB0.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugSplitLL.conf b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugSplitLL.conf index a7eb81ab7a2d..b28b3cbd23da 100644 --- a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugSplitLL.conf +++ b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugSplitLL.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugWithShell.conf b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugWithShell.conf index ebdfbf4a800b..a7749abb994f 100644 --- a/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugWithShell.conf +++ b/applications/nrf_desktop/configuration/nrf52840dongle_nrf52840/app_ZDebugWithShell.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebug.conf index d2bc3bd80ad3..ae06fd7b4453 100644 --- a/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugB0.conf b/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugB0.conf index 9e7522af0a98..25dab2e3ad50 100644 --- a/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugB0.conf +++ b/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugB0.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugSplitLL.conf b/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugSplitLL.conf index e8e0dad99e65..0284a5096225 100644 --- a/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugSplitLL.conf +++ b/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugSplitLL.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugWithShell.conf b/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugWithShell.conf index 304fb23d91ac..d1165b45b79d 100644 --- a/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugWithShell.conf +++ b/applications/nrf_desktop/configuration/nrf52840gmouse_nrf52840/app_ZDebugWithShell.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52dmouse_nrf52832/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf52dmouse_nrf52832/app_ZDebug.conf index 5d220bc5eb57..e39fca444348 100644 --- a/applications/nrf_desktop/configuration/nrf52dmouse_nrf52832/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf52dmouse_nrf52832/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebug.conf index 396bf786eacd..65f4ddd3531e 100644 --- a/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugB0.conf b/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugB0.conf index 95063d88091b..da72daca555e 100644 --- a/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugB0.conf +++ b/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugB0.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugSplitLL.conf b/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugSplitLL.conf index f7fd3bd104f2..1739458223da 100644 --- a/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugSplitLL.conf +++ b/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugSplitLL.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugWithShell.conf b/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugWithShell.conf index 8fbce35c0d7e..0db4b093a27c 100644 --- a/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugWithShell.conf +++ b/applications/nrf_desktop/configuration/nrf52kbd_nrf52832/app_ZDebugWithShell.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf5340dk_nrf5340_cpuapp/app_ZDebug.conf b/applications/nrf_desktop/configuration/nrf5340dk_nrf5340_cpuapp/app_ZDebug.conf index d5b04eb10084..cbe5b95f3344 100644 --- a/applications/nrf_desktop/configuration/nrf5340dk_nrf5340_cpuapp/app_ZDebug.conf +++ b/applications/nrf_desktop/configuration/nrf5340dk_nrf5340_cpuapp/app_ZDebug.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/configuration/nrf5340dk_nrf5340_cpuapp/app_ZDebugB0.conf b/applications/nrf_desktop/configuration/nrf5340dk_nrf5340_cpuapp/app_ZDebugB0.conf index 2f6ee037a8ec..63d2ce923d4a 100644 --- a/applications/nrf_desktop/configuration/nrf5340dk_nrf5340_cpuapp/app_ZDebugB0.conf +++ b/applications/nrf_desktop/configuration/nrf5340dk_nrf5340_cpuapp/app_ZDebugB0.conf @@ -9,6 +9,7 @@ CONFIG_DESKTOP_INIT_LOG_MOTION_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_EVENT=n CONFIG_DESKTOP_INIT_LOG_HID_REPORT_SENT_EVENT=n +CONFIG_CAF_INIT_LOG_KEEP_ALIVE_EVENTS=n CONFIG_DESKTOP_HID_REPORT_DESC="configuration/common/hid_report_desc.c" diff --git a/applications/nrf_desktop/doc/bas.rst b/applications/nrf_desktop/doc/bas.rst index 79fa9c838c9d..699abf316935 100644 --- a/applications/nrf_desktop/doc/bas.rst +++ b/applications/nrf_desktop/doc/bas.rst @@ -22,8 +22,8 @@ Module events Configuration ************* -The module is enabled with the :option:`CONFIG_DESKTOP_BAS_ENABLE` option. -The option is selected by :option:`CONFIG_DESKTOP_HID_PERIPHERAL` -- Battery Service is required for the HID peripheral device. +The module is enabled with the :kconfig:`CONFIG_DESKTOP_BAS_ENABLE` option. +The option is selected by :kconfig:`CONFIG_DESKTOP_HID_PERIPHERAL` -- Battery Service is required for the HID peripheral device. Implementation details ********************** diff --git a/applications/nrf_desktop/doc/battery_charger.rst b/applications/nrf_desktop/doc/battery_charger.rst index eaaf83583124..5e68f2e52f07 100644 --- a/applications/nrf_desktop/doc/battery_charger.rst +++ b/applications/nrf_desktop/doc/battery_charger.rst @@ -23,22 +23,22 @@ Configuration ************* The module implemented in :file:`battery_charger.c` uses Zephyr's :ref:`zephyr:gpio_api` driver to control and monitor battery charging. -For this reason, you should set :option:`CONFIG_GPIO` option. +For this reason, you should set :kconfig:`CONFIG_GPIO` option. -By default, the module is disabled and the :option:`CONFIG_DESKTOP_BATTERY_CHARGER_NONE` option is selected. -Set the option :option:`CONFIG_DESKTOP_BATTERY_CHARGER_DISCRETE` to enable the module. +By default, the module is disabled and the :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_NONE` option is selected. +Set the option :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_DISCRETE` to enable the module. The following module configuration options are available: -* :option:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_PIN` - Configures the pin to which the charge status output (CSO) from the charger is connected. +* :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_PIN` - Configures the pin to which the charge status output (CSO) from the charger is connected. - * :option:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_PULL_NONE` - CSO pin pull disabled (default setting). - * :option:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_PULL_UP` - CSO pin pull up. - * :option:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_PULL_DOWN` - CSO pin pull down. + * :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_PULL_NONE` - CSO pin pull disabled (default setting). + * :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_PULL_UP` - CSO pin pull up. + * :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_PULL_DOWN` - CSO pin pull down. -* :option:`CONFIG_DESKTOP_BATTERY_CHARGER_ENABLE_PIN` - Configures the pin that enables the battery charging. -* :option:`CONFIG_DESKTOP_BATTERY_CHARGER_ENABLE_INVERSED` - Option for inversing the charging enable signal. -* :option:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_FREQ` - Set this Kconfig option to the CSO pin state switching frequency (in Hz) for when a charging error occurs. +* :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_ENABLE_PIN` - Configures the pin that enables the battery charging. +* :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_ENABLE_INVERSED` - Option for inversing the charging enable signal. +* :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_FREQ` - Set this Kconfig option to the CSO pin state switching frequency (in Hz) for when a charging error occurs. Implementation details ********************** @@ -59,4 +59,4 @@ The battery state can have one of the following values: * :c:enumerator:`BATTERY_STATE_IDLE` - Battery is not being charged (CSO pin set to logical high). * :c:enumerator:`BATTERY_STATE_CHARGING` - Battery is being charged (CSO pin set to logical low). -* :c:enumerator:`BATTERY_STATE_ERROR` - Battery charger reported an error (a signal with the :option:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_FREQ` frequency and a 50% duty cycle on the CSO pin). +* :c:enumerator:`BATTERY_STATE_ERROR` - Battery charger reported an error (a signal with the :kconfig:`CONFIG_DESKTOP_BATTERY_CHARGER_CSO_FREQ` frequency and a 50% duty cycle on the CSO pin). diff --git a/applications/nrf_desktop/doc/battery_meas.rst b/applications/nrf_desktop/doc/battery_meas.rst index 7d08f2c6da9a..31f5562cf2a9 100644 --- a/applications/nrf_desktop/doc/battery_meas.rst +++ b/applications/nrf_desktop/doc/battery_meas.rst @@ -25,18 +25,18 @@ Configuration The |battery_meas| uses Zephyr's :ref:`zephyr:adc_api` driver to measure voltage. For this reason, set the following options: -* :option:`CONFIG_ADC` - The module's implementation uses Zephyr ADC driver. -* :option:`CONFIG_ADC_ASYNC` - The module's implementation uses asynchronous calls. -* :option:`CONFIG_ADC_NRFX_SAADC` - The module's implementation uses nrfx SAADC driver for nRF52 MCU series. +* :kconfig:`CONFIG_ADC` - The module's implementation uses Zephyr ADC driver. +* :kconfig:`CONFIG_ADC_ASYNC` - The module's implementation uses asynchronous calls. +* :kconfig:`CONFIG_ADC_NRFX_SAADC` - The module's implementation uses nrfx SAADC driver for nRF52 MCU series. -Set :option:`CONFIG_DESKTOP_BATTERY_MEAS` to enable the module. -Also, make sure to define :option:`CONFIG_DESKTOP_BATTERY_MEAS_POLL_INTERVAL_MS`, that is the amount of time between the subsequent battery measurements (in ms). +Set :kconfig:`CONFIG_DESKTOP_BATTERY_MEAS` to enable the module. +Also, make sure to define :kconfig:`CONFIG_DESKTOP_BATTERY_MEAS_POLL_INTERVAL_MS`, that is the amount of time between the subsequent battery measurements (in ms). -If the measurement circuit contains a voltage divider made of two resistors, set the :option:`CONFIG_DESKTOP_BATTERY_MEAS_HAS_VOLTAGE_DIVIDER` option. +If the measurement circuit contains a voltage divider made of two resistors, set the :kconfig:`CONFIG_DESKTOP_BATTERY_MEAS_HAS_VOLTAGE_DIVIDER` option. The following defines specify the values of these two resistors (in kOhm): -* :option:`CONFIG_DESKTOP_BATTERY_MEAS_VOLTAGE_DIVIDER_UPPER` - Upper resistor. -* :option:`CONFIG_DESKTOP_BATTERY_MEAS_VOLTAGE_DIVIDER_LOWER` - Lower resistor. +* :kconfig:`CONFIG_DESKTOP_BATTERY_MEAS_VOLTAGE_DIVIDER_UPPER` - Upper resistor. +* :kconfig:`CONFIG_DESKTOP_BATTERY_MEAS_VOLTAGE_DIVIDER_LOWER` - Lower resistor. The module measures the voltage over the lower resistor. @@ -45,14 +45,14 @@ You can find this file the in board-specific directory in the application config Remember to also define the following battery parameters (otherwise, the default values will be used): -* :option:`CONFIG_DESKTOP_BATTERY_MEAS_MIN_LEVEL` - Battery voltage in mV that corresponds to the 0% battery level. -* :option:`CONFIG_DESKTOP_BATTERY_MEAS_MAX_LEVEL` - Battery voltage in mV that corresponds to the 100% battery level. -* :option:`CONFIG_DESKTOP_VOLTAGE_TO_SOC_DELTA` - Difference in mV between the adjacent elements in the conversion lookup table. +* :kconfig:`CONFIG_DESKTOP_BATTERY_MEAS_MIN_LEVEL` - Battery voltage in mV that corresponds to the 0% battery level. +* :kconfig:`CONFIG_DESKTOP_BATTERY_MEAS_MAX_LEVEL` - Battery voltage in mV that corresponds to the 100% battery level. +* :kconfig:`CONFIG_DESKTOP_VOLTAGE_TO_SOC_DELTA` - Difference in mV between the adjacent elements in the conversion lookup table. -If a pin is used to enable the battery measurement, enable the :option:`CONFIG_DESKTOP_BATTERY_MEAS_HAS_ENABLE_PIN` option. -The number of the pin used for this purpose must be defined as :option:`CONFIG_DESKTOP_BATTERY_MEAS_ENABLE_PIN`. +If a pin is used to enable the battery measurement, enable the :kconfig:`CONFIG_DESKTOP_BATTERY_MEAS_HAS_ENABLE_PIN` option. +The number of the pin used for this purpose must be defined as :kconfig:`CONFIG_DESKTOP_BATTERY_MEAS_ENABLE_PIN`. The implementation uses the ``GPIO0`` port. -Because Zephyr's :ref:`zephyr:gpio_api` driver is used to control this pin, also set the :option:`CONFIG_GPIO` option. +Because Zephyr's :ref:`zephyr:gpio_api` driver is used to control this pin, also set the :kconfig:`CONFIG_GPIO` option. Implementation details ********************** diff --git a/applications/nrf_desktop/doc/ble_adv.rst b/applications/nrf_desktop/doc/ble_adv.rst index dc258db29a4d..106a6e8033e5 100644 --- a/applications/nrf_desktop/doc/ble_adv.rst +++ b/applications/nrf_desktop/doc/ble_adv.rst @@ -31,10 +31,10 @@ Avoiding connection requests from unbonded centrals when bonded =============================================================== If the Bluetooth local identity currently in use already has a bond and the nRF Desktop device uses indirect advertising, the device will not set the General Discoverable flag. -The nRF desktop devices also enable :option:`CONFIG_BT_WHITELIST` to whitelist incoming scan response data requests and connection requests. +The nRF desktop devices also enable :kconfig:`CONFIG_BT_WHITELIST` to whitelist incoming scan response data requests and connection requests. This is done to prevent Bluetooth Centrals other than the bonded one from connecting with the device. The nRF Desktop dongle scans for peripheral devices using the Bluetooth device name, which is provided in the scan response data. -.. |ble_adv| replace:: Bluetooth LE advertising module +.. |ble_adv| replace:: Bluetooth® LE advertising module diff --git a/applications/nrf_desktop/doc/ble_bond.rst b/applications/nrf_desktop/doc/ble_bond.rst index d2a021648c8f..90455711c341 100644 --- a/applications/nrf_desktop/doc/ble_bond.rst +++ b/applications/nrf_desktop/doc/ble_bond.rst @@ -109,7 +109,7 @@ The application local identity still uses the Bluetooth local identity that was The erase advertising timeout can be extended in case a new peer connects. This ensures that a new peer will have time to establish the Bluetooth security level. - The timeout is increased to a bigger value when the passkey authentication is enabled (:option:`CONFIG_DESKTOP_BLE_ENABLE_PASSKEY`). + The timeout is increased to a bigger value when the passkey authentication is enabled (:kconfig:`CONFIG_DESKTOP_BLE_ENABLE_PASSKEY`). This gives the end user enough time to enter the passkey. Standby states @@ -146,17 +146,17 @@ Peer control using a button Complete the following steps to let the user control Bluetooth peers using the dedicated button: -1. Set the :option:`CONFIG_DESKTOP_BLE_PEER_CONTROL` option to enable the feature. +1. Set the :kconfig:`CONFIG_DESKTOP_BLE_PEER_CONTROL` option to enable the feature. #. Configure the :ref:`caf_buttons`. -#. Define the button's key ID as :option:`CONFIG_DESKTOP_BLE_PEER_CONTROL_BUTTON`. +#. Define the button's key ID as :kconfig:`CONFIG_DESKTOP_BLE_PEER_CONTROL_BUTTON`. #. Add the button to the :ref:`nrf_desktop_click_detector` configuration, because the |ble_bond| reacts on ``click_event``. The following peer operations can be enabled: -* :option:`CONFIG_DESKTOP_BLE_PEER_ERASE` - Bluetooth LE peer erase triggered at any time. -* :option:`CONFIG_DESKTOP_BLE_PEER_ERASE_ON_START` - Erase advertising triggered by long press of the predefined button on system start. +* :kconfig:`CONFIG_DESKTOP_BLE_PEER_ERASE` - Bluetooth LE peer erase triggered at any time. +* :kconfig:`CONFIG_DESKTOP_BLE_PEER_ERASE_ON_START` - Erase advertising triggered by long press of the predefined button on system start. This option can be used only by nRF Desktop peripheral. -* :option:`CONFIG_DESKTOP_BLE_PEER_SELECT` - Select Bluetooth LE peer. +* :kconfig:`CONFIG_DESKTOP_BLE_PEER_SELECT` - Select Bluetooth LE peer. This option can be used only by nRF Desktop peripheral. * ``CONFIG_DESKTOP0_BLE_NEW_PEER_SCAN_REQUEST`` - Scan for new Bluetooth peers. This option can be used only by nRF Desktop central. @@ -167,7 +167,7 @@ Peer control using a hardware selector .. note:: This feature can be used only by nRF Desktop peripheral devices. -Set the :option:`CONFIG_DESKTOP_BLE_DONGLE_PEER_ENABLE` option to use the dedicated local identity to connect with the dongle. +Set the :kconfig:`CONFIG_DESKTOP_BLE_DONGLE_PEER_ENABLE` option to use the dedicated local identity to connect with the dongle. The last application local identity (the one with the highest ID) is used for this purpose. The dongle is the nRF Desktop central. @@ -177,8 +177,8 @@ This local identity is meant to be paired with the dongle during the production The dongle peer is selected using the :ref:`nrf_desktop_selector`. You must also define the following parameters of the selector used to switch between dongle peer and other Bluetooth LE peers: -* :option:`CONFIG_DESKTOP_BLE_DONGLE_PEER_SELECTOR_ID` - Selector ID. -* :option:`CONFIG_DESKTOP_BLE_DONGLE_PEER_SELECTOR_POS` - Selector position for the dongle peer (when selector is in other position, other Bluetooth peers are selected). +* :kconfig:`CONFIG_DESKTOP_BLE_DONGLE_PEER_SELECTOR_ID` - Selector ID. +* :kconfig:`CONFIG_DESKTOP_BLE_DONGLE_PEER_SELECTOR_POS` - Selector position for the dongle peer (when selector is in other position, other Bluetooth peers are selected). .. note:: The Bluetooth local identity used for the dongle peer does not provide any special capabilities. @@ -191,7 +191,7 @@ Default Bluetooth local identity on peripheral ============================================== By default, the default Bluetooth local identity is unused, because it cannot be reset. -You can set :option:`CONFIG_DESKTOP_BLE_USE_DEFAULT_ID` to make the nRF Desktop peripheral initially use the default Bluetooth local identity for the application local identity with ID ``0``. +You can set :kconfig:`CONFIG_DESKTOP_BLE_USE_DEFAULT_ID` to make the nRF Desktop peripheral initially use the default Bluetooth local identity for the application local identity with ID ``0``. After the successful erase advertising for application local identity with ID ``0``, the default Bluetooth local identity is switched out and it is no longer used. The peer bonded with the default Bluetooth local identity is unpaired. @@ -235,4 +235,4 @@ The module uses Zephyr's :ref:`zephyr:settings_api` subsystem to store the follo * Currently selected peer (application local identity) * Mapping between the application local identities and the Bluetooth local identities -.. |ble_bond| replace:: Bluetooth LE bond module +.. |ble_bond| replace:: Bluetooth® LE bond module diff --git a/applications/nrf_desktop/doc/ble_conn_params.rst b/applications/nrf_desktop/doc/ble_conn_params.rst index f5a710df19e8..1789f27c4cd2 100644 --- a/applications/nrf_desktop/doc/ble_conn_params.rst +++ b/applications/nrf_desktop/doc/ble_conn_params.rst @@ -26,7 +26,7 @@ Configuration ************* The module requires the basic Bluetooth configuration, as described in :ref:`nrf_desktop_bluetooth_guide`. -The module is automatically enabled for every nRF Desktop central device (:option:`CONFIG_BT_CENTRAL`). +The module is automatically enabled for every nRF Desktop central device (:kconfig:`CONFIG_BT_CENTRAL`). Implementation details ********************** @@ -43,8 +43,8 @@ LLPM connections The Low Latency Packet Mode (LLPM) connection parameters are not supported by the standard Bluetooth. -The LLPM connection parameters update requires using Vendor Sprecific HCI commands. -Moreover, the peripheral cannot request the LLPM connection parameters using Zephyr Bluetooth API. +The LLPM connection parameters update requires using vendor-specific HCI commands. +Moreover, the peripheral cannot request the LLPM connection parameters using Zephyr Bluetooth® API. Connection interval update ========================== @@ -54,9 +54,9 @@ After the :ref:`nrf_desktop_ble_discovery` completes the peripheral discovery, t * If the central and the connected peripheral both support the Low Latency Packet Mode (LLPM), the connection interval is set to **1 ms**. * If neither the central nor the connected peripheral support LLPM, or if only one of them supports it, the interval is set to the following values: - * **7.5 ms** if LLPM is not supported by the central or :option:`CONFIG_BT_MAX_CONN` is set to value 2 or lower. + * **7.5 ms** if LLPM is not supported by the central or :kconfig:`CONFIG_BT_MAX_CONN` is set to value 2 or lower. This is the shortest interval allowed by the standard Bluetooth. * **10 ms** otherwise. This is required to avoid Bluetooth Link Layer scheduling conflicts that could lead to HID report rate drop. -.. |ble_conn_params| replace:: Bluetooth LE connection parameters module +.. |ble_conn_params| replace:: Bluetooth® LE connection parameters module diff --git a/applications/nrf_desktop/doc/ble_discovery.rst b/applications/nrf_desktop/doc/ble_discovery.rst index a1910a4d08fd..dd198e7ef115 100644 --- a/applications/nrf_desktop/doc/ble_discovery.rst +++ b/applications/nrf_desktop/doc/ble_discovery.rst @@ -26,8 +26,8 @@ Configuration Complete the following steps to configure the module: 1. Complete the basic Bluetooth configuration, as described in :ref:`nrf_desktop_bluetooth_guide`. -#. Set the :option:`CONFIG_BT_GATT_CLIENT` Kconfig option to enable support for the GATT Client role. -#. Set the :option:`CONFIG_BT_GATT_DM` Kconfig option to enable the :ref:`gatt_dm_readme`. +#. Set the :kconfig:`CONFIG_BT_GATT_CLIENT` Kconfig option to enable support for the GATT Client role. +#. Set the :kconfig:`CONFIG_BT_GATT_DM` Kconfig option to enable the :ref:`gatt_dm_readme`. The :ref:`gatt_dm_readme` is used by the ``ble_discovery`` application module. #. Define the module configuration in the :file:`ble_discovery_def.h` file, located in the board-specific directory in the application configuration directory. You must define the following parameters for every nRF Desktop peripheral that connects with the given nRF Desktop central: @@ -49,7 +49,7 @@ Complete the following steps to configure the module: The assigned PIDs should be unique for devices with the same VID. -#. Set the :option:`CONFIG_DESKTOP_BLE_DISCOVERY_ENABLE` Kconfig option to enable the ``ble_discovery`` application module. +#. Set the :kconfig:`CONFIG_DESKTOP_BLE_DISCOVERY_ENABLE` Kconfig option to enable the ``ble_discovery`` application module. Implementation details ********************** @@ -88,4 +88,4 @@ The same actions are taken if the peripheral's VID and PID value combination is The nRF Desktop central works only with predefined subset of peripherals. The mentioned peripherals must be described in the :file:`ble_discovery_def.h` file. -.. |ble_discovery| replace:: Bluetooth LE discovery module +.. |ble_discovery| replace:: Bluetooth® LE discovery module diff --git a/applications/nrf_desktop/doc/ble_latency.rst b/applications/nrf_desktop/doc/ble_latency.rst index eb21f34cfb16..28ac045bf12b 100644 --- a/applications/nrf_desktop/doc/ble_latency.rst +++ b/applications/nrf_desktop/doc/ble_latency.rst @@ -30,10 +30,10 @@ Configuration The module requires the basic Bluetooth configuration, as described in :ref:`nrf_desktop_bluetooth_guide`. The module is enabled for every nRF Desktop peripheral device. -You can use the option :option:`CONFIG_DESKTOP_BLE_SECURITY_FAIL_TIMEOUT_S` to define the maximum allowed time for establishing the connection security. +You can use the option :kconfig:`CONFIG_DESKTOP_BLE_SECURITY_FAIL_TIMEOUT_S` to define the maximum allowed time for establishing the connection security. If the connection is not secured during this period of time, the peripheral device disconnects. -You can set the option :option:`CONFIG_DESKTOP_BLE_LOW_LATENCY_LOCK` to keep the connection latency low for the LLPM connections. +You can set the option :kconfig:`CONFIG_DESKTOP_BLE_LOW_LATENCY_LOCK` to keep the connection latency low for the LLPM connections. This speeds up sending the first HID report after not sending a report for some connection intervals. Enabling this option increases the power consumption - the connection latency is kept low unless the device is in the low power mode. @@ -52,10 +52,10 @@ The module listens for the following events related to data transfer initiated b * ``ble_smp_transfer_event`` - This event is received when the firmware update is received by :ref:`nrf_desktop_ble_smp`. When these events are received, the module sets the connection latency to low. -When the :ref:`nrf_desktop_config_channel` is no longer in use and firmware update is not received by :ref:`nrf_desktop_ble_smp` (no mentioned events for ``LOW_LATENCY_CHECK_PERIOD_MS``), the module sets the connection latency to :option:`CONFIG_BT_PERIPHERAL_PREF_SLAVE_LATENCY` to reduce the power consumption. +When the :ref:`nrf_desktop_config_channel` is no longer in use and firmware update is not received by :ref:`nrf_desktop_ble_smp` (no mentioned events for ``LOW_LATENCY_CHECK_PERIOD_MS``), the module sets the connection latency to :kconfig:`CONFIG_BT_PERIPHERAL_PREF_SLAVE_LATENCY` to reduce the power consumption. .. note:: - If the option :option:`CONFIG_DESKTOP_BLE_LOW_LATENCY_LOCK` is enabled, the LLPM connection latency is not increased unless the device is in the low power mode. + If the option :kconfig:`CONFIG_DESKTOP_BLE_LOW_LATENCY_LOCK` is enabled, the LLPM connection latency is not increased unless the device is in the low power mode. When the device is in the low power mode and the events related to data transfer are not received, the connection latency is set to higher value to reduce the power consumption. @@ -71,4 +71,4 @@ The module does not register itself using the ``GEN_CONFIG_EVENT_HANDLERS`` macr For more detailed information, see the :ref:`nrf_desktop_ble_conn_params` documentation page. -.. |ble_latency| replace:: Bluetooth LE latency module +.. |ble_latency| replace:: Bluetooth® LE latency module diff --git a/applications/nrf_desktop/doc/ble_passkey.rst b/applications/nrf_desktop/doc/ble_passkey.rst index e60c29cafb20..d18001beca7d 100644 --- a/applications/nrf_desktop/doc/ble_passkey.rst +++ b/applications/nrf_desktop/doc/ble_passkey.rst @@ -23,9 +23,9 @@ Configuration ************* The module requires the basic Bluetooth configuration, as described in :ref:`nrf_desktop_bluetooth_guide`. -The module can be used only for Bluetooth Peripheral devices (:option:`CONFIG_BT_PERIPHERAL`). +The module can be used only for Bluetooth Peripheral devices (:kconfig:`CONFIG_BT_PERIPHERAL`). -Use the option :option:`CONFIG_DESKTOP_BLE_ENABLE_PASSKEY` to enable the module. +Use the option :kconfig:`CONFIG_DESKTOP_BLE_ENABLE_PASSKEY` to enable the module. Make sure to enable and configure the :ref:`nrf_desktop_passkey` if you decide to use this option. Implementation details @@ -43,4 +43,4 @@ The passkey input is handled in the :ref:`nrf_desktop_passkey`. .. note:: By default, Zephyr's Bluetooth Peripheral demands the security level 3 in case the passkey authentication is enabled. If the nRF Desktop dongle is unable to achieve the security level 3, it will be unable to connect with the peripheral. - Disable the :option:`CONFIG_BT_SMP_ENFORCE_MITM` option to allow the dongle to connect without the authentication. + Disable the :kconfig:`CONFIG_BT_SMP_ENFORCE_MITM` option to allow the dongle to connect without the authentication. diff --git a/applications/nrf_desktop/doc/ble_qos.rst b/applications/nrf_desktop/doc/ble_qos.rst index e7e9fe7f8231..a79c978e3e0b 100644 --- a/applications/nrf_desktop/doc/ble_qos.rst +++ b/applications/nrf_desktop/doc/ble_qos.rst @@ -7,8 +7,8 @@ Bluetooth LE Quality of Service module :local: :depth: 2 -Use the Bluetooth LE Quality of Service (QoS) module to achieve better connection quality and higher report rate by avoiding congested RF channels. -The module can be used by both nRF Desktop peripheral and nRF Desktop central with the SoftDevice Link Layer (:option:`CONFIG_BT_LL_SOFTDEVICE`). +Use the Bluetooth® LE Quality of Service (QoS) module to achieve better connection quality and higher report rate by avoiding congested RF channels. +The module can be used by both nRF Desktop peripheral and nRF Desktop central with the SoftDevice Link Layer (:kconfig:`CONFIG_BT_LL_SOFTDEVICE`). However, only the Bluetooth central can update the Bluetooth LE channel map that is in use. Module events @@ -27,27 +27,27 @@ Configuration The module requires the basic Bluetooth configuration, as described in :ref:`nrf_desktop_bluetooth_guide`. The QoS module uses the ``chmap_filter`` library, whose API is described in :file:`src/util/chmap_filter/include/chmap_filter.h`. -The library is linked if :option:`CONFIG_DESKTOP_BLE_QOS_ENABLE` Kconfig option is enabled. +The library is linked if :kconfig:`CONFIG_DESKTOP_BLE_QOS_ENABLE` Kconfig option is enabled. -Enable the module using the :option:`CONFIG_DESKTOP_BLE_QOS_ENABLE` Kconfig option. -The option selects :option:`CONFIG_BT_HCI_VS_EVT_USER`, because the module uses vendor-specific HCI events. +Enable the module using the :kconfig:`CONFIG_DESKTOP_BLE_QOS_ENABLE` Kconfig option. +The option selects :kconfig:`CONFIG_BT_HCI_VS_EVT_USER`, because the module uses vendor-specific HCI events. -You can use the :option:`CONFIG_DESKTOP_BLE_QOS_STATS_PRINTOUT_ENABLE` option to enable real-time QoS information printouts through a virtual COM port (serial port emulated over USB). +You can use the :kconfig:`CONFIG_DESKTOP_BLE_QOS_STATS_PRINTOUT_ENABLE` option to enable real-time QoS information printouts through a virtual COM port (serial port emulated over USB). This option also enables and configures the COM port (USB CDC ACM). -For this reason, the :option:`CONFIG_USB` must be enabled. +For this reason, the :kconfig:`CONFIG_USB` must be enabled. The QoS module creates additional thread for processing the QoS algorithm. You can define the following options: -* :option:`CONFIG_DESKTOP_BLE_QOS_INTERVAL` +* :kconfig:`CONFIG_DESKTOP_BLE_QOS_INTERVAL` This option specifies the amount of time of the processing interval for the QoS thread. The interval is defined in milliseconds. The thread periodically performs calculations and then sleeps during the interval. Longer intervals give more time to accumulate the Cyclic Redundancy Check (CRC) stats. -* :option:`CONFIG_DESKTOP_BLE_QOS_STACK_SIZE` +* :kconfig:`CONFIG_DESKTOP_BLE_QOS_STACK_SIZE` This option defines the base stack size for the QoS thread. -* :option:`CONFIG_DESKTOP_BLE_QOS_STATS_PRINT_STACK_SIZE` - This option specifies the stack size increase if :option:`CONFIG_DESKTOP_BLE_QOS_STATS_PRINTOUT_ENABLE` is enabled. +* :kconfig:`CONFIG_DESKTOP_BLE_QOS_STATS_PRINT_STACK_SIZE` + This option specifies the stack size increase if :kconfig:`CONFIG_DESKTOP_BLE_QOS_STATS_PRINTOUT_ENABLE` is enabled. .. tip:: You can use the default thread stack sizes as long as you do not modify the module source code. @@ -123,7 +123,7 @@ The thread is used to periodically perform the following operations: * Submit the suggested channel map as ``ble_qos_event``. * If the device is a Bluetooth central, update the used Bluetooth LE channel map. -If the :option:`CONFIG_DESKTOP_BLE_QOS_STATS_PRINTOUT_ENABLE` Kconfig option is set, the module prints the following information through the virtual COM port: +If the :kconfig:`CONFIG_DESKTOP_BLE_QOS_STATS_PRINTOUT_ENABLE` Kconfig option is set, the module prints the following information through the virtual COM port: * HID report rate The module counts the number of HID input reports received via Bluetoooth LE and prints the report rate through the virtual COM port every 100 packets. diff --git a/applications/nrf_desktop/doc/ble_scan.rst b/applications/nrf_desktop/doc/ble_scan.rst index 2f83a3364967..32728abf5595 100644 --- a/applications/nrf_desktop/doc/ble_scan.rst +++ b/applications/nrf_desktop/doc/ble_scan.rst @@ -35,26 +35,26 @@ Complete the following steps to enable the |ble_scan|: 1. Configure Bluetooth, as described in :ref:`nrf_desktop_bluetooth_guide`. #. Enable the following configuration options: - * :option:`CONFIG_BT_SCAN` - * :option:`CONFIG_BT_SCAN_FILTER_ENABLE` + * :kconfig:`CONFIG_BT_SCAN` + * :kconfig:`CONFIG_BT_SCAN_FILTER_ENABLE` These options are used by the |NCS|'s :ref:`nrf_bt_scan_readme`. -#. Configure the number of scan filters based on the Bluetooth address (:option:`CONFIG_BT_SCAN_ADDRESS_CNT`). +#. Configure the number of scan filters based on the Bluetooth address (:kconfig:`CONFIG_BT_SCAN_ADDRESS_CNT`). The value must be equal to the number of Bluetooth bonds. - The number of Bluetooth bonds is defined by the :option:`CONFIG_BT_MAX_PAIRED` Kconfig option. + The number of Bluetooth bonds is defined by the :kconfig:`CONFIG_BT_MAX_PAIRED` Kconfig option. The |ble_scan| module uses the Bluetooth address filters to look for bonded peripherals. -#. Configure the number of scan filters based on the Bluetooth name (:option:`CONFIG_BT_SCAN_NAME_CNT`). +#. Configure the number of scan filters based on the Bluetooth name (:kconfig:`CONFIG_BT_SCAN_NAME_CNT`). The |ble_scan| module uses Bluetooth name filters to look for unbonded peripherals. The value must be equal to the number of peripheral types the nRF Desktop central connects to. The peripheral type may be either a mouse or a keyboard. -#. If you want to limit the number of attempts to connect to a device, you can enable the connection attempt filter with the :option:`CONFIG_BT_SCAN_CONN_ATTEMPTS_FILTER` Kconfig option. +#. If you want to limit the number of attempts to connect to a device, you can enable the connection attempt filter with the :kconfig:`CONFIG_BT_SCAN_CONN_ATTEMPTS_FILTER` Kconfig option. After the predefined number of disconnections or connection failures, the nRF Desktop central will no longer try to connect with the given peripheral device. This is done to prevent connecting and disconnecting with a peripheral in a never-ending loop. You can further configure this setting with the following Kconfig options: - * :option:`CONFIG_BT_SCAN_CONN_ATTEMPTS_FILTER_LEN` - This option defines the maximum number of filtered devices. - * :option:`CONFIG_BT_SCAN_CONN_ATTEMPTS_COUNT` - This option defines the connection attempt count for a given peripheral. + * :kconfig:`CONFIG_BT_SCAN_CONN_ATTEMPTS_FILTER_LEN` - This option defines the maximum number of filtered devices. + * :kconfig:`CONFIG_BT_SCAN_CONN_ATTEMPTS_COUNT` - This option defines the connection attempt count for a given peripheral. The :ref:`nrf_bt_scan_readme` counts all disconnections for a peripheral. The |ble_scan| uses :c:func:`bt_scan_conn_attempts_filter_clear` to clear all the connection attempt counters on the following occasions: @@ -63,30 +63,30 @@ Complete the following steps to enable the |ble_scan|: * When you request scan start or peer erase. If filters are not cleared by the application, the Bluetooth Central will be unable to reconnect to the peripheral after exceeding the maximum connection attempts. -#. Configure the maximum number of bonded mice (:option:`CONFIG_DESKTOP_BLE_SCAN_MOUSE_LIMIT`) and keyboards (:option:`CONFIG_DESKTOP_BLE_SCAN_KEYBOARD_LIMIT`) for the nRF Desktop central. +#. Configure the maximum number of bonded mice (:kconfig:`CONFIG_DESKTOP_BLE_SCAN_MOUSE_LIMIT`) and keyboards (:kconfig:`CONFIG_DESKTOP_BLE_SCAN_KEYBOARD_LIMIT`) for the nRF Desktop central. By default, the nRF Desktop central connects and bonds with only one mouse and one keyboard. #. Define the Bluetooth name filters in the :file:`ble_scan_def.h` file that is located in the board-specific directory in the application configuration directory. You must define a Bluetooth name filter for every peripheral type the nRF Desktop central connects to. For an example, see :file:`configuration/nrf52840dongle_nrf52840/ble_scan_def.h`. .. note:: - The Bluetooth device name for given peripheral is defined as the :option:`CONFIG_BT_DEVICE_NAME` Kconfig option in the peripheral's configuration. + The Bluetooth device name for given peripheral is defined as the :kconfig:`CONFIG_BT_DEVICE_NAME` Kconfig option in the peripheral's configuration. For more detailed information about the Bluetooth advertising configuration in the nRF Desktop application, see the :ref:`nrf_desktop_ble_adv` documentation. -#. Set the :option:`CONFIG_DESKTOP_BLE_SCANNING_ENABLE` option to enable the |ble_scan| module. +#. Set the :kconfig:`CONFIG_DESKTOP_BLE_SCANNING_ENABLE` option to enable the |ble_scan| module. By default, the nRF Desktop central always looks for both bonded and unbonded peripherals. -You can set the :option:`CONFIG_DESKTOP_BLE_NEW_PEER_SCAN_REQUEST` option to make the device look for unbonded peripherals only on user request. +You can set the :kconfig:`CONFIG_DESKTOP_BLE_NEW_PEER_SCAN_REQUEST` option to make the device look for unbonded peripherals only on user request. The request is submitted by :ref:`nrf_desktop_ble_bond` as :c:struct:`ble_peer_operation_event` with :c:member:`ble_peer_operation_event.op` set to :c:enumerator:`PEER_OPERATION_SCAN_REQUEST`. The central always looks for new bonds also after the bond erase (on :c:struct:`ble_peer_operation_event` with :c:member:`ble_peer_operation_event.op` set to :c:enumerator:`PEER_OPERATION_ERASED`). -If :option:`CONFIG_DESKTOP_BLE_NEW_PEER_SCAN_REQUEST` is enabled, you can also set the :option:`CONFIG_DESKTOP_BLE_NEW_PEER_SCAN_ON_BOOT` option to make the central scan for new peers after every boot. +If :kconfig:`CONFIG_DESKTOP_BLE_NEW_PEER_SCAN_REQUEST` is enabled, you can also set the :kconfig:`CONFIG_DESKTOP_BLE_NEW_PEER_SCAN_ON_BOOT` option to make the central scan for new peers after every boot. The following scanning scenarios are possible: * If no peripheral is connected, the central scans for the peripheral devices without interruption. * If a peripheral is connected, the scanning is triggered periodically. - If none of the connected peripherals is in use for at least :option:`CONFIG_DESKTOP_BLE_SCAN_START_TIMEOUT_S`, the scanning is started. + If none of the connected peripherals is in use for at least :kconfig:`CONFIG_DESKTOP_BLE_SCAN_START_TIMEOUT_S`, the scanning is started. Scanning not started ==================== @@ -97,7 +97,7 @@ The scanning will not start if one of the following conditions occurs: * The :ref:`nrf_desktop_ble_discovery` is in the process of discovering a peer. * The central is going to scan only for bonded peers and all the bonded peers are already connected. -The number of Bluetooth connections is defined as the :option:`CONFIG_BT_MAX_CONN` Kconfig option. +The number of Bluetooth connections is defined as the :kconfig:`CONFIG_BT_MAX_CONN` Kconfig option. Scanning interrupted ==================== @@ -106,7 +106,7 @@ The scanning is interrupted if one of the following conditions occurs: * A connected peripheral is in use. Scanning in this situation will have a negative impact on user experience. -* The maximum scan duration specified by :option:`CONFIG_DESKTOP_BLE_SCAN_DURATION_S` times out. +* The maximum scan duration specified by :kconfig:`CONFIG_DESKTOP_BLE_SCAN_DURATION_S` times out. The scanning is never interrupted if there is no connected Bluetooth peer. @@ -135,9 +135,9 @@ a. The scanning is stopped and the |NCS|'s :ref:`nrf_bt_scan_readme` automatical .. important:: If a Bluetooth peer is aready connected with a 1-ms connection interval, the next peer is connected with a 10-ms connection interval instead of 7.5 ms. - The peer is connected with a 10-ms connection interval also in case :option:`CONFIG_BT_MAX_CONN` is set to value greater than 2 and :option:`CONFIG_CAF_BLE_USE_LLPM` Kconfig option is enabled. + The peer is connected with a 10-ms connection interval also in case :kconfig:`CONFIG_BT_MAX_CONN` is set to value greater than 2 and :kconfig:`CONFIG_CAF_BLE_USE_LLPM` Kconfig option is enabled. This is required to avoid Bluetooth scheduling issues that may lead to HID input report rate drops and disconnections. At this point, the scanning can be restarted. -.. |ble_scan| replace:: Bluetooth LE scanning module +.. |ble_scan| replace:: Bluetooth® LE scanning module diff --git a/applications/nrf_desktop/doc/ble_state.rst b/applications/nrf_desktop/doc/ble_state.rst index 67f8aaa3aafb..9144a88713cf 100644 --- a/applications/nrf_desktop/doc/ble_state.rst +++ b/applications/nrf_desktop/doc/ble_state.rst @@ -7,7 +7,7 @@ Bluetooth LE state module :local: :depth: 2 -In nRF Desktop, the Bluetooth LE state module is responsible for the following actions: +In nRF Desktop, the Bluetooth® LE state module is responsible for the following actions: * Enabling Bluetooth (:c:func:`bt_enable`). * Handling Zephyr connection callbacks (:c:struct:`bt_conn_cb`). diff --git a/applications/nrf_desktop/doc/board.rst b/applications/nrf_desktop/doc/board.rst index 39c89ab69da5..ed8f39a4e4f9 100644 --- a/applications/nrf_desktop/doc/board.rst +++ b/applications/nrf_desktop/doc/board.rst @@ -24,7 +24,7 @@ Configuration ************* The module uses Zephyr's :ref:`zephyr:gpio_api` driver to set the pin state. -For this reason, set the :option:`CONFIG_GPIO` option. +For this reason, set the :kconfig:`CONFIG_GPIO` option. For every configuration, you must define the :file:`port_state_def.h` file in the board-specific directory in the application configuration directory. diff --git a/applications/nrf_desktop/doc/buttons_sim.rst b/applications/nrf_desktop/doc/buttons_sim.rst index b0535db3cac6..d007d6431cf6 100644 --- a/applications/nrf_desktop/doc/buttons_sim.rst +++ b/applications/nrf_desktop/doc/buttons_sim.rst @@ -28,13 +28,13 @@ To configure the |button_sim|: 1. Enable and configure the :ref:`caf_buttons`. ``button_event`` is used to trigger the simulated button sequence. -#. Enable the ``buttons_sim`` module by setting the :option:`CONFIG_DESKTOP_BUTTONS_SIM_ENABLE` Kconfig option. +#. Enable the ``buttons_sim`` module by setting the :kconfig:`CONFIG_DESKTOP_BUTTONS_SIM_ENABLE` Kconfig option. #. Define the output key ID sequence in the :file:`buttons_sim_def.h` file located in the board-specific directory in the :file:`configuration` directory. The mapping from the defined key ID to the HID report ID and usage ID is defined in :file:`hid_keymap_def.h` (this might be different for different boards). -#. Define the interval between subsequent simulated button presses (:option:`CONFIG_DESKTOP_BUTTONS_SIM_INTERVAL`). +#. Define the interval between subsequent simulated button presses (:kconfig:`CONFIG_DESKTOP_BUTTONS_SIM_INTERVAL`). One second is used by default. -If you want the sequence to automatically restart after it ends, set :option:`CONFIG_DESKTOP_BUTTONS_SIM_LOOP_FOREVER`. +If you want the sequence to automatically restart after it ends, set :kconfig:`CONFIG_DESKTOP_BUTTONS_SIM_LOOP_FOREVER`. By default, the sequence is generated only once. Implementation details @@ -43,6 +43,6 @@ Implementation details The |button_sim| generates button sequence using :c:struct:`k_work_delayable`, which resubmits itself. The work handler submits the press and the release of a single button from the sequence. -Receiving ``button_event`` with the key ID set to :option:`CONFIG_DESKTOP_BUTTONS_SIM_TRIGGER_KEY_ID` either stops generating the sequence (in case it is already being generated) or starts generating it. +Receiving ``button_event`` with the key ID set to :kconfig:`CONFIG_DESKTOP_BUTTONS_SIM_TRIGGER_KEY_ID` either stops generating the sequence (in case it is already being generated) or starts generating it. .. |button_sim| replace:: button simulator module diff --git a/applications/nrf_desktop/doc/config_channel.rst b/applications/nrf_desktop/doc/config_channel.rst index 454cc15e5b58..855a138ff080 100644 --- a/applications/nrf_desktop/doc/config_channel.rst +++ b/applications/nrf_desktop/doc/config_channel.rst @@ -22,7 +22,7 @@ Behavior The HID feature reports are used for transporting information between the host and the connected embedded device. The cross-platform `HIDAPI library`_ is used for exchanging the reports. -The library supports both Bluetooth LE and USB. +The library supports both Bluetooth® Low Energy and USB. The host computer can set configuration values of the embedded device. It can also request fetching a value, for example in order to display it to the user. @@ -46,7 +46,7 @@ Fetching a configuration value Host<` where either :option:`CONFIG_DESKTOP_MOTION_SENSOR_PMW3360_ENABLE` or :option:`CONFIG_DESKTOP_MOTION_SENSOR_PAW3212_ENABLE` is used, you can configure the module through the :ref:`nrf_desktop_config_channel`. +In a :ref:`configuration ` where either :kconfig:`CONFIG_DESKTOP_MOTION_SENSOR_PMW3360_ENABLE` or :kconfig:`CONFIG_DESKTOP_MOTION_SENSOR_PAW3212_ENABLE` is used, you can configure the module through the :ref:`nrf_desktop_config_channel`. In these configurations, the module is a configuration channel listener and it provides the following configuration options: * :c:macro:`OPT_DESCR_MODULE_VARIANT` @@ -145,5 +145,5 @@ Upon connection, the following happens: #. At that point, a next motion sampling is performed and the next ``motion_event`` sent. The module continues to sample data until disconnection or when there is no motion detected. -The ``motion`` module assumes no motion when a number of consecutive samples equal to :option:`CONFIG_DESKTOP_MOTION_SENSOR_EMPTY_SAMPLES_COUNT` returns zero on both axis. +The ``motion`` module assumes no motion when a number of consecutive samples equal to :kconfig:`CONFIG_DESKTOP_MOTION_SENSOR_EMPTY_SAMPLES_COUNT` returns zero on both axis. In such case, the module will switch back to ``STATE_IDLE`` and wait for the motion sensor trigger. diff --git a/applications/nrf_desktop/doc/passkey.rst b/applications/nrf_desktop/doc/passkey.rst index ff6338c81c78..c4e4c94c665e 100644 --- a/applications/nrf_desktop/doc/passkey.rst +++ b/applications/nrf_desktop/doc/passkey.rst @@ -28,8 +28,8 @@ The passkey input handling is based on ``button_event``. To configure the passkey module, complete the following steps: 1. Enable and configure the :ref:`caf_buttons`. -#. Enable the passkey module by using the :option:`CONFIG_DESKTOP_PASSKEY_BUTTONS` Kconfig option. -#. Define the maximum number of digits in the passkey by using :option:`CONFIG_DESKTOP_PASSKEY_MAX_LEN` option. +#. Enable the passkey module by using the :kconfig:`CONFIG_DESKTOP_PASSKEY_BUTTONS` Kconfig option. +#. Define the maximum number of digits in the passkey by using :kconfig:`CONFIG_DESKTOP_PASSKEY_MAX_LEN` option. #. Define the IDs of the keys used by the passkey module in the :file:`passkey_buttons_def.h` file located in the board-specific directory in the :file:`configuration` directory. You must define the IDs of the following keys: diff --git a/applications/nrf_desktop/doc/profiler_sync.rst b/applications/nrf_desktop/doc/profiler_sync.rst index 8b236f36fd3d..7c8fe3f43c91 100644 --- a/applications/nrf_desktop/doc/profiler_sync.rst +++ b/applications/nrf_desktop/doc/profiler_sync.rst @@ -28,18 +28,18 @@ Configuration ************* A predefined signal on the GPIO is used to simultaneously generate synchronization profiler events on both devices. -For this reason, you must enable the :option:`CONFIG_GPIO` option. +For this reason, you must enable the :kconfig:`CONFIG_GPIO` option. -Make also sure that the :option:`CONFIG_EVENT_MANAGER_PROFILER_ENABLED` Kconfig option is enabled and the :option:`CONFIG_EVENT_MANAGER_TRACE_EVENT_EXECUTION` Kconfig option is disabled. +Make also sure that the :kconfig:`CONFIG_EVENT_MANAGER_PROFILER_ENABLED` Kconfig option is enabled and the :kconfig:`CONFIG_EVENT_MANAGER_TRACE_EVENT_EXECUTION` Kconfig option is disabled. The profiler synchronization module generates a :ref:`profiler` event (``sync_event``) that is not an :ref:`event_manager` event. For this reason, the ``sync_event`` execution is not traced. You also need to define: -* the GPIO port (:option:`CONFIG_DESKTOP_PROFILER_SYNC_GPIO_PORT`) and the pin (:option:`CONFIG_DESKTOP_PROFILER_SYNC_GPIO_PIN`) that are used for synchronization +* the GPIO port (:kconfig:`CONFIG_DESKTOP_PROFILER_SYNC_GPIO_PORT`) and the pin (:kconfig:`CONFIG_DESKTOP_PROFILER_SYNC_GPIO_PIN`) that are used for synchronization These GPIOs must be defined separately for both devices and connected using a physical wire. * the device role - One of the devices must be set as ``Central`` (:option:`CONFIG_DESKTOP_PROFILER_SYNC_CENTRAL`) and the other device must be set as ``Peripheral`` (:option:`CONFIG_DESKTOP_PROFILER_SYNC_PERIPHERAL`). + One of the devices must be set as ``Central`` (:kconfig:`CONFIG_DESKTOP_PROFILER_SYNC_CENTRAL`) and the other device must be set as ``Peripheral`` (:kconfig:`CONFIG_DESKTOP_PROFILER_SYNC_PERIPHERAL`). Implementation details ********************** diff --git a/applications/nrf_desktop/doc/qos.rst b/applications/nrf_desktop/doc/qos.rst index a01658b22bff..de04ac57b1bd 100644 --- a/applications/nrf_desktop/doc/qos.rst +++ b/applications/nrf_desktop/doc/qos.rst @@ -7,8 +7,8 @@ Quality of Service module :local: :depth: 2 -The Quality of Service (QoS) module provides the QoS information through the Bluetooth GATT service. -The module can be used only by nRF Desktop peripheral with the SoftDevice Link Layer (:option:`CONFIG_BT_LL_SOFTDEVICE`). +The Quality of Service (QoS) module provides the QoS information through the Bluetooth® GATT service. +The module can be used only by nRF Desktop peripheral with the SoftDevice Link Layer (:kconfig:`CONFIG_BT_LL_SOFTDEVICE`). The module is made available in case the peripheral is meant to be paired with a third party dongle. In such case, the vendor can use the Quality of Service data provided by the nRF Desktop peripheral to improve the link quality. @@ -32,9 +32,9 @@ Module events Configuration ************* -The module requires the basic Bluetooth configuration, as described in :ref:`nrf_desktop_bluetooth_guide`. +The module requires the basic Bluetooth® configuration, as described in :ref:`nrf_desktop_bluetooth_guide`. -The module is enabled with :option:`CONFIG_DESKTOP_QOS_ENABLE` option. +The module is enabled with :kconfig:`CONFIG_DESKTOP_QOS_ENABLE` option. The module is available on the :ref:`peripheral devices ` only and requires the :ref:`nrf_desktop_ble_qos` to be enabled. Implementation details diff --git a/applications/nrf_desktop/doc/selector.rst b/applications/nrf_desktop/doc/selector.rst index e60817134be8..6b6022c7f3e1 100644 --- a/applications/nrf_desktop/doc/selector.rst +++ b/applications/nrf_desktop/doc/selector.rst @@ -24,9 +24,9 @@ Configuration ************* The module implemented in :file:`selector_hw.c` uses the Zephyr :ref:`zephyr:gpio_api` driver to check the state of hardware selectors. -For this reason, you should set :option:`CONFIG_GPIO` option. +For this reason, you should set :kconfig:`CONFIG_GPIO` option. -Set :option:`CONFIG_DESKTOP_SELECTOR_HW_ENABLE` option to enable the module. +Set :kconfig:`CONFIG_DESKTOP_SELECTOR_HW_ENABLE` option to enable the module. The configuration for this module is an array of :c:struct:`selector_config` pointers. The array is written in the :file:`selector_hw_def.h` file located in the board-specific directory in the application configuration directory. diff --git a/applications/nrf_desktop/doc/settings_loader.rst b/applications/nrf_desktop/doc/settings_loader.rst index 19f0260bc2a1..80b1716d8900 100644 --- a/applications/nrf_desktop/doc/settings_loader.rst +++ b/applications/nrf_desktop/doc/settings_loader.rst @@ -23,9 +23,9 @@ Configuration ************* The settings loader module is enabled for every nRF Desktop device with Zephyr's :ref:`zephyr:settings_api` enabled. -The :ref:`zephyr:settings_api` subsystem is enabled with the :option:`CONFIG_SETTINGS` Kconfig option. +The :ref:`zephyr:settings_api` subsystem is enabled with the :kconfig:`CONFIG_SETTINGS` Kconfig option. -Zephyr's Bluetooth stack does not load the :ref:`zephyr:settings_api` data on its own. +Zephyr's Bluetooth® stack does not load the :ref:`zephyr:settings_api` data on its own. Zephyr assumes that the application will call :c:func:`settings_load` after completing all necessary initialization. This function is called on the settings loader module initialization. @@ -34,12 +34,12 @@ This function is called on the settings loader module initialization. Settings are by default loaded in the system workqueue context. This blocks the workqueue until the operation is finished. -You can set the :option:`CONFIG_DESKTOP_SETTINGS_LOADER_USE_THREAD` Kconfig option to load the settings in a separate thread in the background instead of using the system workqueue for that purpose. +You can set the :kconfig:`CONFIG_DESKTOP_SETTINGS_LOADER_USE_THREAD` Kconfig option to load the settings in a separate thread in the background instead of using the system workqueue for that purpose. This will prevent blocking the system workqueue, but it requires creating an additional thread. -The stack size for the background thread is defined as :option:`CONFIG_DESKTOP_SETTINGS_LOADER_THREAD_STACK_SIZE`. +The stack size for the background thread is defined as :kconfig:`CONFIG_DESKTOP_SETTINGS_LOADER_THREAD_STACK_SIZE`. .. tip:: Using separate thread is recommended for nRF Desktop keyboards. The :ref:`caf_buttons` uses the system workqueue to scan the keyboard matrix. Loading the settings in the system workqueue context could block the workqueue and result in missing key presses on system reboot. - For this reason, :option:`CONFIG_DESKTOP_SETTINGS_LOADER_USE_THREAD` is enabled for keyboard reference design (nRF52832 Desktop Keyboard) + For this reason, :kconfig:`CONFIG_DESKTOP_SETTINGS_LOADER_USE_THREAD` is enabled for keyboard reference design (nRF52832 Desktop Keyboard) diff --git a/applications/nrf_desktop/doc/smp.rst b/applications/nrf_desktop/doc/smp.rst index cbc4df55fb82..b001e8e73b3b 100644 --- a/applications/nrf_desktop/doc/smp.rst +++ b/applications/nrf_desktop/doc/smp.rst @@ -8,10 +8,10 @@ Simple Management Protocol module :local: :depth: 2 -The |smp| is responsible for performing a Device Firmware Upgrade (DFU) over Bluetooth LE. +The |smp| is responsible for performing a Device Firmware Upgrade (DFU) over Bluetooth® LE. You can perform the DFU using for example the `nRF Connect for Mobile`_ application. -The :guilabel:`DFU` button appears in the tab with the connected Bluetooth devices. +The :guilabel:`DFU` button appears in the tab with the connected Bluetooth® devices. After pressing the button, you can select the :file:`*.bin` file that is to be used for the firmware update. Module events diff --git a/applications/nrf_desktop/doc/usb_state.rst b/applications/nrf_desktop/doc/usb_state.rst index 164a16f80a9d..790732e704b3 100644 --- a/applications/nrf_desktop/doc/usb_state.rst +++ b/applications/nrf_desktop/doc/usb_state.rst @@ -23,39 +23,39 @@ Module events Configuration ************* -The module is enabled by selecting :option:`CONFIG_DESKTOP_USB_ENABLE`. -It depends on :option:`CONFIG_USB_DEVICE_HID`. +The module is enabled by selecting :kconfig:`CONFIG_DESKTOP_USB_ENABLE`. +It depends on :kconfig:`CONFIG_USB_DEVICE_HID`. When enabling the USB support for the device, set the following generic device options: -* :option:`CONFIG_USB_DEVICE_MANUFACTURER` - Manufacturer's name. -* :option:`CONFIG_USB_DEVICE_PRODUCT` - Product name. -* :option:`CONFIG_USB_DEVICE_VID` - Vendor ID (VID) number. -* :option:`CONFIG_USB_DEVICE_PID` - Product ID (PID) number. +* :kconfig:`CONFIG_USB_DEVICE_MANUFACTURER` - Manufacturer's name. +* :kconfig:`CONFIG_USB_DEVICE_PRODUCT` - Product name. +* :kconfig:`CONFIG_USB_DEVICE_VID` - Vendor ID (VID) number. +* :kconfig:`CONFIG_USB_DEVICE_PID` - Product ID (PID) number. Additionally, you can also configure the options described in the following sections. Low latency device configuration ================================ -For low latency devices, make sure that the device requests a polling rate of 1 ms by setting :option:`CONFIG_USB_HID_POLL_INTERVAL_MS` to ``1``. +For low latency devices, make sure that the device requests a polling rate of 1 ms by setting :kconfig:`CONFIG_USB_HID_POLL_INTERVAL_MS` to ``1``. Boot protocol configuration =========================== If the device is meant to support the boot protocol, set the following options: -#. Enable :option:`CONFIG_USB_HID_BOOT_PROTOCOL`. -#. Make sure :option:`CONFIG_USB_HID_PROTOCOL_CODE` is set to either the mouse or the keyboard code. +#. Enable :kconfig:`CONFIG_USB_HID_BOOT_PROTOCOL`. +#. Make sure :kconfig:`CONFIG_USB_HID_PROTOCOL_CODE` is set to either the mouse or the keyboard code. USB device instance configuration ================================= The nRF Desktop device can provide multiple instances of a HID-class USB device. -The number of instances is controlled by :option:`CONFIG_USB_HID_DEVICE_COUNT`. +The number of instances is controlled by :kconfig:`CONFIG_USB_HID_DEVICE_COUNT`. -* The Bluetooth Peripheral device will be able to use a single instance only. -* The Bluetooth Central device can use either a single instance or a number of instances equal to :option:`CONFIG_BT_MAX_PAIRED`. +* The Bluetooth® Peripheral device will be able to use a single instance only. +* The Bluetooth® Central device can use either a single instance or a number of instances equal to :kconfig:`CONFIG_BT_MAX_PAIRED`. On the Bluetooth Central device, if only one instance is used, reports from all Peripherals connected to the Central are forwarded to the same instance. In other cases, reports from each of the bonded peripherals will be forwarded to a dedicated HID-class USB device instance. @@ -66,7 +66,7 @@ USB wake-up configuration The nRF Desktop device can work as a source of wake-up events for the host device if connected through the USB. -To use the feature, select :option:`CONFIG_USB_DEVICE_REMOTE_WAKEUP`. +To use the feature, select :kconfig:`CONFIG_USB_DEVICE_REMOTE_WAKEUP`. When host enters the suspended state, the USB will be suspended as well. With this feature enabled, this state change is used to suspend the nRF Desktop device (see :ref:`nrf_desktop_power_manager`). @@ -79,7 +79,7 @@ When the nRF Desktop device wakes up from standby, the |usb_state| will issue a Implementation details ********************** -The |usb_state| registers the :option:`CONFIG_USB_HID_DEVICE_COUNT` instances of HID-class USB device and initializes the USB subsystem. +The |usb_state| registers the :kconfig:`CONFIG_USB_HID_DEVICE_COUNT` instances of HID-class USB device and initializes the USB subsystem. The necessary callbacks are connected to the module to ensure that the state of the USB connection is tracked. From the application's viewpoint, USB can be in the following states: diff --git a/applications/nrf_desktop/doc/watchdog.rst b/applications/nrf_desktop/doc/watchdog.rst index 73381b6f214e..0abc9db27fcd 100644 --- a/applications/nrf_desktop/doc/watchdog.rst +++ b/applications/nrf_desktop/doc/watchdog.rst @@ -26,11 +26,11 @@ Configuration ************* The module uses Zephyr's :ref:`zephyr:watchdog_api` driver. -For this reason, set the :option:`CONFIG_WATCHDOG` option. +For this reason, set the :kconfig:`CONFIG_WATCHDOG` option. -The module is enabled by the :option:`CONFIG_DESKTOP_WATCHDOG_ENABLE` option. +The module is enabled by the :kconfig:`CONFIG_DESKTOP_WATCHDOG_ENABLE` option. -You must define :option:`CONFIG_DESKTOP_WATCHDOG_TIMEOUT`. +You must define :kconfig:`CONFIG_DESKTOP_WATCHDOG_TIMEOUT`. After this amount of time (in ms), the device will be restarted if the watchdog timer was not reset. .. note:: diff --git a/applications/nrf_desktop/doc/wheel.rst b/applications/nrf_desktop/doc/wheel.rst index b38365415e7b..a938ac74be67 100644 --- a/applications/nrf_desktop/doc/wheel.rst +++ b/applications/nrf_desktop/doc/wheel.rst @@ -22,17 +22,17 @@ Module events Configuration ************* -Enable the module with the :option:`CONFIG_DESKTOP_WHEEL_ENABLE` Kconfig option. +Enable the module with the :kconfig:`CONFIG_DESKTOP_WHEEL_ENABLE` Kconfig option. For detecting rotation, the wheel module uses Zephyr's QDEC driver. -The module can be enabled only when QDEC is configured in DTS (that is, :option:`CONFIG_QDEC_NRFX` is set). +The module can be enabled only when QDEC is configured in DTS (that is, :kconfig:`CONFIG_QDEC_NRFX` is set). The QDEC DTS configuration specifies how many steps are done during one full angle. The sensor reports the rotation data in angle degrees. -Then, :option:`CONFIG_DESKTOP_WHEEL_SENSOR_VALUE_DIVIDER` (a wheel configuration option) converts the angle value into a value that is passed with a ``wheel_event`` to the destination module. +Then, :kconfig:`CONFIG_DESKTOP_WHEEL_SENSOR_VALUE_DIVIDER` (a wheel configuration option) converts the angle value into a value that is passed with a ``wheel_event`` to the destination module. For example, configuring QDEC with 24 steps means that for each step the sensor will report a rotation of 15 degrees. -For HID to see this rotation as increment of one, :option:`CONFIG_DESKTOP_WHEEL_SENSOR_VALUE_DIVIDER` should be set to 15. +For HID to see this rotation as increment of one, :kconfig:`CONFIG_DESKTOP_WHEEL_SENSOR_VALUE_DIVIDER` should be set to 15. Implementation details ********************** @@ -47,7 +47,7 @@ The wheel module can be in the following states: When in ``STATE_ACTIVE``, the module enables the QDEC driver and waits for callback that indicates rotation. The QDEC driver may consume power during its operation. -If no rotation is detected after the time specified in :option:`CONFIG_DESKTOP_WHEEL_SENSOR_IDLE_TIMEOUT`, the wheel module switches to ``STATE_ACTIVE_IDLE``, in which QDEC is disabled. +If no rotation is detected after the time specified in :kconfig:`CONFIG_DESKTOP_WHEEL_SENSOR_IDLE_TIMEOUT`, the wheel module switches to ``STATE_ACTIVE_IDLE``, in which QDEC is disabled. In this state, the rotation is detected using GPIO interrupts. When the rotation is detected, the module switches back to ``STATE_ACTIVE``. diff --git a/applications/nrf_desktop/src/hw_interface/wheel.c b/applications/nrf_desktop/src/hw_interface/wheel.c index b1b25bbe7d72..ce78b9cc4643 100644 --- a/applications/nrf_desktop/src/hw_interface/wheel.c +++ b/applications/nrf_desktop/src/hw_interface/wheel.c @@ -199,8 +199,7 @@ static int enable_qdec(enum state next_state) { __ASSERT_NO_MSG(next_state == STATE_ACTIVE); - int err = pm_device_state_set(qdec_dev, PM_DEVICE_STATE_ACTIVE, - NULL, NULL); + int err = pm_device_state_set(qdec_dev, PM_DEVICE_STATE_ACTIVE); if (err) { LOG_ERR("Cannot activate QDEC"); return err; @@ -238,8 +237,7 @@ static int disable_qdec(enum state next_state) return err; } - err = pm_device_state_set(qdec_dev, PM_DEVICE_STATE_SUSPEND, - NULL, NULL); + err = pm_device_state_set(qdec_dev, PM_DEVICE_STATE_SUSPEND); if (err) { LOG_ERR("Cannot suspend QDEC"); } else { diff --git a/applications/pelion_client/README.rst b/applications/pelion_client/README.rst index 42e7cd74e3dd..36943d5d95a8 100644 --- a/applications/pelion_client/README.rst +++ b/applications/pelion_client/README.rst @@ -182,7 +182,7 @@ Zephyr's system heap -------------------- Zephyr contains its own memory allocation algorithm that implements heap. -To configure the heap memory size, use the :option:`CONFIG_HEAP_MEM_POOL_SIZE` Kconfig option. +To configure the heap memory size, use the :kconfig:`CONFIG_HEAP_MEM_POOL_SIZE` Kconfig option. For more information about Zephyr's system heap, see the :ref:`zephyr:heap_v2` page in Zephyr's documentation. @@ -199,7 +199,7 @@ The Mbed TLS library can use the libc heap for allocation. Alternatively, it can use the dedicated allocation area (see `mbedtls_memory_buffer_alloc_init`_ in the official Mbed TLS documentation). The :ref:`nrf_security` variant of the Mbed TLS library allows to set such dedicated allocation buffer. -See :option:`CONFIG_MBEDTLS_ENABLE_HEAP` and :option:`CONFIG_MBEDTLS_HEAP_SIZE` for more details. +See :kconfig:`CONFIG_MBEDTLS_ENABLE_HEAP` and :kconfig:`CONFIG_MBEDTLS_HEAP_SIZE` for more details. Flash memory layout =================== @@ -354,7 +354,7 @@ The application supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns, nrf5340dk_nrf5340_cpuapp, nrf5340dk_nrf5340_cpuappns, nrf52840dk_nrf52840 + :rows: nrf9160dk_nrf9160_ns, nrf5340dk_nrf5340_cpuapp, nrf5340dk_nrf5340_cpuapp_ns, nrf52840dk_nrf52840 The nRF Pelion Client application is configured to compile and run as a non-secure application on nRF91's and nRF5340's Cortex-M33. Therefore, it automatically includes the :ref:`secure_partition_manager` that prepares the required peripherals to be available for the application. @@ -392,7 +392,7 @@ Configuration ************* |pelion_lib_explanation| -The Pelion Device Management library is enabled with :option:`CONFIG_PELION_CLIENT` configuration option. +The Pelion Device Management library is enabled with :kconfig:`CONFIG_PELION_CLIENT` configuration option. For the library to work, you must enable and properly configure the Mbed TLS library. To connect to Pelion Device Management Portal, the device must be provisioned with valid credentials. @@ -405,7 +405,7 @@ Mbed TLS The Pelion Device Management library is depending on a properly configured Mbed TLS library. To simplify the development within the |NCS|, a predefined set of Mbed TLS configuration options was prepared. -Set compatible with :ref:`nrfxlib:nrf_security` can be enabled using :option:`CONFIG_PELION_NRF_SECURITY` configuration option. +Set compatible with :ref:`nrfxlib:nrf_security` can be enabled using :kconfig:`CONFIG_PELION_NRF_SECURITY` configuration option. Pelion credentials ================== @@ -427,8 +427,8 @@ You can provide the devices with the new version of the firmware image over-the- Before the update, you must enable a compatible bootloader. The Pelion Device Management library is compatible with MCUboot. -Enable it with the :option:`CONFIG_BOOTLOADER_MCUBOOT` Kconfig option. -Along with the bootloader, you must also enable an image manager with the :option:`CONFIG_IMG_MANAGER` and :option:`CONFIG_MCUBOOT_IMG_MANAGER` Kconfig options. +Enable it with the :kconfig:`CONFIG_BOOTLOADER_MCUBOOT` Kconfig option. +Along with the bootloader, you must also enable an image manager with the :kconfig:`CONFIG_IMG_MANAGER` and :kconfig:`CONFIG_MCUBOOT_IMG_MANAGER` Kconfig options. When MCUboot is enabled the |NCS| build system generates the update image that can be uploaded to the secondary (update) slot. The resulting signed file named ``app_update.bin`` can be found in the build directory. @@ -440,7 +440,7 @@ If key is not present and configuration does not point to any specific key path, Additionally, if the application image is large, you may need to store the update image on an external flash device. In such case, enable the external flash support and correctly configure the partition layout. -The Pelion Device Management library's update manager is enabled when you select the :option:`CONFIG_PELION_UPDATE` Kconfig option. +The Pelion Device Management library's update manager is enabled when you select the :kconfig:`CONFIG_PELION_UPDATE` Kconfig option. This option enables components required for image transport and storage. For the update campaign to be recognized and the image be accepted, you need to provision the device with the valid update resources (device unique identifiers and certificate used for update process validation). diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/app_ZDebug.conf b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/app_ZDebug.conf similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/app_ZDebug.conf rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/app_ZDebug.conf diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/app_ZRelease.conf b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/app_ZRelease.conf similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/app_ZRelease.conf rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/app_ZRelease.conf diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/buttons_def.h b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/buttons_def.h similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/buttons_def.h rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/buttons_def.h diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/dts.overlay b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/dts.overlay similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/dts.overlay rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/dts.overlay diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/led_state_def.h b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/led_state_def.h similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/led_state_def.h rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/led_state_def.h diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/mcuboot_ZDebug.conf b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/mcuboot_ZDebug.conf similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/mcuboot_ZDebug.conf rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/mcuboot_ZDebug.conf diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/mcuboot_ZRelease.conf b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/mcuboot_ZRelease.conf similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/mcuboot_ZRelease.conf rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/mcuboot_ZRelease.conf diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/mcuboot_private.pem b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/mcuboot_private.pem similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/mcuboot_private.pem rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/mcuboot_private.pem diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/pm_static_ZDebug.yml b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/pm_static_ZDebug.yml similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/pm_static_ZDebug.yml rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/pm_static_ZDebug.yml diff --git a/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/pm_static_ZRelease.yml b/applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/pm_static_ZRelease.yml similarity index 100% rename from applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuappns/pm_static_ZRelease.yml rename to applications/pelion_client/configuration/nrf5340dk_nrf5340_cpuapp_ns/pm_static_ZRelease.yml diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/app_ZDebug.conf b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/app_ZDebug.conf similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/app_ZDebug.conf rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/app_ZDebug.conf diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/app_ZRelease.conf b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/app_ZRelease.conf similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/app_ZRelease.conf rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/app_ZRelease.conf diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/buttons_def.h b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/buttons_def.h similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/buttons_def.h rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/buttons_def.h diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/dts.overlay b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/dts.overlay similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/dts.overlay rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/dts.overlay diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/led_state_def.h b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/led_state_def.h similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/led_state_def.h rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/led_state_def.h diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/mcuboot_ZDebug.conf b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/mcuboot_ZDebug.conf similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/mcuboot_ZDebug.conf rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/mcuboot_ZDebug.conf diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/mcuboot_ZRelease.conf b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/mcuboot_ZRelease.conf similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/mcuboot_ZRelease.conf rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/mcuboot_ZRelease.conf diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/mcuboot_private.pem b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/mcuboot_private.pem similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/mcuboot_private.pem rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/mcuboot_private.pem diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/pm_static_ZDebug.yml b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/pm_static_ZDebug.yml similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/pm_static_ZDebug.yml rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/pm_static_ZDebug.yml diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/pm_static_ZRelease.yml b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/pm_static_ZRelease.yml similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/pm_static_ZRelease.yml rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/pm_static_ZRelease.yml diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns/spm_ZRelease.conf b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/spm_ZRelease.conf similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns/spm_ZRelease.conf rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns/spm_ZRelease.conf diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/app_ZDebug.conf b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/app_ZDebug.conf similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/app_ZDebug.conf rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/app_ZDebug.conf diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/app_ZRelease.conf b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/app_ZRelease.conf similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/app_ZRelease.conf rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/app_ZRelease.conf diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/buttons_def.h b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/buttons_def.h similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/buttons_def.h rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/buttons_def.h diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/dts.overlay b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/dts.overlay similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/dts.overlay rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/dts.overlay diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/led_state_def.h b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/led_state_def.h similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/led_state_def.h rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/led_state_def.h diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/mcuboot_ZDebug.conf b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/mcuboot_ZDebug.conf similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/mcuboot_ZDebug.conf rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/mcuboot_ZDebug.conf diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/mcuboot_ZRelease.conf b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/mcuboot_ZRelease.conf similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/mcuboot_ZRelease.conf rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/mcuboot_ZRelease.conf diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/mcuboot_private.pem b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/mcuboot_private.pem similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/mcuboot_private.pem rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/mcuboot_private.pem diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/pm_static_ZDebug.yml b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/pm_static_ZDebug.yml similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/pm_static_ZDebug.yml rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/pm_static_ZDebug.yml diff --git a/applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/pm_static_ZRelease.yml b/applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/pm_static_ZRelease.yml similarity index 100% rename from applications/pelion_client/configuration/nrf9160dk_nrf9160ns@1.0.0/pm_static_ZRelease.yml rename to applications/pelion_client/configuration/nrf9160dk_nrf9160_ns@1.0.0/pm_static_ZRelease.yml diff --git a/applications/serial_lte_modem/CMakeLists.txt b/applications/serial_lte_modem/CMakeLists.txt index 46e77587dd40..665ee6c38702 100644 --- a/applications/serial_lte_modem/CMakeLists.txt +++ b/applications/serial_lte_modem/CMakeLists.txt @@ -25,7 +25,7 @@ target_sources_ifdef(CONFIG_SLM_SMS app PRIVATE src/slm_at_sms.c) target_sources_ifdef(CONFIG_SLM_NATIVE_TLS app PRIVATE src/slm_native_tls.c) target_sources_ifdef(CONFIG_SLM_NATIVE_TLS app PRIVATE src/slm_at_cmng.c) -add_subdirectory_ifdef(CONFIG_SLM_GPS src/gps) +add_subdirectory_ifdef(CONFIG_SLM_GNSS src/gnss) add_subdirectory_ifdef(CONFIG_SLM_FTPC src/ftp_c) add_subdirectory_ifdef(CONFIG_SLM_MQTTC src/mqtt_c) add_subdirectory_ifdef(CONFIG_SLM_HTTPC src/http_c) diff --git a/applications/serial_lte_modem/Kconfig b/applications/serial_lte_modem/Kconfig index 9420ccb2fda1..89a3789300ce 100644 --- a/applications/serial_lte_modem/Kconfig +++ b/applications/serial_lte_modem/Kconfig @@ -130,7 +130,7 @@ config SLM_SMS help Support SMS send/receive in plain text -rsource "src/gps/Kconfig" +rsource "src/gnss/Kconfig" rsource "src/ftp_c/Kconfig" rsource "src/mqtt_c/Kconfig" rsource "src/http_c/Kconfig" diff --git a/applications/serial_lte_modem/doc/AT_commands_intro.rst b/applications/serial_lte_modem/doc/AT_commands_intro.rst index e77bdb2164d5..c4ba34380831 100644 --- a/applications/serial_lte_modem/doc/AT_commands_intro.rst +++ b/applications/serial_lte_modem/doc/AT_commands_intro.rst @@ -41,7 +41,7 @@ The modem-specific AT commands are documented in the `nRF91 AT Commands Referenc FOTA_AT_commands SMS_AT_commands FTP_AT_commands - GPS_AT_commands + GNSS_AT_commands MQTT_AT_commands HTTPC_AT_commands TWI_AT_commands diff --git a/applications/serial_lte_modem/doc/FTP_AT_commands.rst b/applications/serial_lte_modem/doc/FTP_AT_commands.rst index 2ed81f4fab51..a0c55a1ac85d 100644 --- a/applications/serial_lte_modem/doc/FTP_AT_commands.rst +++ b/applications/serial_lte_modem/doc/FTP_AT_commands.rst @@ -47,6 +47,7 @@ The ```` command is a string, and can be used as follows: * ``AT#XFTP="mput",[,]`` The values of the parameters depend on the command string used. +When using the ``put``,``uput`` and ``mput`` commands, if the ```` attribute is not specified, SLM enters ``slm_data_mode``. Response syntax ~~~~~~~~~~~~~~~ diff --git a/applications/serial_lte_modem/doc/GNSS_AT_commands.rst b/applications/serial_lte_modem/doc/GNSS_AT_commands.rst new file mode 100644 index 000000000000..97b555abf877 --- /dev/null +++ b/applications/serial_lte_modem/doc/GNSS_AT_commands.rst @@ -0,0 +1,565 @@ +.. _SLM_AT_GNSS: + +GNSS AT commands +**************** + +.. contents:: + :local: + :depth: 2 + +The following commands list contains GNSS-related AT commands. + +Run GPS +======= + +The ``#XGPS`` command controls the GPS. + +Set command +----------- + +The set command allows you to start and stop the GPS. + +Syntax +~~~~~~ + +:: + + #XGPS=[,[,]] + +The ```` parameter accepts the following integer values: + +* ``0`` - Stop GPS +* ``1`` - Start GPS + +The ```` parameter represents the GNSS fix interval in seconds. +It must be set when starting the GPS. +It accepts the following integer values: + +* ``0`` - Single-fix navigation mode. +* ``1`` - Continuous navigation mode. + The fix interval is set to 1 second +* Ranging from ``10`` to ``1800`` - Periodic navigation mode. + The fix interval is set to the specified value. + +In periodic navigation mode, the ```` parameter controls the maximum time in seconds that the GNSS receiver is allowed to run while trying to produce a valid PVT estimate. +In continuous navigation mode, this parameter doesn't have any effect. +It accepts the following integer values: + +* ``0`` - the GNSS receiver runs indefinitely until a valid PVT estimate is produced. +* Any positive integer lower than the ```` value - the GNSS receiver is turned off after the specified time is up, even if a valid PVT estimate was not produced. + +When not specified, it defaults to a timeout value of 60 seconds. + +Unsolicited notification +~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + #XGPS: ,,,,,, + +* The ```` value represents the latitude in degrees. +* The ```` value represents the longitude in degrees. +* The ```` value represents the altitude above the WGS-84 ellipsoid in meters. +* The ```` value represents the accuracy (2D 1-sigma) in meters. +* The ```` value represents the horizontal speed in meters. +* The ```` value represents the heading of the movement of the user in degrees. +* The ```` value represents the UTC date-time. + +Example +~~~~~~~ + +:: + + AT%XSYSTEMMODE=0,0,1,0 + + OK + AT%XCOEX0=1,1,1565,1586 + + OK + AT+CFUN=31 + + OK + at#xgps=1,1 + + OK + + #XGPS: 35.457576,139.625090,121.473785,22.199919,0.442868,0.000000,"2021-06-02 06:25:48" + + #XGPS: 35.457550,139.625115,124.293533,15.679427,0.263094,0.000000,"2021-06-02 06:25:49" + + #XGPS: 35.457517,139.625094,120.865372,12.768595,0.166673,0.000000,"2021-06-02 06:25:50" + +Read command +------------ + +The read command is not supported. + +Test command +------------ + +The test command tests the existence of the command and provides information about the type of its subparameters. + +Syntax +~~~~~~ + +:: + + #XGPS=? + +Example +~~~~~~~ + +:: + + AT#XGPS=? + + #XGPS: (0,1),, + + OK + + +Connect to nRF Cloud +==================== + +The ``#XNRFCLOUD`` command controls the connection to the nRF Cloud service. + +Set command +----------- + +The set command allows you to connect and disconnect the nRF Cloud service. + +Syntax +~~~~~~ + +:: + + #XNRFCLOUD=[,] + +The ```` parameter accepts the following integer values: + +* ``0`` - Disconnect from the nRF Cloud service +* ``1`` - Connect to the nRF Cloud service + +The ```` parameter accepts the following integer values: + +* ``0`` - It does not signify the location info to nRF Cloud +* ``1`` - It does signify the location info to nRF Cloud + +When not specified, it does not signify the location info to nRF Cloud. + +Unsolicited notification +~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + #XNRFCLOUD: , + +* The ```` value indicates whether the nRF Cloud connection is ready or not. +* The ```` value indicates whether the location info will be signified to nRF Cloud or not. + +Example +~~~~~~~ + +:: + + AT#XNRFCLOUD=1 + + OK + #XNRFCLOUD: 1,0 + AT#XNRFCLOUD=0 + + AT#XNRFCLOUD: 0,0 + + OK + AT#XNRFCLOUD=1,1 + + OK + #XNRFCLOUD: 1,1 + AT#XNRFCLOUD=0 + + AT#XNRFCLOUD: 0,1 + + OK + +Read command +------------ + +The read command checks if nRF Cloud is connected or not. + +Syntax +~~~~~~ + +:: + + #XNRFCLOUD? + +Response syntax +~~~~~~~~~~~~~~~ + +:: + + #XNRFCLOUD: , + +* The ```` value indicates whether the nRF Cloud connection is ready or not. +* The ```` value indicates whether the location info will be signified to nRF Cloud or not. + +Example +~~~~~~~ + +:: + + AT#XNRFCLOUD? + + #XNRFCLOUD: 1,0 + + OK + + +Test command +------------ + +The test command tests the existence of the command and provides information about the type of its subparameters. + +Syntax +~~~~~~ + +:: + + #XNRFCLOUD=? + +Example +~~~~~~~ + +:: + + AT#XNRFSIGNIFY=? + + #XNRFCLOUD: (1,0), + + OK + +Run GPS with nRF Cloud A-GPS +============================ + +The ``#XAGPS`` command runs the GPS together with the nRF Cloud A-GPS service. +This requires access to nRF Cloud through the LTE network for receiving A-GPS data. + +Set command +----------- + +The set command allows you to start and stop the GPS together with the nRF Cloud A-GPS service. + +Syntax +~~~~~~ + +:: + + #XAGPS=[,[,]] + +The ```` parameter accepts the following integer values: + +* ``0`` - Stop GPS with A-GPS +* ``1`` - Start GPS with A-GPS + +The ```` parameter represents the GNSS fix interval in seconds. +It must be set when starting the GPS. +It accepts the following integer values: + +* ``0`` - Single-fix navigation mode. +* ``1`` - Continuous navigation mode. + The fix interval is set to 1 second +* Ranging from ``10`` to ``1800`` - Periodic navigation mode. + The fix interval is set to the specified value. + +In periodic navigation mode, the ```` parameter controls the maximum time in seconds that the GNSS receiver is allowed to run while trying to produce a valid PVT estimate. +In continuous navigation mode, this parameter doesn't have any effect. +It accepts the following integer values: + +* ``0`` - the GNSS receiver runs indefinitely until a valid PVT estimate is produced. +* Any positive integer lower than the ```` value - the GNSS receiver is turned off after the specified time is up, even if a valid PVT estimate was not produced. + +When not specified, it defaults to a timeout value of 60 seconds. + +Unsolicited notification +~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + #XGPS: ,,,,,, + +* The ```` value represents the latitude in degrees. +* The ```` value represents the longitude in degrees. +* The ```` value represents the altitude above the WGS-84 ellipsoid in meters. +* The ```` value represents the accuracy (2D 1-sigma) in meters. +* The ```` value represents the horizontal speed in meters. +* The ```` value represents the heading of the movement of the user in degrees. +* The ```` value represents the UTC date-time. + +Example +~~~~~~~ + +:: + + AT%XSYSTEMMODE=1,0,1,0 + + OK + AT%XCOEX0=1,1,1565,1586 + + OK + AT+CPSMS=1 + + OK + AT+CFUN=1 + + OK + AT#XNRFCLOUD=1 + + OK + #XNRFCLOUD: 1,0 + AT#XAGPS=1,1 + + OK + + #XGPS: 35.457417,139.625211,162.850952,15.621976,1.418092,0.000000,"2021-06-02 05:21:31" + + #XGPS: 35.457435,139.625348,176.104797,14.245458,1.598184,69.148659,"2021-06-02 05:21:32" + + #XGPS: 35.457417,139.625415,179.132980,13.318132,1.235241,69.148659,"2021-06-02 05:21:33" + + #XGPS: 35.457410,139.625469,181.223541,12.667312,0.803951,69.148659,"2021-06-02 05:21:34" + +Read command +------------ + +The read command is not supported. + +Test command +------------ + +The test command tests the existence of the command and provides information about the type of its subparameters. + +Syntax +~~~~~~ + +:: + + #XAGPS=? + +Example +~~~~~~~ + +:: + + AT#XAGPS=? + + #XAGPS: (0,1),, + + OK + + +Run GPS with nRF Cloud P-GPS +============================ + +The ``#XPGPS`` command runs the GPS together with the nRF Cloud P-GPS service. +This requires access to nRF Cloud through the LTE network for receiving P-GPS data. + +Set command +----------- + +The set command allows you to start and stop the GPS together with the nRF Cloud P-GPS service. + +Syntax +~~~~~~ + +:: + + #XPGPS=[,[,]] + +The ```` parameter accepts the following integer values: + +* ``0`` - Stop GPS with P-GPS +* ``1`` - Start GPS with P-GPS + +The ```` parameter represents the GNSS fix interval in seconds. +It must be set when starting the GPS. +It accepts the following integer values: + +* Ranging from ``10`` to ``1800`` - Periodic navigation mode. + The fix interval is set to the specified value. + +In periodic navigation mode, the ```` parameter controls the maximum time in seconds that the GNSS receiver is allowed to run while trying to produce a valid PVT estimate. +In continuous navigation mode, this parameter doesn't have any effect. +It accepts the following integer values: + +* ``0`` - the GNSS receiver runs indefinitely until a valid PVT estimate is produced. +* Any positive integer lower than the ```` value - the GNSS receiver is turned off after the specified time is up, even if a valid PVT estimate was not produced. + +When not specified, it defaults to a timeout value of 60 seconds. + +Unsolicited notification +~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + #XGPS: ,,,,,, + +* The ```` value represents the latitude in degrees. +* The ```` value represents the longitude in degrees. +* The ```` value represents the altitude above the WGS-84 ellipsoid in meters. +* The ```` value represents the accuracy (2D 1-sigma) in meters. +* The ```` value represents the horizontal speed in meters. +* The ```` value represents the heading of the movement of the user in degrees. +* The ```` value represents the UTC date-time. + +Example +~~~~~~~ + +:: + + AT%XSYSTEMMODE=1,0,1,0 + + OK + AT%XCOEX0=1,1,1565,1586 + + OK + AT+CPSMS=1 + + OK + AT+CFUN=1 + + OK + AT#XNRFCLOUD=1 + + OK + #XNRFCLOUD: 1,0 + AT#XPGPS=1,30 + + OK + + #XGPS: 35.457243,139.625435,149.005020,28.184258,10.431827,281.446014,"2021-06-24 04:35:52" + + #XGPS: 35.457189,139.625602,176.811203,43.015198,0.601837,281.446014,"2021-06-24 04:36:28" + + #XGPS: 35.457498,139.625422,168.243591,31.753956,0.191195,281.446014,"2021-06-24 04:36:41" + + #XGPS: 35.457524,139.624667,100.745979,25.324850,6.347160,94.699837,"2021-06-24 04:37:10" + +Read command +------------ + +The read command is not supported. + +Test command +------------ + +The test command tests the existence of the command and provides information about the type of its subparameters. + +Syntax +~~~~~~ + +:: + + #XPGPS=? + +Example +~~~~~~~ + +:: + + AT#XPGPS=? + + #XPGPS: (0,1),, + + OK + +Run nRF Cloud cellular positioning +================================== + +The ``#XCELLPOS`` command runs the nRF Cloud cellular positioning service for position information. +This requires to define ``CONFIG_SLM_CELL_POS`` and to access nRF Cloud through the LTE network. + +Set command +----------- + +The set command allows you to start and stop the nRF Cloud cellular positioning service. + +Syntax +~~~~~~ + +:: + + #XCELLPOS= + +The ```` parameter accepts the following integer values: + +* ``0`` - Stop cellular positioning +* ``1`` - Start cellular positioning in single-cell mode +* ``2`` - Start cellular positioning in multi-cell mode + +Unsolicited notification +~~~~~~~~~~~~~~~~~~~~~~~~ + +:: + + #XCELLPOS: ,,, + +* The ```` value indicates in which mode the cellular positioning server is running: + + * ``0`` - The server is running in single-cell mode + * ``1`` - The server is running in multi-cell mode + +* The ```` value represents the latitude in degrees. +* The ```` value represents the longitude in degrees. +* The ```` value represents the certainty of the result. + +Example +~~~~~~~ + +:: + + AT%XSYSTEMMODE=1,0,0,0 + + OK + AT+CFUN=1 + + OK + AT#XNRFCLOUD=1 + + OK + #XNRFCLOUD: 1,0 + AT#XCELLPOS=1 + + OK + + #XCELLPOS: 0,35.455833,139.626111,1094 + AT#XCELLPOS=0 + + OK + +Read command +------------ + +The read command is not supported. + +Test command +------------ + +The test command tests the existence of the command and provides information about the type of its subparameters. + +Syntax +~~~~~~ + +:: + + #XCELLPOS=? + +Example +~~~~~~~ + +:: + + AT#XCELLPOS=? + + #XCELLPOS: (0,1,2) + + OK diff --git a/applications/serial_lte_modem/doc/GPS_AT_commands.rst b/applications/serial_lte_modem/doc/GPS_AT_commands.rst deleted file mode 100644 index e71075f42ff7..000000000000 --- a/applications/serial_lte_modem/doc/GPS_AT_commands.rst +++ /dev/null @@ -1,182 +0,0 @@ -.. _SLM_AT_GPS: - -GPS AT commands -*************** - -.. contents:: - :local: - :depth: 2 - -The following commands list contains GPS related AT commands. - -Run GPS #XGPS -============= - -The ``#XGPS`` command controls the GPS. - -Set command ------------ - -The set command allows you to start and stop the GPS. - -Syntax -~~~~~~ - -:: - - #XGPS=[,] - -The ```` parameter accepts the following integer values: - -* ``0`` - Start GPS -* ``1`` - Stop GPS - -The ```` parameter represents the NMEA data mask. -It accepts the following integer values: - -* Bit 0 - Global Positioning System fix data -* Bit 1 - Geographic position latitude/longitude and time -* Bit 2 - DOP and active satellites -* Bit 3 - Satellites in view -* Bit 4 - Recommended minimum specific GPS/transit data - -They are all set if the NMEA data mask value is ignored. - -Response syntax -~~~~~~~~~~~~~~~ - -:: - - #XGPS: [,] - -The ```` value represents the GPS running status. -It can have the following values: - -* ``0`` - Stopped. -* ``1`` - Running. -* *Negative Value* - Error code. - It indicates the reason for the failure. - -When the ```` value is 1, the ```` value syntax appears as follows: - -* Bit 0 - Global Positioning System Fix Data -* Bit 1 - Geographic position latitude/longitude and time -* Bit 2 - DOP and active satellites -* Bit 3 - Satellites in view -* Bit 4 - Recommended minimum specific GPS/transit data - -Unsolicited notification -~~~~~~~~~~~~~~~~~~~~~~~~ - -:: - - #XGPS: - #XGPSS: - #XGPSP: - - -* The ```` value represents the GPS running status. - It can have the following values: - - * ``0`` - Stopped. - * ``1`` - Running. - * *Negative Value* - Error code. - It indicates the reason for the failure. - -* The ```` value represents the satellite statistic info. -* The ```` value represents longitude, latitude, and UTC DateTime. -* The ```` value represents the NMEA raw data, notified after the first satellite fix. - -Example -~~~~~~~ - -:: - - #XGPS: 1,3 - OK - #XGPSS: "GPS suspended" - #XGPSS: "SUPL injection done" - #XGPSS: "GPS resumed" - #XGPSS: "track 3 use 3 unhealthy 0" - #XGPSS: "track 4 use 4 unhealthy 0" - #XGPSS: "track 5 use 5 unhealthy 0" - #XGPSS: "track 4 use 4 unhealthy 0" - #XGPSS: "track 5 use 5 unhealthy 0" - #XGPSS: "track 6 use 6 unhealthy 0" - #XGPSS: "track 7 use 7 unhealthy 0" - #XGPSS: "track 6 use 6 unhealthy 0" - #XGPSP: "long 139.721966 lat 35.534159" - #XGPSP: "2020-04-30 00:11:55" - #XGPSP: "TTFF 57s" - $GPGGA,001155.87,3532.04954,N,13943.31794,E,1,06,17.40,109.53,M,0,,*19 - $GPGLL,3532.04954,N,13943.31794,E,001155.87,A,A*69 - #XGPSP: "long 139.721969 lat 35.534148" - #XGPSP: "2020-04-30 00:11:56" - -Read command ------------- - -The read command checks if the GPS is running. - -Syntax -~~~~~~ - -:: - - #XGPS? - -Response syntax -~~~~~~~~~~~~~~~ - -:: - - #XGPS: [,] - -The ```` parameter represents the GPS running status. -It can accept the following values: - -* ``0`` - Stopped -* ``1`` - Running - -When the ```` value is 1, the ```` value syntax appears as follows: - -* Bit 0 - Global Positioning System fix data -* Bit 1 - Geographic position latitude/longitude and time -* Bit 2 - DOP and active satellites -* Bit 3 - Satellites in view -* Bit 4 - Recommended minimum specific GPS/transit data - -Example -~~~~~~~ - -:: - - AT#XGPS? - #XGPS: 1,2 - OK - -Test command ------------- - -The test command tests the existence of the command and provides information about the type of its subparameters. - -Syntax -~~~~~~ - -:: - - #XGPS=? - -Example -~~~~~~~ - -:: - - #XGPS: (0,1), - NMEA data mask: - Bit 0 - Global Positioning System fix data - Bit 1 - Geographic position latitude/longitude and time - Bit 2 - DOP and active satellites - Bit 3 - Satellites in view - Bit 4 - Recommended minimum specific GPS/transit data - OK diff --git a/applications/serial_lte_modem/doc/Generic_AT_commands.rst b/applications/serial_lte_modem/doc/Generic_AT_commands.rst index fbe41a47d828..2bdf0acdf835 100644 --- a/applications/serial_lte_modem/doc/Generic_AT_commands.rst +++ b/applications/serial_lte_modem/doc/Generic_AT_commands.rst @@ -119,8 +119,8 @@ Power saving #XSLEEP The ``#XSLEEP`` command makes the nRF91 development kit go into idle or sleep mode. If you are going to do power measurements on the nRF9160 DK while running the SLM application it is recommended to disable unused peripherals. -By default UART2 is enabled in the :file:`nrf9160dk_nrf9160ns.overlay` file so disable the UART2 by switching the status. -Change the line ``status = "okay"`` to ``status = "disabled"`` and then save the :file:`nrf9160dk_nrf9160ns.overlay`` file to make sure you will get the expected power consumption numbers when doing the measurements. +By default UART2 is enabled in the :file:`nrf9160dk_nrf9160_ns.overlay` file so disable the UART2 by switching the status. +Change the line ``status = "okay"`` to ``status = "disabled"`` and then save the :file:`nrf9160dk_nrf9160_ns.overlay`` file to make sure you will get the expected power consumption numbers when doing the measurements. Set command ----------- diff --git a/applications/serial_lte_modem/doc/HTTPC_AT_commands.rst b/applications/serial_lte_modem/doc/HTTPC_AT_commands.rst index ee0e1c1e6098..c3e26ba631d2 100644 --- a/applications/serial_lte_modem/doc/HTTPC_AT_commands.rst +++ b/applications/serial_lte_modem/doc/HTTPC_AT_commands.rst @@ -131,8 +131,8 @@ Syntax It represents the length of the payload. If ``payload_length`` is greater than ``0``, the SLM will enter data mode and expect the upcoming UART input data as payload. The SLM will then send the payload to the HTTP server until the ``payload_length`` bytes are sent. - To abort sending the payload, terminate data mode by sending the terminator string defined in :option:`CONFIG_SLM_DATAMODE_TERMINATOR`. - The default pattern string is "+++". Keep in mind that UART silence as configured in :option:`CONFIG_SLM_DATAMODE_SILENCE` is required before and after the pattern string. + To abort sending the payload, terminate data mode by sending the terminator string defined in :kconfig:`CONFIG_SLM_DATAMODE_TERMINATOR`. + The default pattern string is "+++". Keep in mind that UART silence as configured in :kconfig:`CONFIG_SLM_DATAMODE_SILENCE` is required before and after the pattern string. Response syntax ~~~~~~~~~~~~~~~ diff --git a/applications/serial_lte_modem/doc/ICMP_AT_commands.rst b/applications/serial_lte_modem/doc/ICMP_AT_commands.rst index 2a842adb7399..44f4f9feab29 100644 --- a/applications/serial_lte_modem/doc/ICMP_AT_commands.rst +++ b/applications/serial_lte_modem/doc/ICMP_AT_commands.rst @@ -24,7 +24,7 @@ Syntax :: - #XPING=,,[,[,]] + #XPING=,,[,[,[,]]] * The ```` parameter is a string. It represents the hostname, the IPv4, or the IPv6 address of the target host. @@ -38,6 +38,9 @@ Syntax * The ```` parameter is an integer. It represents the time to wait for sending the next echo request, in milliseconds. Its default value is ``1000``. +* The ```` parameter is an integer. + It represents ``cid`` in the ``+CGDCONT`` command. + Its default value is ``0``. Unsolicited notification ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -73,6 +76,14 @@ Example #XPING: 0.037 seconds #XPING: 0.106 seconds #XPING: average 0.123 seconds + AT#XPING="5.189.130.26",45,5000,5,1000,1 + OK + #XPING: 1.612 seconds + #XPING: 0.349 seconds + #XPING: 0.334 seconds + #XPING: 0.278 seconds + #XPING: 0.278 seconds + #XPING: average 0.570 seconds Read command ------------ diff --git a/applications/serial_lte_modem/doc/slm_data_mode.rst b/applications/serial_lte_modem/doc/slm_data_mode.rst index 4edce71f427b..8b51e68e669e 100644 --- a/applications/serial_lte_modem/doc/slm_data_mode.rst +++ b/applications/serial_lte_modem/doc/slm_data_mode.rst @@ -54,6 +54,8 @@ To exit data mode, the MCU sends the termination command set by the ``CONFIG_SLM When instructed to exit data mode, the SLM application returns the AT command response ``OK``. +If the current sending function fails, the SLM application exits data mode and returns the AT command response ``ERROR``. + The SLM application also exits data mode automatically in the following scenarios: * The TCP server is stopped. diff --git a/applications/serial_lte_modem/doc/slm_description.rst b/applications/serial_lte_modem/doc/slm_description.rst index f77746cbeb0c..3b0b84e320d5 100644 --- a/applications/serial_lte_modem/doc/slm_description.rst +++ b/applications/serial_lte_modem/doc/slm_description.rst @@ -18,7 +18,7 @@ The application supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -42,7 +42,7 @@ As a client, you can use either a PC or an external MCU. Connecting with a PC -------------------- -To connect to the nRF9160 DK with a PC, make sure that :option:`CONFIG_SLM_CONNECT_UART_0` is defined in the application. +To connect to the nRF9160 DK with a PC, make sure that :kconfig:`CONFIG_SLM_CONNECT_UART_0` is defined in the application. It is defined in the default configuration. Use LTE Link Monitor to connect to the nRF9160 DK. @@ -64,7 +64,7 @@ Connecting with an external MCU If you run your user application on an external MCU (for example, an nRF52 Series DK), you can control the modem on the nRF9160 directly from the application. See the `nRF52 client for serial LTE modem application`_ repository for a sample implementation of such an application. -To connect with an external MCU, you must set the configuration option :option:`CONFIG_UART_2_NRF_HW_ASYNC_TIMER` and :option:`CONFIG_SLM_CONNECT_UART_2` in the serial LTE modem application configuration. +To connect with an external MCU, you must set the configuration option :kconfig:`CONFIG_UART_2_NRF_HW_ASYNC_TIMER` and :kconfig:`CONFIG_SLM_CONNECT_UART_2` in the serial LTE modem application configuration. The following table shows how to connect an nRF52 Series DK to the nRF9160 DK to be able to communicate through UART: @@ -149,7 +149,7 @@ Check and configure the following configuration options for the sample: .. option:: CONFIG_SLM_INTERFACE_PIN - Interface GPIO to wake up from sleep or exit idle This option specifies which interface GPIO to use for exiting sleep or idle mode. - By default, **P0.6** (Button 1 on the nRF9160 DK) is used when :option:`CONFIG_SLM_CONNECT_UART_0` is selected, and **P0.31** is used when when :option:`CONFIG_SLM_CONNECT_UART_2` is selected. + By default, **P0.6** (Button 1 on the nRF9160 DK) is used when :kconfig:`CONFIG_SLM_CONNECT_UART_0` is selected, and **P0.31** is used when when :kconfig:`CONFIG_SLM_CONNECT_UART_2` is selected. .. option:: CONFIG_SLM_SOCKET_RX_MAX - Maximum RX buffer size for receiving socket data @@ -195,18 +195,6 @@ Check and configure the following configuration options for the sample: This option enables additional AT commands for using the FTP client service. -.. option:: CONFIG_SLM_FTP_SERVER_PORT - FTP service port on remote host - - This option specifies the port to use when connecting to an FTP server. - -.. option:: CONFIG_SLM_FTP_USER_ANONYMOUS - FTP client anonymous login user - - This option specifies the user name to use for anonymous login on an FTP server. - -.. option:: CONFIG_SLM_FTP_PASSWORD_ANONYMOUS - FTP client anonymous login password - - This option specifies the password to use for anonymous login on an FTP server. - .. option:: CONFIG_SLM_MQTTC - MQTT client support in SLM This option enables additional AT commands for using the MQTT client service. @@ -222,10 +210,6 @@ Check and configure the following configuration options for the sample: Additional configuration ======================== -Check and configure the following library options that are used by the sample: - -* :option:`CONFIG_SUPL_CLIENT_LIB` - Enables the :ref:`supl_client`. - To save power, console and logging output over ``UART_0`` is disabled in this application. This information is logged to RTT instead. See :ref:`testing_rtt_connect` for instructions on how to view this information. diff --git a/applications/serial_lte_modem/doc/slm_testing.rst b/applications/serial_lte_modem/doc/slm_testing.rst index d43f3fe555c5..8890d8de0324 100644 --- a/applications/serial_lte_modem/doc/slm_testing.rst +++ b/applications/serial_lte_modem/doc/slm_testing.rst @@ -1341,9 +1341,9 @@ Complete the following steps to test the functionality provided by the :ref:`SLM FTP AT commands *************** -Note that these commands are available only if :option:`CONFIG_SLM_FTPC` is defined. -Before you test the FTP AT commands, check the setting of the :option:`CONFIG_FTP_CLIENT_KEEPALIVE_TIME` option. -By default, the :ref:`lib_ftp_client` library keeps the connection to the FTP server alive for 60 seconds, but you can change the duration or turn KEEPALIVE off by setting :option:`CONFIG_FTP_CLIENT_KEEPALIVE_TIME` to 0. +Note that these commands are available only if :kconfig:`CONFIG_SLM_FTPC` is defined. +Before you test the FTP AT commands, check the setting of the :kconfig:`CONFIG_FTP_CLIENT_KEEPALIVE_TIME` option. +By default, the :ref:`lib_ftp_client` library keeps the connection to the FTP server alive for 60 seconds, but you can change the duration or turn KEEPALIVE off by setting :kconfig:`CONFIG_FTP_CLIENT_KEEPALIVE_TIME` to 0. The FTP client behavior depends on the FTP server that is used for testing. Complete the following steps to test the functionality provided by the :ref:`SLM_AT_FTP` with two example servers: @@ -1740,274 +1740,3 @@ Complete the following steps to test the functionality provided by the :ref:`SLM 221-Goodbye. You uploaded 1 and downloaded 0 kbytes. 221 Logout. OK - -GPS AT commands -*************** - -Note that these commands are available only if :option:`CONFIG_SLM_GPS` is defined. -Before you test the GPS AT commands, check the following configuration values: - -* :option:`CONFIG_SUPL_CLIENT_LIB` - must be enabled to use the :ref:`supl_client` -* :option:`CONFIG_SLM_SUPL_SERVER` - use the default ("supl.google.com") or specify a different server -* :option:`CONFIG_SLM_SUPL_PORT` - use the default (7276) or specify a different port - -Complete the following steps to test the functionality provided by the :ref:`SLM_AT_GPS`: - -1. Test standalone GPS: - - a. Enable support for GNSS in the modem. - - .. parsed-literal:: - :class: highlight - - **AT+CFUN=0** - OK - - **AT%XSYSTEMMODE=0,0,1,0** - OK - - .. modem_config_start - - b. Configure the Low-Noise Amplifier (LNA). - The required commands depend on the version of the nRF9160 DK. - - For nRF9160 DK versions up to v0.9.0, configure the MAGPIO pin: - - .. parsed-literal:: - :class: highlight - - **AT%XMAGPIO=1,0,0,1,1,1574,1577** - OK - - For nRF9160 DK versions starting with v0.10.x, configure the COEX0 pin: - - .. parsed-literal:: - :class: highlight - - **AT%XCOEX0=1,1,1565,1586** - OK - - .. modem_config_end - - c. Turn on the modem. - - .. parsed-literal:: - :class: highlight - - **AT+CFUN=1** - OK - - #. Start GPS with GPS fix data and geographic position latitude/longitude and time, and observe the output. - Then check the GPS status. - - .. parsed-literal:: - :class: highlight - - **AT#XGPS=1,3** - #XGPS: 1,3 - OK - #XGPSS: tracking 1 using 1 unhealthy 0 - #XGPSS: tracking 2 using 2 unhealthy 0 - *[...]* - - **AT#XGPS?** - #XGPS: 1,3 - OK - - #. Turn off GPS and check the status again. - - .. parsed-literal:: - :class: highlight - - **AT#XGPS=0** - #XGPS: 0 - OK - - **AT#XGPS?** - #XGPS: 0 - OK - -#. Test GPS in PSM mode: - - a. Subscribe to unsolicited network status notifications. - Then enable support for LTE Cat-M1 and GNSS in the modem. - - .. parsed-literal:: - :class: highlight - - **AT+CFUN=0** - OK - - **AT+CEREG=5** - OK - - **AT%XSYSTEMMODE=1,0,1,0** - OK - -.. include:: slm_testing.rst - :start-after: modem_config_start - :end-before: modem_config_end - -.. - - c. Enable power-saving mode. - Then turn on the modem. - - .. parsed-literal:: - :class: highlight - - **AT+CPSMS=1,,,"00100100","00100001"** - OK - - **AT+CFUN=1** - OK - +CEREG: 2,"106A","00A3965D",7,0,0,"11100000","11100000" - +CEREG: 1,"106A","00A3965D",7,,,"00011110","00011000" - - #. Start GPS with GPS fix data and geographic position latitude/longitude and time, and observe the output. - - .. parsed-literal:: - :class: highlight - - **AT#XGPS=1,3** - #XGPS: 1,3 - OK - #XGPSS: tracking 1 using 1 unhealthy 0 - #XGPSS: tracking 2 using 2 unhealthy 0 - *[...]* - - #. Turn off GPS. - - .. parsed-literal:: - :class: highlight - - **AT#XGPS=0** - #XGPS: 0 - OK - -#. Test GPS in eDRX mode: - - a. Subscribe to unsolicited network status notifications. - Then enable support for LTE Cat-M1 and GNSS in the modem. - - .. parsed-literal:: - :class: highlight - - **AT+CFUN=0** - OK - - **AT+CEREG=2** - OK - - **AT%XSYSTEMMODE=1,0,1,0** - OK - -.. include:: slm_testing.rst - :start-after: modem_config_start - :end-before: modem_config_end - -.. - - c. Enable the use of eDRX and configure the PTW parameters. - Then turn on the modem. - - .. parsed-literal:: - :class: highlight - - **AT+CEDRXS=2,4,"1010"** - OK - - **AT%XPTW=4,"0001"** - OK - - **AT+CFUN=1** - OK - +CEREG: 2,"106A","00A3965D",7 - +CEREG: 1,"106A","00A3965D",7 - +CEDRXP: 4,"1010","1010","0001" - - #. Start GPS with GPS fix data and geographic position latitude/longitude and time, and observe the output. - - .. parsed-literal:: - :class: highlight - - **AT#XGPS=1,3** - #XGPS: 1,3 - OK - #XGPSS: tracking 1 using 1 unhealthy 0 - #XGPSS: tracking 2 using 2 unhealthy 0 - *[...]* - - #. Turn off GPS. - - .. parsed-literal:: - :class: highlight - - **AT#XGPS=0** - #XGPS: 0 - OK - -#. Test A-GPS: - - a. Subscribe to unsolicited network status notifications. - Then enable support for LTE Cat-M1 and GNSS in the modem. - - .. parsed-literal:: - :class: highlight - - **AT+CFUN=0** - OK - - **AT+CEREG=2** - OK - - **AT%XSYSTEMMODE=1,0,1,0** - OK - -.. include:: slm_testing.rst - :start-after: modem_config_start - :end-before: modem_config_end - -.. - - c. Turn on the modem. - - .. parsed-literal:: - :class: highlight - - **AT+CFUN=1** - OK - +CEREG: 2,"107E","00B02C03",7 - +CEREG: 1,"107E","00B02C03",7 - - #. Start GPS with GPS fix data and geographic position latitude/longitude and time, and observe the output. - Note that the TTFF printed in the AT response is from the time when AT#XGPS was issued. - For A-GPS, this includes the SUPL injection time. - - .. parsed-literal:: - :class: highlight - - **AT#XGPS=1,3** - #XGPS: 1,3 - OK - GPS suspended - SUPL injection done - GPS resumed - #XGPSS: track 3 use 3 unhealthy 0 - #XGPSS: track 4 use 4 unhealthy 0 - #XGPSS: track 5 use 5 unhealthy 0 - #XGPSS: track 4 use 4 unhealthy 0 - #XGPSS: track 5 use 5 unhealthy 0 - #XGPSS: track 6 use 6 unhealthy 0 - #XGPSS: track 7 use 7 unhealthy 0 - #XGPSS: track 6 use 6 unhealthy 0 - #XGPSP: long 139.721966 lat 35.534159 - #XGPSP: 2020-04-30 00:11:55 - #XGPSP: TTFF 57s - $GPGGA,001155.87,3532.04954,N,13943.31794,E,1,06,17.40,109.53,M,0,,*19 - $GPGLL,3532.04954,N,13943.31794,E,001155.87,A,A*69 - #XGPSP: long 139.721969 lat 35.534148 - #XGPSP: 2020-04-30 00:11:56 - $GPGGA,001156.87,3532.04889,N,13943.31811,E,1,07,17.38,111.08,M,0,,*10 - $GPGLL,3532.04889,N,13943.31811,E,001156.87,A,A*69 - #XGPSP: long 139.721982 lat 35.534138 diff --git a/applications/serial_lte_modem/nrf9160dk_nrf9160ns.overlay b/applications/serial_lte_modem/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from applications/serial_lte_modem/nrf9160dk_nrf9160ns.overlay rename to applications/serial_lte_modem/nrf9160dk_nrf9160_ns.overlay diff --git a/applications/serial_lte_modem/prj.conf b/applications/serial_lte_modem/prj.conf index eeb4b643cb2b..386207078b06 100644 --- a/applications/serial_lte_modem/prj.conf +++ b/applications/serial_lte_modem/prj.conf @@ -45,16 +45,9 @@ CONFIG_MAIN_STACK_SIZE=4096 CONFIG_HEAP_MEM_POOL_SIZE=16384 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 -# AT_CMD -# Enable AT_CMD debug for details -#CONFIG_AT_CMD_LOG_LEVEL_DBG=y - # Device power management CONFIG_PM_DEVICE=y -# Enable SUPL client support -#CONFIG_SUPL_CLIENT_LIB=y - # FOTA CONFIG_HTTP_PARSER_URL=y CONFIG_FOTA_DOWNLOAD=y @@ -77,6 +70,19 @@ CONFIG_SETTINGS=y CONFIG_SETTINGS_FCB=y CONFIG_FCB=y +# nRF Cloud +CONFIG_CLOUD_API=y +CONFIG_NRF_CLOUD=y +CONFIG_NRF_CLOUD_AGPS=y +CONFIG_NRF_CLOUD_PGPS=y +CONFIG_NRF_CLOUD_CELL_POS=y +CONFIG_NRF_CLOUD_LOG_LEVEL_INF=y +CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD=y +CONFIG_NRF_CLOUD_MQTT_KEEPALIVE=1200 +CONFIG_DATE_TIME=y +CONFIG_MODEM_INFO=y +CONFIG_MODEM_INFO_ADD_DATE_TIME=n + # # SLM-specific configurations # @@ -89,3 +95,7 @@ CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2 # Use UART_2 (when working with external MCU) #CONFIG_SLM_CONNECT_UART_2=y #CONFIG_UART_2_NRF_HW_ASYNC_TIMER=2 +# nRF Cloud based location services +CONFIG_SLM_AGPS=n +CONFIG_SLM_PGPS=n +CONFIG_SLM_CELL_POS=n diff --git a/applications/serial_lte_modem/sample.yaml b/applications/serial_lte_modem/sample.yaml index 90e1525e4af3..08dd412e229c 100644 --- a/applications/serial_lte_modem/sample.yaml +++ b/applications/serial_lte_modem/sample.yaml @@ -3,10 +3,10 @@ sample: tests: samples.nrf9160.serial_lte_modem: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns tags: ci_build samples.nrf9160.serial_lte_modem.native_tls: build_only: true extra_args: OVERLAY_CONFIG=overlay-native_tls.conf - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns tags: ci_build diff --git a/applications/serial_lte_modem/src/ftp_c/Kconfig b/applications/serial_lte_modem/src/ftp_c/Kconfig index 177d5b77bf70..5777b0ed53d0 100644 --- a/applications/serial_lte_modem/src/ftp_c/Kconfig +++ b/applications/serial_lte_modem/src/ftp_c/Kconfig @@ -7,23 +7,3 @@ config SLM_FTPC bool "FTP client support in SLM" default y select FTP_CLIENT - -if SLM_FTPC - -config SLM_FTP_SERVER_PORT - int "FTP service port on remote host" - default 21 - -config SLM_FTP_USER_ANONYMOUS - string "FTP client anonymous login user" - default "anonymous" - help - Define the user name for anonymous login. - -config SLM_FTP_PASSWORD_ANONYMOUS - string "FTP client anonymous login password" - default "anonymous@example.com" - help - Define the password for anonymous login. - -endif diff --git a/applications/serial_lte_modem/src/ftp_c/slm_at_ftp.c b/applications/serial_lte_modem/src/ftp_c/slm_at_ftp.c index 09a970b121e8..f22de669c4a4 100644 --- a/applications/serial_lte_modem/src/ftp_c/slm_at_ftp.c +++ b/applications/serial_lte_modem/src/ftp_c/slm_at_ftp.c @@ -17,13 +17,13 @@ LOG_MODULE_REGISTER(slm_ftp, CONFIG_SLM_LOG_LEVEL); -#define INVALID_SEC_TAG -1 -#define FTP_MAX_HOSTNAME 64 -#define FTP_MAX_USERNAME 32 -#define FTP_MAX_PASSWORD 32 #define FTP_MAX_OPTION 32 #define FTP_MAX_FILEPATH 128 +#define FTP_USER_ANONYMOUS "anonymous" +#define FTP_PASSWORD_ANONYMOUS "anonymous@example.com" +#define FTP_DEFAULT_PORT 21 + /**@brief Socketopt operations. */ enum slm_ftp_operation { /* FTP Session Management */ @@ -139,10 +139,13 @@ void ftp_ctrl_callback(const uint8_t *msg, uint16_t len) sprintf(rsp_buf, "\r\n#XFTP: %d,\"disconnected\"\r\n", -ENOEXEC); break; } - rsp_send(rsp_buf, strlen(rsp_buf)); - if (ftp_data_mode_handler && exit_datamode(false)) { + if (ftp_data_mode_handler && exit_datamode(DATAMODE_EXIT_URC)) { ftp_data_mode_handler = NULL; } + if (ftp_verbose_on) { + rsp_send(rsp_buf, strlen(rsp_buf)); + } + return; } if (ftp_verbose_on) { @@ -153,7 +156,7 @@ void ftp_ctrl_callback(const uint8_t *msg, uint16_t len) static int ftp_data_save(uint8_t *data, uint32_t length) { if (ring_buf_space_get(&ftp_data_buf) < length) { - LOG_WRN("RX overrun"); + LOG_WRN("FTP buffer overflow"); return -1; /* RX overrun */ } @@ -166,7 +169,7 @@ static int ftp_data_send(void) if (ring_buf_is_empty(&ftp_data_buf) == 0) { sz_send = ring_buf_get(&ftp_data_buf, rsp_buf, sizeof(rsp_buf)); - rsp_send(rsp_buf, sz_send); + datamode_send(rsp_buf, sz_send); } return sz_send; @@ -182,21 +185,21 @@ void ftp_data_callback(const uint8_t *msg, uint16_t len) static int do_ftp_open(void) { int ret = 0; - char username[FTP_MAX_USERNAME] = ""; /* DO initialize, in case of login error */ - int sz_username = FTP_MAX_USERNAME; - char password[FTP_MAX_PASSWORD] = ""; /* DO initialize, in case of login error */ - int sz_password = FTP_MAX_PASSWORD; - char hostname[FTP_MAX_HOSTNAME]; - int sz_hostname = FTP_MAX_HOSTNAME; - uint16_t port = CONFIG_SLM_FTP_SERVER_PORT; + char username[SLM_MAX_USERNAME] = ""; /* DO initialize, in case of login error */ + int sz_username = sizeof(username); + char password[SLM_MAX_PASSWORD] = ""; /* DO initialize, in case of login error */ + int sz_password = sizeof(password); + char hostname[SLM_MAX_URL]; + int sz_hostname = sizeof(hostname); + uint16_t port = FTP_DEFAULT_PORT; sec_tag_t sec_tag = INVALID_SEC_TAG; int param_count = at_params_valid_count_get(&at_param_list); /* Parse AT command */ ret = util_string_get(&at_param_list, 2, username, &sz_username); if (ret || strlen(username) == 0) { - strcpy(username, CONFIG_SLM_FTP_USER_ANONYMOUS); - strcpy(password, CONFIG_SLM_FTP_PASSWORD_ANONYMOUS); + strcpy(username, FTP_USER_ANONYMOUS); + strcpy(password, FTP_PASSWORD_ANONYMOUS); } else { ret = util_string_get(&at_param_list, 3, password, &sz_password); if (ret) { @@ -221,7 +224,7 @@ static int do_ftp_open(void) } /* FTP open */ - ret = ftp_open(hostname, (uint16_t)port, sec_tag); + ret = ftp_open(hostname, port, sec_tag); if (ret != FTP_CODE_200) { return -ENETUNREACH; } @@ -463,7 +466,7 @@ static int ftp_put_handler(const uint8_t *data, int len) ret = ftp_put(filepath, data, len, FTP_PUT_NORMAL); } - if (exit_datamode(false)) { + if (exit_datamode(DATAMODE_EXIT_URC)) { ftp_data_mode_handler = NULL; } @@ -515,7 +518,7 @@ static int ftp_uput_handler(const uint8_t *data, int len) ret = ftp_put(NULL, data, len, FTP_PUT_UNIQUE); } - if (exit_datamode(false)) { + if (exit_datamode(DATAMODE_EXIT_URC)) { ftp_data_mode_handler = NULL; } diff --git a/applications/serial_lte_modem/src/gnss/CMakeLists.txt b/applications/serial_lte_modem/src/gnss/CMakeLists.txt new file mode 100644 index 000000000000..a2f907fe0961 --- /dev/null +++ b/applications/serial_lte_modem/src/gnss/CMakeLists.txt @@ -0,0 +1,8 @@ +# +# Copyright (c) 2021 Nordic Semiconductor +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +zephyr_include_directories(.) +target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/slm_at_gnss.c) diff --git a/applications/serial_lte_modem/src/gnss/Kconfig b/applications/serial_lte_modem/src/gnss/Kconfig new file mode 100644 index 000000000000..394cc273cb55 --- /dev/null +++ b/applications/serial_lte_modem/src/gnss/Kconfig @@ -0,0 +1,30 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +config SLM_GNSS + bool "GNSS support in SLM" + default y + +if SLM_GNSS + +config SLM_AGPS + bool "Use nRF Cloud A-GPS" + depends on NRF_CLOUD_AGPS + help + Use nRF Cloud A-GPS in GPS operation + +config SLM_PGPS + bool "Use nRF Cloud P-GPS" + depends on NRF_CLOUD_PGPS + help + Use nRF Cloud P-GPS in GPS operation + +config SLM_CELL_POS + bool "Use nRF Cloud cellular positioning" + depends on NRF_CLOUD_CELL_POS + help + Request nRF Cloud cellular positioning service + +endif # SLM_GNSS diff --git a/applications/serial_lte_modem/src/gnss/slm_at_gnss.c b/applications/serial_lte_modem/src/gnss/slm_at_gnss.c new file mode 100644 index 000000000000..3c79b25928f1 --- /dev/null +++ b/applications/serial_lte_modem/src/gnss/slm_at_gnss.c @@ -0,0 +1,855 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "slm_util.h" +#include "slm_at_host.h" +#include "slm_at_gnss.h" + +LOG_MODULE_REGISTER(slm_gnss, CONFIG_SLM_LOG_LEVEL); + +#define SERVICE_INFO_GPS \ + "{\"state\":{\"reported\":{\"device\": {\"serviceInfo\":{\"ui\":[\"GPS\"]}}}}}" + +/**@brief GNSS operations. */ +enum slm_gnss_operation { + GPS_STOP, + GPS_START, + nRF_CLOUD_DISCONNECT = GPS_STOP, + nRF_CLOUD_CONNECT = GPS_START, + AGPS_STOP = GPS_STOP, + AGPS_START = GPS_START, + PGPS_STOP = GPS_STOP, + PGPS_START = GPS_START, + CELLPOS_STOP = GPS_STOP, + CELLPOS_START_SCELL = GPS_START, + CELLPOS_START_MCELL +}; + +static struct k_work agps_req; +static struct k_work pgps_req; +static struct k_work fix_rep; +static struct k_work cell_pos_req; +static enum nrf_cloud_cell_pos_type cell_pos_type; + +static struct cloud_backend *nrf_cloud; +static bool nrf_cloud_ready; +static bool location_signify; +static uint64_t ttft_start; +static enum { + RUN_TYPE_NONE, + RUN_TYPE_GPS, + RUN_TYPE_AGPS, + RUN_TYPE_PGPS, + RUN_TYPE_CELL_POS +} run_type; + +K_SEM_DEFINE(sem_date_time, 0, 1); + +/* global functions defined in different files */ +void rsp_send(const char *str, size_t len); + +/* global variable defined in different files */ +extern struct k_work_q slm_work_q; +extern struct at_param_list at_param_list; +extern char rsp_buf[CONFIG_SLM_SOCKET_RX_MAX * 2]; + +static int read_agps_req(struct gps_agps_request *req) +{ + int err; + struct nrf_modem_gnss_agps_data_frame agps_data; + + err = nrf_modem_gnss_read((void *)&agps_data, sizeof(agps_data), + NRF_MODEM_GNSS_DATA_AGPS_REQ); + if (err) { + LOG_ERR("Failed to read GNSS AGPS req, error %d", err); + return -EAGAIN; + } + + req->sv_mask_ephe = agps_data.sv_mask_ephe, + req->sv_mask_alm = agps_data.sv_mask_alm, + req->utc = (agps_data.data_flags & NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST) ? 1 : 0, + req->klobuchar = (agps_data.data_flags & NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST) ? 1 : 0, + req->nequick = (agps_data.data_flags & NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST) ? 1 : 0, + req->system_time_tow = + (agps_data.data_flags & NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST) ? 1 : 0, + req->position = (agps_data.data_flags & NRF_MODEM_GNSS_AGPS_POSITION_REQUEST) ? 1 : 0, + req->integrity = (agps_data.data_flags & NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST) ? 1 : 0; + + return 0; +} + +static void agps_req_wk(struct k_work *work) +{ + int err; + struct gps_agps_request req; + + ARG_UNUSED(work); + + err = read_agps_req(&req); + if (err) { + return; + } + + err = nrf_cloud_agps_request(req); + if (err) { + LOG_ERR("Failed to request A-GPS data: %d", err); + } +} + +static void pgps_req_wk(struct k_work *work) +{ + int err; + + ARG_UNUSED(work); + + /* Indirect request of P-GPS data and periodic injection */ + err = nrf_cloud_pgps_notify_prediction(); + if (err) { + LOG_ERR("Failed to request notify of prediction: %d", err); + } +} + +static void cell_pos_req_wk(struct k_work *work) +{ + int err; + + ARG_UNUSED(work); + + err = nrf_cloud_cell_pos_request(cell_pos_type, true); + if (err) { + LOG_ERR("Failed to request cell_pos %d, error: %d", cell_pos_type, err); + } +} + +static void pgps_event_handler(enum nrf_cloud_pgps_event event, + struct nrf_cloud_pgps_prediction *prediction) +{ + int err; + + switch (event) { + /* P-GPS initialization beginning. */ + case PGPS_EVT_INIT: + LOG_INF("PGPS_EVT_INIT"); + break; + /* There are currently no P-GPS predictions available. */ + case PGPS_EVT_UNAVAILABLE: + LOG_INF("PGPS_EVT_UNAVAILABLE"); + break; + /* P-GPS predictions are being loaded from the cloud. */ + case PGPS_EVT_LOADING: + LOG_INF("PGPS_EVT_LOADING"); + break; + /* A P-GPS prediction is available now for the current date and time. */ + case PGPS_EVT_AVAILABLE: { + struct gps_agps_request req; + + LOG_INF("PGPS_EVT_AVAILABLE"); + /* read out previous NRF_MODEM_GNSS_EVT_AGPS_REQ */ + err = read_agps_req(&req); + if (err) { + /* All assistance elements as requested */ + err = nrf_cloud_pgps_inject(prediction, &req, NULL); + } else { + /* ephemerides assistance only */ + err = nrf_cloud_pgps_inject(prediction, NULL, NULL); + } + if (err) { + LOG_ERR("Unable to send prediction to modem: %d", err); + break; + } + err = nrf_cloud_pgps_preemptive_updates(); + if (err) { + LOG_ERR("Preemptive updates error: %d", err); + } + } break; + /* All P-GPS predictions are available. */ + case PGPS_EVT_READY: + LOG_INF("PGPS_EVT_READY"); + break; + default: + break; + } +} + +static void on_gnss_evt_pvt(void) +{ + struct nrf_modem_gnss_pvt_data_frame pvt; + int err; + + err = nrf_modem_gnss_read((void *)&pvt, sizeof(pvt), NRF_MODEM_GNSS_DATA_PVT); + if (err) { + LOG_ERR("Failed to read GNSS PVT data, error %d", err); + return; + } + for (int i = 0; i < NRF_MODEM_GNSS_MAX_SATELLITES; ++i) { + if (pvt.sv[i].sv) { /* SV number 0 indicates no satellite */ + LOG_DBG("SV:%3d sig: %d c/n0:%4d", + pvt.sv[i].sv, pvt.sv[i].signal, pvt.sv[i].cn0); + } + } +} + +static void fix_rep_wk(struct k_work *work) +{ + int err; + struct nrf_modem_gnss_pvt_data_frame pvt; + + ARG_UNUSED(work); + + err = nrf_modem_gnss_read((void *)&pvt, sizeof(pvt), NRF_MODEM_GNSS_DATA_PVT); + if (err) { + LOG_ERR("Failed to read GNSS PVT data, error %d", err); + return; + } + + sprintf(rsp_buf, + "\r\n#XGPS: %lf,%lf,%f,%f,%f,%f,\"%04u-%02u-%02u %02u:%02u:%02u\"\r\n", + pvt.latitude, pvt.longitude, pvt.altitude, + pvt.accuracy, pvt.speed, pvt.heading, + pvt.datetime.year, pvt.datetime.month, pvt.datetime.day, + pvt.datetime.hour, pvt.datetime.minute, pvt.datetime.seconds); + rsp_send(rsp_buf, strlen(rsp_buf)); + + for (int i = 0; i < NRF_MODEM_GNSS_MAX_SATELLITES; ++i) { + if (pvt.sv[i].sv) { /* SV number 0 indicates no satellite */ + LOG_INF("SV:%3d sig: %d c/n0:%4d el:%3d az:%3d in-fix: %d unhealthy: %d", + pvt.sv[i].sv, pvt.sv[i].signal, pvt.sv[i].cn0, + pvt.sv[i].elevation, pvt.sv[i].azimuth, + (pvt.sv[i].flags & NRF_MODEM_GNSS_SV_FLAG_USED_IN_FIX) ? 1 : 0, + (pvt.sv[i].flags & NRF_MODEM_GNSS_SV_FLAG_UNHEALTHY) ? 1 : 0); + } + } + + if (run_type == RUN_TYPE_PGPS) { + struct tm gps_time = { + .tm_year = pvt.datetime.year - 1900, + .tm_mon = pvt.datetime.month - 1, + .tm_mday = pvt.datetime.day, + .tm_hour = pvt.datetime.hour, + .tm_min = pvt.datetime.minute, + .tm_sec = pvt.datetime.seconds, + }; + + /* help date_time to save SNTP transactions */ + date_time_set(&gps_time); + /* help nrf_cloud_pgps as most recent known location */ + nrf_cloud_pgps_set_location(pvt.latitude, pvt.longitude); + } +} + +static void on_gnss_evt_fix(void) +{ + if (ttft_start != 0) { + LOG_INF("TTFF %ds", (int)k_uptime_delta(&ttft_start)/1000); + ttft_start = 0; + } + + k_work_submit_to_queue(&slm_work_q, &fix_rep); +} + +static void on_gnss_evt_agps_req(void) +{ + if (run_type == RUN_TYPE_AGPS) { + k_work_submit_to_queue(&slm_work_q, &agps_req); + } else if (run_type == RUN_TYPE_PGPS) { + /* Check whether prediction data available or not */ + k_work_submit_to_queue(&slm_work_q, &pgps_req); + } +} + +/* NOTE this event handler runs in interrupt context */ +static void gnss_event_handler(int event) +{ + switch (event) { + case NRF_MODEM_GNSS_EVT_PVT: + LOG_DBG("GNSS_EVT_PVT"); + on_gnss_evt_pvt(); + break; + case NRF_MODEM_GNSS_EVT_FIX: + LOG_INF("GNSS_EVT_FIX"); + on_gnss_evt_fix(); + break; + case NRF_MODEM_GNSS_EVT_NMEA: + LOG_DBG("GNSS_EVT_NMEA"); + break; + case NRF_MODEM_GNSS_EVT_AGPS_REQ: + LOG_INF("GNSS_EVT_AGPS_REQ"); + on_gnss_evt_agps_req(); + break; + case NRF_MODEM_GNSS_EVT_BLOCKED: + LOG_INF("GNSS_EVT_BLOCKED"); + break; + case NRF_MODEM_GNSS_EVT_UNBLOCKED: + LOG_INF("GNSS_EVT_UNBLOCKED"); + break; + case NRF_MODEM_GNSS_EVT_PERIODIC_WAKEUP: + LOG_DBG("GNSS_EVT_PERIODIC_WAKEUP"); + break; + case NRF_MODEM_GNSS_EVT_SLEEP_AFTER_TIMEOUT: + LOG_DBG("GNSS_EVT_SLEEP_AFTER_TIMEOUT"); + break; + case NRF_MODEM_GNSS_EVT_SLEEP_AFTER_FIX: + LOG_DBG("GNSS_EVT_SLEEP_AFTER_FIX"); + break; + case NRF_MODEM_GNSS_EVT_REF_ALT_EXPIRED: + LOG_DBG("GNSS_EVT_REF_ALT_EXPIRED"); + break; + default: + break; + } +} + +static void on_cloud_evt_ready(void) +{ + if (location_signify) { + int err; + struct cloud_msg msg = { + .qos = CLOUD_QOS_AT_MOST_ONCE, + .endpoint.type = CLOUD_EP_STATE, + .buf = SERVICE_INFO_GPS, + .len = strlen(SERVICE_INFO_GPS) + }; + + /* Update nRF Cloud with GPS service info signifying GPS capabilities. */ + err = cloud_send(nrf_cloud, &msg); + if (err) { + LOG_WRN("Failed to send message to cloud, error: %d", err); + } + } + + nrf_cloud_ready = true; + sprintf(rsp_buf, "\r\n#XNRFCLOUD: %d,%d\r\n", nrf_cloud_ready, location_signify); + rsp_send(rsp_buf, strlen(rsp_buf)); +} + +static void on_cloud_evt_disconnected(void) +{ + nrf_cloud_ready = false; + sprintf(rsp_buf, "\r\n#XNRFCLOUD: %d,%d\r\n", nrf_cloud_ready, location_signify); + rsp_send(rsp_buf, strlen(rsp_buf)); +} + +static void on_cloud_evt_data_received(const struct cloud_event *const evt) +{ + int err = 0; + + if (run_type == RUN_TYPE_AGPS) { + err = nrf_cloud_agps_process(evt->data.msg.buf, evt->data.msg.len, NULL); + if (err) { + LOG_INF("Unable to process A-GPS data, error: %d", err); + } + } else if (run_type == RUN_TYPE_PGPS) { + err = nrf_cloud_pgps_process(evt->data.msg.buf, evt->data.msg.len); + if (err) { + LOG_ERR("Unable to process P-GPS data, error: %d", err); + } + } else if (run_type == RUN_TYPE_CELL_POS) { + struct nrf_cloud_cell_pos_result result; + + err = nrf_cloud_cell_pos_process(evt->data.msg.buf, &result); + if (err == 0) { + if (ttft_start != 0) { + LOG_INF("TTFF %ds", (int)k_uptime_delta(&ttft_start)/1000); + ttft_start = 0; + } + sprintf(rsp_buf, "\r\n#XCELLPOS: %d,%lf,%lf,%d\r\n", + result.type, result.lat, result.lon, result.unc); + rsp_send(rsp_buf, strlen(rsp_buf)); + run_type = RUN_TYPE_NONE; + } else if (err == 1) { + LOG_WRN("No position found"); + } else { + LOG_ERR("Unable to process cell pos data, error: %d", err); + } + } +} + +static void cloud_event_handler(const struct cloud_backend *const backend, + const struct cloud_event *const evt, void *user_data) +{ + ARG_UNUSED(backend); + ARG_UNUSED(user_data); + + switch (evt->type) { + case CLOUD_EVT_CONNECTING: + LOG_DBG("CLOUD_EVT_CONNECTING"); + break; + case CLOUD_EVT_CONNECTED: + LOG_INF("CLOUD_EVT_CONNECTED"); + break; + case CLOUD_EVT_READY: + LOG_INF("CLOUD_EVT_READY"); + on_cloud_evt_ready(); + break; + case CLOUD_EVT_DISCONNECTED: + LOG_INF("CLOUD_EVT_DISCONNECTED"); + on_cloud_evt_disconnected(); + break; + case CLOUD_EVT_ERROR: + LOG_ERR("CLOUD_EVT_ERROR"); + break; + case CLOUD_EVT_DATA_SENT: + LOG_DBG("CLOUD_EVT_DATA_SENT"); + break; + case CLOUD_EVT_DATA_RECEIVED: + LOG_INF("CLOUD_EVT_DATA_RECEIVED"); + on_cloud_evt_data_received(evt); + break; + case CLOUD_EVT_PAIR_REQUEST: + LOG_DBG("CLOUD_EVT_PAIR_REQUEST"); + break; + case CLOUD_EVT_PAIR_DONE: + LOG_DBG("CLOUD_EVT_PAIR_DONE"); + break; + case CLOUD_EVT_FOTA_DONE: + LOG_DBG("CLOUD_EVT_FOTA_DONE"); + break; + case CLOUD_EVT_FOTA_ERROR: + LOG_ERR("CLOUD_EVT_FOTA_ERROR"); + break; + default: + break; + } +} + +static void date_time_event_handler(const struct date_time_evt *evt) +{ + switch (evt->type) { + case DATE_TIME_OBTAINED_MODEM: + case DATE_TIME_OBTAINED_NTP: + case DATE_TIME_OBTAINED_EXT: + LOG_DBG("DATE_TIME OBTAINED"); + k_sem_give(&sem_date_time); + break; + case DATE_TIME_NOT_OBTAINED: + LOG_INF("DATE_TIME_NOT_OBTAINED"); + break; + default: + break; + } +} + +/**@brief handle AT#XGPS commands + * AT#XGPS=[,[,]] + * AT#XGPS? READ command not supported + * AT#XGPS=? + */ +int handle_at_gps(enum at_cmd_type cmd_type) +{ + int err = -EINVAL; + uint16_t op; + uint16_t interval; + uint16_t timeout; + + switch (cmd_type) { + case AT_CMD_TYPE_SET_COMMAND: + err = at_params_unsigned_short_get(&at_param_list, 1, &op); + if (err < 0) { + return err; + } + if (op == GPS_START && run_type == RUN_TYPE_NONE) { + err = at_params_unsigned_short_get(&at_param_list, 2, &interval); + if (err < 0) { + return err; + } + /* GNSS API spec check */ + if (interval != 0 && interval != 1 && + (interval < 10 || interval > 65535)) { + return -EINVAL; + } + if (interval == 0) { + err = nrf_modem_gnss_use_case_set( + NRF_MODEM_GNSS_USE_CASE_LOW_ACCURACY); + if (err) { + LOG_ERR("Failed to set use case, error: %d", err); + return err; + } + } + err = nrf_modem_gnss_fix_interval_set(interval); + if (err) { + LOG_ERR("Failed to set fix interval, error: %d", err); + return err; + } + if (at_params_unsigned_short_get(&at_param_list, 3, &timeout) == 0) { + err = nrf_modem_gnss_fix_retry_set(timeout); + if (err) { + LOG_ERR("Failed to set fix retry, error: %d", err); + return err; + } + } + + run_type = RUN_TYPE_GPS; + err = nrf_modem_gnss_start(); + if (err) { + LOG_ERR("Failed to start GPS, error: %d", err); + run_type = RUN_TYPE_NONE; + } else { + ttft_start = k_uptime_get(); + } + } else if (op == GPS_STOP && run_type == RUN_TYPE_GPS) { + err = nrf_modem_gnss_stop(); + run_type = RUN_TYPE_NONE; + } else { + err = -EINVAL; + } break; + + case AT_CMD_TYPE_TEST_COMMAND: + sprintf(rsp_buf, "\r\n#XGPS: (%d,%d),,\r\n", + GPS_STOP, GPS_START); + rsp_send(rsp_buf, strlen(rsp_buf)); + err = 0; + break; + + default: + break; + } + + return err; +} + +/**@brief handle AT#XNRFCLOUD commands + * AT#XNRFCLOUD=[,] + * AT#XNRFCLOUD? + * AT#XNRFCLOUD=? + */ +int handle_at_nrf_cloud(enum at_cmd_type cmd_type) +{ + int err = -EINVAL; + uint16_t op; + uint16_t signify = 0; + + switch (cmd_type) { + case AT_CMD_TYPE_SET_COMMAND: + err = at_params_unsigned_short_get(&at_param_list, 1, &op); + if (err < 0) { + return err; + } + if (op == nRF_CLOUD_CONNECT && !nrf_cloud_ready) { + location_signify = 0; + if (at_params_valid_count_get(&at_param_list) > 2) { + err = at_params_unsigned_short_get(&at_param_list, 2, &signify); + if (err < 0) { + return err; + } + location_signify = (signify > 0); + } + err = cloud_connect(nrf_cloud); + if (err) { + LOG_ERR("Cloud connection failed, error: %d", err); + } + } else if (op == nRF_CLOUD_DISCONNECT && nrf_cloud_ready) { + err = cloud_disconnect(nrf_cloud); + if (err) { + LOG_ERR("Cloud disconnection failed, error: %d", err); + } + } else { + err = -EINVAL; + } break; + + case AT_CMD_TYPE_READ_COMMAND: + sprintf(rsp_buf, "\r\n#XNRFCLOUD: %d,%d\r\n", nrf_cloud_ready, location_signify); + rsp_send(rsp_buf, strlen(rsp_buf)); + err = 0; + break; + + case AT_CMD_TYPE_TEST_COMMAND: + sprintf(rsp_buf, "\r\n#XNRFCLOUD: (%d,%d),\r\n", + nRF_CLOUD_CONNECT, nRF_CLOUD_DISCONNECT); + rsp_send(rsp_buf, strlen(rsp_buf)); + err = 0; + break; + + default: + break; + } + + return err; +} + +/**@brief handle AT#XAGPS commands + * AT#XAGPS=[,[,]] + * AT#XAGPS? READ command not supported + * AT#XAGPS=? + */ +int handle_at_agps(enum at_cmd_type cmd_type) +{ + int err = -EINVAL; + uint16_t op; + uint16_t interval; + uint16_t timeout; + + switch (cmd_type) { + case AT_CMD_TYPE_SET_COMMAND: + err = at_params_unsigned_short_get(&at_param_list, 1, &op); + if (err < 0) { + return err; + } + if (op == AGPS_START && nrf_cloud_ready && run_type == RUN_TYPE_NONE) { + err = at_params_unsigned_short_get(&at_param_list, 2, &interval); + if (err < 0) { + return err; + } + /* GNSS API spec check */ + if (interval != 0 && interval != 1 && + (interval < 10 || interval > 65535)) { + return -EINVAL; + } + if (interval == 0) { + err = nrf_modem_gnss_use_case_set( + NRF_MODEM_GNSS_USE_CASE_LOW_ACCURACY); + if (err) { + LOG_ERR("Failed to set use case, error: %d", err); + return err; + } + } + err = nrf_modem_gnss_fix_interval_set(interval); + if (err) { + LOG_ERR("Failed to set fix interval, error: %d", err); + return err; + } + if (at_params_unsigned_short_get(&at_param_list, 3, &timeout) == 0) { + err = nrf_modem_gnss_fix_retry_set(timeout); + if (err) { + LOG_ERR("Failed to set fix retry, error: %d", err); + return err; + } + } + + /* A-GPS needs date_time, trigger to update current time */ + date_time_update_async(date_time_event_handler); + if (k_sem_take(&sem_date_time, K_SECONDS(10)) != 0) { + LOG_ERR("Failed to get current time"); + return -EAGAIN; + } + + /** set the flag before starting GNSS as modem instantly + * send NRF_MODEM_GNSS_EVT_AGPS_REQ event + */ + run_type = RUN_TYPE_AGPS; + err = nrf_modem_gnss_start(); + if (err) { + LOG_ERR("Failed to start GNSS, error: %d", err); + run_type = RUN_TYPE_NONE; + } else { + ttft_start = k_uptime_get(); + } + } else if (op == AGPS_STOP && run_type == RUN_TYPE_AGPS) { + err = nrf_modem_gnss_stop(); + run_type = RUN_TYPE_NONE; + } else { + err = -EINVAL; + } break; + + case AT_CMD_TYPE_TEST_COMMAND: + sprintf(rsp_buf, "\r\n#XAGPS: (%d,%d),,\r\n", + AGPS_STOP, AGPS_START); + rsp_send(rsp_buf, strlen(rsp_buf)); + err = 0; + break; + + default: + break; + } + + return err; +} + +/**@brief handle AT#XPGPS commands + * AT#XPGPS=[,[,]] + * AT#XPGPS? READ command not supported + * AT#XPGPS=? + */ +int handle_at_pgps(enum at_cmd_type cmd_type) +{ + int err = -EINVAL; + uint16_t op; + uint16_t interval; + uint16_t timeout; + + switch (cmd_type) { + case AT_CMD_TYPE_SET_COMMAND: + err = at_params_unsigned_short_get(&at_param_list, 1, &op); + if (err < 0) { + return err; + } + if (op == PGPS_START && nrf_cloud_ready && run_type == RUN_TYPE_NONE) { + err = at_params_unsigned_short_get(&at_param_list, 2, &interval); + if (err < 0) { + return err; + } + /* GNSS API spec check, P-GPS is used in periodic mode only */ + if (interval < 10 || interval > 65535) { + return -EINVAL; + } + err = nrf_modem_gnss_fix_interval_set(interval); + if (err) { + LOG_ERR("Failed to set fix interval, error: %d", err); + return err; + } + if (at_params_unsigned_short_get(&at_param_list, 3, &timeout) == 0) { + err = nrf_modem_gnss_fix_retry_set(timeout); + if (err) { + LOG_ERR("Failed to set fix retry, error: %d", err); + return err; + } + } + + /* P-GPS needs date_time, trigger to update current time */ + date_time_update_async(date_time_event_handler); + if (k_sem_take(&sem_date_time, K_SECONDS(10)) != 0) { + LOG_ERR("Failed to get current time"); + return -EAGAIN; + } + + struct nrf_cloud_pgps_init_param param = { + .event_handler = pgps_event_handler, + .storage_base = PM_MCUBOOT_SECONDARY_ADDRESS, + .storage_size = PM_MCUBOOT_SECONDARY_SIZE}; + + err = nrf_cloud_pgps_init(¶m); + if (err) { + LOG_ERR("Error from P-GPS init: %d", err); + return err; + } + + run_type = RUN_TYPE_PGPS; + err = nrf_modem_gnss_start(); + if (err) { + LOG_ERR("Failed to start GNSS, error: %d", err); + run_type = RUN_TYPE_NONE; + } else { + ttft_start = k_uptime_get(); + } + } else if (op == PGPS_STOP && run_type == RUN_TYPE_PGPS) { + err = nrf_modem_gnss_stop(); + run_type = RUN_TYPE_NONE; + } else { + err = -EINVAL; + } break; + + case AT_CMD_TYPE_TEST_COMMAND: + sprintf(rsp_buf, "\r\n#XPGPS: (%d,%d),,\r\n", + PGPS_STOP, PGPS_START); + rsp_send(rsp_buf, strlen(rsp_buf)); + err = 0; + break; + + default: + break; + } + + return err; +} + +/**@brief handle AT#XCELLPOS commands + * AT#XCELLPOS= + * AT#XCELLPOS? READ command not supported + * AT#XCELLPOS=? + */ +int handle_at_cellpos(enum at_cmd_type cmd_type) +{ + int err = -EINVAL; + uint16_t op; + + switch (cmd_type) { + case AT_CMD_TYPE_SET_COMMAND: + err = at_params_unsigned_short_get(&at_param_list, 1, &op); + if (err < 0) { + return err; + } + if ((op == CELLPOS_START_SCELL || op == CELLPOS_START_MCELL) && + nrf_cloud_ready && run_type == RUN_TYPE_NONE) { + if (op == CELLPOS_START_SCELL) { + cell_pos_type = CELL_POS_TYPE_SINGLE; + } else { + sprintf(rsp_buf, "\r\n#XCELLPOS: \"not supported\"\r\n"); + rsp_send(rsp_buf, strlen(rsp_buf)); + return -ENOTSUP; + } + ttft_start = k_uptime_get(); + k_work_submit_to_queue(&slm_work_q, &cell_pos_req); + run_type = RUN_TYPE_CELL_POS; + } else if (op == CELLPOS_STOP) { + run_type = RUN_TYPE_NONE; + } else { + err = -EINVAL; + } break; + + case AT_CMD_TYPE_TEST_COMMAND: + sprintf(rsp_buf, "\r\n#XCELLPOS: (%d,%d,%d)\r\n", + CELLPOS_STOP, CELLPOS_START_SCELL, CELLPOS_START_MCELL); + rsp_send(rsp_buf, strlen(rsp_buf)); + err = 0; + break; + + default: + break; + } + + return err; +} + +/**@brief API to initialize GNSS AT commands handler + */ +int slm_at_gnss_init(void) +{ + int err = 0; + + err = nrf_modem_gnss_init(); + if (err) { + LOG_ERR("Could not initialize GNSS, error: %d", err); + return err; + } + err = nrf_modem_gnss_event_handler_set(gnss_event_handler); + if (err) { + LOG_ERR("Could set GNSS event handler, error: %d", err); + return err; + } + + if (nrf_cloud == NULL) { + nrf_cloud = cloud_get_binding("NRF_CLOUD"); + if (nrf_cloud == NULL) { + LOG_ERR("Could not get binding to backend"); + return -EINVAL; + } + err = cloud_init(nrf_cloud, cloud_event_handler); + if (err) { + LOG_ERR("Cloud backend could not be initialized, error: %d", err); + return err; + } + } + + k_work_init(&agps_req, agps_req_wk); + k_work_init(&pgps_req, pgps_req_wk); + k_work_init(&cell_pos_req, cell_pos_req_wk); + k_work_init(&fix_rep, fix_rep_wk); + + return err; +} + +/**@brief API to uninitialize GNSS AT commands handler + */ +int slm_at_gnss_uninit(void) +{ + if (nrf_cloud_ready) { + (void)cloud_disconnect(nrf_cloud); + } + (void)cloud_uninit(nrf_cloud); + nrf_cloud = NULL; + (void)nrf_modem_gnss_deinit(); + + return 0; +} diff --git a/applications/serial_lte_modem/src/gnss/slm_at_gnss.h b/applications/serial_lte_modem/src/gnss/slm_at_gnss.h new file mode 100644 index 000000000000..d39673bbc675 --- /dev/null +++ b/applications/serial_lte_modem/src/gnss/slm_at_gnss.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#ifndef SLM_AT_GNSS_ +#define SLM_AT_GNSS_ + +/**@file slm_at_gnss.h + * + * @brief Vendor-specific AT command for GNSS service. + * @{ + */ + +/** + * @brief Initialize GNSS AT command parser. + * + * @retval 0 If the operation was successful. + * Otherwise, a (negative) error code is returned. + */ +int slm_at_gnss_init(void); + +/** + * @brief Uninitialize GNSS AT command parser. + * + * @retval 0 If the operation was successful. + * Otherwise, a (negative) error code is returned. + */ +int slm_at_gnss_uninit(void); + +/** @} */ + +#endif /* SLM_AT_GNSS_ */ diff --git a/applications/serial_lte_modem/src/gps/CMakeLists.txt b/applications/serial_lte_modem/src/gps/CMakeLists.txt deleted file mode 100644 index 58f8eccb2715..000000000000 --- a/applications/serial_lte_modem/src/gps/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# -# Copyright (c) 2020 Nordic Semiconductor -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -zephyr_include_directories(.) -target_sources_ifdef(CONFIG_SLM_GPS app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/slm_at_gps.c) diff --git a/applications/serial_lte_modem/src/gps/Kconfig b/applications/serial_lte_modem/src/gps/Kconfig deleted file mode 100644 index 28af44d23ddf..000000000000 --- a/applications/serial_lte_modem/src/gps/Kconfig +++ /dev/null @@ -1,21 +0,0 @@ -# -# Copyright (c) 2020 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - -config SLM_GPS - bool "GPS support in SLM" - default y - - -if SLM_GPS - -config SLM_SUPL_SERVER - string "SUPL server" - default "supl.google.com" - -config SLM_SUPL_PORT - int "SUPL server port" - default 7276 - -endif diff --git a/applications/serial_lte_modem/src/gps/slm_at_gps.c b/applications/serial_lte_modem/src/gps/slm_at_gps.c deleted file mode 100644 index ead15e495f33..000000000000 --- a/applications/serial_lte_modem/src/gps/slm_at_gps.c +++ /dev/null @@ -1,508 +0,0 @@ -/* - * Copyright (c) 2020 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ -#include - -#include -#include -#include -#include "slm_util.h" -#include "slm_at_host.h" -#include "slm_at_gps.h" - -#ifdef CONFIG_SUPL_CLIENT_LIB -#include -#include -#include -#endif - -LOG_MODULE_REGISTER(slm_gps, CONFIG_SLM_LOG_LEVEL); - -#define IS_FIX(_flag) (_flag & NRF_GNSS_PVT_FLAG_FIX_VALID_BIT) -#define IS_UNHEALTHY(_flag) (_flag & NRF_GNSS_SV_FLAG_UNHEALTHY) - -#define INVALID_SOCKET -1 - -/**@brief List of supported AT commands. */ -enum slm_gps_mode { - GPS_MODE_STANDALONE, - GPS_MODE_PSM, - GPS_MODE_EDRX, - GPS_MODE_AGPS -}; - -static struct gps_client { - int sock; /* Socket descriptor. */ - uint16_t mask; /* NMEA mask */ - bool running; /* GPS running status */ - bool has_fix; /* At least one fix is got */ -} client; - -static nrf_gnss_data_frame_t gps_data; - -#define THREAD_STACK_SIZE KB(1) -#define THREAD_PRIORITY K_LOWEST_APPLICATION_THREAD_PRIO - -static struct k_thread gps_thread; -static k_tid_t gps_thread_id; -static K_THREAD_STACK_DEFINE(gps_thread_stack, THREAD_STACK_SIZE); -static uint64_t ttft_start; - -/* global variable defined in different files */ -extern struct at_param_list at_param_list; -extern char rsp_buf[CONFIG_AT_CMD_RESPONSE_MAX_LEN]; -extern struct k_work_q slm_work_q; - -#ifdef CONFIG_SUPL_CLIENT_LIB -static int supl_fd; -int connect_supl_server(void) -{ - int ret; - struct sockaddr_in server; - struct addrinfo *res; - struct addrinfo hints = { - .ai_family = AF_INET, - .ai_socktype = SOCK_STREAM, - .ai_protocol = IPPROTO_TCP, - /* Either a valid, - * NULL-terminated access point name or NULL. - */ - .ai_canonname = NULL, - }; - - ret = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (ret < 0) { - LOG_ERR("socket() error: %d", -errno); - return -errno; - } - - supl_fd = ret; - ret = getaddrinfo(CONFIG_SLM_SUPL_SERVER, NULL, &hints, &res); - if (ret || res == NULL) { - LOG_ERR("getaddrinfo() error: %d", ret); - close(supl_fd); - return ret; - } - server.sin_family = AF_INET; - server.sin_port = htons(CONFIG_SLM_SUPL_PORT); - server.sin_addr.s_addr = - ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; - ret = connect(supl_fd, (struct sockaddr *)&server, - sizeof(struct sockaddr_in)); - if (ret) { - LOG_ERR("connect() error: %d", -errno); - close(supl_fd); - ret = -errno; - } - - freeaddrinfo(res); - return ret; -} - -ssize_t supl_write(const void *buff, size_t nbytes, void *user_data) -{ - ARG_UNUSED(user_data); - return send(supl_fd, buff, nbytes, 0); -} - -int supl_logger(int level, const char *fmt, ...) -{ - char buffer[256] = { 0 }; - va_list args; - - va_start(args, fmt); - int ret = vsnprintk(buffer, sizeof(buffer), fmt, args); - - va_end(args); - - if (ret < 0) { - LOG_ERR("[SUPL] Encoding error"); - return ret; - } else if ((size_t)ret >= sizeof(buffer)) { - LOG_WRN("[SUPL] Too long message"); - } - - LOG_DBG("[SUPL] %s", log_strdup(buffer)); - - return ret; -} - -ssize_t supl_read(void *buff, size_t nbytes, void *user_data) -{ - ssize_t rc = recv(supl_fd, buff, nbytes, 0); - - ARG_UNUSED(user_data); - - if (rc < 0 && (errno == ETIMEDOUT)) { - return 0; - } - - return rc; -} - -int supl_inject(void *agps, size_t agps_size, nrf_gnss_agps_data_type_t type, - void *user_data) -{ - int ret; - - ARG_UNUSED(user_data); - - ret = nrf_sendto(client.sock, agps, agps_size, 0, &type, sizeof(type)); - if (ret) { - LOG_ERR("Inject error, type: %d (err: %d)", type, errno); - return ret; - } - - LOG_INF("Injected AGPS data, flags: %d, size: %d", type, agps_size); - return 0; -} - -void supl_handler(struct k_work *work) -{ - int ret; - nrf_gnss_delete_mask_t delete_mask = 0; - - ARG_UNUSED(work); - - /* suspend GPS */ - ret = nrf_setsockopt(client.sock, NRF_SOL_GNSS, NRF_SO_GNSS_STOP, - &delete_mask, sizeof(delete_mask)); - if (ret) { - LOG_ERR("Failed to suspend GPS (err: %d)", -errno); - return; - } - k_thread_suspend(gps_thread_id); - sprintf(rsp_buf, "#XGPSS: \"GPS suspended\"\r\n"); - rsp_send(rsp_buf, strlen(rsp_buf)); - - /* SUPL injection */ - ret = connect_supl_server(); - if (ret == 0) { - LOG_DBG("SUPL session start"); - supl_session(&gps_data.agps); - LOG_DBG("SUPL session done"); - close(supl_fd); - } - sprintf(rsp_buf, "#XGPSS: \"SUPL injection done\"\r\n"); - rsp_send(rsp_buf, strlen(rsp_buf)); - - /* Resume GPS */ - k_thread_resume(gps_thread_id); - ret = nrf_setsockopt(client.sock, NRF_SOL_GNSS, NRF_SO_GNSS_START, - &delete_mask, sizeof(delete_mask)); - if (ret) { - LOG_ERR("Failed to resume GPS (err: %d)", -errno); - } else { - ttft_start = k_uptime_get(); - sprintf(rsp_buf, "#XGPSS: \"GPS resumed\"\r\n"); - rsp_send(rsp_buf, strlen(rsp_buf)); - } -} - -K_WORK_DEFINE(supl_work, supl_handler); - -#endif /* CONFIG_SUPL_CLIENT_LIB */ - -static void gps_satellite_stats(void) -{ - static uint8_t last_tracked; - uint8_t tracked = 0; - uint8_t in_fix = 0; - uint8_t unhealthy = 0; - - if (gps_data.data_id != NRF_GNSS_PVT_DATA_ID || client.has_fix) { - return; - } - - for (int i = 0; i < NRF_GNSS_MAX_SATELLITES; ++i) { - if ((gps_data.pvt.sv[i].sv > 0) && - (gps_data.pvt.sv[i].sv < 33)) { - LOG_DBG("GPS tracking: %d", gps_data.pvt.sv[i].sv); - tracked++; - if (IS_FIX(gps_data.pvt.sv[i].flags)) { - in_fix++; - } - if (IS_UNHEALTHY(gps_data.pvt.sv[i].flags)) { - unhealthy++; - } - } - } - - if (last_tracked != tracked) { - sprintf(rsp_buf, - "#XGPSS: \"track %d use %d unhealthy %d\"\r\n", - tracked, in_fix, unhealthy); - rsp_send(rsp_buf, strlen(rsp_buf)); - last_tracked = tracked; - } -} - -static void gps_pvt_notify(void) -{ - sprintf(rsp_buf, "#XGPSP: \"long %f lat %f\"\r\n", - gps_data.pvt.longitude, - gps_data.pvt.latitude); - rsp_send(rsp_buf, strlen(rsp_buf)); - sprintf(rsp_buf, "#XGPSP: \"%04u-%02u-%02u %02u:%02u:%02u\"\r\n", - gps_data.pvt.datetime.year, - gps_data.pvt.datetime.month, - gps_data.pvt.datetime.day, - gps_data.pvt.datetime.hour, - gps_data.pvt.datetime.minute, - gps_data.pvt.datetime.seconds); - rsp_send(rsp_buf, strlen(rsp_buf)); -} - -static void gps_thread_fn(void *arg1, void *arg2, void *arg3) -{ - ARG_UNUSED(arg1); - ARG_UNUSED(arg2); - ARG_UNUSED(arg3); - - while (true) { - if (nrf_recv(client.sock, &gps_data, sizeof(gps_data), 0) - <= 0) { - LOG_ERR("GPS nrf_recv(): %d", -errno); - sprintf(rsp_buf, "#XGPS: %d\r\n", -errno); - rsp_send(rsp_buf, strlen(rsp_buf)); - nrf_close(client.sock); - client.running = false; - break; - } - gps_satellite_stats(); - switch (gps_data.data_id) { - case NRF_GNSS_PVT_DATA_ID: - if (IS_FIX(gps_data.pvt.flags)) { - gps_pvt_notify(); - if (!client.has_fix) { - uint64_t now = k_uptime_get(); - - sprintf(rsp_buf, - "#XGPSP: \"TTFF %ds\"\r\n", - (int)(now - ttft_start)/1000); - rsp_send(rsp_buf, strlen(rsp_buf)); - client.has_fix = true; - } - } - break; - case NRF_GNSS_NMEA_DATA_ID: - if (client.has_fix) { - rsp_send(gps_data.nmea, - strlen(gps_data.nmea)); - } - break; - - case NRF_GNSS_AGPS_DATA_ID: -#ifdef CONFIG_SUPL_CLIENT_LIB - LOG_INF("New AGPS data requested, flags 0x%08x", - gps_data.agps.data_flags); - k_work_submit_to_queue(&slm_work_q, &supl_work); -#endif - break; - - default: - break; - } - } -} - -static int do_gps_start(void) -{ - int ret = -EINVAL; - - nrf_gnss_fix_retry_t fix_retry = 0; /* unlimited retry period */ - nrf_gnss_fix_interval_t fix_interval = 1; /* 1s delay between fixes */ - nrf_gnss_delete_mask_t delete_mask = 0; - nrf_gnss_nmea_mask_t nmea_mask = (nrf_gnss_nmea_mask_t)client.mask; - - client.sock = nrf_socket(NRF_AF_LOCAL, NRF_SOCK_DGRAM, NRF_PROTO_GNSS); - if (client.sock < 0) { - LOG_ERR("Could not init socket (err: %d)", -errno); - goto error; - } - ret = nrf_setsockopt(client.sock, NRF_SOL_GNSS, NRF_SO_GNSS_FIX_RETRY, - &fix_retry, sizeof(fix_retry)); - if (ret) { - LOG_ERR("Failed to set fix retry value (err: %d)", -errno); - goto error; - } - ret = nrf_setsockopt(client.sock, NRF_SOL_GNSS, - NRF_SO_GNSS_FIX_INTERVAL, &fix_interval, sizeof(fix_interval)); - if (ret) { - LOG_ERR("Failed to set fix interval value (err: %d)", -errno); - goto error; - } - ret = nrf_setsockopt(client.sock, NRF_SOL_GNSS, NRF_SO_GNSS_NMEA_MASK, - &nmea_mask, sizeof(nmea_mask)); - if (ret) { - LOG_ERR("Failed to set nmea mask (err: %d)", -errno); - goto error; - } - ret = nrf_setsockopt(client.sock, NRF_SOL_GNSS, NRF_SO_GNSS_START, - &delete_mask, sizeof(delete_mask)); - if (ret) { - LOG_ERR("Failed to start GPS (err: %d)", -errno); - goto error; - } - - /* Start GPS listening thread */ - if (gps_thread_id != NULL) { - k_thread_resume(gps_thread_id); - } else { - gps_thread_id = k_thread_create(&gps_thread, gps_thread_stack, - K_THREAD_STACK_SIZEOF(gps_thread_stack), - gps_thread_fn, NULL, NULL, NULL, - THREAD_PRIORITY, 0, K_NO_WAIT); - } - - client.running = true; - LOG_DBG("GPS started"); - - sprintf(rsp_buf, "#XGPS: 1,%d\r\n", client.mask); - rsp_send(rsp_buf, strlen(rsp_buf)); - ttft_start = k_uptime_get(); - return 0; - -error: - nrf_close(client.sock); - LOG_ERR("GPS start failed: %d", ret); - sprintf(rsp_buf, "#XGPS: %d\r\n", ret); - rsp_send(rsp_buf, strlen(rsp_buf)); - client.running = false; - - return -errno; -} - -static int do_gps_stop(void) -{ - int ret = 0; - nrf_gnss_delete_mask_t delete_mask = 0; - - if (client.sock != INVALID_SOCKET) { - ret = nrf_setsockopt(client.sock, NRF_SOL_GNSS, - NRF_SO_GNSS_STOP, &delete_mask, sizeof(delete_mask)); - if (ret != 0) { - LOG_ERR("Failed to stop GPS (err: %d)", -errno); - ret = -errno; - } else { - k_thread_suspend(gps_thread_id); - nrf_close(client.sock); - client.running = false; - sprintf(rsp_buf, "#XGPS: 0\r\n"); - rsp_send(rsp_buf, strlen(rsp_buf)); - LOG_DBG("GPS stopped"); - } - - } - - return ret; -} - -/**@brief handle AT#XGPS commands - * AT#XGPS=[,] - * AT#XGPS? - * AT#XGPS=? TEST command not supported - */ -int handle_at_gps(enum at_cmd_type cmd_type) -{ - int err = -EINVAL; - uint16_t op; - - switch (cmd_type) { - case AT_CMD_TYPE_SET_COMMAND: - err = at_params_unsigned_short_get(&at_param_list, 1, &op); - if (err < 0) { - return err; - } - if (op == 1) { - if (at_params_valid_count_get(&at_param_list) > 2) { - err = at_params_unsigned_short_get(&at_param_list, 2, - &client.mask); - if (err < 0) { - return err; - } - } - if (client.running) { - LOG_WRN("GPS is running"); - } else { - err = do_gps_start(); - } - } else if (op == 0) { - if (!client.running) { - LOG_WRN("GPS is not running"); - } else { - err = do_gps_stop(); - } - } break; - - case AT_CMD_TYPE_READ_COMMAND: - if (client.running) { - sprintf(rsp_buf, "#XGPS: 1,%d\r\n", client.mask); - } else { - sprintf(rsp_buf, "#XGPS: 0\r\n"); - } - rsp_send(rsp_buf, strlen(rsp_buf)); - err = 0; - break; - - case AT_CMD_TYPE_TEST_COMMAND: - sprintf(rsp_buf, "#XGPS: (0,1),(bitmask)\r\n"); - rsp_send(rsp_buf, strlen(rsp_buf)); - err = 0; - break; - - default: - break; - } - - return err; -} - -/**@brief API to initialize GPS AT commands handler - */ -int slm_at_gps_init(void) -{ -#ifdef CONFIG_SUPL_CLIENT_LIB - int ret; - static struct supl_api supl_api = { - .read = supl_read, - .write = supl_write, - .handler = supl_inject, - .logger = supl_logger, - .counter_ms = k_uptime_get - }; - - ret = supl_init(&supl_api); - if (ret) { - LOG_ERR("SUPL init error: %d", ret); - return ret; - } -#endif - - client.sock = INVALID_SOCKET; - client.mask = NRF_GNSS_NMEA_GSV_MASK | - NRF_GNSS_NMEA_GSA_MASK | - NRF_GNSS_NMEA_GLL_MASK | - NRF_GNSS_NMEA_GGA_MASK | - NRF_GNSS_NMEA_RMC_MASK; - client.running = false; - client.has_fix = false; - gps_thread_id = NULL; - - return 0; -} - -/**@brief API to uninitialize GPS AT commands handler - */ -int slm_at_gps_uninit(void) -{ - if (gps_thread_id != NULL) { - do_gps_stop(); - k_thread_abort(gps_thread_id); - gps_thread_id = NULL; - } - - return 0; -} diff --git a/applications/serial_lte_modem/src/gps/slm_at_gps.h b/applications/serial_lte_modem/src/gps/slm_at_gps.h deleted file mode 100644 index 0d12f5133561..000000000000 --- a/applications/serial_lte_modem/src/gps/slm_at_gps.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#ifndef SLM_AT_GPS_ -#define SLM_AT_GPS_ - -/**@file slm_at_gps.h - * - * @brief Vendor-specific AT command for GPS service. - * @{ - */ - -#include -#include - -/** - * @brief GPS AT command parser. - * - * @param at_cmd AT command string. - * - * @retval 0 If the operation was successful. - * Otherwise, a (negative) error code is returned. - */ -int slm_at_gps_parse(const char *at_cmd); - -/** - * @brief List GPS AT commands. - * - */ -void slm_at_gps_clac(void); - -/** - * @brief Initialize GPS AT command parser. - * - * @retval 0 If the operation was successful. - * Otherwise, a (negative) error code is returned. - */ -int slm_at_gps_init(void); - -/** - * @brief Uninitialize GPS AT command parser. - * - * @retval 0 If the operation was successful. - * Otherwise, a (negative) error code is returned. - */ -int slm_at_gps_uninit(void); - -/** @} */ - -#endif /* SLM_AT_GPS_ */ diff --git a/applications/serial_lte_modem/src/http_c/slm_at_httpc.c b/applications/serial_lte_modem/src/http_c/slm_at_httpc.c index 7921ad720db2..6e5e279fa4ce 100644 --- a/applications/serial_lte_modem/src/http_c/slm_at_httpc.c +++ b/applications/serial_lte_modem/src/http_c/slm_at_httpc.c @@ -507,7 +507,7 @@ static void httpc_thread_fn(void *arg1, void *arg2, void *arg3) int err; err = do_http_request(); - (void)exit_datamode(false); + (void)exit_datamode(DATAMODE_EXIT_URC); if (err < 0) { LOG_ERR("do_http_request fail:%d", err); /* Disconnect from server */ diff --git a/applications/serial_lte_modem/src/main.c b/applications/serial_lte_modem/src/main.c index 6bd0c79df633..c29662fc783c 100644 --- a/applications/serial_lte_modem/src/main.c +++ b/applications/serial_lte_modem/src/main.c @@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(slm, CONFIG_SLM_LOG_LEVEL); -#define SLM_WQ_STACK_SIZE KB(2) +#define SLM_WQ_STACK_SIZE KB(4) #define SLM_WQ_PRIORITY K_LOWEST_APPLICATION_THREAD_PRIO static K_THREAD_STACK_DEFINE(slm_wq_stack_area, SLM_WQ_STACK_SIZE); diff --git a/applications/serial_lte_modem/src/slm_at_commands.c b/applications/serial_lte_modem/src/slm_at_commands.c index 3cf2129982d7..3a60534ea6a0 100644 --- a/applications/serial_lte_modem/src/slm_at_commands.c +++ b/applications/serial_lte_modem/src/slm_at_commands.c @@ -28,8 +28,8 @@ #include "slm_at_icmp.h" #include "slm_at_sms.h" #include "slm_at_fota.h" -#if defined(CONFIG_SLM_GPS) -#include "slm_at_gps.h" +#if defined(CONFIG_SLM_GNSS) +#include "slm_at_gnss.h" #endif #if defined(CONFIG_SLM_FTPC) #include "slm_at_ftp.h" @@ -340,8 +340,12 @@ int handle_at_sms(enum at_cmd_type cmd_type); /* FOTA commands */ int handle_at_fota(enum at_cmd_type cmd_type); -#if defined(CONFIG_SLM_GPS) +#if defined(CONFIG_SLM_GNSS) int handle_at_gps(enum at_cmd_type cmd_type); +int handle_at_nrf_cloud(enum at_cmd_type cmd_type); +int handle_at_agps(enum at_cmd_type cmd_type); +int handle_at_pgps(enum at_cmd_type cmd_type); +int handle_at_cellpos(enum at_cmd_type cmd_type); #endif #if defined(CONFIG_SLM_FTPC) @@ -420,9 +424,19 @@ static struct slm_at_cmd { /* FOTA commands */ {"AT#XFOTA", handle_at_fota}, -#if defined(CONFIG_SLM_GPS) - /* GPS commands */ +#if defined(CONFIG_SLM_GNSS) + /* GNSS commands */ {"AT#XGPS", handle_at_gps}, + {"AT#XNRFCLOUD", handle_at_nrf_cloud}, +#if defined(CONFIG_SLM_AGPS) + {"AT#XAGPS", handle_at_agps}, +#endif +#if defined(CONFIG_SLM_PGPS) + {"AT#XPGPS", handle_at_pgps}, +#endif +#if defined(CONFIG_SLM_CELL_POS) + {"AT#XCELLPOS", handle_at_cellpos}, +#endif #endif #if defined(CONFIG_SLM_FTPC) @@ -536,8 +550,8 @@ int slm_at_init(void) LOG_ERR("FOTA could not be initialized: %d", err); return -EFAULT; } -#if defined(CONFIG_SLM_GPS) - err = slm_at_gps_init(); +#if defined(CONFIG_SLM_GNSS) + err = slm_at_gnss_init(); if (err) { LOG_ERR("GPS could not be initialized: %d", err); return -EFAULT; @@ -611,8 +625,8 @@ void slm_at_uninit(void) if (err) { LOG_WRN("FOTA could not be uninitialized: %d", err); } -#if defined(CONFIG_SLM_GPS) - err = slm_at_gps_uninit(); +#if defined(CONFIG_SLM_GNSS) + err = slm_at_gnss_uninit(); if (err) { LOG_WRN("GPS could not be uninitialized: %d", err); } diff --git a/applications/serial_lte_modem/src/slm_at_host.c b/applications/serial_lte_modem/src/slm_at_host.c index e3319f690903..f16a54176841 100644 --- a/applications/serial_lte_modem/src/slm_at_host.c +++ b/applications/serial_lte_modem/src/slm_at_host.c @@ -164,7 +164,7 @@ bool in_datamode(void) return (slm_operation_mode == SLM_DATA_MODE); } -bool exit_datamode(bool response) +bool exit_datamode(int exit_mode) { if (slm_operation_mode == SLM_DATA_MODE) { ring_buf_reset(&data_rb); @@ -173,8 +173,10 @@ bool exit_datamode(bool response) k_sleep(K_MSEC(10)); (void)uart_receive(); - if (response) { + if (exit_mode == DATAMODE_EXIT_OK) { strcpy(rsp_buf, OK_STR); + } else if (exit_mode == DATAMODE_EXIT_ERROR) { + strcpy(rsp_buf, ERROR_STR); } else { sprintf(rsp_buf, "\r\n#XDATAMODE: 0\r\n"); } @@ -195,7 +197,7 @@ int poweroff_uart(void) uart_rx_disable(uart_dev); k_sleep(K_MSEC(100)); - err = pm_device_state_set(uart_dev, PM_DEVICE_STATE_OFF, NULL, NULL); + err = pm_device_state_set(uart_dev, PM_DEVICE_STATE_OFF); if (err) { LOG_ERR("Can't power off uart: %d", err); } @@ -206,7 +208,7 @@ int poweroff_uart(void) int poweron_uart(void) { int err; - uint32_t current_state = 0; + enum pm_device_state current_state = PM_DEVICE_STATE_ACTIVE; err = pm_device_state_get(uart_dev, ¤t_state); if (err) { @@ -215,7 +217,7 @@ int poweron_uart(void) } if (current_state != PM_DEVICE_STATE_ACTIVE) { - pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL); + pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE); k_sleep(K_MSEC(100)); err = uart_receive(); if (err == 0) { @@ -282,7 +284,7 @@ static void response_handler(void *context, const char *response) static void raw_send(struct k_work *work) { uint8_t *data = NULL; - uint32_t size_send, size_sent; + int size_send, size_sent; ARG_UNUSED(work); @@ -299,7 +301,13 @@ static void raw_send(struct k_work *work) } else if (size_sent == 0) { (void)ring_buf_get_finish(&data_rb, size_send); } else { - LOG_WRN("Raw send failed"); + LOG_WRN("Raw send failed, %d dropped", size_send); + (void)ring_buf_get_finish(&data_rb, size_send); + (void)exit_datamode(DATAMODE_EXIT_ERROR); + if (datamode_rx_disabled) { + /* UART RX already resumed */ + datamode_rx_disabled = false; + } break; } } else { @@ -347,7 +355,7 @@ static void silence_timer_handler(struct k_timer *timer) } else { LOG_WRN("missing datamode handler"); } - (void)exit_datamode(true); + (void)exit_datamode(DATAMODE_EXIT_OK); datamode_off_pending = false; } @@ -768,7 +776,7 @@ int slm_at_host_init(void) return -EFAULT; } /* Power on UART module */ - pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL); + pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE); err = uart_receive(); if (err) { return -EFAULT; @@ -827,7 +835,7 @@ void slm_at_host_uninit(void) /* Power off UART module */ uart_rx_disable(uart_dev); k_sleep(K_MSEC(100)); - err = pm_device_state_set(uart_dev, PM_DEVICE_STATE_OFF, NULL, NULL); + err = pm_device_state_set(uart_dev, PM_DEVICE_STATE_OFF); if (err) { LOG_WRN("Can't power off uart: %d", err); } diff --git a/applications/serial_lte_modem/src/slm_at_host.h b/applications/serial_lte_modem/src/slm_at_host.h index fad67e9d1a34..e8c0c0a49d0f 100644 --- a/applications/serial_lte_modem/src/slm_at_host.h +++ b/applications/serial_lte_modem/src/slm_at_host.h @@ -20,11 +20,18 @@ #include "slm_defines.h" /**@brief Operations in datamode. */ -enum slm_datamode_operation_t { +enum slm_datamode_operation { DATAMODE_SEND, /* Send data in datamode */ DATAMODE_EXIT /* Exit data mode */ }; +/**@brief Exit modes in datamode. */ +enum slm_datamode_exit_mode { + DATAMODE_EXIT_OK, /* Exit datamode, send OK response */ + DATAMODE_EXIT_ERROR, /* Exit datamode, send ERROR response */ + DATAMODE_EXIT_URC /* Exit datamode, send URC notification */ +}; + /**@brief Data mode sending handler type. * * @retval 0 means all data is sent successfully. @@ -87,12 +94,12 @@ bool in_datamode(void); /** * @brief Request SLM AT host to exit data mode * - * @param response Whether to send "OK" response or not + * @param exit_mode Response type. Refer to enum slm_datamode_exit_mode. * * @retval true If normal exit from data mode. * false If not in data mode. */ -bool exit_datamode(bool response); +bool exit_datamode(int exit_mode); /** @} */ #endif /* SLM_AT_HOST_ */ diff --git a/applications/serial_lte_modem/src/slm_at_icmp.c b/applications/serial_lte_modem/src/slm_at_icmp.c index c47b41a10270..8598c7183da4 100644 --- a/applications/serial_lte_modem/src/slm_at_icmp.c +++ b/applications/serial_lte_modem/src/slm_at_icmp.c @@ -35,6 +35,7 @@ static struct ping_argv_t { uint16_t waitms; uint16_t count; uint16_t interval; + uint16_t pdn; } ping_argv; /* global variable defined in different files */ @@ -249,6 +250,23 @@ static uint32_t send_ping_wait_reply(void) return (uint32_t)delta_t; } + /* Use non-primary PDN if specified, fail if cannot proceed + */ + if (ping_argv.pdn != 0) { + size_t len; + struct ifreq ifr = { 0 }; + + snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "pdn%d", ping_argv.pdn); + len = strlen(ifr.ifr_name); + if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, len) < 0) { + LOG_WRN("Unable to set socket SO_BINDTODEVICE, abort"); + goto close_end; + } + LOG_DBG("Use PDN: %d", ping_argv.pdn); + } else { + LOG_DBG("Use PDN: 0"); + } + /* We have a blocking socket and we do not want to block for * a long for sending. Thus, let's set the timeout: */ @@ -469,7 +487,7 @@ static int ping_test_handler(const char *target) char ipv4_addr[NET_IPV4_ADDR_LEN] = {0}; LOG_INF("Ping target's IPv4 address"); - util_get_ip_addr(ipv4_addr, NULL); + util_get_ip_addr(ping_argv.pdn, ipv4_addr, NULL); if (strlen(ipv4_addr) == 0) { LOG_ERR("Unable to obtain local IPv4 address"); freeaddrinfo(res); @@ -489,7 +507,7 @@ static int ping_test_handler(const char *target) char ipv6_addr[NET_IPV6_ADDR_LEN] = {0}; LOG_INF("Ping target's IPv6 address"); - util_get_ip_addr(NULL, ipv6_addr); + util_get_ip_addr(ping_argv.pdn, NULL, ipv6_addr); if (strlen(ipv6_addr) == 0) { LOG_ERR("Unable to obtain local IPv6 address"); freeaddrinfo(res); @@ -514,7 +532,7 @@ static int ping_test_handler(const char *target) } /**@brief handle AT#XPING commands - * AT#XPING=,,[,[,]] + * AT#XPING=,,[,[,[,]]] * AT#XPING? READ command not supported * AT#XPING=? TEST command not supported */ @@ -552,6 +570,13 @@ int handle_at_icmp_ping(enum at_cmd_type cmd_type) return err; }; } + ping_argv.pdn = 0; /* default 0 primary PDN */ + if (at_params_valid_count_get(&at_param_list) > 6) { + err = at_params_unsigned_short_get(&at_param_list, 6, &ping_argv.pdn); + if (err < 0) { + return err; + }; + } err = ping_test_handler(target); break; diff --git a/applications/serial_lte_modem/src/slm_at_socket.c b/applications/serial_lte_modem/src/slm_at_socket.c index ac086ef2e333..f28cfddee45b 100644 --- a/applications/serial_lte_modem/src/slm_at_socket.c +++ b/applications/serial_lte_modem/src/slm_at_socket.c @@ -430,7 +430,7 @@ static int do_bind(uint16_t port) if (sock.family == AF_INET) { char ipv4_addr[INET_ADDRSTRLEN] = {0}; - util_get_ip_addr(ipv4_addr, NULL); + util_get_ip_addr(0, ipv4_addr, NULL); if (strlen(ipv4_addr) == 0) { LOG_ERR("Get local IPv4 address failed"); return -EINVAL; @@ -455,7 +455,7 @@ static int do_bind(uint16_t port) } else if (sock.family == AF_INET6) { char ipv6_addr[INET6_ADDRSTRLEN] = {0}; - util_get_ip_addr(NULL, ipv6_addr); + util_get_ip_addr(0, NULL, ipv6_addr); if (strlen(ipv6_addr) == 0) { LOG_ERR("Get local IPv6 address failed"); return -EINVAL; @@ -757,11 +757,11 @@ static int do_sendto(const char *url, uint16_t port, const uint8_t *data, int da sprintf(rsp_buf, "\r\n#XSENDTO: %d\r\n", offset); rsp_send(rsp_buf, strlen(rsp_buf)); + freeaddrinfo(res); if (ret >= 0) { return 0; } - freeaddrinfo(res); return ret; } diff --git a/applications/serial_lte_modem/src/slm_at_tcp_proxy.c b/applications/serial_lte_modem/src/slm_at_tcp_proxy.c index 8e5482680e7d..66c201ac2092 100644 --- a/applications/serial_lte_modem/src/slm_at_tcp_proxy.c +++ b/applications/serial_lte_modem/src/slm_at_tcp_proxy.c @@ -134,7 +134,7 @@ static int do_tcp_server_start(uint16_t port) if (proxy.family == AF_INET) { char ipv4_addr[NET_IPV4_ADDR_LEN] = {0}; - util_get_ip_addr(ipv4_addr, NULL); + util_get_ip_addr(0, ipv4_addr, NULL); if (strlen(ipv4_addr) == 0) { LOG_ERR("Unable to obtain local IPv4 address"); ret = -ENETUNREACH; @@ -155,7 +155,7 @@ static int do_tcp_server_start(uint16_t port) } else { char ipv6_addr[NET_IPV6_ADDR_LEN] = {0}; - util_get_ip_addr(NULL, ipv6_addr); + util_get_ip_addr(0, NULL, ipv6_addr); if (strlen(ipv6_addr) == 0) { LOG_ERR("Unable to obtain local IPv6 address"); ret = -ENETUNREACH; @@ -202,6 +202,7 @@ static int do_tcp_server_start(uint16_t port) #if defined(CONFIG_SLM_NATIVE_TLS) if (proxy.sec_tag != INVALID_SEC_TAG) { (void)slm_tls_unloadcrdl(proxy.sec_tag); + proxy.sec_tag = INVALID_SEC_TAG; } #endif if (proxy.sock != INVALID_SOCKET) { @@ -224,6 +225,7 @@ static int do_tcp_server_stop(void) #if defined(CONFIG_SLM_NATIVE_TLS) if (proxy.sec_tag != INVALID_SEC_TAG) { (void)slm_tls_unloadcrdl(proxy.sec_tag); + proxy.sec_tag = INVALID_SEC_TAG; } #endif if (proxy.sock_peer != INVALID_SOCKET) { @@ -256,7 +258,6 @@ static int do_tcp_client_connect(const char *url, uint16_t port) ret = socket(proxy.family, SOCK_STREAM, IPPROTO_TCP); } else { ret = socket(proxy.family, SOCK_STREAM, IPPROTO_TLS_1_2); - } if (ret < 0) { LOG_ERR("socket() failed: %d", -errno); @@ -430,7 +431,7 @@ static int tcp_datamode_callback(uint8_t op, const uint8_t *data, int len) static void tcpsvr_terminate_connection(int cause) { if (in_datamode()) { - (void)exit_datamode(false); + (void)exit_datamode(DATAMODE_EXIT_URC); } if (proxy.sock_peer != INVALID_SOCKET) { close(proxy.sock_peer); @@ -516,10 +517,10 @@ static void tcpsvr_thread_func(void *p1, void *p2, void *p3) LOG_WRN("accept(ipv6) error: %d", -errno); goto client_events; } - (void)inet_ntop(AF_INET, &client.sin6_addr, peer_addr, + (void)inet_ntop(AF_INET6, &client.sin6_addr, peer_addr, sizeof(peer_addr)); } - if (fds[1].fd != INVALID_SOCKET) { + if (fds[1].fd >= 0) { LOG_WRN("Full. Close connection."); close(ret); goto client_events; @@ -578,15 +579,10 @@ static void tcpsvr_thread_func(void *p1, void *p2, void *p3) #if defined(CONFIG_SLM_NATIVE_TLS) if (proxy.sec_tag != INVALID_SEC_TAG) { (void)slm_tls_unloadcrdl(proxy.sec_tag); + proxy.sec_tag = INVALID_SEC_TAG; } #endif - if (in_datamode()) { - (void)exit_datamode(false); - } - if (proxy.sock_peer != INVALID_SOCKET) { - (void)close(proxy.sock_peer); - proxy.sock_peer = INVALID_SOCKET; - } + tcpsvr_terminate_connection(ret); if (proxy.sock != INVALID_SOCKET) { (void)close(proxy.sock); proxy.sock = INVALID_SOCKET; @@ -661,7 +657,7 @@ static void tcpcli_thread_func(void *p1, void *p2, void *p3) } if (in_datamode()) { - (void)exit_datamode(false); + (void)exit_datamode(DATAMODE_EXIT_URC); } if (proxy.sock != INVALID_SOCKET) { (void)close(proxy.sock); diff --git a/applications/serial_lte_modem/src/slm_at_udp_proxy.c b/applications/serial_lte_modem/src/slm_at_udp_proxy.c index 7f30e1fd6db0..d63883150aa0 100644 --- a/applications/serial_lte_modem/src/slm_at_udp_proxy.c +++ b/applications/serial_lte_modem/src/slm_at_udp_proxy.c @@ -77,7 +77,7 @@ static int do_udp_server_start(uint16_t port) if (proxy.family == AF_INET) { char ipv4_addr[NET_IPV4_ADDR_LEN] = {0}; - util_get_ip_addr(ipv4_addr, NULL); + util_get_ip_addr(0, ipv4_addr, NULL); if (strlen(ipv4_addr) == 0) { LOG_ERR("Unable to obtain local IPv4 address"); close(proxy.sock); @@ -98,7 +98,7 @@ static int do_udp_server_start(uint16_t port) } else { char ipv6_addr[NET_IPV6_ADDR_LEN] = {0}; - util_get_ip_addr(NULL, ipv6_addr); + util_get_ip_addr(0, NULL, ipv6_addr); if (strlen(ipv6_addr) == 0) { LOG_ERR("Unable to obtain local IPv6 address"); close(proxy.sock); diff --git a/applications/serial_lte_modem/src/slm_util.c b/applications/serial_lte_modem/src/slm_util.c index 511b966bc62d..3ed42cbb5705 100644 --- a/applications/serial_lte_modem/src/slm_util.c +++ b/applications/serial_lte_modem/src/slm_util.c @@ -153,27 +153,29 @@ int util_string_get(const struct at_param_list *list, size_t index, char *value, } /** - * @brief use AT command to get IPv4 and/or IPv6 address + * @brief use AT command to get IPv4 and/or IPv6 address for specified PDN */ -void util_get_ip_addr(char *addr4, char *addr6) +void util_get_ip_addr(int cid, char *addr4, char *addr6) { int err; - char rsp[128]; + char buf[128]; char tmp[sizeof(struct in6_addr)]; char addr[NET_IPV6_ADDR_LEN]; size_t addr_len; - err = at_cmd_write("AT+CGPADDR", rsp, sizeof(rsp), NULL); + sprintf(buf, "AT+CGPADDR=%d", cid); + err = at_cmd_write(buf, buf, sizeof(buf), NULL); if (err) { return; } + /** parse +CGPADDR: ,, * PDN type "IP": PDP_addr_1 is * PDN type "IPV6": PDP_addr_1 is * PDN type "IPV4V6": , or or */ at_params_list_clear(&at_param_list); - err = at_parser_params_from_str(rsp, NULL, &at_param_list); + err = at_parser_params_from_str(buf, NULL, &at_param_list); if (err) { return; } diff --git a/applications/serial_lte_modem/src/slm_util.h b/applications/serial_lte_modem/src/slm_util.h index 305eece3f251..7859c0ba2de9 100644 --- a/applications/serial_lte_modem/src/slm_util.h +++ b/applications/serial_lte_modem/src/slm_util.h @@ -94,12 +94,13 @@ int slm_util_atoh(const char *ascii, uint16_t ascii_len, uint8_t *hex, uint16_t int util_string_get(const struct at_param_list *list, size_t index, char *value, size_t *len); /** - * @brief use AT command to get IPv4 and IPv6 addresses + * @brief use AT command to get IPv4 and IPv6 addresses for specified PDN * + * @param[in] cid PDP Context ID as defined in "+CGDCONT" command (0~10) * @param[in] addr4 buffer to hold the IPv4 address, size NET_IPV4_ADDR_LEN * @param[in] addr6 buffer to hold the IPv6 address, size NET_IPV6_ADDR_LEN */ -void util_get_ip_addr(char *addr4, char *addr6); +void util_get_ip_addr(int cid, char *addr4, char *addr6); /** @} */ #endif /* SLM_UTIL_ */ diff --git a/boards/arm/thingy91_nrf9160/CMakeLists.txt b/boards/arm/thingy91_nrf9160/CMakeLists.txt index 11781f16d657..3681c4346ed2 100644 --- a/boards/arm/thingy91_nrf9160/CMakeLists.txt +++ b/boards/arm/thingy91_nrf9160/CMakeLists.txt @@ -9,7 +9,7 @@ if(CONFIG_BOARD_THINGY91_NRF9160 AND NOT DEFINED CONFIG_MCUBOOT) zephyr_library_sources(board_secure.c) endif() -if(CONFIG_BOARD_THINGY91_NRF9160NS) +if(CONFIG_BOARD_THINGY91_NRF9160_NS) zephyr_library() zephyr_library_sources(board_nonsecure.c) diff --git a/boards/arm/thingy91_nrf9160/Kconfig.board b/boards/arm/thingy91_nrf9160/Kconfig.board index 8f6f5016f9e5..220bc075d0e0 100644 --- a/boards/arm/thingy91_nrf9160/Kconfig.board +++ b/boards/arm/thingy91_nrf9160/Kconfig.board @@ -9,7 +9,7 @@ if SOC_NRF9160_SICA config BOARD_THINGY91_NRF9160 bool "nRF9160 THINGY91" -config BOARD_THINGY91_NRF9160NS +config BOARD_THINGY91_NRF9160_NS bool "nRF9160 THINGY91 non-secure" endif # SOC_NRF9160_SICA diff --git a/boards/arm/thingy91_nrf9160/Kconfig.defconfig b/boards/arm/thingy91_nrf9160/Kconfig.defconfig index 61bffe59d509..4d46041c86ef 100644 --- a/boards/arm/thingy91_nrf9160/Kconfig.defconfig +++ b/boards/arm/thingy91_nrf9160/Kconfig.defconfig @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -if BOARD_THINGY91_NRF9160 || BOARD_THINGY91_NRF9160NS +if BOARD_THINGY91_NRF9160 || BOARD_THINGY91_NRF9160_NS config BOARD default "thingy91_nrf9160" @@ -26,7 +26,7 @@ config FLASH_LOAD_SIZE endif # BOARD_THINGY91_NRF9160 && TRUSTED_EXECUTION_SECURE -if BOARD_THINGY91_NRF9160NS +if BOARD_THINGY91_NRF9160_NS config FLASH_LOAD_OFFSET default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) @@ -34,7 +34,7 @@ config FLASH_LOAD_OFFSET config FLASH_LOAD_SIZE default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) -endif # BOARD_THINGY91_NRF9160NS +endif # BOARD_THINGY91_NRF9160_NS config BT_HCI_VS default y if BT @@ -42,4 +42,4 @@ config BT_HCI_VS config HW_STACK_PROTECTION default ARCH_HAS_STACK_PROTECTION -endif # BOARD_THINGY91_NRF9160 || BOARD_THINGY91_NRF9160NS +endif # BOARD_THINGY91_NRF9160 || BOARD_THINGY91_NRF9160_NS diff --git a/boards/arm/thingy91_nrf9160/thingy91_nrf9160ns.dts b/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns.dts similarity index 100% rename from boards/arm/thingy91_nrf9160/thingy91_nrf9160ns.dts rename to boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns.dts diff --git a/boards/arm/thingy91_nrf9160/thingy91_nrf9160ns.yaml b/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns.yaml similarity index 80% rename from boards/arm/thingy91_nrf9160/thingy91_nrf9160ns.yaml rename to boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns.yaml index 40dd4cf43e6d..fb69b8d7b9ca 100644 --- a/boards/arm/thingy91_nrf9160/thingy91_nrf9160ns.yaml +++ b/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns.yaml @@ -1,4 +1,4 @@ -identifier: thingy91_nrf9160ns +identifier: thingy91_nrf9160_ns name: THINGY91-nRF9160-Non-Secure type: mcu arch: arm diff --git a/boards/arm/thingy91_nrf9160/thingy91_nrf9160ns_defconfig b/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns_defconfig similarity index 94% rename from boards/arm/thingy91_nrf9160/thingy91_nrf9160ns_defconfig rename to boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns_defconfig index 9fc33268d083..80b8f3f4213f 100644 --- a/boards/arm/thingy91_nrf9160/thingy91_nrf9160ns_defconfig +++ b/boards/arm/thingy91_nrf9160/thingy91_nrf9160_ns_defconfig @@ -1,6 +1,6 @@ CONFIG_SOC_SERIES_NRF91X=y CONFIG_SOC_NRF9160_SICA=y -CONFIG_BOARD_THINGY91_NRF9160NS=y +CONFIG_BOARD_THINGY91_NRF9160_NS=y # Enable MPU CONFIG_ARM_MPU=y diff --git a/boards/deprecated.cmake b/boards/deprecated.cmake index 4e2d819bc567..e6c5da056928 100644 --- a/boards/deprecated.cmake +++ b/boards/deprecated.cmake @@ -14,4 +14,5 @@ set(nrf52840_pca20035_DEPRECATED thingy91_nrf52840) set(nrf9160_pca20035_DEPRECATED thingy91_nrf9160) -set(nrf9160_pca20035ns_DEPRECATED thingy91_nrf9160ns) +set(nrf9160_pca20035ns_DEPRECATED thingy91_nrf9160_ns) +set(thingy91_nrf9160ns_DEPRECATED thingy91_nrf9160_ns) diff --git a/boards/shields/nrf21540_ek/Kconfig.shield b/boards/shields/nrf21540_ek/Kconfig.shield new file mode 100644 index 000000000000..1aa1c00ba473 --- /dev/null +++ b/boards/shields/nrf21540_ek/Kconfig.shield @@ -0,0 +1,8 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +config SHIELD_NRF21540_EK + def_bool $(shields_list_contains,nrf21540_ek) diff --git a/samples/bluetooth/direct_test_mode/configuration/dts-nrf21540-fem.overlay b/boards/shields/nrf21540_ek/nrf21540_ek.overlay similarity index 92% rename from samples/bluetooth/direct_test_mode/configuration/dts-nrf21540-fem.overlay rename to boards/shields/nrf21540_ek/nrf21540_ek.overlay index f22bae3d2468..dae59cb669cf 100644 --- a/samples/bluetooth/direct_test_mode/configuration/dts-nrf21540-fem.overlay +++ b/boards/shields/nrf21540_ek/nrf21540_ek.overlay @@ -3,7 +3,7 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ - / { +/ { nrf_radio_fem: nrf21540_fem { compatible = "nordic,nrf21540-fem"; tx-en-gpios = <&arduino_header 11 GPIO_ACTIVE_HIGH>; /* D5 */ @@ -17,7 +17,7 @@ fem_spi: &arduino_spi { status = "okay"; - cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */ + cs-gpios = <&arduino_header 16 0>; /* D10 */ nrf_radio_fem_spi: nrf21540_fem_spi@0 { compatible = "nordic,nrf21540-fem-spi"; diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake index 1aad6d1a0337..fbef1053bb01 100644 --- a/cmake/extensions.cmake +++ b/cmake/extensions.cmake @@ -4,6 +4,66 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # +# +# Helper macro for verifying that at least one of the required arguments has +# been provided by the caller. +# +# As FATAL_ERROR will be raised if not one of the required arguments has been +# passed by the caller. +# +# Usage: +# check_arguments_required( [ ...]) +# +macro(check_arguments_required function prefix) + set(required_found FALSE) + foreach(required ${ARGN}) + if(DEFINED ${prefix}_${required}) + set(required_found TRUE) + endif() + endforeach() + + if(NOT required_found) + message(FATAL_ERROR "${function}(...) missing a required argument: ${ARGN}") + endif() +endmacro() + +# +# Helper macro for verifying that all the required arguments has # been +# provided by the caller. +# +# As FATAL_ERROR will be raised if one of the required arguments is missing. +# +# Usage: +# check_arguments_required_all( [ ...]) +# +macro(check_arguments_required_all function prefix) + foreach(required ${ARGN}) + if(NOT DEFINED ${prefix}_${required}) + message(FATAL_ERROR "${function}(...) missing a required argument: ${required}") + endif() + endforeach() +endmacro() + +# +# Helper macro for verifying that none of the mutual exclusive arguments are +# provided together with the first argument. +# +# As FATAL_ERROR will be raised if first argument is given together with one +# of the following mutual exclusive arguments. +# +# Usage: +# check_arguments_exclusive( [ ...]) +# +macro(check_arguments_exclusive function prefix argument) + foreach(prohibited ${ARGN}) + if(DEFINED ${prefix}_${argument} AND ${prefix}_${prohibited}) + message(FATAL_ERROR "set_shared(${argument} ...) cannot be used with " + "argument: ${prohibited}" + ) + endif() + endforeach() +endmacro() + function(get_board_without_ns_suffix board_in board_out) string(REGEX REPLACE "(_?ns)$" "" board_in_without_suffix ${board_in}) if(NOT ${board_in} STREQUAL ${board_in_without_suffix}) @@ -140,3 +200,109 @@ Please provide one of following: CONF_FILES") set(${ZEPHYR_FILE_DTS} ${${ZEPHYR_FILE_DTS}} PARENT_SCOPE) endif() endfunction() + +# +# Usage +# set_shared(IMAGE [APPEND] PROPERTY ) +# +# Shares a property from child to parent. +# The property is shared through an intermediate shared_vars.cmake file which +# will be parsed by the parent image at CMake configure time. +# +# Example usage 'set_shared(IMAGE child PROPERTY visible_in_parent "I AM YOUR CHILD")' +# +# Usage +# set_shared(FILE ) +# +# Shares all properties in file to parent. +# This function can be used to re-share properties from a child to its +# grand parent. +# +function(set_shared) + set(flags "APPEND") + set(single_args "FILE;IMAGE") + set(multi_args "PROPERTY") + cmake_parse_arguments(SHARE "${flags}" "${single_args}" "${multi_args}" ${ARGN}) + + check_arguments_required("set_shared" SHARE IMAGE FILE) + + check_arguments_exclusive("set_shared" SHARE FILE IMAGE PROPERTY APPEND) + check_arguments_exclusive("set_shared" SHARE IMAGE FILE) + + set(prop_target ${IMAGE_NAME}_shared_property_target) + if(NOT TARGET ${prop_target}) + add_custom_target(${prop_target}) + endif() + + if(DEFINED SHARE_IMAGE) + # When using IMAGE, then PROPERTY is also required. + check_arguments_required("set_shared" SHARE PROPERTY) + + set(share_prop_target ${SHARE_IMAGE}_shared_property_target) + + if(SHARE_APPEND) + set(SHARE_APPEND APPEND) + else() + set(SHARE_APPEND) + endif() + + get_property(string_targets TARGET ${prop_target} PROPERTY image_targets) + if(NOT "add_custom_target(${share_prop_target})" IN_LIST string_targets) + set_property( + TARGET ${prop_target} APPEND PROPERTY + image_targets "add_custom_target(${share_prop_target})" + ) + endif() + + set_property(TARGET ${prop_target} APPEND_STRING PROPERTY shared_vars + "set_property(TARGET ${share_prop_target} ${SHARE_APPEND} PROPERTY ${SHARE_PROPERTY})\n" + ) + endif() + + if(DEFINED SHARE_FILE) + set_property(TARGET ${prop_target} APPEND_STRING PROPERTY shared_vars + "include(${SHARE_FILE})\n" + ) + endif() +endfunction() + +# generate_shared(IMAGE FILE ) +function(generate_shared) + set(single_args "IMAGE;FILE") + cmake_parse_arguments(SHARE "" "${single_args}" "" ${ARGN}) + + check_arguments_required_all("generate_shared" SHARE IMAGE FILE) + + set(prop_target ${IMAGE_NAME}_shared_property_target) + file(GENERATE OUTPUT ${SHARE_FILE} + CONTENT + "$,\n> +$" + ) +endfunction() + +# +# Usage +# get_shared( IMAGE PROPERTY ) +# +# Get a property value defined by the child image or domain if it exists. +# The property value will be returned in the variable referenced by . +# +# Example usage 'get_shared(prop_value IMAGE child PROPERTY property_in_child)' +# +function(get_shared var) + set(single_args "IMAGE") + set(multi_args "PROPERTY") + cmake_parse_arguments(SHARE "" "${single_args}" "${multi_args}" ${ARGN}) + + check_arguments_required_all("get_shared" SHARE IMAGE PROPERTY) + + if(TARGET ${SHARE_IMAGE}_shared_property_target) + get_property( + ${var} + TARGET ${SHARE_IMAGE}_shared_property_target + PROPERTY ${SHARE_PROPERTY} + ) + set(${var} ${${var}} PARENT_SCOPE) + endif() +endfunction() diff --git a/cmake/multi_image.cmake b/cmake/multi_image.cmake index a39bd28d7ab7..b4728348b384 100644 --- a/cmake/multi_image.cmake +++ b/cmake/multi_image.cmake @@ -4,41 +4,25 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -function(share content) - # Adds 'content' as a line in the 'shared_vars' property. - # This property is again written to a file which is imported as a cmake file - # by the parent image. In other words, this function can be used to share - # information (variables, lists etc) with the parent image. - # - # Example usage 'share("set(visible_in_parent \"I AM YOUR CHILD\")")' - - set_property( - TARGET zephyr_property_target - APPEND_STRING - PROPERTY shared_vars - "${content}\n" - ) -endfunction() - if(IMAGE_NAME) - share("set(${IMAGE_NAME}KERNEL_HEX_NAME ${KERNEL_HEX_NAME})") - share("set(${IMAGE_NAME}ZEPHYR_BINARY_DIR ${ZEPHYR_BINARY_DIR})") + set_shared(IMAGE ${IMAGE_NAME} PROPERTY KERNEL_HEX_NAME ${KERNEL_HEX_NAME}) + set_shared(IMAGE ${IMAGE_NAME} PROPERTY ZEPHYR_BINARY_DIR ${ZEPHYR_BINARY_DIR}) # Share the elf file, in order to support symbol loading for debuggers. - share("set(${IMAGE_NAME}KERNEL_ELF_NAME ${KERNEL_ELF_NAME})") - share("list(APPEND ${IMAGE_NAME}BUILD_BYPRODUCTS ${PROJECT_BINARY_DIR}/${KERNEL_HEX_NAME})") - share("list(APPEND ${IMAGE_NAME}BUILD_BYPRODUCTS ${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME})") + set_shared(IMAGE ${IMAGE_NAME} PROPERTY KERNEL_ELF_NAME ${KERNEL_ELF_NAME}) + set_shared(IMAGE ${IMAGE_NAME} + PROPERTY BUILD_BYPRODUCTS + ${PROJECT_BINARY_DIR}/${KERNEL_HEX_NAME} + ${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME} + ) # Share the signing key file so that the parent image can use it to # generate signed update candidates. if(CONFIG_BOOT_SIGNATURE_KEY_FILE) - share("set(${IMAGE_NAME}SIGNATURE_KEY_FILE ${CONFIG_BOOT_SIGNATURE_KEY_FILE})") + set_shared(IMAGE ${IMAGE_NAME} PROPERTY SIGNATURE_KEY_FILE ${CONFIG_BOOT_SIGNATURE_KEY_FILE}) endif() - file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/shared_vars.cmake - CONTENT $ - ) + generate_shared(IMAGE ${IMAGE_NAME} FILE ${CMAKE_BINARY_DIR}/shared_vars.cmake) endif(IMAGE_NAME) - function(add_child_image) # Adds a child image to the build. # @@ -116,6 +100,20 @@ function(add_child_image_from_source) "typically defined in ${BOARD_DIR}/Kconfig") endif() + set(domain_parent ${${ACI_DOMAIN}_PM_DOMAIN_DYNAMIC_PARTITION}) + if(DEFINED ${ACI_DOMAIN}_PM_DOMAIN_DYNAMIC_PARTITION + AND NOT "${domain_parent}" STREQUAL "${ACI_NAME}" + ) + # A domain may only have one child image, which can then act as a parent + # to other images in the domain. + # As it is a cache variable we check it's content so that CMake re-run + # will pass the check as long as the child image hasn't changed. + message(FATAL_ERROR "A domain may only have a single child image." + "Current domain image is: ${domain_parent}, `${domain_parent}` is a " + "domain parent image, so you may add `${ACI_NAME}` as a child inside " + "`${domain_parent}`" + ) + endif() # This needs to be made globally available as it is used in other files. set(${ACI_DOMAIN}_PM_DOMAIN_DYNAMIC_PARTITION ${ACI_NAME} CACHE INTERNAL "") @@ -282,7 +280,7 @@ function(add_child_image_from_source) COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} ${EXTRA_MULTI_IMAGE_CMAKE_ARGS} # E.g. --trace-expand - -DIMAGE_NAME=${ACI_NAME}_ + -DIMAGE_NAME=${ACI_NAME} ${image_cmake_args} ${ACI_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${ACI_NAME} @@ -291,7 +289,7 @@ function(add_child_image_from_source) if (IMAGE_NAME) # Expose your childrens secrets to your parent - share("include(${CMAKE_BINARY_DIR}/${ACI_NAME}/shared_vars.cmake)") + set_shared(FILE ${CMAKE_BINARY_DIR}/${ACI_NAME}/shared_vars.cmake) endif() set_property(DIRECTORY APPEND PROPERTY @@ -309,10 +307,6 @@ function(add_child_image_from_source) # namespace include(${CMAKE_BINARY_DIR}/${ACI_NAME}/shared_vars.cmake) - # Increase the scope of this variable to make it more available - set(${ACI_NAME}_KERNEL_HEX_NAME ${${ACI_NAME}_KERNEL_HEX_NAME} CACHE STRING "" FORCE) - set(${ACI_NAME}_KERNEL_ELF_NAME ${${ACI_NAME}_KERNEL_ELF_NAME} CACHE STRING "" FORCE) - if(MULTI_IMAGE_DEBUG_MAKEFILE AND "${CMAKE_GENERATOR}" STREQUAL "Ninja") set(multi_image_build_args "-d" "${MULTI_IMAGE_DEBUG_MAKEFILE}") endif() @@ -320,11 +314,13 @@ function(add_child_image_from_source) set(multi_image_build_args "--debug=${MULTI_IMAGE_DEBUG_MAKEFILE}") endif() + get_shared(${ACI_NAME}_byproducts IMAGE ${ACI_NAME} PROPERTY BUILD_BYPRODUCTS) + include(ExternalProject) ExternalProject_Add(${ACI_NAME}_subimage SOURCE_DIR ${ACI_SOURCE_DIR} BINARY_DIR ${CMAKE_BINARY_DIR}/${ACI_NAME} - BUILD_BYPRODUCTS ${${ACI_NAME}_BUILD_BYPRODUCTS} # Set by shared_vars.cmake + BUILD_BYPRODUCTS ${${ACI_NAME}_byproducts} CONFIGURE_COMMAND "" BUILD_COMMAND ${CMAKE_COMMAND} --build . -- ${multi_image_build_args} INSTALL_COMMAND "" diff --git a/cmake/partition_manager.cmake b/cmake/partition_manager.cmake index 9aa61b61b948..3fdbb301146e 100644 --- a/cmake/partition_manager.cmake +++ b/cmake/partition_manager.cmake @@ -55,7 +55,9 @@ endif() # # The dynamic partition is specified by the parent domain (i.e. the domain # which creates the current domain through 'create_domain_image()'. -if("${IMAGE_NAME}" STREQUAL "${${DOMAIN}_PM_DOMAIN_DYNAMIC_PARTITION}_") +if(DEFINED ${DOMAIN}_PM_DOMAIN_DYNAMIC_PARTITION + AND "${IMAGE_NAME}" STREQUAL "${${DOMAIN}_PM_DOMAIN_DYNAMIC_PARTITION}" +) set(is_dynamic_partition_in_domain TRUE) endif() @@ -111,22 +113,22 @@ set_property(GLOBAL PROPERTY # Prepare the input_files, header_files, and images lists set(generated_path include/generated) foreach (image ${PM_IMAGES}) - set(shared_vars_file ${CMAKE_BINARY_DIR}/${image}/shared_vars.cmake) - if (NOT (EXISTS ${shared_vars_file})) - message(FATAL_ERROR "Could not find shared vars file: ${shared_vars_file}") - endif() - include(${shared_vars_file}) list(APPEND prefixed_images ${DOMAIN}:${image}) list(APPEND images ${image}) - list(APPEND input_files ${${image}_PM_YML_FILES}) - list(APPEND header_files ${${image}_ZEPHYR_BINARY_DIR}/${generated_path}/pm_config.h) + + get_shared(${image}_input_files IMAGE ${image} PROPERTY PM_YML_FILES) + get_shared(${image}_binary_dir IMAGE ${image} PROPERTY ZEPHYR_BINARY_DIR) + + list(APPEND input_files ${${image}_input_files}) + list(APPEND header_files ${${image}_binary_dir}/${generated_path}/pm_config.h) # Re-configure (Re-execute all CMakeLists.txt code) when original # (not preprocessed) configuration file changes. + get_shared(dependencies IMAGE ${image} PROPERTY PM_YML_DEP_FILES) set_property( DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS - ${${image}_PM_YML_DEP_FILES} + ${dependencies} ) endforeach() @@ -271,8 +273,11 @@ foreach(part ${PM_ALL_BY_SIZE}) list(APPEND explicitly_assigned ${part}) else() if(${part} IN_LIST images) - set(${part}_PM_HEX_FILE ${${part}_ZEPHYR_BINARY_DIR}/${${part}_KERNEL_HEX_NAME}) - set(${part}_PM_ELF_FILE ${${part}_ZEPHYR_BINARY_DIR}/${${part}_KERNEL_ELF_NAME}) + get_shared(${part}_bin_dir IMAGE ${part} PROPERTY ZEPHYR_BINARY_DIR) + get_shared(${part}_hex_file IMAGE ${part} PROPERTY KERNEL_HEX_NAME) + get_shared(${part}_elf_file IMAGE ${part} PROPERTY KERNEL_ELF_NAME) + set(${part}_PM_HEX_FILE ${${part}_bin_dir}/${${part}_hex_file}) + set(${part}_PM_ELF_FILE ${${part}_bin_dir}/${${part}_elf_file}) set(${part}_PM_TARGET ${part}_subimage) elseif(${part} IN_LIST containers) set(${part}_PM_HEX_FILE ${PROJECT_BINARY_DIR}/${part}.hex) @@ -371,18 +376,21 @@ if (is_dynamic_partition_in_domain) # Expose the generated partition manager configuration files to parent image. # This is used by the root image to create the global configuration in # pm_config.h. - share("set(${DOMAIN}_PM_DOMAIN_PARTITIONS ${pm_out_partition_file})") - share("set(${DOMAIN}_PM_DOMAIN_REGIONS ${pm_out_region_file})") - share("set(${DOMAIN}_PM_DOMAIN_HEADER_FILES ${header_files})") - share("set(${DOMAIN}_PM_DOMAIN_IMAGES ${prefixed_images})") - share("set(${DOMAIN}_PM_HEX_FILE ${PROJECT_BINARY_DIR}/${merged}.hex)") - share("set(${DOMAIN}_PM_DOTCONF_FILES ${pm_out_dotconf_file})") - share("set(${DOMAIN}_PM_APP_HEX ${PROJECT_BINARY_DIR}/app.hex)") - share("set(${DOMAIN}_PM_SIGNED_APP_HEX ${PROJECT_BINARY_DIR}/signed_by_b0_app.hex)") - share("list(APPEND ${IMAGE_NAME}BUILD_BYPRODUCTS ${PROJECT_BINARY_DIR}/${merged}.hex)") + set_shared(IMAGE ${DOMAIN} PROPERTY PM_DOMAIN_PARTITIONS ${pm_out_partition_file}) + set_shared(IMAGE ${DOMAIN} PROPERTY PM_DOMAIN_REGIONS ${pm_out_region_file}) + set_shared(IMAGE ${DOMAIN} PROPERTY PM_DOMAIN_HEADER_FILES ${header_files}) + set_shared(IMAGE ${DOMAIN} PROPERTY PM_DOMAIN_IMAGES ${prefixed_images}) + set_shared(IMAGE ${DOMAIN} PROPERTY PM_HEX_FILE ${PROJECT_BINARY_DIR}/${merged}.hex) + set_shared(IMAGE ${DOMAIN} PROPERTY PM_DOTCONF_FILES ${pm_out_dotconf_file}) + set_shared(IMAGE ${DOMAIN} PROPERTY PM_APP_HEX ${PROJECT_BINARY_DIR}/app.hex) + set_shared(IMAGE ${IMAGE_NAME} APPEND PROPERTY BUILD_BYPRODUCTS ${PROJECT_BINARY_DIR}/${merged}.hex) + if(CONFIG_SECURE_BOOT) + # Only when secure boot is enabled the app will be signed. + set_shared(IMAGE ${DOMAIN} PROPERTY PM_SIGNED_APP_HEX ${PROJECT_BINARY_DIR}/signed_by_b0_app.hex) + endif() else() # This is the root image, generate the global pm_config.h - # First, include the shared_vars.cmake file for all child images. + # First, include the shared properties for all child images. if (PM_DOMAINS) # We ensure the existence of PM_DOMAINS to support older cmake versions. # When version >= 3.17 is required this check can be removed. @@ -391,19 +399,18 @@ else() foreach (d ${PM_DOMAINS}) # Don't include shared vars from own domain. if (NOT ("${DOMAIN}" STREQUAL "${d}")) - set(shared_vars_file - ${CMAKE_BINARY_DIR}/${${d}_PM_DOMAIN_DYNAMIC_PARTITION}/shared_vars.cmake - ) - if (NOT (EXISTS ${shared_vars_file})) - message(FATAL_ERROR "Could not find shared vars file: ${shared_vars_file}") - endif() - include(${shared_vars_file}) - list(APPEND header_files ${${d}_PM_DOMAIN_HEADER_FILES}) - list(APPEND prefixed_images ${${d}_PM_DOMAIN_IMAGES}) - list(APPEND pm_out_partition_file ${${d}_PM_DOMAIN_PARTITIONS}) - list(APPEND pm_out_region_file ${${d}_PM_DOMAIN_REGIONS}) - list(APPEND global_hex_depends ${${d}_PM_DOMAIN_DYNAMIC_PARTITION}_subimage) - list(APPEND domain_hex_files ${${d}_PM_HEX_FILE}) + get_shared(shared_header_files IMAGE ${d} PROPERTY PM_DOMAIN_HEADER_FILES) + get_shared(shared_prefixed_images IMAGE ${d} PROPERTY PM_DOMAIN_IMAGES) + get_shared(shared_pm_out_partition_file IMAGE ${d} PROPERTY PM_DOMAIN_PARTITIONS) + get_shared(shared_pm_out_region_file IMAGE ${d} PROPERTY PM_DOMAIN_REGIONS) + get_shared(shared_domain_hex_files IMAGE ${d} PROPERTY PM_HEX_FILE) + + list(APPEND header_files ${shared_header_files}) + list(APPEND prefixed_images ${shared_prefixed_images}) + list(APPEND pm_out_partition_file ${shared_pm_out_partition_file}) + list(APPEND pm_out_region_file ${shared_pm_out_region_file}) + list(APPEND domain_hex_files ${shared_domain_hex_files}) + list(APPEND global_hex_depends ${${d}_PM_DOMAIN_DYNAMIC_PARTITION}_subimage) # Add domain prefix cmake variables for all partitions # Here, we actually overwrite the already imported kconfig values @@ -411,7 +418,8 @@ else() # are accessed through the 'partition_manager' target, and most likely # through generator expression, as this file is one of the last # cmake files executed in the configure stage. - import_kconfig(PM_ ${${d}_PM_DOTCONF_FILES} ${d}_pm_var_names) + get_shared(conf_file IMAGE ${d} PROPERTY PM_DOTCONF_FILES) + import_kconfig(PM_ ${conf_file} ${d}_pm_var_names) foreach(name ${${d}_pm_var_names}) set_property( @@ -502,7 +510,6 @@ else() -o ${final_merged} ${domain_hex_files} DEPENDS - ${domain_hex_files} ${global_hex_depends} ) diff --git a/cmake/s1.cmake b/cmake/s1.cmake index 052ff287c875..108e0ad985b9 100644 --- a/cmake/s1.cmake +++ b/cmake/s1.cmake @@ -7,7 +7,7 @@ if (CONFIG_BUILD_S1_VARIANT AND ((${CONFIG_S1_VARIANT_IMAGE_NAME} STREQUAL "app" AND NOT IMAGE_NAME) OR - ("${CONFIG_S1_VARIANT_IMAGE_NAME}_" STREQUAL "${IMAGE_NAME}"))) + ("${CONFIG_S1_VARIANT_IMAGE_NAME}" STREQUAL "${IMAGE_NAME}"))) # Create second executable for the second slot of the second stage # bootloader. This is done inside this file since it is non-trivial to add # executable targets outside the root CMakeLists.txt. The problem is that @@ -143,15 +143,10 @@ if (CONFIG_BUILD_S1_VARIANT AND ) if (IMAGE_NAME) - # Register in the parent image that this child image will have - # ${link_variant}image.hex as a byproduct, this allows the parent image to know - # where the hex file comes from and create custom commands that - # depend on it. - set_property( - TARGET zephyr_property_target - APPEND_STRING - PROPERTY shared_vars - "list(APPEND ${IMAGE_NAME}BUILD_BYPRODUCTS ${output})\n" - ) + # Register in the parent image that this child image will have + # ${link_variant}image.hex as a byproduct, this allows the parent image to know + # where the hex file comes from and create custom commands that + # depend on it. + set_shared(IMAGE ${IMAGE_NAME} APPEND PROPERTY BUILD_BYPRODUCTS ${output}) endif() endif() diff --git a/doc/kconfig/conf.py b/doc/kconfig/conf.py index 009452e05e4d..441711ee8c3d 100644 --- a/doc/kconfig/conf.py +++ b/doc/kconfig/conf.py @@ -11,6 +11,8 @@ sys.path.insert(0, str(NRF_BASE / "doc" / "_utils")) import utils +ZEPHYR_BASE = utils.get_projdir("zephyr") + # General configuration -------------------------------------------------------- project = "Kconfig reference" @@ -19,9 +21,10 @@ # NOTE: use blank space as version to preserve space version = " " +sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions")) sys.path.insert(0, str(NRF_BASE / "doc" / "_extensions")) -extensions = ["ncs_cache"] +extensions = ["zephyr.kconfig-role", "ncs_cache"] # Options for HTML output ------------------------------------------------------ diff --git a/doc/mcuboot/conf.py b/doc/mcuboot/conf.py index b6871f60872b..58fc27b2f860 100644 --- a/doc/mcuboot/conf.py +++ b/doc/mcuboot/conf.py @@ -12,6 +12,7 @@ import utils MCUBOOT_BASE = utils.get_projdir("mcuboot") +ZEPHYR_BASE = utils.get_projdir("zephyr") # General configuration -------------------------------------------------------- @@ -19,9 +20,16 @@ copyright = "2019-2021" version = release = "1.7.99" +sys.path.insert(0, str(ZEPHYR_BASE / "doc" / "_extensions")) sys.path.insert(0, str(NRF_BASE / "doc" / "_extensions")) -extensions = ["sphinx.ext.intersphinx", "recommonmark", "ncs_cache", "external_content"] +extensions = [ + "zephyr.kconfig-role", + "sphinx.ext.intersphinx", + "recommonmark", + "ncs_cache", + "external_content" +] source_suffix = [".rst", ".md"] master_doc = "wrapper" diff --git a/doc/mcuboot/readme-ncs.rst b/doc/mcuboot/readme-ncs.rst index 2cf18e61ecde..c03cf5289a5b 100644 --- a/doc/mcuboot/readme-ncs.rst +++ b/doc/mcuboot/readme-ncs.rst @@ -8,7 +8,7 @@ See :doc:`readme-zephyr` for general information on how to integrate MCUboot wit nRF Connect SDK provides additional functionality that is available when MCUboot is included. This functionality is implemented in the files in the ``modules/mcuboot`` subfolder in the `sdk-nrf`_ repository. -To include MCUboot in your nRF Connect SDK application, enable :option:`CONFIG_BOOTLOADER_MCUBOOT`. +To include MCUboot in your nRF Connect SDK application, enable :kconfig:`CONFIG_BOOTLOADER_MCUBOOT`. When you build your application with this option set, the following files that can be used for firmware over-the-air (FOTA) upgrades are automatically generated: diff --git a/doc/nrf/app_boards.rst b/doc/nrf/app_boards.rst index b3ee95cc6ccd..878401aeba87 100644 --- a/doc/nrf/app_boards.rst +++ b/doc/nrf/app_boards.rst @@ -52,11 +52,11 @@ Also see the :ref:`zephyr:boards` section in the Zephyr documentation. | | | | | | | | | ``nrf5340dk_nrf5340_cpuapp`` | | | | | | -| | | | ``nrf5340dk_nrf5340_cpuappns`` | +| | | | ``nrf5340dk_nrf5340_cpuapp_ns`` | +-------------------+------------+-----------------------------------------------------------------+---------------------------------------+ | nRF9160 DK | PCA10090 | :ref:`nrf9160dk_nrf9160 ` | ``nrf9160dk_nrf9160`` | | | | | | -| | | | ``nrf9160dk_nrf9160ns`` | +| | | | ``nrf9160dk_nrf9160_ns`` | | | +-----------------------------------------------------------------+---------------------------------------+ | | | :ref:`nrf9160dk_nrf52840 ` | ``nrf9160dk_nrf52840`` | +-------------------+------------+-----------------------------------------------------------------+---------------------------------------+ @@ -90,11 +90,12 @@ The following boards are defined in the :file:`nrf/boards/arm/` folder. +-------------------+------------+----------------------------------------------------------+---------------------------------------+ | Thingy:91 | PCA20035 | :ref:`thingy91_nrf9160 ` | ``thingy91_nrf9160`` | | | | | | -| | | | ``thingy91_nrf9160ns`` | +| | | | ``thingy91_nrf9160_ns`` | | | +----------------------------------------------------------+---------------------------------------+ | | | :ref:`thingy91_nrf52840 ` | ``thingy91_nrf52840`` | +-------------------+------------+----------------------------------------------------------+---------------------------------------+ +The :ref:`nRF21540 EK shield ` is defined in the :file:`nrf/boards/shields` folder. Custom boards ************* diff --git a/doc/nrf/app_bootloaders.rst b/doc/nrf/app_bootloaders.rst index 892a4e83da80..b22780afba5a 100644 --- a/doc/nrf/app_bootloaders.rst +++ b/doc/nrf/app_bootloaders.rst @@ -20,7 +20,7 @@ The bootloaders support two types of updates: You can deliver the updated images to the device in two ways: * Wired - where updates are sent through a wired connection, like UART, or delivered by connecting a flash device. -* Over-the-air (OTA) - where updates are sent through a wireless connection, like Bluetooth LE. +* Over-the-air (OTA) - where updates are sent through a wireless connection, like Bluetooth® Low Energy. You can use a second-stage bootloader only in combination with a first-stage one. Also, not all bootloaders supported by the |NCS| can be used as either first-stage or second-stage ones. diff --git a/doc/nrf/app_memory.rst b/doc/nrf/app_memory.rst index fb5ccb5bb38a..cbe22720fd7e 100644 --- a/doc/nrf/app_memory.rst +++ b/doc/nrf/app_memory.rst @@ -25,7 +25,7 @@ The following subsections give more information on how to optimize specific subs Bluetooth ********* -Complete the following actions to optimize the Bluetooth part of your application: +Complete the following actions to optimize the Bluetooth® part of your application: * Disable features that your application does not use. For example, disable the following features: @@ -42,23 +42,23 @@ Complete the following actions to optimize the Bluetooth part of your applicatio The following configuration options affect the stack sizes of the Bluetooth threads: - * :option:`CONFIG_SDC_RX_STACK_SIZE` - * :option:`CONFIG_BT_RX_STACK_SIZE` - * :option:`CONFIG_BT_HCI_TX_STACK_SIZE` - * :option:`CONFIG_MPSL_SIGNAL_STACK_SIZE` + * :kconfig:`CONFIG_SDC_RX_STACK_SIZE` + * :kconfig:`CONFIG_BT_RX_STACK_SIZE` + * :kconfig:`CONFIG_BT_HCI_TX_STACK_SIZE` + * :kconfig:`CONFIG_MPSL_SIGNAL_STACK_SIZE` * Reduce the overall number and the sizes of the Bluetooth buffers, based on the expected data traffic in your application. The following configuration options affect the Bluetooth buffers: - * :option:`CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT` - * :option:`CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE` - * :option:`CONFIG_BT_BUF_EVT_RX_COUNT` - * :option:`CONFIG_BT_CONN_TX_MAX` - * :option:`CONFIG_BT_L2CAP_TX_BUF_COUNT` - * :option:`CONFIG_BT_CTLR_RX_BUFFERS` - * :option:`CONFIG_BT_BUF_ACL_TX_COUNT` - * :option:`CONFIG_BT_BUF_ACL_TX_SIZE` + * :kconfig:`CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT` + * :kconfig:`CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE` + * :kconfig:`CONFIG_BT_BUF_EVT_RX_COUNT` + * :kconfig:`CONFIG_BT_CONN_TX_MAX` + * :kconfig:`CONFIG_BT_L2CAP_TX_BUF_COUNT` + * :kconfig:`CONFIG_BT_CTLR_RX_BUFFERS` + * :kconfig:`CONFIG_BT_BUF_ACL_TX_COUNT` + * :kconfig:`CONFIG_BT_BUF_ACL_TX_SIZE` For reference, you can find minimal footprint configurations of the :ref:`peripheral_lbs` sample in :file:`nrf/samples/bluetooth/peripheral_lbs/minimal.conf` and the :ref:`peripheral_uart` sample in :file:`nrf/samples/bluetooth/peripheral_uart/minimal.conf`. @@ -82,17 +82,17 @@ Complete the following actions to optimize the Thread part of your application: The following configuration options affect the stack sizes of the Thread threads: - * :option:`CONFIG_OPENTHREAD_THREAD_STACK_SIZE` - * :option:`CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE` - * :option:`CONFIG_NET_RX_STACK_SIZE` - * :option:`CONFIG_NET_TX_STACK_SIZE` - * :option:`CONFIG_NET_MGMT_EVENT_STACK_SIZE` - * :option:`CONFIG_IEEE802154_NRF5_RX_STACK_SIZE` - * :option:`CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE` - * :option:`CONFIG_MPSL_SIGNAL_STACK_SIZE` - * :option:`CONFIG_SHELL_STACK_SIZE` - * :option:`CONFIG_IDLE_STACK_SIZE` - * :option:`CONFIG_MAIN_STACK_SIZE` - * :option:`CONFIG_ISR_STACK_SIZE` + * :kconfig:`CONFIG_OPENTHREAD_THREAD_STACK_SIZE` + * :kconfig:`CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE` + * :kconfig:`CONFIG_NET_RX_STACK_SIZE` + * :kconfig:`CONFIG_NET_TX_STACK_SIZE` + * :kconfig:`CONFIG_NET_MGMT_EVENT_STACK_SIZE` + * :kconfig:`CONFIG_IEEE802154_NRF5_RX_STACK_SIZE` + * :kconfig:`CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE` + * :kconfig:`CONFIG_MPSL_SIGNAL_STACK_SIZE` + * :kconfig:`CONFIG_SHELL_STACK_SIZE` + * :kconfig:`CONFIG_IDLE_STACK_SIZE` + * :kconfig:`CONFIG_MAIN_STACK_SIZE` + * :kconfig:`CONFIG_ISR_STACK_SIZE` For reference, you can find minimal footprint configurations for the single protocol and multiprotocol variants of the :ref:`ot_cli_sample` sample in :file:`nrf/samples/openthread/cli/overlay-minimal_*protocol.conf`. diff --git a/doc/nrf/app_power_opt.rst b/doc/nrf/app_power_opt.rst index 8a4e7afc21aa..0efd91589e51 100644 --- a/doc/nrf/app_power_opt.rst +++ b/doc/nrf/app_power_opt.rst @@ -51,7 +51,7 @@ To disable serial output, you must change the project configuration associated w See :ref:`ug_nrf5340` and :ref:`ug_multi_image`. 1. Set the project configuration ``CONFIG_SERIAL`` to ``n`` irrespective of whether you are building the sample for the secure or non-secure build targets. -#. For the non-secure build target (``nrf9160dk_nrf9160ns``), ensure that serial logging is also disabled in :ref:`secure_partition_manager`. To disable serial logging in Secure Partition Manager, complete the following steps: +#. For the non-secure build target (``nrf9160dk_nrf9160_ns``), ensure that serial logging is also disabled in :ref:`secure_partition_manager`. To disable serial logging in Secure Partition Manager, complete the following steps: a. Add a :file:`spm.conf` file in the project directory with the following content: @@ -78,7 +78,7 @@ The average current reduces to 4 µA, which implies 14 years of battery life on For a similar configuration, see the :ref:`udp` sample, which transmits UDP packets to an LTE network using an nRF9160 DK. You can use the sample to characterize the current consumption of the nRF9160 SiP. -It is optimized for low power operation on the ``nrf9160dk_nrf9160ns`` build target without any modifications. +It is optimized for low power operation on the ``nrf9160dk_nrf9160_ns`` build target without any modifications. Idle current due to other peripherals ************************************* @@ -192,7 +192,7 @@ To measure current on an nRF9160 DK using the Power Profiler Kit II, while it is Even though the requested time-out value in the use case is 60 minutes, it is decided by the network. The PSM floor current is now 4.69 µA. -#. Since the data transfer interval is 20 minutes, you can increase the frequency of transmission. Set :option:`CONFIG_UDP_DATA_UPLOAD_FREQUENCY_SECONDS` to ``120`` in :file:`prj.conf`. +#. Since the data transfer interval is 20 minutes, you can increase the frequency of transmission. Set :kconfig:`CONFIG_UDP_DATA_UPLOAD_FREQUENCY_SECONDS` to ``120`` in :file:`prj.conf`. #. Rebuild and program the sample. #. A 40-byte data packet is now sent every two minutes. Make sure that the frequency is sufficiently higher than the duration of RRC inactivity present in the network. @@ -217,7 +217,7 @@ To measure current on an nRF9160 DK using the Power Profiler Kit II, while it is It is recommended to send a batch of six measurements for every 60 minutes to have some margin. Hence, you can change the payload size to a value of 120 bytes in the :file:`prj.conf` to observe how it affects the charge in a single transmission. -#. To change the payload size, set :option:`CONFIG_UDP_DATA_UPLOAD_SIZE_BYTES` to ``120`` in :file:`prj.conf` +#. To change the payload size, set :kconfig:`CONFIG_UDP_DATA_UPLOAD_SIZE_BYTES` to ``120`` in :file:`prj.conf` #. Rebuild and program the sample. Observe the results in the Power Profiler Kit II interface: diff --git a/doc/nrf/conf.py b/doc/nrf/conf.py index 441b8e460ef1..c45a1194ba14 100644 --- a/doc/nrf/conf.py +++ b/doc/nrf/conf.py @@ -34,6 +34,7 @@ "sphinxcontrib.mscgen", "zephyr.html_redirects", "zephyr.warnings_filter", + "zephyr.kconfig-role", "ncs_cache", "external_content", "doxyrunner", @@ -145,9 +146,6 @@ (NRF_BASE / "doc" / "nrf", "*"), (NRF_BASE, "applications/**/*.rst"), (NRF_BASE, "applications/**/doc"), - (NRF_BASE, "include/**/*.rst"), - (NRF_BASE, "lib/**/*.rst"), - (NRF_BASE, "lib/**/doc"), (NRF_BASE, "samples/**/*.rst"), (NRF_BASE, "scripts/**/*.rst"), (NRF_BASE, "tests/**/*.rst"), diff --git a/doc/nrf/doc_styleguide.rst b/doc/nrf/doc_styleguide.rst index 1c68a44d0e14..4ec6784b55f4 100644 --- a/doc/nrf/doc_styleguide.rst +++ b/doc/nrf/doc_styleguide.rst @@ -118,9 +118,9 @@ To link directly to a doxygen reference from RST, use the following Breathe doma Kconfig ------- -Kconfig options can be linked to from RST by using the ``:option:`` domain:: +Kconfig options can be linked to from RST by using the ``:kconfig:`` domain:: - :option:`CONFIG_DEBUG` + :kconfig:`CONFIG_DEBUG` Doxygen |gl| ************ diff --git a/doc/nrf/drivers/eth_rtt.rst b/doc/nrf/drivers/eth_rtt.rst index c455ee153bdb..345652dc64a1 100644 --- a/doc/nrf/drivers/eth_rtt.rst +++ b/doc/nrf/drivers/eth_rtt.rst @@ -42,7 +42,7 @@ The content of this frame is constant and it is available in the driver source c Initialization ************** -You can initialize the RTT driver using the :option:`CONFIG_ETH_RTT` Kconfig option. +You can initialize the RTT driver using the :kconfig:`CONFIG_ETH_RTT` Kconfig option. API documentation ***************** diff --git a/doc/nrf/drivers/hw_cc310.rst b/doc/nrf/drivers/hw_cc310.rst index 1f86e8f31707..cc86d176f330 100644 --- a/doc/nrf/drivers/hw_cc310.rst +++ b/doc/nrf/drivers/hw_cc310.rst @@ -15,7 +15,7 @@ It initializes the following elements of the library: * hardware mutex and mutex API, * platform with or without RNG. -You can initialize the hw_cc310 driver using the :option:`CONFIG_HW_CC3XX` Kconfig option. +You can initialize the hw_cc310 driver using the :kconfig:`CONFIG_HW_CC3XX` Kconfig option. API documentation ***************** diff --git a/doc/nrf/drivers/uart_nrf_sw_lpuart.rst b/doc/nrf/drivers/uart_nrf_sw_lpuart.rst index 400557a4571c..d3ba72c853e6 100644 --- a/doc/nrf/drivers/uart_nrf_sw_lpuart.rst +++ b/doc/nrf/drivers/uart_nrf_sw_lpuart.rst @@ -7,8 +7,8 @@ Low power UART driver :local: :depth: 2 -The low power UART driver implements the standard *asynchronous UART API* that can be enabled with the :option:`CONFIG_UART_ASYNC_API` configuration option. -Alternatively, you can also enable the *interrupt-driven UART API* using the :option:`CONFIG_NRF_SW_LPUART_INT_DRIVEN` configuration option. +The low power UART driver implements the standard *asynchronous UART API* that can be enabled with the :kconfig:`CONFIG_UART_ASYNC_API` configuration option. +Alternatively, you can also enable the *interrupt-driven UART API* using the :kconfig:`CONFIG_NRF_SW_LPUART_INT_DRIVEN` configuration option. The protocol used by this driver implements two control lines, instead of standard hardware flow control lines, to allow for disabling the UART receiver during the idle period. This results in low power consumption, as you can shut down the high-frequency clock when UART is in idle state. @@ -84,15 +84,15 @@ See the following configuration example: The low power UART configuration includes: -* :option:`CONFIG_NRF_SW_LPUART_MAX_PACKET_SIZE`: Sets the maximum RX packet size. +* :kconfig:`CONFIG_NRF_SW_LPUART_MAX_PACKET_SIZE`: Sets the maximum RX packet size. -* :option:`CONFIG_NRF_SW_LPUART_INT_DRIVEN`: Enables the interrupt-driven API. +* :kconfig:`CONFIG_NRF_SW_LPUART_INT_DRIVEN`: Enables the interrupt-driven API. When enabled, the asynchronous API cannot be used. -* :option:`CONFIG_NRF_SW_LPUART_DEFAULT_TX_TIMEOUT`: Sets the timeout value, in milliseconds. +* :kconfig:`CONFIG_NRF_SW_LPUART_DEFAULT_TX_TIMEOUT`: Sets the timeout value, in milliseconds. It is used in :c:func:`uart_poll_out` and :c:func:`uart_fifo_fill` when the interrupt-driven API is enabled. -* :option:`CONFIG_NRF_SW_LPUART_INT_DRV_TX_BUF_SIZE`: Set the size of the internal buffer created and used by :c:func:`uart_fifo_fill`. +* :kconfig:`CONFIG_NRF_SW_LPUART_INT_DRV_TX_BUF_SIZE`: Set the size of the internal buffer created and used by :c:func:`uart_fifo_fill`. For optimal performance, it should be able to fit the longest possible packet. Usage diff --git a/doc/nrf/glossary.rst b/doc/nrf/glossary.rst index 2f601dddfe48..1e51a4433586 100644 --- a/doc/nrf/glossary.rst +++ b/doc/nrf/glossary.rst @@ -32,10 +32,10 @@ Glossary "[It] allows a device referred to as the server to expose a set of attributes and their associated values to a peer device referred to as the client." `Bluetooth Core Specification`_, Version 5.3, Vol 3, Part F, Section 1.1. - Bluetooth LE Controller layer + Bluetooth® LE Controller layer A layer of the Bluetooth LE protocol stack that implements the Link Layer (LL). - Bluetooth LE Host layer + Bluetooth® LE Host layer A layer of the Bluetooth LE protocol stack comprised of multiple (non real-time) network and transport protocols enabling applications to communicate with peer devices in a standard and interoperable way. Board diff --git a/doc/nrf/gs_assistant.rst b/doc/nrf/gs_assistant.rst index e13ad9a8f5ce..2d0532f3f601 100644 --- a/doc/nrf/gs_assistant.rst +++ b/doc/nrf/gs_assistant.rst @@ -54,18 +54,16 @@ Once you have installed the Toolchain manager, open it in nRF Connect for Deskto Click :guilabel:`Settings` in the navigation bar to specify where you want to install the |NCS|. Then, in :guilabel:`SDK Environments`, click the :guilabel:`Install` button next to the |NCS| version that you want to install. - The |NCS| version of your choice is installed on your machine, and the :guilabel:`Install` button changes to :guilabel:`Open IDE`. -This button lets you start SEGGER Embedded Studio if you want to start :ref:`gs_programming_ses`. -.. figure:: images/gs-assistant_tm_installed.png - :alt: The Toolchain manager options after installing the nRF Connect SDK version, cropped +There are two ways you can build an application: - The Toolchain Manager options after installing the |NCS| version +1. To :ref:`build with SES `, click on the :guilabel:`Open IDE` button. +#. To build on the command line, use the following steps: -Additionally, the dropdown menu becomes available. -Among other options, this menu lets you open bash and command prompt that use the installed Toolchain manager tools. -You can use the :guilabel:`Open bash` option from this menu when you start :ref:`gs_programming_cmd`. + 1. With admin permissions enabled, download and install the `nRF Command Line Tools`_. + #. Restart the Toolchain manager application. + #. Follow the instructions in :ref:`gs_programming_cmd`. .. figure:: images/gs-assistant_tm_dropdown.png :alt: The Toolchain manager dropdown menu for the installed nRF Connect SDK version, cropped @@ -77,7 +75,7 @@ You can use the :guilabel:`Open bash` option from this menu when you start :ref: Getting Started Assistant ************************* -The |GSA| app is available for Linux. +The |GSA| app is the automatic installation option for Linux. It provides you with step-by-step instructions for installing the toolchain for |NCS|. The app allows you to check which of the required tools are already installed on your computer and verify the installation. diff --git a/doc/nrf/gs_programming.rst b/doc/nrf/gs_programming.rst index 0a87518b9640..dd7b5d2e4f83 100644 --- a/doc/nrf/gs_programming.rst +++ b/doc/nrf/gs_programming.rst @@ -73,7 +73,7 @@ Complete the following steps to build |NCS| projects with SES after :ref:`instal .. build_SES_projimport_open_end - The following figure shows an example configuration for the Asset Tracker application built for the ``nrf9160dk_nrf9160ns`` build target: + The following figure shows an example configuration for the Asset Tracker application built for the ``nrf9160dk_nrf9160_ns`` build target: .. figure:: images/ses_config.png :alt: Opening the Asset Tracker project @@ -143,7 +143,7 @@ If it is installed, verify that its location is correct in the PATH variable or, Building on the command line **************************** -Complete the following steps to build |NCS| projects on the command line after completing the :ref:`command-line build setup `. +After completing the :ref:`manual ` or :ref:`automatic ` command-line build setup, use the following steps to build |NCS| projects on the command line. 1. Open a terminal window. diff --git a/doc/nrf/images/chiptool_relative_humidity.gif b/doc/nrf/images/chiptool_relative_humidity.gif new file mode 100644 index 000000000000..5cf1b379c74a Binary files /dev/null and b/doc/nrf/images/chiptool_relative_humidity.gif differ diff --git a/doc/nrf/images/chiptool_sensor_cluster.gif b/doc/nrf/images/chiptool_sensor_cluster.gif new file mode 100644 index 000000000000..9ed8215ae810 Binary files /dev/null and b/doc/nrf/images/chiptool_sensor_cluster.gif differ diff --git a/doc/nrf/images/chiptool_temperature_read.gif b/doc/nrf/images/chiptool_temperature_read.gif new file mode 100644 index 000000000000..0195d2d522c8 Binary files /dev/null and b/doc/nrf/images/chiptool_temperature_read.gif differ diff --git a/doc/nrf/images/chiptool_temperature_watch.gif b/doc/nrf/images/chiptool_temperature_watch.gif new file mode 100644 index 000000000000..72230a8f708b Binary files /dev/null and b/doc/nrf/images/chiptool_temperature_watch.gif differ diff --git a/doc/nrf/images/nrf21540_ek.png b/doc/nrf/images/nrf21540_ek.png new file mode 100644 index 000000000000..99afd951901c Binary files /dev/null and b/doc/nrf/images/nrf21540_ek.png differ diff --git a/doc/nrf/includes/boardname_tables/sample_boardnames.txt b/doc/nrf/includes/boardname_tables/sample_boardnames.txt index 5a0704094b8c..80b957982eb9 100644 --- a/doc/nrf/includes/boardname_tables/sample_boardnames.txt +++ b/doc/nrf/includes/boardname_tables/sample_boardnames.txt @@ -9,7 +9,7 @@ Set used by Bluetooth LE Samples, NFC samples, and NUS shell transport sample. +================================+===========+================================================+================================+ |:ref:`nRF5340 DK ` |PCA10095 |:ref:`nrf5340dk_nrf5340 ` |``nrf5340dk_nrf5340_cpuapp`` | | | | | | -| | | |``nrf5340dk_nrf5340_cpuappns`` | +| | | |``nrf5340dk_nrf5340_cpuapp_ns`` | +--------------------------------+-----------+------------------------------------------------+--------------------------------+ |:ref:`nRF52840 DK ` |PCA10056 |:ref:`nrf52840dk_nrf52840 `|``nrf52840dk_nrf52840`` | +--------------------------------+-----------+------------------------------------------------+--------------------------------+ @@ -36,19 +36,19 @@ Set used by Bluetooth LE samples (Peripheral LBS) .. set3_start -+---------------------------------+-----------+--------------------------------------------------------+-------------------------------+ -|Hardware platforms |PCA |Board name |Build target | -+=================================+===========+========================================================+===============================+ -|:ref:`nRF5340 DK ` |PCA10095 |:ref:`nrf5340dk_nrf5340 ` |``nrf5340dk_nrf5340_cpuapp`` | -| | | | | -| | | |``nrf5340dk_nrf5340_cpuappns`` | -+---------------------------------+-----------+--------------------------------------------------------+-------------------------------+ -|:ref:`nRF52840 Dongle `|PCA10059 |:ref:`nrf52840dongle_nrf52840 `|``nrf52840dongle_nrf52840`` | -+---------------------------------+-----------+--------------------------------------------------------+-------------------------------+ -|:ref:`nRF52840 DK ` |PCA10056 |:ref:`nrf52840dk_nrf52840 ` |``nrf52840dk_nrf52840`` | -+---------------------------------+-----------+--------------------------------------------------------+-------------------------------+ -|:ref:`nRF52 DK ` |PCA10040 |:ref:`nrf52dk_nrf52832 ` |``nrf52dk_nrf52832`` | -+---------------------------------+-----------+--------------------------------------------------------+-------------------------------+ ++---------------------------------+-----------+--------------------------------------------------------+--------------------------------+ +|Hardware platforms |PCA |Board name |Build target | ++=================================+===========+========================================================+================================+ +|:ref:`nRF5340 DK ` |PCA10095 |:ref:`nrf5340dk_nrf5340 ` |``nrf5340dk_nrf5340_cpuapp`` | +| | | | | +| | | |``nrf5340dk_nrf5340_cpuapp_ns`` | ++---------------------------------+-----------+--------------------------------------------------------+--------------------------------+ +|:ref:`nRF52840 Dongle `|PCA10059 |:ref:`nrf52840dongle_nrf52840 `|``nrf52840dongle_nrf52840`` | ++---------------------------------+-----------+--------------------------------------------------------+--------------------------------+ +|:ref:`nRF52840 DK ` |PCA10056 |:ref:`nrf52840dk_nrf52840 ` |``nrf52840dk_nrf52840`` | ++---------------------------------+-----------+--------------------------------------------------------+--------------------------------+ +|:ref:`nRF52 DK ` |PCA10040 |:ref:`nrf52dk_nrf52832 ` |``nrf52dk_nrf52832`` | ++---------------------------------+-----------+--------------------------------------------------------+--------------------------------+ .. set3_end @@ -76,7 +76,7 @@ LTE Sensor Gateway, LwM2M carrier, LwM2M Client, Simple MQTT, Secure Services S +--------------------------------+-----------+------------------------------------------------+-------------------------------+ |Hardware platforms |PCA |Board name |Build target | +================================+===========+================================================+===============================+ -|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160ns`` | +|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160_ns`` | +--------------------------------+-----------+------------------------------------------------+-------------------------------+ .. set5_end @@ -88,9 +88,9 @@ Set used by nRF9160 samples (Cloud Client, nRF Cloud A-GPS) and application (Ass +--------------------------------+-----------+------------------------------------------------+------------------------------+ |Hardware platforms |PCA |Board name |Build target | +================================+===========+================================================+==============================+ -|:ref:`Thingy:91 ` |PCA20035 |thingy91_nrf9160 |``thingy91_nrf9160ns`` | +|:ref:`Thingy:91 ` |PCA20035 |thingy91_nrf9160 |``thingy91_nrf9160_ns`` | +--------------------------------+-----------+------------------------------------------------+------------------------------+ -|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160ns`` | +|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160_ns`` | +--------------------------------+-----------+------------------------------------------------+------------------------------+ .. set6_end @@ -128,7 +128,7 @@ Set used by samples (Event Manager, Profiler, PPI Trace) +--------------------------------+-----------+------------------------------------------------+-------------------------------+ |Hardware platforms |PCA |Board name |Build target | +================================+===========+================================================+===============================+ -|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160ns`` | +|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160_ns`` | +--------------------------------+-----------+------------------------------------------------+-------------------------------+ |:ref:`nRF52840 DK ` |PCA10056 |:ref:`nrf52840dk_nrf52840 `|``nrf52840dk_nrf52840`` | +--------------------------------+-----------+------------------------------------------------+-------------------------------+ @@ -144,7 +144,7 @@ Set used by samples (BH1749: Ambient Light Sensor IC) +--------------------------------+-----------+------------------+---------------------------+ |Hardware platforms |PCA |Board name |Build target | +================================+===========+==================+===========================+ -|:ref:`Thingy:91 ` |PCA20035 |thingy91_nrf9160 |``thingy91_nrf9160ns`` | +|:ref:`Thingy:91 ` |PCA20035 |thingy91_nrf9160 |``thingy91_nrf9160_ns`` | +--------------------------------+-----------+------------------+---------------------------+ .. set10_end @@ -214,7 +214,7 @@ Set used by nRF53 samples (Empty firmware for application core) +================================+===========+===============================================+================================+ |:ref:`nRF5340 DK ` |PCA10095 |:ref:`nrf5340dk_nrf5340 ` |``nrf5340dk_nrf5340_cpuapp`` | | | | | | -| | | |``nrf5340dk_nrf5340_cpuappns`` | +| | | |``nrf5340dk_nrf5340_cpuapp_ns`` | +--------------------------------+-----------+-----------------------------------------------+--------------------------------+ .. set15_end @@ -226,11 +226,11 @@ Set used by sample (Immutable bootloader) +--------------------------------+-----------+------------------------------------------------+--------------------------------+ |Hardware platforms |PCA |Board name |Build target | +================================+===========+================================================+================================+ -|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160ns`` | +|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160_ns`` | +--------------------------------+-----------+------------------------------------------------+--------------------------------+ |:ref:`nRF5340 DK ` |PCA10095 |:ref:`nrf5340dk_nrf5340 ` |``nrf5340dk_nrf5340_cpuapp`` | | | | | | -| | | |``nrf5340dk_nrf5340_cpuappns`` | +| | | |``nrf5340dk_nrf5340_cpuapp_ns`` | +--------------------------------+-----------+------------------------------------------------+--------------------------------+ |:ref:`nRF52840 DK ` |PCA10056 |:ref:`nrf52840dk_nrf52840 `|``nrf52840dk_nrf52840`` | +--------------------------------+-----------+------------------------------------------------+--------------------------------+ @@ -258,7 +258,7 @@ Set used by Tests (Crypto) +--------------------------------+-----------+------------------------------------------------+--------------------------------+ |Hardware platforms |PCA |Board name |Build target | +================================+===========+================================================+================================+ -|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160ns`` | +|:ref:`nRF9160 DK ` |PCA10090 |:ref:`nrf9160dk_nrf9160 ` |``nrf9160dk_nrf9160_ns`` | +--------------------------------+-----------+------------------------------------------------+--------------------------------+ |:ref:`nRF52840 DK ` |PCA10056 |:ref:`nrf52840dk_nrf52840 `|``nrf52840dk_nrf52840`` | +--------------------------------+-----------+------------------------------------------------+--------------------------------+ diff --git a/doc/nrf/includes/ieee802154_eui64_conf.txt b/doc/nrf/includes/ieee802154_eui64_conf.txt index 7bc25114d486..f8f22df96eba 100644 --- a/doc/nrf/includes/ieee802154_eui64_conf.txt +++ b/doc/nrf/includes/ieee802154_eui64_conf.txt @@ -10,8 +10,8 @@ Use the default The extension identifier is set to the DEVICEID from the factory information configuration registers (FICR). Replace the company ID - You can enable :option:`CONFIG_IEEE802154_VENDOR_OUI_ENABLE` to replace Nordic Semiconductor's company ID with your own company ID. - Specify your company ID in :option:`CONFIG_IEEE802154_VENDOR_OUI`. + You can enable :kconfig:`CONFIG_IEEE802154_VENDOR_OUI_ENABLE` to replace Nordic Semiconductor's company ID with your own company ID. + Specify your company ID in :kconfig:`CONFIG_IEEE802154_VENDOR_OUI`. The extension identifier is set to the default, namely the DEVICEID from FICR. @@ -20,12 +20,12 @@ Replace the full EUI-64 For nRF52 Series devices, the CUSTOMER registers block is used. For nRF53 Series devices, the OTP registers block is used. - To use the EUI-64 value from the UICR, enable :option:`CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE` and set :option:`CONFIG_IEEE802154_NRF5_UICR_EUI64_REG` to the base of the two consecutive registers that contain your EUI-64 value. + To use the EUI-64 value from the UICR, enable :kconfig:`CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE` and set :kconfig:`CONFIG_IEEE802154_NRF5_UICR_EUI64_REG` to the base of the two consecutive registers that contain your EUI-64 value. The following example shows how to replace the full EUI-64 on an nRF52840 device: - 1. Enable :option:`CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE`. - #. Specify the offset for the UICR registers in :option:`CONFIG_IEEE802154_NRF5_UICR_EUI64_REG`. + 1. Enable :kconfig:`CONFIG_IEEE802154_NRF5_UICR_EUI64_ENABLE`. + #. Specify the offset for the UICR registers in :kconfig:`CONFIG_IEEE802154_NRF5_UICR_EUI64_REG`. This example uses UICR->CUSTOMER[0] and UICR->CUSTOMER[1], which means that you can keep the default value ``0``. #. Build and program your application erasing the whole memory (replace *serial_number* with the serial number of your debugger): @@ -44,4 +44,4 @@ Replace the full EUI-64 nrfjprog --snr *serial_number* --memwr 0x10001084 --val 0x55667788 nrfjprog --snr *serial_number* --reset - If you used a different value for :option:`CONFIG_IEEE802154_NRF5_UICR_EUI64_REG`, you must use different register addresses. + If you used a different value for :kconfig:`CONFIG_IEEE802154_NRF5_UICR_EUI64_REG`, you must use different register addresses. diff --git a/doc/nrf/includes/sample_board_rows.txt b/doc/nrf/includes/sample_board_rows.txt index 718281d72648..db5da7cf8dc0 100644 --- a/doc/nrf/includes/sample_board_rows.txt +++ b/doc/nrf/includes/sample_board_rows.txt @@ -18,9 +18,9 @@ | :ref:`nRF9160 DK ` | PCA10090 | :ref:`nrf9160dk_nrf9160 ` | ``nrf9160dk_nrf9160`` | -.. nrf9160dk_nrf9160ns +.. nrf9160dk_nrf9160_ns -| :ref:`nRF9160 DK ` | PCA10090 | :ref:`nrf9160dk_nrf9160 ` | ``nrf9160dk_nrf9160ns`` | +| :ref:`nRF9160 DK ` | PCA10090 | :ref:`nrf9160dk_nrf9160 ` | ``nrf9160dk_nrf9160_ns`` | .. nrf9160dk_nrf52840 @@ -30,9 +30,9 @@ | :ref:`nRF5340 DK ` | PCA10095 | :ref:`nrf5340dk_nrf5340 ` | ``nrf5340dk_nrf5340_cpuapp`` | -.. nrf5340dk_nrf5340_cpuappns +.. nrf5340dk_nrf5340_cpuapp_ns -| :ref:`nRF5340 DK ` | PCA10095 | :ref:`nrf5340dk_nrf5340 ` | ``nrf5340dk_nrf5340_cpuappns`` | +| :ref:`nRF5340 DK ` | PCA10095 | :ref:`nrf5340dk_nrf5340 ` | ``nrf5340dk_nrf5340_cpuapp_ns`` | .. nrf5340dk_nrf5340_cpunet @@ -54,9 +54,9 @@ | nRF52820 Dongle | PCA10114 | nrf52820dongle_nrf52820 | ``nrf52820dongle_nrf52820`` | -.. thingy91_nrf9160ns +.. thingy91_nrf9160_ns -| :ref:`Thingy:91 ` | PCA20035 | thingy91_nrf9160 | ``thingy91_nrf9160ns`` | +| :ref:`Thingy:91 ` | PCA20035 | thingy91_nrf9160 | ``thingy91_nrf9160_ns`` | .. nrf52dk_nrf52810 @@ -92,9 +92,9 @@ .. nrf5340dk_nrf5340_cpuapp_and_cpuappns -| :ref:`nRF5340 DK ` | PCA10095 | :ref:`nrf5340dk_nrf5340 ` | ``nrf5340dk_nrf5340_cpuapp`` | -| | | | | -| | | | ``nrf5340dk_nrf5340_cpuappns`` | +| :ref:`nRF5340 DK ` | PCA10095 | :ref:`nrf5340dk_nrf5340 ` | ``nrf5340dk_nrf5340_cpuapp`` | +| | | | | +| | | | ``nrf5340dk_nrf5340_cpuapp_ns`` | .. nrf5340dk_nrf5340_cpuapp_and_cpunet diff --git a/doc/nrf/includes/sample_dtm_radio_test_fem.txt b/doc/nrf/includes/sample_dtm_radio_test_fem.txt index 0986eef04c10..034cbd543f49 100644 --- a/doc/nrf/includes/sample_dtm_radio_test_fem.txt +++ b/doc/nrf/includes/sample_dtm_radio_test_fem.txt @@ -1,33 +1,14 @@ You can add support for the nRF21540 front-end module (FEM) to the sample. -Set ``-DNRF21540EK_FEM=y`` when you invoke ``west build`` or ``cmake`` in your sample directory. -Follow the instructions in :ref:`cmake_options`. -For example: -``west build -b nrf5340dk_nrf5340_cpunet -- -DNRF21540EK_FEM=y`` - -When you set ``NRF21540EK_FEM=y`` the :file:`dts-nrf21540-fem.overlay` devicetree overlay file is used to override the default settings. -The configuration from this file is merged with the additional development kit overlay file from the :file:`boards` folder if it exists. - -The :file:`dts-nrf21540-fem.overlay` is located in the |fem_file_path| folder. -Make sure that the GPIOs and the SPI configuration in the file correspond to those in which your front-end module is connected. +To add support for the nRF21540 FEM, build the sample for a board containing nRF21540 FEM like :ref:`nrf21540dk_nrf52840 ` or create a devicetree overlay file describing how FEM is connected to nRF5 SoC in your device. .. note:: - You must set ``NRF21540EK_FEM=y`` if you use the nRF21540 EK. + If you use the nRF21540 EK, append ``nrf21540_ek`` shield to your build command instructing build system to append the appropriate devicetree overlay file. If you use the nRF21540 DK, build your application for the :ref:`nrf21540dk_nrf52840 ` board. The devicetree for the nRF21540 DK already contains the required FEM configuration, so you do not need to set an additional build option. -Sometimes, you may need to add an extra overlay file. -The easiest way to add the file when building is to set it in the ``DTC_OVERLAY_FILE`` variable. -However, that will override the default settings. -When you set the ``DTC_OVERLAY_FILE`` variable, you must specify all overlay files that are needed for building. - -Follow the instructions in :ref:`cmake_options` to specify the ``DTC_OVERLAY_FILE`` variable. For example, to build the sample from the command line for an nRF5340 DK with an attached nRF21540 EK, invoke the following command within the sample directory: -``west build -b nrf5340dk_nrf5340_cpunet -- -DDTC_OVERLAY_FILE="boards/nrf5340dk_nrf5340_cpunet.overlay;../configuration/dts-nrf21540-fem.overlay;your_overlay_file.overlay"`` - -See :ref:`zephyr:set-devicetree-overlays` for different ways of adding the overlay file. - -Alternatively, you can copy the contents of :file:`dts-nrf21540-fem.overlay` to the board's overlay file. +``west build -b nrf5340dk_nrf5340_cpunet -- -DSHIELD=nrf21540_ek`` .. note:: The nRF5340 DK network core peripherals, like UART and SPI, share an ID and a base address. diff --git a/doc/nrf/includes/sample_fem_support.txt b/doc/nrf/includes/sample_fem_support.txt index 4458dbdb7d70..4ff47a3a9ec1 100644 --- a/doc/nrf/includes/sample_fem_support.txt +++ b/doc/nrf/includes/sample_fem_support.txt @@ -5,30 +5,19 @@ You can add support for the nRF21540 front-end module to the sample. See :ref:`ug_radio_fem` for more information. -To add support for the nRF21540 FEM, add the provided :file:`dts-nrf21540-fem.overlay` devicetree overlay file when building. -The file is located in the |fem_file_path| folder. -Make sure that the GPIOs in the file correspond to those in which your front-end module is connected. +To add support for the nRF21540 FEM, the devicetree must contain the description of the nRF21540 FEM. +To include this description in your application, use one of the following options, depending on your hardware: -.. note:: - You must add the provided overlay file if you use the nRF21540 EK. - If you use the nRF21540 DK, build your application for the :ref:`nrf21540dk_nrf52840 ` board. - The devicetree for the nRF21540 DK already contains the required FEM configuration, so you do not need to add the overlay file. - -See :ref:`zephyr:set-devicetree-overlays` for different ways of adding the overlay file. - -The easiest way to add the file when building is to set it in the ``DTC_OVERLAY_FILE`` variable. -However, doing so will override the default settings. -For some boards, this sample requires additional overlay files, which are automatically included when building with the default settings. -When you set the ``DTC_OVERLAY_FILE`` variable, you must specify all overlay files that are needed for building. -Check the :file:`boards` folder to see the additional overlay files. - -Follow the instructions in :ref:`cmake_options` to specify the ``DTC_OVERLAY_FILE`` variable. -For example, to build the sample from the command line for an nRF52833 DK with an attached nRF21540 EK, invoke the following command within the sample directory: - -.. code-block:: console +* Build the sample for one board that contains the nRF21540 FEM, such as :ref:`nrf21540dk_nrf52840 `. +* Manually create a devicetree overlay file that describes how FEM is connected to the nRF5 SoC in your device. + See :ref:`zephyr:set-devicetree-overlays` for different ways of adding the overlay file. +* Provide nRF21540 FEM capabilities by using a :ref:`shield `, for example the :ref:`ug_radio_fem_nrf21540_ek` shield that is available in the |NCS|. + In this case, build the project for a board connected to the shield you are using with an appropriate variable included in the build command. + This variable instructs the build system to append the appropriate devicetree overlay file. + For example, to build the sample from the command line for an nRF52833 DK with the nRF21540 EK attached, use the following command within the sample directory: - west build -b nrf52833dk_nrf52833 -- -DDTC_OVERLAY_FILE="boards/nrf52833dk_nrf52833.overlay;../common/dts-nrf21540-fem.overlay" + .. code-block:: console -Alternatively, you can copy the contents of :file:`dts-nrf21540-fem.overlay` to the board's overlay file. + west build -b nrf52833dk_nrf52833 -- -DSHIELD=nrf21540_ek -To add support for other front-end modules, add the respective overlay files in the same way. +To add support for other front-end modules, add the respective devicetree file entries to the board devicetree file or the devicetree overlay file. diff --git a/doc/nrf/includes/tfm.txt b/doc/nrf/includes/tfm.txt index 0f8f14c82f9e..1563ab77c964 100644 --- a/doc/nrf/includes/tfm.txt +++ b/doc/nrf/includes/tfm.txt @@ -1,2 +1,2 @@ -When built for nrf5340dk_nrf5340_cpuappns and nrf9160dk_nrf9160ns targets, the sample is configured to compile and run as a non-secure application. +When built for nrf5340dk_nrf5340_cpuapp_ns and nrf9160dk_nrf9160_ns targets, the sample is configured to compile and run as a non-secure application. Therefore, it automatically includes :ref:`TF-M ` that prepares the required peripherals to be available for the application. diff --git a/doc/nrf/index.rst b/doc/nrf/index.rst index 21d134ac463b..1f44db21989b 100644 --- a/doc/nrf/index.rst +++ b/doc/nrf/index.rst @@ -5,7 +5,7 @@ Welcome to the |NCS|! The |NCS| is where you begin building low power wireless applications with Nordic Semiconductor nRF52, nRF53, and nRF91 Series devices. -The SDK contains optimized cellular IoT (LTE-M and NB-IoT), Bluetooth Low Energy, Thread, Zigbee, and Bluetooth mesh stacks, a range of applications, samples, and reference implementations, as well as a full suite of drivers for Nordic Semiconductor's devices. +The SDK contains optimized cellular IoT (LTE-M and NB-IoT), Bluetooth® Low Energy, Thread, Zigbee, and Bluetooth mesh stacks, a range of applications, samples, and reference implementations, as well as a full suite of drivers for Nordic Semiconductor's devices. The |NCS| includes the Zephyr™ real-time operating system (RTOS), which is built for connected low power products. .. note:: @@ -62,7 +62,7 @@ In addition to the |NCS| documentation, information is available in the followin applications samples drivers - libraries + libraries/index scripts release_notes known_issues diff --git a/doc/nrf/known_issues.rst b/doc/nrf/known_issues.rst index d9baaec5efa5..842ae9897b5e 100644 --- a/doc/nrf/known_issues.rst +++ b/doc/nrf/known_issues.rst @@ -63,19 +63,19 @@ Asset tracker .. rst-class:: v1-6-1 v1-6-0 v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 -NCSDK-6898: Setting :option:`CONFIG_SECURE_BOOT` does not work +NCSDK-6898: Setting :kconfig:`CONFIG_SECURE_BOOT` does not work The immutable bootloader is not able to find the required metadata in the MCUboot image. See the related NCSDK-6898 known issue in `Build system`_ for more details. - **Workaround:** Set :option:`CONFIG_FW_INFO` in MCUboot. + **Workaround:** Set :kconfig:`CONFIG_FW_INFO` in MCUboot. .. rst-class:: v1-6-1 v1-6-0 v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 External antenna performance setting The preprogrammed Asset Tracker does not come with the best external antenna performance. - **Workaround:** If you are using nRF9160 DK v0.15.0 or higher and Thingy:91 v1.4.0 or higher, set :option:`CONFIG_NRF9160_GPS_ANTENNA_EXTERNAL` to ``y``. - Alternatively, for nRF9160 DK v0.15.0, you can set the :option:`CONFIG_NRF9160_GPS_COEX0_STRING` option to ``AT%XCOEX0`` when building the preprogrammed Asset Tracker to achieve the best external antenna performance. + **Workaround:** If you are using nRF9160 DK v0.15.0 or higher and Thingy:91 v1.4.0 or higher, set :kconfig:`CONFIG_NRF9160_GPS_ANTENNA_EXTERNAL` to ``y``. + Alternatively, for nRF9160 DK v0.15.0, you can set the :kconfig:`CONFIG_NRF9160_GPS_COEX0_STRING` option to ``AT%XCOEX0`` when building the preprogrammed Asset Tracker to achieve the best external antenna performance. .. rst-class:: v1-3-2 v1-3-1 v1-3-0 @@ -202,17 +202,17 @@ nRF5340 .. rst-class:: v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 NCSDK-9786: Wrong FLASH_PAGE_ERASE_MAX_TIME_US for the nRF53 network core - ``FLASH_PAGE_ERASE_MAX_TIME_US`` defines the execution window duration when doing the flash operation synchronously along the radio operations (:option:`CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE` not enabled). + ``FLASH_PAGE_ERASE_MAX_TIME_US`` defines the execution window duration when doing the flash operation synchronously along the radio operations (:kconfig:`CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE` not enabled). The ``FLASH_PAGE_ERASE_MAX_TIME_US`` value of the nRF53 network core is lower than required. - For this reason, if :option:`CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL` is set to ``y`` and :option:`CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE` is set to ``n``, a flash erase operation on the nRF5340 network core will result in an MPSL timeslot OVERSTAYED assert. + For this reason, if :kconfig:`CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL` is set to ``y`` and :kconfig:`CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE` is set to ``n``, a flash erase operation on the nRF5340 network core will result in an MPSL timeslot OVERSTAYED assert. **Workaround:** Increase ``FLASH_PAGE_ERASE_MAX_TIME_US`` (defined in :file:`ncs/zephyr/soc/arm/nordic_nrf/nrf53/soc.h`) from 44850UL to 89700UL (the same value as for the application core). .. rst-class:: v1-6-1 v1-6-0 v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 NCSDK-7234: UART output is not received from the network core - The UART output is not received from the network core if the application core is programmed and running with a non-secure image (using the ``nrf5340dk_nrf5340_cpuappns`` build target). + The UART output is not received from the network core if the application core is programmed and running with a non-secure image (using the ``nrf5340dk_nrf5340_cpuapp_ns`` build target). .. rst-class:: v1-6-1 v1-6-0 v1-5-1 v1-5-0 @@ -253,7 +253,7 @@ KRKNWK-10633: Incorrect data when using ACK-based Probing with Link Metrics KRKNWK-10467: Security issues for retransmitted frames with Thread 1.2 The Thread 1.2 current implementation does not guarantee that all retransmitted frames will be secured when using the transmission security capabilities of the radio driver. - For this reason, OpenThread retransmissions are disabled by default when the :option:`CONFIG_NRF_802154_ENCRYPTION` Kconfig option is enabled. + For this reason, OpenThread retransmissions are disabled by default when the :kconfig:`CONFIG_NRF_802154_ENCRYPTION` Kconfig option is enabled. You can enable the retransmissions at your own risk. .. rst-class:: v1-6-1 v1-6-0 @@ -289,10 +289,10 @@ KRKNWK-7885: Throughput is lower when using CC310 nrf_security backend **Workaround:** Use AES-CCM ciphers from the nrf_oberon backend by setting the following options: - * :option:`CONFIG_OBERON_BACKEND` to ``y`` - * :option:`CONFIG_OBERON_MBEDTLS_AES_C` to ``y`` - * :option:`CONFIG_OBERON_MBEDTLS_CCM_C` to ``y`` - * :option:`CONFIG_CC3XX_MBEDTLS_AES_C` to ``n`` + * :kconfig:`CONFIG_OBERON_BACKEND` to ``y`` + * :kconfig:`CONFIG_OBERON_MBEDTLS_AES_C` to ``y`` + * :kconfig:`CONFIG_OBERON_MBEDTLS_CCM_C` to ``y`` + * :kconfig:`CONFIG_CC3XX_MBEDTLS_AES_C` to ``n`` .. rst-class:: v1-4-2 v1-4-1 v1-4-0 @@ -305,7 +305,7 @@ KRKNWK-7721: MAC counter updating issue .. rst-class:: v1-6-1 v1-6-0 v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 KRKNWK-7962: Logging interferes with shell output - :option:`CONFIG_LOG_MINIMAL` is configured by default for most OpenThread samples. + :kconfig:`CONFIG_LOG_MINIMAL` is configured by default for most OpenThread samples. It accesses the UART independently from the shell backend, which sometimes leads to malformed output. **Workaround:** Disable logging or enable a more advanced logging option. @@ -492,14 +492,14 @@ Matter (Project CHIP) .. rst-class:: v1-6-1 v1-6-0 KRKNWK-10589: Android CHIPTool crashes when commissioning a Matter device - In random circumstances, Android CHIPTool crashes when trying to connect to a Matter device over Bluetooth LE. + In random circumstances, Android CHIPTool crashes when trying to connect to a Matter device over Bluetooth® LE. **Workaround** Restart the application and try to commission the Matter device again. If the problem persists, clear the application data and try again. .. rst-class:: v1-6-1 v1-6-0 -KRKNWK-10387: Matter service is needlessly advertised over Bluetooth LE during DFU +KRKNWK-10387: Matter service is needlessly advertised over Bluetooth® LE during DFU The Matter samples can be configured to include the support for Device Firmware Upgrade (DFU) over Bluetooth LE. When the DFU procedure is started, the Matter Bluetooth LE service is needlessly advertised, revealing the device identifiers such as Vendor and Product IDs. The service is meant to be advertised only during the device commissioning. @@ -540,13 +540,13 @@ DESK-978: Directed advertising issues with SoftDevice Link Layer For more detailed information, see the ``Known issues and limitations`` section of the SoftDevice Controller's :ref:`nrfxlib:softdevice_controller_changelog`. .. note:: - The Kconfig option name changed from ``CONFIG_DESKTOP_BLE_DIRECT_ADV`` to :option:`CONFIG_CAF_BLE_ADV_DIRECT_ADV` beginning with the nRF Connect SDK v1.5.99. + The Kconfig option name changed from ``CONFIG_DESKTOP_BLE_DIRECT_ADV`` to :kconfig:`CONFIG_CAF_BLE_ADV_DIRECT_ADV` beginning with the nRF Connect SDK v1.5.99. **Workaround:** Directed advertising is disabled by default for nRF Desktop. .. rst-class:: v1-6-1 v1-6-0 v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 v1-2-1 v1-2-0 v1-1-0 v1-0-0 -NCSDK-8304: HID configurator issues for peripherals connected over Bluetooth LE to Linux host +NCSDK-8304: HID configurator issues for peripherals connected over Bluetooth® LE to Linux host Using :ref:`nrf_desktop_config_channel_script` for peripherals connected to host directly over Bluetooth LE may result in receiving improper HID feature report ID. In such case, the device will provide HID input reports, but it cannot be configured with the HID configurator. @@ -558,7 +558,7 @@ Pelion .. rst-class:: v1-6-1 v1-6-0 NCSDK-10196: DFU fails for some configurations with the quick session resume feature enabled - Enabling :option:`CONFIG_PELION_QUICK_SESSION_RESUME` together with the OpenThread network backend leads to the quick session resume failure during the DFU packet exchange. + Enabling :kconfig:`CONFIG_PELION_QUICK_SESSION_RESUME` together with the OpenThread network backend leads to the quick session resume failure during the DFU packet exchange. This is valid for the :ref:`nRF52840 DK ` and the :ref:`nRF5340 DK `. **Workaround:** Use the quick session resume feature only for configurations with the cellular network backend. @@ -575,10 +575,10 @@ NCSDK-9820: The :ref:`peripheral_lbs` - If **Button 1** is pushed and released w .. rst-class:: v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 v1-2-1 v1-2-0 v1-1-0 v1-0-0 -NCSDK-9106: Bluetooth ECC thread stack size too small +NCSDK-9106: Bluetooth® ECC thread stack size too small The Bluetooth ECC thread used during the pairing procedure with LE Secure Connections might overflow when an interrupt is triggered when the stack usage is at its maximum. - **Workaround:** Increase the ECC stack size by setting :option:`CONFIG_BT_HCI_ECC_STACK_SIZE` to ``1140``. + **Workaround:** Increase the ECC stack size by setting :kconfig:`CONFIG_BT_HCI_ECC_STACK_SIZE` to ``1140``. .. rst-class:: v1-5-0 v1-4-2 v1-4-1 v1-4-0 @@ -615,7 +615,7 @@ NCSDK-8223: GATT requests might deadlock RX thread This causes a deadlock because only the RX thread releases the TX buffers for the GATT requests. The deadlock is resolved by a 30 second timeout, but the ATT bearer cannot transmit without reconnecting. - **Workaround:** Set :option:`CONFIG_BT_L2CAP_TX_BUF_COUNT` >= ``CONFIG_BT_ATT_TX_MAX`` + 2. + **Workaround:** Set :kconfig:`CONFIG_BT_L2CAP_TX_BUF_COUNT` >= ``CONFIG_BT_ATT_TX_MAX`` + 2. .. rst-class:: v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 v1-2-1 v1-2-0 v1-1-0 v1-0-0 @@ -640,14 +640,14 @@ NCSDK-5711: High-throughput transmission can deadlock the receive thread .. rst-class:: v1-2-1 v1-2-0 -Only secure applications can use Bluetooth LE +Only secure applications can use Bluetooth® LE Bluetooth LE cannot be used in a non-secure application, for example, an application built for the ``nrf5340_dk_nrf5340_cpuappns`` build target. **Workaround:** Use the ``nrf5340_dk_nrf5340_cpuapp`` build target instead. .. rst-class:: v1-2-1 v1-2-0 -Peripheral HIDS keyboard sample cannot be used with nRF Bluetooth LE Controller +Peripheral HIDS keyboard sample cannot be used with nRF Bluetooth® LE Controller The :ref:`peripheral_hids_keyboard` sample cannot be used with the :ref:`nrfxlib:softdevice_controller` because the NFC subsystem does not work with the controller library. The library uses the MPSL Clock driver, which does not provide an API for asynchronous clock operation. NFC requires this API to work correctly. @@ -655,7 +655,7 @@ Peripheral HIDS keyboard sample cannot be used with nRF Bluetooth LE Controller .. rst-class:: v1-2-1 v1-2-0 Peripheral HIDS mouse sample advertising issues - When the :ref:`peripheral_hids_mouse` sample is used with the Zephyr Bluetooth LE Controller, directed advertising does not time out and the regular advertising cannot be started. + When the :ref:`peripheral_hids_mouse` sample is used with the Zephyr Bluetooth® LE Controller, directed advertising does not time out and the regular advertising cannot be started. .. rst-class:: v1-2-1 v1-2-0 @@ -665,12 +665,12 @@ Central HIDS sample issues with directed advertising .. rst-class:: v1-1-0 Unstable samples - Bluetooth Low Energy peripheral samples are unstable in some conditions (when pairing and bonding are performed and then disconnections/re-connections happen). + Bluetooth® Low Energy peripheral samples are unstable in some conditions (when pairing and bonding are performed and then disconnections/re-connections happen). .. rst-class:: v1-2-1 v1-2-0 v1-1-0 -:option:`CONFIG_BT_SMP` alignment requirement - When running the :ref:`bluetooth_central_dfu_smp` sample, the :option:`CONFIG_BT_SMP` configuration must be aligned between this sample and the Zephyr counterpart (:ref:`zephyr:smp_svr_sample`). +:kconfig:`CONFIG_BT_SMP` alignment requirement + When running the :ref:`bluetooth_central_dfu_smp` sample, the :kconfig:`CONFIG_BT_SMP` configuration must be aligned between this sample and the Zephyr counterpart (:ref:`zephyr:smp_svr_sample`). However, security is not enabled by default in the Zephyr sample. .. rst-class:: v1-2-1 v1-2-0 v1-1-0 v1-0-0 @@ -686,13 +686,13 @@ Reconnection issues on some operating systems .. rst-class:: v1-0-0 :ref:`bluetooth_central_hids` loses UART connectivity - After programming a HEX file to the nrf52_pca10040 board, UART connectivity is lost when using the Bluetooth LE Controller. + After programming a HEX file to the nrf52_pca10040 board, UART connectivity is lost when using the Bluetooth® LE Controller. The board must be reset to get UART output. .. rst-class:: v1-1-0 v1-0-0 Samples crashing on nRF51 when using GPIO - On nRF51 devices, Bluetooth LE samples that use GPIO might crash when buttons are pressed frequently. + On nRF51 devices, Bluetooth® LE samples that use GPIO might crash when buttons are pressed frequently. In such case, the GPIO ISR introduces latency that violates real-time requirements of the Radio ISR. nRF51 is more sensitive to this issue than nRF52 (faster core). @@ -704,7 +704,7 @@ GATT Discovery Manager missing support .. rst-class:: v0-4-0 Samples do not work with SD Controller v0.1.0 - Bluetooth LE samples cannot be built with the :ref:`nrfxlib:softdevice_controller` v0.1.0. + Bluetooth® LE samples cannot be built with the :ref:`nrfxlib:softdevice_controller` v0.1.0. .. rst-class:: v1-0-0 v0-4-0 v0-3-0 @@ -733,12 +733,12 @@ Bluetooth mesh .. rst-class:: v1-6-1 v1-6-0 v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 NCSDK-5580: nRF5340 only supports SoftDevice Controller - On nRF5340, only the :ref:`nrfxlib:softdevice_controller` is supported for Bluetooth mesh. + On nRF5340, only the :ref:`nrfxlib:softdevice_controller` is supported for Bluetooth® mesh. .. rst-class:: v1-6-1 v1-6-0 NCSDK-10200: The device stops sending Secure Network Beacons after re-provisioning - Bluetooth mesh stops sending Secure Network Beacons if the device is re-provisioned after reset through Config Node Reset message or ``bt_mesh_reset()`` call. + Bluetooth® mesh stops sending Secure Network Beacons if the device is re-provisioned after reset through Config Node Reset message or ``bt_mesh_reset()`` call. **Workaround:** Reboot the device after re-provisioning. @@ -796,7 +796,7 @@ Build system Missing files or permissions when building on Windows Because of the Windows path length limitations, the build can fail with errors related to permissions or missing files if some paths in the build are too long. - **Workaround:** Shorten the build folder name, for example, from "build_nrf5340dk_nrf5340_cpuappns" to "build", or shorten the path to the build folder in some other way. + **Workaround:** Shorten the build folder name, for example, from "build_nrf5340dk_nrf5340_cpuapp_ns" to "build", or shorten the path to the build folder in some other way. .. rst-class:: v1-4-2 v1-4-1 v1-4-0 @@ -807,7 +807,7 @@ NCSDK-6898: Overriding child images .. rst-class:: v1-4-2 v1-4-1 v1-4-0 -NCSDK-6777: Project out of date when :option:`CONFIG_SECURE_BOOT` is set +NCSDK-6777: Project out of date when :kconfig:`CONFIG_SECURE_BOOT` is set The DFU :file:`.zip` file is regenerated even when no changes are made to the files it depends on. As a consequence, SES displays a "Project out of date" message even when the project is not out of date. @@ -816,9 +816,9 @@ NCSDK-6777: Project out of date when :option:`CONFIG_SECURE_BOOT` is set .. rst-class:: v1-4-2 v1-4-1 v1-4-0 NCSDK-6848: MCUboot must be built from source when included - The build will fail if either :option:`CONFIG_MCUBOOT_BUILD_STRATEGY_SKIP_BUILD` or :option:`CONFIG_MCUBOOT_BUILD_STRATEGY_USE_HEX_FILE` is set. + The build will fail if either :kconfig:`CONFIG_MCUBOOT_BUILD_STRATEGY_SKIP_BUILD` or :kconfig:`CONFIG_MCUBOOT_BUILD_STRATEGY_USE_HEX_FILE` is set. - **Workaround:** Set :option:`CONFIG_MCUBOOT_BUILD_STRATEGY_FROM_SOURCE` instead. + **Workaround:** Set :kconfig:`CONFIG_MCUBOOT_BUILD_STRATEGY_FROM_SOURCE` instead. .. rst-class:: v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 v1-2-1 v1-2-0 v1-1-0 v1-0-0 v0-4-0 v0-3-0 @@ -830,9 +830,9 @@ KRKNWK-7827: Application build system is not aware of the settings partition You can use one of the following solutions: * :ref:`partition_manager` from |NCS| - see the page for all configuration options. - For example, for single image (without bootloader and with the settings partition used), set the :option:`CONFIG_PM_SINGLE_IMAGE` Kconfig option to ``y`` and define the value for :option:`CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE` to the required settings storage size. + For example, for single image (without bootloader and with the settings partition used), set the :kconfig:`CONFIG_PM_SINGLE_IMAGE` Kconfig option to ``y`` and define the value for :kconfig:`CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE` to the required settings storage size. * :ref:`Devicetree code partition ` from Zephyr. - Set :option:`CONFIG_USE_DT_CODE_PARTITION` Kconfig option to ``y``. + Set :kconfig:`CONFIG_USE_DT_CODE_PARTITION` Kconfig option to ``y``. Make sure that the code partition is defined and chosen correctly (``offset`` and ``size``). .. rst-class:: v1-6-1 v1-6-0 v1-5-1 v1-5-0 v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 @@ -871,7 +871,7 @@ NCSDK-6238: Socket API calls may hang when using Download client When using the :ref:`lib_download_client` library with HTTP (without TLS), the application might not process incoming fragments fast enough, which can starve the :ref:`nrfxlib:nrf_modem` buffers and make calls to the Modem library hang. Samples and applications that are affected include those that use :ref:`lib_download_client` to download files through HTTP, or those that use :ref:`lib_fota_download` with modem updates enabled. - **Workaround:** Set :option:`CONFIG_DOWNLOAD_CLIENT_RANGE_REQUESTS`. + **Workaround:** Set :kconfig:`CONFIG_DOWNLOAD_CLIENT_RANGE_REQUESTS`. .. rst-class:: v1-1-0 @@ -934,8 +934,8 @@ Secure Partition Manager (SPM) .. rst-class:: v1-5-1 v1-5-0 -CIA-248: Samples with default SPM config fails to build for ``thingy91_nrf9160ns`` - All samples using the default SPM config fails to build for the ``thingy91_nrf9160ns`` build target if the sample is not set up with MCUboot. +CIA-248: Samples with default SPM config fails to build for ``thingy91_nrf9160_ns`` + All samples using the default SPM config fails to build for the ``thingy91_nrf9160_ns`` build target if the sample is not set up with MCUboot. **Workaround:** Use the master branch. @@ -1021,21 +1021,21 @@ Multiprotocol Service Layer (MPSL) .. rst-class:: v1-6-1 v1-6-0 v1-5-1 v1-5-0 -DRGN-15979: :option:`CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION` must be set when :option:`CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC` is set. +DRGN-15979: :kconfig:`CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION` must be set when :kconfig:`CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC` is set. MPSL requires RC clock calibration to be enabled when the RC clock is used as the Low Frequency clock source. .. rst-class:: v1-5-0 v1-4-2 v1-4-1 DRGN-15223: `CONFIG_SYSTEM_CLOCK_NO_WAIT` is not supported for nRF5340 - Using :option:`CONFIG_SYSTEM_CLOCK_NO_WAIT` with nRF5340 devices might not work as expected. + Using :kconfig:`CONFIG_SYSTEM_CLOCK_NO_WAIT` with nRF5340 devices might not work as expected. .. rst-class:: v1-4-2 v1-4-1 DRGN-15176: `CONFIG_SYSTEM_CLOCK_NO_WAIT` is ignored when Low Frequency Clock is started before initializing MPSL - If the application starts the Low Frequency Clock before calling :c:func:`mpsl_init()`, the clock configuration option :option:`CONFIG_SYSTEM_CLOCK_NO_WAIT` has no effect. + If the application starts the Low Frequency Clock before calling :c:func:`mpsl_init()`, the clock configuration option :kconfig:`CONFIG_SYSTEM_CLOCK_NO_WAIT` has no effect. MPSL will wait for the Low Frequency Clock to start. - **Workaround:** When :option:`CONFIG_SYSTEM_CLOCK_NO_WAIT` is set, do not start the Low Frequency Clock. + **Workaround:** When :kconfig:`CONFIG_SYSTEM_CLOCK_NO_WAIT` is set, do not start the Low Frequency Clock. .. rst-class:: v1-4-0 v1-3-2 v1-3-1 v1-3-0 @@ -1094,10 +1094,10 @@ SoftDevice Controller DRGN-15852: In rare cases on nRF53 Series devices, an assert can occur while scanning This only occurs when the host started scanning using HCI LE Set Scan Enable. - This is default configuration of the Bluetooth host. + This is default configuration of the Bluetooth® host. **Workaround:** Use extended scanning commands. - That is, set :option:`CONFIG_BT_EXT_ADV` to use HCI LE Set Extended Scan Enable instead. + That is, set :kconfig:`CONFIG_BT_EXT_ADV` to use HCI LE Set Extended Scan Enable instead. .. rst-class:: v1-6-0 v1-5-0 v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 v1-2-1 v1-2-0 @@ -1125,8 +1125,8 @@ DRGN-15547: Assertion when updating PHY and the event length is configured too l * :c:union:`sdc_cfg_t` with :c:member:`event_length` is set to less than 2500 us and the PHY is updated from 2M to 1M, or from either 1M or 2M to Coded PHY. * :c:union:`sdc_cfg_t` with :c:member:`event_length` is set to less than 7500 us and a PHY update to Coded PHY is performed. - | The default value of :option:`CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT` is 7500 us. - | The minimum event length supported by :option:`CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT` is 2500 us. + | The default value of :kconfig:`CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT` is 7500 us. + | The minimum event length supported by :kconfig:`CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT` is 2500 us. **Workaround:** * Set :c:union:`sdc_cfg_t` with :c:member:`event_length` to at least 2500 us if the application is using 1M PHY. @@ -1189,7 +1189,7 @@ DRGN-15251: Very rare assertion fault when connected as peripheral on Coded PHY * The devices have performed a data length update, and the supported values are above the minimum specification defined values. * A packet is received with a CRC error. - **Workaround:** Do not enable :option:`CONFIG_BT_DATA_LEN_UPDATE` for applications that require Coded PHY as a peripheral device. + **Workaround:** Do not enable :kconfig:`CONFIG_BT_DATA_LEN_UPDATE` for applications that require Coded PHY as a peripheral device. .. rst-class:: v1-5-0 v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 v1-2-1 v1-2-0 v1-1-0 @@ -1198,7 +1198,7 @@ DRGN-15310: HCI Read RSSI fails .. rst-class:: v1-5-0 -DRGN-15465: Corrupted advertising data when :option:`CONFIG_BT_EXT_ADV` is set +DRGN-15465: Corrupted advertising data when :kconfig:`CONFIG_BT_EXT_ADV` is set Setting scan response data for a legacy advertiser on a build with extended advertising support corrupts parts of the advertising data. When using ``BT_LE_ADV_OPT_USE_NAME`` (which is the default configuration in most samples), the device name is put in the scan response. This corrupts the advertising data. @@ -1213,7 +1213,7 @@ DRGN-15475: Samples might not initialize the SoftDevice Controller HCI driver co Samples using both the advertising and the scanning state, but not the connected state, fail to initialize the SoftDevice Controller HCI driver. As a result, the function :c:func:`bt_enable()` returns an error code. - **Workaround:** Manually enable :option:`CONFIG_SOFTDEVICE_CONTROLLER_MULTIROLE` for the project configuration. + **Workaround:** Manually enable :kconfig:`CONFIG_SOFTDEVICE_CONTROLLER_MULTIROLE` for the project configuration. .. rst-class:: v1-5-0 @@ -1237,7 +1237,7 @@ DRGN-15291: The generation of QoS Connection events is not disabled after an HCI DRGN-15226: Link disconnects with reason "LMP Response Timeout (0x22)" If the slave receives an encryption request while the "HCI LE Long Term Key Request" event is disabled, the link disconnects with the reason "LMP Response Timeout (0x22)". - The event is disabled when :option:`CONFIG_BT_SMP` and/or :option:`CONFIG_BT_CTLR_LE_ENC` is disabled. + The event is disabled when :kconfig:`CONFIG_BT_SMP` and/or :kconfig:`CONFIG_BT_CTLR_LE_ENC` is disabled. .. rst-class:: v1-4-2 v1-4-1 v1-4-0 v1-3-2 v1-3-1 v1-3-0 v1-2-1 v1-2-0 v1-1-0 @@ -1288,18 +1288,18 @@ DRGN-13079: An assert occurs when setting a secondary PHY to 0 when using HCI LE .. rst-class:: v1-1-0 -:option:`CONFIG_BT_HCI_TX_STACK_SIZE` requires specific value - :option:`CONFIG_BT_HCI_TX_STACK_SIZE` must be set to 1536 when selecting :option:`CONFIG_BT_LL_SOFTDEVICE`. +:kconfig:`CONFIG_BT_HCI_TX_STACK_SIZE` requires specific value + :kconfig:`CONFIG_BT_HCI_TX_STACK_SIZE` must be set to 1536 when selecting :kconfig:`CONFIG_BT_LL_SOFTDEVICE`. .. rst-class:: v1-1-0 -:option:`CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE` requires specific value - :option:`CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE` must be set to 2048 when selecting :option:`CONFIG_BT_LL_SOFTDEVICE` on :ref:`central_uart` and :ref:`central_bas`. +:kconfig:`CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE` requires specific value + :kconfig:`CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE` must be set to 2048 when selecting :kconfig:`CONFIG_BT_LL_SOFTDEVICE` on :ref:`central_uart` and :ref:`central_bas`. .. rst-class:: v1-1-0 -:option:`CONFIG_NFCT_IRQ_PRIORITY` requires specific value - :option:`CONFIG_NFCT_IRQ_PRIORITY` must be set to 5 or less when selecting :option:`CONFIG_BT_LL_SOFTDEVICE` on :ref:`peripheral_hids_keyboard`. +:kconfig:`CONFIG_NFCT_IRQ_PRIORITY` requires specific value + :kconfig:`CONFIG_NFCT_IRQ_PRIORITY` must be set to 5 or less when selecting :kconfig:`CONFIG_BT_LL_SOFTDEVICE` on :ref:`peripheral_hids_keyboard`. .. rst-class:: v1-1-0 @@ -1439,7 +1439,7 @@ NCSDK-6832: SMP Server sample fails upon initialization The :ref:`zephyr:smp_svr_sample` will fail upon initialization when using the :file:`bt-overlay.conf` Kconfig overlay file. This happens because of a stack overflow. - **Workaround:** Set :option:`CONFIG_MAIN_STACK_SIZE` to ``2048``. + **Workaround:** Set :kconfig:`CONFIG_MAIN_STACK_SIZE` to ``2048``. SEGGER Embedded Studio Nordic Edition ************************************* diff --git a/doc/nrf/libraries/lib_bin.rst b/doc/nrf/libraries/bin/index.rst similarity index 84% rename from doc/nrf/libraries/lib_bin.rst rename to doc/nrf/libraries/bin/index.rst index 841c0792ef6d..2b3c8fec0deb 100644 --- a/doc/nrf/libraries/lib_bin.rst +++ b/doc/nrf/libraries/bin/index.rst @@ -8,4 +8,4 @@ Binary libraries :glob: :caption: Subpages: - ../../lib/bin/*/* + */index diff --git a/lib/bin/lwm2m_carrier/doc/CHANGELOG.rst b/doc/nrf/libraries/bin/lwm2m_carrier/CHANGELOG.rst similarity index 97% rename from lib/bin/lwm2m_carrier/doc/CHANGELOG.rst rename to doc/nrf/libraries/bin/lwm2m_carrier/CHANGELOG.rst index cc8209a7effc..1d646e469662 100644 --- a/lib/bin/lwm2m_carrier/doc/CHANGELOG.rst +++ b/doc/nrf/libraries/bin/lwm2m_carrier/CHANGELOG.rst @@ -44,8 +44,8 @@ Changes * Renamed the event :c:macro:`LWM2M_CARRIER_BSDLIB_INIT` to :c:macro:`LWM2M_CARRIER_EVENT_MODEM_INIT`. * Added a new error code :c:macro:`LWM2M_CARRIER_ERROR_SERVICE_UNAVAILABLE` which indicates that the LwM2M server is unavailable due to maintenance. * Added a new error code :c:macro:`LWM2M_CARRIER_ERROR_CONFIGURATION` which indicates that an illegal object configuration was detected. -* Added new Kconfig options :c:option:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_APN` and :c:option:`CONFIG_LWM2M_CARRIER_CUSTOM_APN` to set the ``apn`` member of :c:type:`lwm2m_carrier_config_t`. -* It is now possible to configure a custom bootstrap URI using :c:option:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI` regardless of operator SIM. +* Added new Kconfig options :c:kconfig:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_APN` and :c:kconfig:`CONFIG_LWM2M_CARRIER_CUSTOM_APN` to set the ``apn`` member of :c:type:`lwm2m_carrier_config_t`. +* It is now possible to configure a custom bootstrap URI using :c:kconfig:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI` regardless of operator SIM. liblwm2m_carrier 0.10.2 *********************** diff --git a/lib/bin/lwm2m_carrier/doc/app_integration.rst b/doc/nrf/libraries/bin/lwm2m_carrier/app_integration.rst similarity index 86% rename from lib/bin/lwm2m_carrier/doc/app_integration.rst rename to doc/nrf/libraries/bin/lwm2m_carrier/app_integration.rst index 266fd2548358..86f9c2e4ef97 100644 --- a/lib/bin/lwm2m_carrier/doc/app_integration.rst +++ b/doc/nrf/libraries/bin/lwm2m_carrier/app_integration.rst @@ -35,36 +35,36 @@ It provides an abstraction of the following modules: The OS abstraction layer is fully implemented for the |NCS|, and it would have to be ported if used with other RTOS or on other systems. To run the library in an application, you must implement the application with the API of the library. -You can enable the module using the :option:`CONFIG_LWM2M_CARRIER` Kconfig option. +You can enable the module using the :kconfig:`CONFIG_LWM2M_CARRIER` Kconfig option. The :ref:`lwm2m_carrier` sample project configuration (:file:`nrf/samples/nrf9160/lwm2m_carrier/prj.conf`) contains all the configurations that are needed by the LwM2M carrier library. You can provide the initialization parameter :c:type:`lwm2m_carrier_config_t` to overwrite the carrier default settings with the Kconfig options described below: -* :option:`CONFIG_LWM2M_CARRIER_CERTIFICATION_MODE`: +* :kconfig:`CONFIG_LWM2M_CARRIER_CERTIFICATION_MODE`: * This configuration specifies if the LwM2M carrier library will connect to the carrier's certification servers or production servers. * Expected to be set during self-testing part of the certification process. - * This configuration is ignored if :option:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI` is set. + * This configuration is ignored if :kconfig:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI` is set. -* :option:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI`: +* :kconfig:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI`: - * This configuration, together with :option:`CONFIG_LWM2M_CARRIER_CUSTOM_BOOTSTRAP_URI` lets the LwM2M carrier library connect to a bootstrap server other than the normal carrier server, thereby enabling the generic mode. + * This configuration, together with :kconfig:`CONFIG_LWM2M_CARRIER_CUSTOM_BOOTSTRAP_URI` lets the LwM2M carrier library connect to a bootstrap server other than the normal carrier server, thereby enabling the generic mode. * Expected to be set during self-testing, or if the end product is not to be certified with the applicable carriers. See :ref:`lwm2m_certification`. - * If this configuration is set, :option:`CONFIG_LWM2M_CARRIER_CERTIFICATION_MODE` is ignored. + * If this configuration is set, :kconfig:`CONFIG_LWM2M_CARRIER_CERTIFICATION_MODE` is ignored. -* :option:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_PSK`: +* :kconfig:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_PSK`: - * This configuration, together with :option:`CONFIG_LWM2M_CARRIER_CUSTOM_BOOTSTRAP_PSK` can be set to use a non-default `Pre-Shared Key (PSK)`_. + * This configuration, together with :kconfig:`CONFIG_LWM2M_CARRIER_CUSTOM_BOOTSTRAP_PSK` can be set to use a non-default `Pre-Shared Key (PSK)`_. * If connecting to the normal carrier device management servers (normal operation), this configuration must not be set unless your carrier explicitly states to use a custom PSK, for example during self-testing. - * If the :option:`CONFIG_LWM2M_CARRIER_CUSTOM_BOOTSTRAP_URI` option is set and the server requires a secure connection, a PSK is required. + * If the :kconfig:`CONFIG_LWM2M_CARRIER_CUSTOM_BOOTSTRAP_URI` option is set and the server requires a secure connection, a PSK is required. -* :option:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_APN`: +* :kconfig:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_APN`: - * This configuration, together with :option:`CONFIG_LWM2M_CARRIER_CUSTOM_APN` produce different results depending on normal or generic mode of operation. - * If :option:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI` is not set (normal), this configuration supplies a fallback APN. This might be required in your application, depending on the requirements from the carrier. - * If :option:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI` is set (generic), :option:`CONFIG_LWM2M_CARRIER_CUSTOM_APN` is used instead of the default APN, (and there is no fallback APN). + * This configuration, together with :kconfig:`CONFIG_LWM2M_CARRIER_CUSTOM_APN` produce different results depending on normal or generic mode of operation. + * If :kconfig:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI` is not set (normal), this configuration supplies a fallback APN. This might be required in your application, depending on the requirements from the carrier. + * If :kconfig:`CONFIG_LWM2M_CARRIER_USE_CUSTOM_BOOTSTRAP_URI` is set (generic), :kconfig:`CONFIG_LWM2M_CARRIER_CUSTOM_APN` is used instead of the default APN, (and there is no fallback APN). Note that these settings can put the LwM2M carrier library either in the normal mode where it connects to the applicable carriers, or in the generic mode where it can connect to any bootstrap server. diff --git a/lib/bin/lwm2m_carrier/doc/certification.rst b/doc/nrf/libraries/bin/lwm2m_carrier/certification.rst similarity index 100% rename from lib/bin/lwm2m_carrier/doc/certification.rst rename to doc/nrf/libraries/bin/lwm2m_carrier/certification.rst diff --git a/lib/bin/lwm2m_carrier/lwm2m_carrier.rst b/doc/nrf/libraries/bin/lwm2m_carrier/index.rst similarity index 93% rename from lib/bin/lwm2m_carrier/lwm2m_carrier.rst rename to doc/nrf/libraries/bin/lwm2m_carrier/index.rst index c49bc3876888..16af80b2f79d 100644 --- a/lib/bin/lwm2m_carrier/lwm2m_carrier.rst +++ b/doc/nrf/libraries/bin/lwm2m_carrier/index.rst @@ -26,11 +26,11 @@ The LwM2M carrier library is also used in the :ref:`asset_tracker` application. :maxdepth: 1 :caption: Subpages: - doc/certification - doc/app_integration - doc/requirements - doc/msc - doc/CHANGELOG + certification + app_integration + requirements + msc + CHANGELOG diff --git a/lib/bin/lwm2m_carrier/doc/msc.rst b/doc/nrf/libraries/bin/lwm2m_carrier/msc.rst similarity index 100% rename from lib/bin/lwm2m_carrier/doc/msc.rst rename to doc/nrf/libraries/bin/lwm2m_carrier/msc.rst diff --git a/lib/bin/lwm2m_carrier/doc/requirements.rst b/doc/nrf/libraries/bin/lwm2m_carrier/requirements.rst similarity index 95% rename from lib/bin/lwm2m_carrier/doc/requirements.rst rename to doc/nrf/libraries/bin/lwm2m_carrier/requirements.rst index 7647102b9afe..9f2c35cdcd21 100644 --- a/lib/bin/lwm2m_carrier/doc/requirements.rst +++ b/doc/nrf/libraries/bin/lwm2m_carrier/requirements.rst @@ -17,7 +17,7 @@ Below are some of the requirements and limitations of the application while runn * The application must not use the *NB-IoT* LTE mode. * The LwM2M carrier library is currently only certified for the *LTE-M* LTE mode. - * The :option:`CONFIG_LTE_NETWORK_USE_FALLBACK` must be disabled in your application, as seen in the :ref:`lwm2m_carrier` sample project configuration (:file:`nrf/samples/nrf9160/lwm2m_carrier/prj.conf`). + * The :kconfig:`CONFIG_LTE_NETWORK_USE_FALLBACK` must be disabled in your application, as seen in the :ref:`lwm2m_carrier` sample project configuration (:file:`nrf/samples/nrf9160/lwm2m_carrier/prj.conf`). * The LwM2M carrier library registers to receive several AT event reports using the :ref:`at_cmd_readme` and :ref:`at_notif_readme` libraries. The following notifications must not be deregistered by the application: diff --git a/include/bluetooth/conn_ctx.rst b/doc/nrf/libraries/bluetooth_services/conn_ctx.rst similarity index 89% rename from include/bluetooth/conn_ctx.rst rename to doc/nrf/libraries/bluetooth_services/conn_ctx.rst index b81d68f4b58f..febb8d3346d4 100644 --- a/include/bluetooth/conn_ctx.rst +++ b/doc/nrf/libraries/bluetooth_services/conn_ctx.rst @@ -7,7 +7,7 @@ Bluetooth connection context :local: :depth: 2 -Data related to a Bluetooth connection can be stored in a Bluetooth connection context. +Data related to a Bluetooth® connection can be stored in a Bluetooth® connection context. The Bluetooth connection context library can be used with Bluetooth LE services that require the connection context to support multilink functionality for the GATT server role. Each instance of the library can store the contexts for a configurable number of Bluetooth connections (see :ref:`zephyr:bluetooth_connection_mgmt` in the Zephyr documentation). diff --git a/include/bluetooth/enocean.rst b/doc/nrf/libraries/bluetooth_services/enocean.rst similarity index 85% rename from include/bluetooth/enocean.rst rename to doc/nrf/libraries/bluetooth_services/enocean.rst index 9521cffb3fee..84aeda8642d5 100644 --- a/include/bluetooth/enocean.rst +++ b/doc/nrf/libraries/bluetooth_services/enocean.rst @@ -7,7 +7,7 @@ Bluetooth EnOcean :local: :depth: 2 -The Bluetooth EnOcean library allows passive observation of wall switches and sensors based on Bluetooth LE from `EnOcean`_, such as wall switches based on the Push Button Transmitter module (PTM 215B) and the Easyfit Motion Detector with Illumination (EMDCB) sensor module. +The Bluetooth® EnOcean library allows passive observation of wall switches and sensors based on Bluetooth LE from `EnOcean`_, such as wall switches based on the Push Button Transmitter module (PTM 215B) and the Easyfit Motion Detector with Illumination (EMDCB) sensor module. The library is only capable of observing the output of the devices, and does not send anything back. NFC-based configuration is not supported. @@ -19,7 +19,7 @@ The library supports different types of commissioning for both wall switches and The library supports replay protection based on sequence numbers. Only new, authenticated packets from commissioned devices will go through to the event callbacks. -If the :option:`CONFIG_BT_SETTINGS` subsystem is enabled, the device information of all commissioned devices are stored persistently using the :ref:`zephyr:settings_api` subsystem, including the sequence number information. +If the :kconfig:`CONFIG_BT_SETTINGS` subsystem is enabled, the device information of all commissioned devices are stored persistently using the :ref:`zephyr:settings_api` subsystem, including the sequence number information. For a demonstration of the library features, see the :ref:`enocean_sample` sample. @@ -90,9 +90,9 @@ See the :ref:`enocean_sample` for a demonstration of the handler callback functi Dependencies ************ -The EnOcean library depends on the :option:`CONFIG_BT_OBSERVER` capability in the Bluetooth stack to function. +The EnOcean library depends on the :kconfig:`CONFIG_BT_OBSERVER` capability in the Bluetooth stack to function. -To enable persistent storage of device commissioning data, the :option:`CONFIG_BT_SETTINGS` subsystem must also be enabled. +To enable persistent storage of device commissioning data, the :kconfig:`CONFIG_BT_SETTINGS` subsystem must also be enabled. API documentation ================= diff --git a/include/bluetooth/gatt_dm.rst b/doc/nrf/libraries/bluetooth_services/gatt_dm.rst similarity index 89% rename from include/bluetooth/gatt_dm.rst rename to doc/nrf/libraries/bluetooth_services/gatt_dm.rst index 8d0f135714cf..ced9bd0c1c1e 100644 --- a/include/bluetooth/gatt_dm.rst +++ b/doc/nrf/libraries/bluetooth_services/gatt_dm.rst @@ -10,7 +10,7 @@ GATT Discovery Manager The GATT Discovery Manager handles service discovery on GATT servers. When a client connects to a peer device that has a desired server, service discovery is necessary to ensure that the client interacts with the server's characteristics using the correct attributes handles. -Service discovery is also important because Bluetooth LE advertising does not mandate that all services are advertised. +Service discovery is also important because Bluetooth® LE advertising does not mandate that all services are advertised. To actually know if a service is present on a peer device, you must perform a service discovery. The GATT Discovery Manager simplifies the usage of :ref:`Zephyr `'s :c:func:`bt_gatt_discover` function by processing the data using predefined filters. diff --git a/include/bluetooth/gatt_pool.rst b/doc/nrf/libraries/bluetooth_services/gatt_pool.rst similarity index 96% rename from include/bluetooth/gatt_pool.rst rename to doc/nrf/libraries/bluetooth_services/gatt_pool.rst index 3cba0d3a5f91..0efe1e5f39c4 100644 --- a/include/bluetooth/gatt_pool.rst +++ b/doc/nrf/libraries/bluetooth_services/gatt_pool.rst @@ -21,7 +21,7 @@ The API of the GATT attribute pools module allows to register different types of After each registration, a part of the memory is reserved for each attribute. You can also unregister attributes that are no longer needed by using the module's API. In this case, the previously reserved memory is released. -This can be useful when you want to restructure your service by using the Service Changed feature that is supported by the Zephyr Bluetooth stack (see, for example, the :ref:`hids_readme`). +This can be useful when you want to restructure your service by using the Service Changed feature that is supported by the Zephyr Bluetooth® stack (see, for example, the :ref:`hids_readme`). Additionally, you can adjust the memory footprint of this module to your needs by changing the configuration options for the size of the module's memory pool. If you are unsure about the proper values, print the module's statistics to see how the pool utilization level is affected by the chosen configuration. diff --git a/doc/nrf/libraries/lib_bluetooth_services.rst b/doc/nrf/libraries/bluetooth_services/index.rst similarity index 57% rename from doc/nrf/libraries/lib_bluetooth_services.rst rename to doc/nrf/libraries/bluetooth_services/index.rst index b2b8d0cdf0d4..eec0e296902b 100644 --- a/doc/nrf/libraries/lib_bluetooth_services.rst +++ b/doc/nrf/libraries/bluetooth_services/index.rst @@ -5,15 +5,15 @@ Bluetooth libraries and services .. toctree:: :maxdepth: 1 - :caption: Bluetooth libraries: + :caption: Bluetooth® libraries: :glob: - ../../include/bluetooth/* + * .. toctree:: :maxdepth: 1 - :caption: Bluetooth services: + :caption: Bluetooth® services: :glob: - ../../include/bluetooth/services/* + services/* diff --git a/include/bluetooth/mesh.rst b/doc/nrf/libraries/bluetooth_services/mesh.rst similarity index 90% rename from include/bluetooth/mesh.rst rename to doc/nrf/libraries/bluetooth_services/mesh.rst index ce2ac3031dfa..89a2f649be6a 100644 --- a/include/bluetooth/mesh.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh.rst @@ -3,10 +3,10 @@ Bluetooth mesh profile ###################### -Bluetooth mesh is supported for development in |NCS|, through the Zephyr :ref:`zephyr:bluetooth_mesh` implementation. +Bluetooth® mesh is supported for development in |NCS|, through the Zephyr :ref:`zephyr:bluetooth_mesh` implementation. Nordic Semiconductor's implementation of the Bluetooth mesh allows applications to use the features provided by the Bluetooth mesh when running on supported Nordic devices. -The `Bluetooth mesh profile specification`_ is developed and published by the Bluetooth SIG. +The `Bluetooth mesh profile specification`_ is developed and published by the Bluetooth® Special Interest Group (SIG). It's a solution that allows one-to-one, one-to-many, and many-to-many communication, using the Bluetooth Low Energy protocol to exchange messages between the nodes in the network. The nodes can communicate with each other as long as they are in direct radio range of each other, or there are enough devices available that are capable of listening and forwarding these messages. See the :ref:`Bluetooth mesh user guide ` for an overview of the technology, like supported features, concepts and architecture. diff --git a/include/bluetooth/mesh/dk_prov.rst b/doc/nrf/libraries/bluetooth_services/mesh/dk_prov.rst similarity index 85% rename from include/bluetooth/mesh/dk_prov.rst rename to doc/nrf/libraries/bluetooth_services/mesh/dk_prov.rst index 56dc143acefc..281431a3338b 100644 --- a/include/bluetooth/mesh/dk_prov.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/dk_prov.rst @@ -9,10 +9,10 @@ Bluetooth mesh provisioning handler for Nordic DKs This application-side module is a basic implementation of the provisioning process handling for Development Kits from Nordic Semiconductor. It supports four types of out-of-band (OOB) authentication methods and uses the Hardware Information driver to generate a deterministic UUID to uniquely represent the device. -For more information about provisioning in Bluetooth mesh, see the :ref:`zephyr:bluetooth_mesh_provisioning` page in Zephyr. +For more information about provisioning in Bluetooth® mesh, see the :ref:`zephyr:bluetooth_mesh_provisioning` page in Zephyr. Used primarily in :ref:`Bluetooth mesh sample applications `, this handler acts as a reference implementation for the application-specific part of provisioning. -It is enabled with the :option:`CONFIG_BT_MESH_DK_PROV` option and by calling :c:func:`bt_mesh_dk_prov_init` in main. +It is enabled with the :kconfig:`CONFIG_BT_MESH_DK_PROV` option and by calling :c:func:`bt_mesh_dk_prov_init` in main. The handling of the OOB authentication methods is closely tied to the hardware parameters of the Development Kits from Nordic Semiconductor. For deployments with custom hardware, do not extend this module. @@ -28,27 +28,27 @@ Output: Display number If selected, the node will print an authentication number in its serial log. Enter this number into the provisioner. - Enabled by :option:`CONFIG_BT_MESH_DK_PROV_OOB_LOG`. + Enabled by :kconfig:`CONFIG_BT_MESH_DK_PROV_OOB_LOG`. Output: Display string The Display string OOB method requires access to the application log through a serial connection. If selected, the node will print an authentication string in its serial log. Enter this number into the provisioner. - Enabled by :option:`CONFIG_BT_MESH_DK_PROV_OOB_LOG`. + Enabled by :kconfig:`CONFIG_BT_MESH_DK_PROV_OOB_LOG`. Output: Blink The Blink OOB method blinks the LEDs a certain number of times. Enter the number of blinks into the provisioner. The blinks occur at a frequency of two blinks per second, and the sequence is repeated every three seconds. - Enabled by :option:`CONFIG_BT_MESH_DK_PROV_OOB_BLINK`. + Enabled by :kconfig:`CONFIG_BT_MESH_DK_PROV_OOB_BLINK`. Input: Push button The Push button OOB method requires the user to press a button the number of times specified by the provisioner. After three seconds of inactivity, the button count is sent to the provisioner. - Enabled by :option:`CONFIG_BT_MESH_DK_PROV_OOB_BUTTON`. + Enabled by :kconfig:`CONFIG_BT_MESH_DK_PROV_OOB_BUTTON`. .. note:: It is also possible for the provisioner to select "No authentication" and skip the OOB authentication. diff --git a/include/bluetooth/mesh/gen_battery.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_battery.rst similarity index 100% rename from include/bluetooth/mesh/gen_battery.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_battery.rst diff --git a/include/bluetooth/mesh/gen_battery_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_battery_cli.rst similarity index 100% rename from include/bluetooth/mesh/gen_battery_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_battery_cli.rst diff --git a/include/bluetooth/mesh/gen_battery_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_battery_srv.rst similarity index 100% rename from include/bluetooth/mesh/gen_battery_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_battery_srv.rst diff --git a/include/bluetooth/mesh/gen_dtt.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_dtt.rst similarity index 100% rename from include/bluetooth/mesh/gen_dtt.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_dtt.rst diff --git a/include/bluetooth/mesh/gen_dtt_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_dtt_cli.rst similarity index 100% rename from include/bluetooth/mesh/gen_dtt_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_dtt_cli.rst diff --git a/include/bluetooth/mesh/gen_dtt_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_dtt_srv.rst similarity index 87% rename from include/bluetooth/mesh/gen_dtt_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_dtt_srv.rst index 6cc965edcc4c..87b0c9165b1b 100644 --- a/include/bluetooth/mesh/gen_dtt_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/gen_dtt_srv.rst @@ -16,10 +16,10 @@ Configuration The following configuration parameters are associated with the Generic DTT Server model: -* :option:`CONFIG_BT_MESH_DTT_SRV_PERSISTENT` - Control whether changes to the Generic Default Transition Time are stored persistently. +* :kconfig:`CONFIG_BT_MESH_DTT_SRV_PERSISTENT` - Control whether changes to the Generic Default Transition Time are stored persistently. .. note:: - This option is only available if :option:`CONFIG_BT_SETTINGS` is enabled. + This option is only available if :kconfig:`CONFIG_BT_SETTINGS` is enabled. States ====== @@ -58,7 +58,7 @@ None. Persistent storage ================== -The Generic Default Transition Time is stored persistently if :option:`CONFIG_BT_MESH_DTT_SRV_PERSISTENT` is enabled. +The Generic Default Transition Time is stored persistently if :kconfig:`CONFIG_BT_MESH_DTT_SRV_PERSISTENT` is enabled. API documentation ================= diff --git a/include/bluetooth/mesh/gen_loc.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_loc.rst similarity index 100% rename from include/bluetooth/mesh/gen_loc.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_loc.rst diff --git a/include/bluetooth/mesh/gen_loc_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_loc_cli.rst similarity index 100% rename from include/bluetooth/mesh/gen_loc_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_loc_cli.rst diff --git a/include/bluetooth/mesh/gen_loc_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_loc_srv.rst similarity index 100% rename from include/bluetooth/mesh/gen_loc_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_loc_srv.rst diff --git a/include/bluetooth/mesh/gen_lvl.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_lvl.rst similarity index 100% rename from include/bluetooth/mesh/gen_lvl.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_lvl.rst diff --git a/include/bluetooth/mesh/gen_lvl_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_lvl_cli.rst similarity index 100% rename from include/bluetooth/mesh/gen_lvl_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_lvl_cli.rst diff --git a/include/bluetooth/mesh/gen_lvl_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_lvl_srv.rst similarity index 100% rename from include/bluetooth/mesh/gen_lvl_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_lvl_srv.rst diff --git a/include/bluetooth/mesh/gen_onoff.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_onoff.rst similarity index 100% rename from include/bluetooth/mesh/gen_onoff.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_onoff.rst diff --git a/include/bluetooth/mesh/gen_onoff_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_onoff_cli.rst similarity index 100% rename from include/bluetooth/mesh/gen_onoff_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_onoff_cli.rst diff --git a/include/bluetooth/mesh/gen_onoff_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_onoff_srv.rst similarity index 100% rename from include/bluetooth/mesh/gen_onoff_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_onoff_srv.rst diff --git a/include/bluetooth/mesh/gen_plvl.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_plvl.rst similarity index 100% rename from include/bluetooth/mesh/gen_plvl.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_plvl.rst diff --git a/include/bluetooth/mesh/gen_plvl_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_plvl_cli.rst similarity index 100% rename from include/bluetooth/mesh/gen_plvl_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_plvl_cli.rst diff --git a/include/bluetooth/mesh/gen_plvl_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_plvl_srv.rst similarity index 95% rename from include/bluetooth/mesh/gen_plvl_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_plvl_srv.rst index 11a0a8197249..a7723ba27a0f 100644 --- a/include/bluetooth/mesh/gen_plvl_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/gen_plvl_srv.rst @@ -85,8 +85,8 @@ Persistent storage The Generic Power Level Server stores any changes to the Default Power and Power Range states, as well as the last known non-zero Generic Power Level and whether the Generic Power Level is on or off. This information is used to reestablish the correct Generic Power Level when the device powers up. -If :option:`CONFIG_BT_SETTINGS` is enabled, the Generic Power Level Server stores all its states persistently using a configurable storage delay to stagger storing. -See :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Generic Power Level Server stores all its states persistently using a configurable storage delay to stagger storing. +See :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. API documentation ================== diff --git a/include/bluetooth/mesh/gen_ponoff.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_ponoff.rst similarity index 100% rename from include/bluetooth/mesh/gen_ponoff.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_ponoff.rst diff --git a/include/bluetooth/mesh/gen_ponoff_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_ponoff_cli.rst similarity index 100% rename from include/bluetooth/mesh/gen_ponoff_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_ponoff_cli.rst diff --git a/include/bluetooth/mesh/gen_ponoff_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_ponoff_srv.rst similarity index 86% rename from include/bluetooth/mesh/gen_ponoff_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_ponoff_srv.rst index 001d09c5da5e..cfcaccb182f2 100644 --- a/include/bluetooth/mesh/gen_ponoff_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/gen_ponoff_srv.rst @@ -25,8 +25,8 @@ Configuration The following configuration parameters are associated with the Generic Power OnOff Server model: -* :option:`CONFIG_BT_SETTINGS` - The server requires this option to be enabled to work properly. - Unless :option:`CONFIG_BT_SETTINGS` is explicitly disabled, including the Generic Power OnOff Server will enable :option:`CONFIG_BT_SETTINGS`. +* :kconfig:`CONFIG_BT_SETTINGS` - The server requires this option to be enabled to work properly. + Unless :kconfig:`CONFIG_BT_SETTINGS` is explicitly disabled, including the Generic Power OnOff Server will enable :kconfig:`CONFIG_BT_SETTINGS`. States ====== @@ -61,8 +61,8 @@ Persistent storage The Generic On Power Up state is stored persistently, along with the current Generic OnOff state of the extended :ref:`bt_mesh_onoff_srv_readme`. -If :option:`CONFIG_BT_SETTINGS` is enabled, the Generic Power OnOff Server stores all its states persistently using a configurable storage delay to stagger storing. -See :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Generic Power OnOff Server stores all its states persistently using a configurable storage delay to stagger storing. +See :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. API documentation ================= diff --git a/include/bluetooth/mesh/gen_prop.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_prop.rst similarity index 79% rename from include/bluetooth/mesh/gen_prop.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_prop.rst index 5d31fc694b34..87ad32bbc982 100644 --- a/include/bluetooth/mesh/gen_prop.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/gen_prop.rst @@ -15,8 +15,8 @@ For types common to all models, see :ref:`bt_mesh_models`. The following configuration parameters are associated with the Generic Property models: -* :option:`CONFIG_BT_MESH_PROP_MAXSIZE` - The largest available property value. -* :option:`CONFIG_BT_MESH_PROP_MAXCOUNT` - The largest number of properties available on a single Generic Property Server. +* :kconfig:`CONFIG_BT_MESH_PROP_MAXSIZE` - The largest available property value. +* :kconfig:`CONFIG_BT_MESH_PROP_MAXCOUNT` - The largest number of properties available on a single Generic Property Server. .. toctree:: :maxdepth: 1 diff --git a/include/bluetooth/mesh/gen_prop_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_prop_cli.rst similarity index 100% rename from include/bluetooth/mesh/gen_prop_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_prop_cli.rst diff --git a/include/bluetooth/mesh/gen_prop_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/gen_prop_srv.rst similarity index 88% rename from include/bluetooth/mesh/gen_prop_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/gen_prop_srv.rst index 6a8798228383..bf1f77c04a28 100644 --- a/include/bluetooth/mesh/gen_prop_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/gen_prop_srv.rst @@ -52,7 +52,7 @@ Extended models Generic Admin Property Server and Generic Manufacturer Property Server should both extend the Generic User Property Server. This is not handled automatically by the model implementation. -For this reason, to ensure compliance with the Bluetooth mesh model specification, a Generic User Property Server must be instantiated in the same element in the device composition data as the Generic Admin or Generic Manufacturer Property Server. +For this reason, to ensure compliance with the Bluetooth® mesh model specification, a Generic User Property Server must be instantiated in the same element in the device composition data as the Generic Admin or Generic Manufacturer Property Server. Persistent storage ================== @@ -60,8 +60,8 @@ Persistent storage The Generic Manufacturer Property Server and Generic Admin Property Server models will store changes to the user access rights of their properties. Any permanent changes to the property values themselves should be stored manually by the application. -If :option:`CONFIG_BT_SETTINGS` is enabled, the Generic Admin Property Server stores all its states persistently using a configurable storage delay to stagger storing. -See :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Generic Admin Property Server stores all its states persistently using a configurable storage delay to stagger storing. +See :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. API documentation ================= diff --git a/doc/nrf/images/CIExy1931.png b/doc/nrf/libraries/bluetooth_services/mesh/images/CIExy1931.png similarity index 100% rename from doc/nrf/images/CIExy1931.png rename to doc/nrf/libraries/bluetooth_services/mesh/images/CIExy1931.png diff --git a/doc/nrf/images/bt_mesh_light_ctrl_composition.svg b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_composition.svg similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_composition.svg rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_composition.svg diff --git a/doc/nrf/images/bt_mesh_light_ctrl_composition.vsdx b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_composition.vsdx similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_composition.vsdx rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_composition.vsdx diff --git a/doc/nrf/images/bt_mesh_light_ctrl_levels.svg b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_levels.svg similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_levels.svg rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_levels.svg diff --git a/doc/nrf/images/bt_mesh_light_ctrl_levels.vsdx b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_levels.vsdx similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_levels.vsdx rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_levels.vsdx diff --git a/doc/nrf/images/bt_mesh_light_ctrl_nodes.svg b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_nodes.svg similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_nodes.svg rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_nodes.svg diff --git a/doc/nrf/images/bt_mesh_light_ctrl_nodes.vsdx b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_nodes.vsdx similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_nodes.vsdx rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_nodes.vsdx diff --git a/doc/nrf/images/bt_mesh_light_ctrl_reg.svg b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_reg.svg similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_reg.svg rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_reg.svg diff --git a/doc/nrf/images/bt_mesh_light_ctrl_reg.vsdx b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_reg.vsdx similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_reg.vsdx rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_reg.vsdx diff --git a/doc/nrf/images/bt_mesh_light_ctrl_states.svg b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_states.svg similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_states.svg rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_states.svg diff --git a/doc/nrf/images/bt_mesh_light_ctrl_states.vsdx b/doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_states.vsdx similarity index 100% rename from doc/nrf/images/bt_mesh_light_ctrl_states.vsdx rename to doc/nrf/libraries/bluetooth_services/mesh/images/bt_mesh_light_ctrl_states.vsdx diff --git a/include/bluetooth/mesh/light_ctl.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_ctl.rst similarity index 100% rename from include/bluetooth/mesh/light_ctl.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_ctl.rst diff --git a/include/bluetooth/mesh/light_ctl_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_ctl_cli.rst similarity index 100% rename from include/bluetooth/mesh/light_ctl_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_ctl_cli.rst diff --git a/include/bluetooth/mesh/light_ctl_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_ctl_srv.rst similarity index 98% rename from include/bluetooth/mesh/light_ctl_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_ctl_srv.rst index 522f18d7c801..629489c61ed7 100644 --- a/include/bluetooth/mesh/light_ctl_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/light_ctl_srv.rst @@ -51,7 +51,7 @@ The Lightness and Light Temperature Server callbacks will pass pointers to :c:me .. note:: The Light CTL Server will verify that its internal Light Temperature Server is instantiated on a subsequent element on startup. - If the Light Temperature Server is missing or instantiated on the same or a preceding element, the Bluetooth mesh startup procedure will fail, and the device will not be responsive. + If the Light Temperature Server is missing or instantiated on the same or a preceding element, the Bluetooth® mesh startup procedure will fail, and the device will not be responsive. States ====== diff --git a/include/bluetooth/mesh/light_ctrl.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_ctrl.rst similarity index 100% rename from include/bluetooth/mesh/light_ctrl.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_ctrl.rst diff --git a/include/bluetooth/mesh/light_ctrl_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_ctrl_cli.rst similarity index 100% rename from include/bluetooth/mesh/light_ctrl_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_ctrl_cli.rst diff --git a/include/bluetooth/mesh/light_ctrl_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_ctrl_srv.rst similarity index 91% rename from include/bluetooth/mesh/light_ctrl_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_ctrl_srv.rst index dc642b7be8d3..207fd5477004 100644 --- a/include/bluetooth/mesh/light_ctrl_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/light_ctrl_srv.rst @@ -38,7 +38,7 @@ As both the Light LC Server and the Light Lightness Server extend the Generic On .. note:: Due to implementation limitations, the Light LC Server is instantiated on the next element after the Light Lightness Server it is controlling. -.. figure:: /images/bt_mesh_light_ctrl_composition.svg +.. figure:: images/bt_mesh_light_ctrl_composition.svg :alt: Light Lightness Control Server composition data structure Light Lightness Control Server composition data structure @@ -65,7 +65,7 @@ Relationship with other nodes When the Light LC Server model controls a Light Lightness Server, all nodes should publish to the LC Server or its extended Generic OnOff model, instead of publishing directly to the Light Lightness Server: -.. figure:: /images/bt_mesh_light_ctrl_nodes.svg +.. figure:: images/bt_mesh_light_ctrl_nodes.svg :alt: Light Lightness Control Server node organization The dimmer devices that want to override the light level of the Lightness Server can publish directly to the Lightness Server. @@ -93,7 +93,7 @@ When the state changes, the light level fades from the previous state's level to When the Light LC Server is turned on, the following sequence takes place: -.. figure:: /images/bt_mesh_light_ctrl_levels.svg +.. figure:: images/bt_mesh_light_ctrl_levels.svg :alt: Light Lightness Control Server light levels Light Lightness Control Server light levels @@ -114,7 +114,7 @@ The On and Prolong states will start a timer as soon as the transition into the When this timer expires, the state machine will automatically go into the next state. If the On event is triggered while in the On state, the timer is reset, and the transition to the Prolong state is postponed. -.. figure:: /images/bt_mesh_light_ctrl_states.svg +.. figure:: images/bt_mesh_light_ctrl_states.svg :alt: Light Lightness Control Server state machine Light Lightness Control Server state machine @@ -129,10 +129,10 @@ Whenever something but the Light LC Server interacts with the controlled Lightne To resume the state machine operation, the Light LC Server must be explicitly re-enabled. To avoid having a Lightness Server running independently forever, the Light LC Server implements a resume timer that lets the Light LC Server regain control after being disabled for a certain number of seconds. -The resume timer can be configured with the :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_RESUME_DELAY` option, and is disabled by default. +The resume timer can be configured with the :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_RESUME_DELAY` option, and is disabled by default. .. note:: - The resume timer does not exist in the Bluetooth mesh specification, and may become incompatible with future specification changes. + The resume timer does not exist in the Bluetooth® mesh specification, and may become incompatible with future specification changes. Although it does not break the specification or qualification tests in the current iteration of the Bluetooth mesh specification, its behavior may be unexpected for third party devices, and should be used with caution. State machine outputs @@ -203,7 +203,7 @@ Off event The Off event can only be generated by a light switch being turned off. It moves the Light LC Server into Standby, transitioning from the previous light level with the manual mode Standby fade time (:c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_TIME_FADE_STANDBY_MANUAL`). -The Off event puts the Light LC Server into manual mode, which disables sensor input until the manual mode timeout (:option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_MANUAL`) expires. +The Off event puts the Light LC Server into manual mode, which disables sensor input until the manual mode timeout (:kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_MANUAL`) expires. This prevents the lights from turning back on by the movement of the person that presses the light switch. .. note:: @@ -231,35 +231,35 @@ Timing parameters This section lists compile and runtime options to be used when setting timing parameters. Delay from occupancy detected until light turns on - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_OCCUPANCY_DELAY` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_OCCUPANCY_DELAY` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_TIME_OCCUPANCY_DELAY` Transition time to On state - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_ON` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_ON` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_TIME_FADE_ON` Time in On state - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_ON` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_ON` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_TIME_ON` Transition time to Prolong state - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_PROLONG` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_PROLONG` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_TIME_FADE_PROLONG` Time in Prolong state - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_PROLONG` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_PROLONG` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_TIME_PROLONG` Transition time to Standby state (in auto mode) - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_STANDBY_AUTO` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_STANDBY_AUTO` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_TIME_FADE_STANDBY_AUTO` Transition time to Standby state (in manual mode) - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_STANDBY_MANUAL` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_STANDBY_MANUAL` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_TIME_FADE_STANDBY_MANUAL` Manual mode timeout - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_MANUAL` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_MANUAL` * No runtime option available. Output parameters @@ -268,27 +268,27 @@ Output parameters This section lists compile and runtime options to be used when setting output parameters. On state light level - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_ON` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_ON` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_LIGHTNESS_ON` Prolong state light level - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_LIGHTNESS_PROLONG` Standby state light level - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_STANDBY` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_STANDBY` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_LIGHTNESS_STANDBY` On state target illuminance - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_LUX_ON` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_LUX_ON` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_ILLUMINANCE_ON` Prolong state target illuminance - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_LUX_PROLONG` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_LUX_PROLONG` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_ILLUMINANCE_PROLONG` Standby state target illuminance - * Compile time: :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_LUX_STANDBY` + * Compile time: :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_LUX_STANDBY` * Runtime: :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_ILLUMINANCE_STANDBY` @@ -300,7 +300,7 @@ Illuminance regulator The illuminance regulator complements the light level state machine by adding an ambient illuminance sensor feedback loop. This allows the Lightness Server to adjust its output level that is based on the room's ambient light, and as a result conserve energy and achieve more consistent light levels. -.. figure:: /images/bt_mesh_light_ctrl_reg.svg +.. figure:: images/bt_mesh_light_ctrl_reg.svg :alt: Light Lightness Control Server illuminance regulator Light Lightness Control Server illuminance regulator @@ -325,7 +325,7 @@ The error, the regulator coefficients, and the internal sum, are represented as The resulting output level is represented as an unsigned 16-bit integer. To reduce noise, the regulator has a configurable accuracy property, which allows it to ignore errors smaller than the configured accuracy (represented as a percentage of the light level). -See :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_ACCURACY` and :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_REG_ACCURACY` for more information. +See :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_ACCURACY` and :c:enumerator:`BT_MESH_LIGHT_CTRL_PROP_REG_ACCURACY` for more information. Sensor input ------------ @@ -427,8 +427,8 @@ See the :ref:`bt_mesh_light_ctrl_srv_composition` section for details. Persistent Storage ****************** -If :option:`CONFIG_BT_SETTINGS` is enabled, the Light LC Server stores all its states persistently using a configurable storage delay to stagger storing. -See :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Light LC Server stores all its states persistently using a configurable storage delay to stagger storing. +See :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. Changes to the configuration properties are stored and restored on power-up, so the compile time configuration is only valid the first time the device powers up, until the configuration is changed. diff --git a/include/bluetooth/mesh/light_hsl.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_hsl.rst similarity index 94% rename from include/bluetooth/mesh/light_hsl.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_hsl.rst index 1e42291546a1..4d048c166507 100644 --- a/include/bluetooth/mesh/light_hsl.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/light_hsl.rst @@ -13,7 +13,7 @@ While easy to visualize and explain to end users, the HSL does not map well to c The HSL models are best suited for applications where the color of the light is a primary function, such as decorative lighting. For applications where illumination is the primary function of the light, and its color and temperature is secondary, the CTL and xyL models might be better alternatives. -However, neither the Bluetooth mesh model specification nor the nRF Connect SDK put any restrictions on the application areas for the different models. +However, neither the Bluetooth® mesh model specification nor the nRF Connect SDK put any restrictions on the application areas for the different models. Developers may freely use the model best suited for their application. On the light fixture side, the HSL Server models are separated into three independent models: diff --git a/include/bluetooth/mesh/light_hsl_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_hsl_cli.rst similarity index 100% rename from include/bluetooth/mesh/light_hsl_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_hsl_cli.rst diff --git a/include/bluetooth/mesh/light_hsl_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_hsl_srv.rst similarity index 85% rename from include/bluetooth/mesh/light_hsl_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_hsl_srv.rst index aa874b4c87f3..81a33cbd1e49 100644 --- a/include/bluetooth/mesh/light_hsl_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/light_hsl_srv.rst @@ -12,7 +12,7 @@ It should be instantiated in the light fixture node. The Light HSL Server provides functionality for working on the individual hue, saturation and lightness channels in a combined message interface, controlled by a :ref:`bt_mesh_light_hsl_cli_readme`. -The Light HSL Server adds the following new model instances in the composition data, in addition to the extended :ref:`bt_mesh_lightness_srv_readme` model: +The Light HSL Server adds the following new model instances in the composition data: * Light HSL Server * Light HSL Setup Server @@ -24,6 +24,8 @@ This allows for a fine-grained control of the access rights for the Light HSL st * The Light HSL Setup Server provides write access to the corresponding :ref:`bt_mesh_light_hue_srv_readme` and :ref:`bt_mesh_light_sat_srv_readme` models' meta states. This allows the configurator devices to set up the range and the default value for the various HSL states. +The extended :ref:`bt_mesh_lightness_srv_readme` model should be defined and initialized separately, and the pointer to this model should be passed to the Light HSL Server initialization macro. + Model composition ***************** @@ -46,12 +48,17 @@ In the application code, this would look like this: .. code-block:: c + static struct bt_mesh_lightness_srv lightess_srv = + BT_MESH_LIGHTNESS_SRV_INIT(&lightness_cb); + static struct bt_mesh_light_hsl_srv hsl_srv = - BT_MESH_LIGHT_HSL_SRV_INIT(&hue_cb, &sat_cb, &light_cb); + BT_MESH_LIGHT_HSL_SRV_INIT(&lightness_srv, &hue_cb, &sat_cb); static struct bt_mesh_elem elements[] = { BT_MESH_ELEM( - 1, BT_MESH_MODEL_LIST(BT_MESH_MODEL_LIGHT_HSL_SRV(&hsl_srv)), + 1, BT_MESH_MODEL_LIST( + BT_MESH_MODEL_LIGHTNESS_SRV(&lightness_srv), + BT_MESH_MODEL_LIGHT_HSL_SRV(&hsl_srv)), BT_MESH_MODEL_NONE), BT_MESH_ELEM( 2, BT_MESH_MODEL_LIST(BT_MESH_MODEL_LIGHT_HUE_SRV(&hsl_srv.hue)), @@ -64,6 +71,8 @@ In the application code, this would look like this: .. note:: The :c:struct:`bt_mesh_light_hsl_srv` contains the memory for its corresponding Light Hue Server and Light Saturation Server. When instantiating these models in the composition data, the model entries must point to these substructures. + The :c:struct:`bt_mesh_light_hsl_srv` also contains a pointer to the Light Lightness Server model. + Pointer to this model should be passed to the Light HSL Server initialization macro. The Light HSL Server does not contain any states on its own, but instead operates on the underlying Hue, Saturation and Lightness Server model's states. Because of this, the Light HSL Server does not have a message handler structure, but will instead defer its messages to the individual submodels' handler callbacks. diff --git a/include/bluetooth/mesh/light_hue_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_hue_srv.rst similarity index 95% rename from include/bluetooth/mesh/light_hue_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_hue_srv.rst index 92d74932ef26..888fa1da1f46 100644 --- a/include/bluetooth/mesh/light_hue_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/light_hue_srv.rst @@ -71,8 +71,8 @@ The Light Hue Server stores the following information: This information is used to reestablish the correct Hue level when the device powers up. -If :option:`CONFIG_BT_SETTINGS` is enabled, the Light Hue Server stores all its states persistently using a configurable storage delay to stagger storing. -See :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Light Hue Server stores all its states persistently using a configurable storage delay to stagger storing. +See :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. API documentation ****************** diff --git a/include/bluetooth/mesh/light_sat_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_sat_srv.rst similarity index 94% rename from include/bluetooth/mesh/light_sat_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_sat_srv.rst index 9477e0d2c9bc..11832086050d 100644 --- a/include/bluetooth/mesh/light_sat_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/light_sat_srv.rst @@ -64,8 +64,8 @@ The Light Saturation Server stores the following information: This information is used to reestablish the correct Saturation level when the device powers up. -If :option:`CONFIG_BT_SETTINGS` is enabled, the Light Saturation Server stores all its states persistently using a configurable storage delay to stagger storing. -See :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Light Saturation Server stores all its states persistently using a configurable storage delay to stagger storing. +See :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. API documentation ****************** diff --git a/include/bluetooth/mesh/light_temp_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_temp_srv.rst similarity index 100% rename from include/bluetooth/mesh/light_temp_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_temp_srv.rst diff --git a/include/bluetooth/mesh/light_xyl.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_xyl.rst similarity index 97% rename from include/bluetooth/mesh/light_xyl.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_xyl.rst index c32445f647eb..a7faa0a4f6df 100644 --- a/include/bluetooth/mesh/light_xyl.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/light_xyl.rst @@ -12,7 +12,7 @@ The CIE1931 color spaces are the first defined quantitative links between distri The CIE1931 color space chart is utilized by the models to determine the color light emitted by an element. The xyL models allow remote control and configuration of a light device with x and y chromaticity coordinates support in a mesh network. -.. figure:: /images/CIExy1931.png +.. figure:: images/CIExy1931.png :scale: 50 % :alt: CIE1931 color space chromaticity diagram diff --git a/include/bluetooth/mesh/light_xyl_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_xyl_cli.rst similarity index 100% rename from include/bluetooth/mesh/light_xyl_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_xyl_cli.rst diff --git a/include/bluetooth/mesh/light_xyl_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/light_xyl_srv.rst similarity index 96% rename from include/bluetooth/mesh/light_xyl_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/light_xyl_srv.rst index f80de5cf67fd..8fd4cffbd504 100644 --- a/include/bluetooth/mesh/light_xyl_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/light_xyl_srv.rst @@ -110,8 +110,8 @@ In addition, the model takes over the persistent storage responsibility of the : This information is used to reestablish the correct light configuration when the device powers up. -If :option:`CONFIG_BT_SETTINGS` is enabled, the Light xyL Server stores all its states persistently using a configurable storage delay to stagger storing. -See :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Light xyL Server stores all its states persistently using a configurable storage delay to stagger storing. +See :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. API documentation ***************** diff --git a/include/bluetooth/mesh/lightness.rst b/doc/nrf/libraries/bluetooth_services/mesh/lightness.rst similarity index 92% rename from include/bluetooth/mesh/lightness.rst rename to doc/nrf/libraries/bluetooth_services/mesh/lightness.rst index 9fbceec8f712..66abd199d886 100644 --- a/include/bluetooth/mesh/lightness.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/lightness.rst @@ -26,8 +26,8 @@ For types common to all models, see :ref:`bt_mesh_models`. The application can select whether to use the Actual or Linear representation. To do so, use the following options in the API at compile time: -* :option:`CONFIG_BT_MESH_LIGHTNESS_ACTUAL` - Used by default. -* :option:`CONFIG_BT_MESH_LIGHTNESS_LINEAR` +* :kconfig:`CONFIG_BT_MESH_LIGHTNESS_ACTUAL` - Used by default. +* :kconfig:`CONFIG_BT_MESH_LIGHTNESS_LINEAR` Internally, the models will always support both representations, so nodes with different representations can be be used interchangeably. diff --git a/include/bluetooth/mesh/lightness_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/lightness_cli.rst similarity index 100% rename from include/bluetooth/mesh/lightness_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/lightness_cli.rst diff --git a/include/bluetooth/mesh/lightness_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/lightness_srv.rst similarity index 95% rename from include/bluetooth/mesh/lightness_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/lightness_srv.rst index 68816b1b5b9c..d4f3021c5b16 100644 --- a/include/bluetooth/mesh/lightness_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/lightness_srv.rst @@ -100,8 +100,8 @@ The Light Lightness Server stores the following information: This information is used to reestablish the correct Light level when the device powers up. -If :option:`CONFIG_BT_SETTINGS` is enabled, the Light Lightness Server stores all its states persistently using a configurable storage delay to stagger storing. -See :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Light Lightness Server stores all its states persistently using a configurable storage delay to stagger storing. +See :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. API documentation ================== diff --git a/include/bluetooth/mesh/model_types.rst b/doc/nrf/libraries/bluetooth_services/mesh/model_types.rst similarity index 95% rename from include/bluetooth/mesh/model_types.rst rename to doc/nrf/libraries/bluetooth_services/mesh/model_types.rst index 7793ad6bc4eb..b4e749905592 100644 --- a/include/bluetooth/mesh/model_types.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/model_types.rst @@ -7,7 +7,7 @@ Bluetooth mesh models overview :local: :depth: 2 -A Bluetooth mesh model is a standardized component that defines a series of states and related behaviors. +A Bluetooth® mesh model is a standardized component that defines a series of states and related behaviors. Models encapsulate a single feature of a mesh node, and expose this feature to the mesh network. Each mesh-based product implements several models. diff --git a/doc/nrf/libraries/bluetooth_services/mesh/models.rst b/doc/nrf/libraries/bluetooth_services/mesh/models.rst new file mode 100644 index 000000000000..3585df90ae8f --- /dev/null +++ b/doc/nrf/libraries/bluetooth_services/mesh/models.rst @@ -0,0 +1,32 @@ +.. _bt_mesh_models: + +Bluetooth mesh models +##################### + +Nordic Semiconductor provides a variety of model implementations from the `Bluetooth mesh model specification`_ and their API documentation, as well as vendor-specific models. + +For more information about these and other models, see also `Bluetooth mesh model overview`_. + +.. toctree:: + :maxdepth: 1 + :caption: Subpages: + :glob: + + gen_onoff.rst + gen_lvl.rst + gen_dtt.rst + gen_ponoff.rst + gen_plvl.rst + gen_battery.rst + gen_loc.rst + gen_prop.rst + lightness.rst + light_ctrl.rst + light_ctl.rst + light_xyl.rst + light_hsl.rst + sensor_models.rst + time.rst + scene.rst + scheduler.rst + vnd/silvair_enocean_srv.rst diff --git a/include/bluetooth/mesh/properties.rst b/doc/nrf/libraries/bluetooth_services/mesh/properties.rst similarity index 82% rename from include/bluetooth/mesh/properties.rst rename to doc/nrf/libraries/bluetooth_services/mesh/properties.rst index 4843e852fb8e..956b469d7449 100644 --- a/include/bluetooth/mesh/properties.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/properties.rst @@ -7,7 +7,7 @@ Bluetooth mesh properties :local: :depth: 2 -The Bluetooth SIG defines a list of Bluetooth mesh properties in the Bluetooth mesh device properties specification. +The Bluetooth® Special Interest Group (SIG) defines a list of Bluetooth mesh properties in the Bluetooth mesh device properties specification. Each property has an assigned ID and an associated Bluetooth GATT characteristic. The properties all represent values on a format defined by the associated characteristic. diff --git a/include/bluetooth/mesh/scene.rst b/doc/nrf/libraries/bluetooth_services/mesh/scene.rst similarity index 100% rename from include/bluetooth/mesh/scene.rst rename to doc/nrf/libraries/bluetooth_services/mesh/scene.rst diff --git a/include/bluetooth/mesh/scene_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/scene_cli.rst similarity index 100% rename from include/bluetooth/mesh/scene_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/scene_cli.rst diff --git a/include/bluetooth/mesh/scene_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/scene_srv.rst similarity index 98% rename from include/bluetooth/mesh/scene_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/scene_srv.rst index 048217da3218..df02b6d94404 100644 --- a/include/bluetooth/mesh/scene_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/scene_srv.rst @@ -58,7 +58,7 @@ These macros will allocate the structure in flash, and make them known to the Sc For instance, the Generic OnOff Server model defines its scene entry by declaring a :c:type:`bt_mesh_scene_entry` structure with the Generic OnOff Server model ID and a set of callbacks: -.. literalinclude:: ../../../subsys/bluetooth/mesh/gen_onoff_srv.c +.. literalinclude:: ../../../../../subsys/bluetooth/mesh/gen_onoff_srv.c :language: c :start-after: include_startingpoint_scene_srv_rst_1 :end-before: include_endpoint_scene_srv_rst_1 @@ -101,7 +101,7 @@ Current scene: ``uint16_t`` Scene registry: ``uint16_t[]`` The full list of scenes stored by the Scene Server. - The scene registry has a limited number of slots, controlled by :option:`CONFIG_BT_MESH_SCENES_MAX`. + The scene registry has a limited number of slots, controlled by :kconfig:`CONFIG_BT_MESH_SCENES_MAX`. Extended models ================ diff --git a/include/bluetooth/mesh/scheduler.rst b/doc/nrf/libraries/bluetooth_services/mesh/scheduler.rst similarity index 100% rename from include/bluetooth/mesh/scheduler.rst rename to doc/nrf/libraries/bluetooth_services/mesh/scheduler.rst diff --git a/include/bluetooth/mesh/scheduler_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/scheduler_cli.rst similarity index 100% rename from include/bluetooth/mesh/scheduler_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/scheduler_cli.rst diff --git a/include/bluetooth/mesh/scheduler_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/scheduler_srv.rst similarity index 100% rename from include/bluetooth/mesh/scheduler_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/scheduler_srv.rst diff --git a/include/bluetooth/mesh/sensor.rst b/doc/nrf/libraries/bluetooth_services/mesh/sensor.rst similarity index 97% rename from include/bluetooth/mesh/sensor.rst rename to doc/nrf/libraries/bluetooth_services/mesh/sensor.rst index 3af3fa27423b..2689d6e8885d 100644 --- a/include/bluetooth/mesh/sensor.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/sensor.rst @@ -7,7 +7,7 @@ Bluetooth mesh sensors :local: :depth: 2 -The Bluetooth mesh specification provides a common scheme for representing all sensors. +The Bluetooth® mesh specification provides a common scheme for representing all sensors. A single Bluetooth mesh sensor instance represents a single physical sensor, and a mesh device may present any number of sensors to the network through a Sensor Server model. Sensors represent their measurements as a list of sensor channels, as described by the sensor's assigned type. @@ -60,7 +60,7 @@ Each sensor type is assigned its own Device Property ID, as specified in the Blu Like the Device Properties, the Sensor types are connected to a Bluetooth GATT Characteristic, which describes the unit, range, resolution and encoding scheme of the sensor type. .. note:: - The Bluetooth mesh specification only allows sensor types that have a Device Property ID in the Bluetooth mesh device properties specification. + The Bluetooth® mesh specification only allows sensor types that have a Device Property ID in the Bluetooth mesh device properties specification. It's not possible to represent vendor specific sensor values. The sensor types may either be used as the data types of the sensor output values, or as configuration parameters for the sensors. @@ -82,7 +82,7 @@ For sensor values that are represented as whole numbers, the fractional part of Boolean types are inferred only from the integer part of the value (:c:member:`sensor_value.val1`). Every sensor channel has a name and a unit, as listed in the sensor type documentation. -The name and unit are only available if :option:`CONFIG_BT_MESH_SENSOR_LABELS` option is set, and can aid in debugging and presentation of the sensor output. +The name and unit are only available if :kconfig:`CONFIG_BT_MESH_SENSOR_LABELS` option is set, and can aid in debugging and presentation of the sensor output. Both the channel name and unit is also listed in the documentation for each sensor type. Most sensor values are reported as scalars with some scaling factor applied to them during encoding. diff --git a/include/bluetooth/mesh/sensor_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/sensor_cli.rst similarity index 95% rename from include/bluetooth/mesh/sensor_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/sensor_cli.rst index 5c44f199783b..3ebfca132c7d 100644 --- a/include/bluetooth/mesh/sensor_cli.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/sensor_cli.rst @@ -21,7 +21,7 @@ In most cases, the incoming data needs to be interpreted differently based on th When parsing incoming messages, the Sensor Client is required to do a lookup of the sensor type of the data so it can decode it correctly. For this purpose, the :ref:`bt_mesh_sensor_types` module includes the :ref:`list of available sensor types `. -By default, all sensor types are available when the Sensor Client model is compiled in, but this behavior can be overridden to reduce flash consumption by explicitly disabling :option:`CONFIG_BT_MESH_SENSOR_ALL_TYPES`. +By default, all sensor types are available when the Sensor Client model is compiled in, but this behavior can be overridden to reduce flash consumption by explicitly disabling :kconfig:`CONFIG_BT_MESH_SENSOR_ALL_TYPES`. In this case, only the referenced sensor types will be available. .. note:: diff --git a/include/bluetooth/mesh/sensor_models.rst b/doc/nrf/libraries/bluetooth_services/mesh/sensor_models.rst similarity index 100% rename from include/bluetooth/mesh/sensor_models.rst rename to doc/nrf/libraries/bluetooth_services/mesh/sensor_models.rst diff --git a/include/bluetooth/mesh/sensor_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/sensor_srv.rst similarity index 93% rename from include/bluetooth/mesh/sensor_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/sensor_srv.rst index babaa5a28f6e..f7aec9c3e8ca 100644 --- a/include/bluetooth/mesh/sensor_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/sensor_srv.rst @@ -77,8 +77,8 @@ The Sensor Server stores the cadence state of each sensor instance persistently, Any other data is managed by the application and must be stored separately. This applies for example to sensor settings or sample data. -If :option:`CONFIG_BT_SETTINGS` is enabled, the Sensor Server stores all its states persistently using a configurable storage delay to stagger storing. -See :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Sensor Server stores all its states persistently using a configurable storage delay to stagger storing. +See :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`. API documentation ================= diff --git a/include/bluetooth/mesh/sensor_types.rst b/doc/nrf/libraries/bluetooth_services/mesh/sensor_types.rst similarity index 93% rename from include/bluetooth/mesh/sensor_types.rst rename to doc/nrf/libraries/bluetooth_services/mesh/sensor_types.rst index 5674f164e403..51783ff5d931 100644 --- a/include/bluetooth/mesh/sensor_types.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/sensor_types.rst @@ -10,8 +10,8 @@ Bluetooth mesh sensor types All sensor types are collected in :file:`include/bluetooth/mesh/sensor_types.h`, and are divided into the categories listed in the page index. To keep the total flash usage down, the sensor types are only instantiated if they're referenced by the application. -This behavior can be overridden by enabling :option:`CONFIG_BT_MESH_SENSOR_ALL_TYPES`. -Note that if the Sensor Client is enabled, :option:`CONFIG_BT_MESH_SENSOR_ALL_TYPES` is enabled by default. +This behavior can be overridden by enabling :kconfig:`CONFIG_BT_MESH_SENSOR_ALL_TYPES`. +Note that if the Sensor Client is enabled, :kconfig:`CONFIG_BT_MESH_SENSOR_ALL_TYPES` is enabled by default. Sensor types can be forced into the build by the :c:macro:`BT_MESH_SENSOR_TYPE_FORCE` macro. diff --git a/include/bluetooth/mesh/time.rst b/doc/nrf/libraries/bluetooth_services/mesh/time.rst similarity index 100% rename from include/bluetooth/mesh/time.rst rename to doc/nrf/libraries/bluetooth_services/mesh/time.rst diff --git a/include/bluetooth/mesh/time_cli.rst b/doc/nrf/libraries/bluetooth_services/mesh/time_cli.rst similarity index 100% rename from include/bluetooth/mesh/time_cli.rst rename to doc/nrf/libraries/bluetooth_services/mesh/time_cli.rst diff --git a/include/bluetooth/mesh/time_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/time_srv.rst similarity index 95% rename from include/bluetooth/mesh/time_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/time_srv.rst index ab1bda6ea8d2..f097ff00f147 100644 --- a/include/bluetooth/mesh/time_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/time_srv.rst @@ -57,14 +57,14 @@ The Time Server's time synchronization mechanism is not perfect, and every times The clock uncertainty is measured in milliseconds, and can come from various sources, like inaccuracies in the original clock source, internal clock drift or uncertainty in the mesh stack itself. The Time Server inherits the uncertainty of the node it got its Time Status from, and the clock uncertainty of each mesh node increases for every hop the Time Status had to make from the Time Authority. -The expected uncertainty in the mesh stack comes from the fluctuation in time to encrypt a message and broadcast it, and can be configured through the :option:`CONFIG_BT_MESH_TIME_MESH_HOP_UNCERTAINTY`. +The expected uncertainty in the mesh stack comes from the fluctuation in time to encrypt a message and broadcast it, and can be configured through the :kconfig:`CONFIG_BT_MESH_TIME_MESH_HOP_UNCERTAINTY`. In addition to the uncertainty added by the mesh stack itself, the internal clock of each device will increase the uncertainty of the timestamp over time. As crystal hardware is not perfectly accurate, it will gradually drift away from the correct time. The potential range of this clock drift is generally a known property of the onboard hardware, even if the actual drift fluctuates. As it's impossible to measure the actual clock drift at any given moment, the Time Server will instead gradually increase the uncertainty of its timestamp based on the known clock accuracy. -The Time Server's notion of the local clock accuracy can be configured with :option:`CONFIG_BT_MESH_TIME_SRV_CLOCK_ACCURACY`. +The Time Server's notion of the local clock accuracy can be configured with :kconfig:`CONFIG_BT_MESH_TIME_SRV_CLOCK_ACCURACY`. By default, it uses the configured kernel clock control accuracy. Leap seconds and time zones @@ -161,8 +161,8 @@ Configuration The clock uncertainty of the Time Server model can be configured with the following configuration options: -* :option:`CONFIG_BT_MESH_TIME_MESH_HOP_UNCERTAINTY`: The amount of uncertainty introduced in the mesh stack through sending a single message, in milliseconds. -* :option:`CONFIG_BT_MESH_TIME_SRV_CLOCK_ACCURACY`: The largest possible clock drift introduced by the kernel clock's hardware, in parts per million. +* :kconfig:`CONFIG_BT_MESH_TIME_MESH_HOP_UNCERTAINTY`: The amount of uncertainty introduced in the mesh stack through sending a single message, in milliseconds. +* :kconfig:`CONFIG_BT_MESH_TIME_SRV_CLOCK_ACCURACY`: The largest possible clock drift introduced by the kernel clock's hardware, in parts per million. States ====== diff --git a/include/bluetooth/mesh/time_tai.rst b/doc/nrf/libraries/bluetooth_services/mesh/time_tai.rst similarity index 92% rename from include/bluetooth/mesh/time_tai.rst rename to doc/nrf/libraries/bluetooth_services/mesh/time_tai.rst index 16adc0546510..2e6efb4ec019 100644 --- a/include/bluetooth/mesh/time_tai.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/time_tai.rst @@ -18,5 +18,5 @@ This allows applications to calculate the number of seconds between any two TAI To convert to UTC, TAI based applications keep track of the UTC leap seconds separately, as well as the time zone and time zone adjustments. -The Bluetooth mesh Time models share time as a composite state of TAI seconds, 256 subseconds, UTC offset, time zone steps and uncertainty. +The Bluetooth® mesh Time models share time as a composite state of TAI seconds, 256 subseconds, UTC offset, time zone steps and uncertainty. See :cpp:type:`bt_mesh_time_status` for details. diff --git a/include/bluetooth/mesh/vnd/silvair_enocean_srv.rst b/doc/nrf/libraries/bluetooth_services/mesh/vnd/silvair_enocean_srv.rst similarity index 93% rename from include/bluetooth/mesh/vnd/silvair_enocean_srv.rst rename to doc/nrf/libraries/bluetooth_services/mesh/vnd/silvair_enocean_srv.rst index ebb5356ff13d..526e50ed43c0 100644 --- a/include/bluetooth/mesh/vnd/silvair_enocean_srv.rst +++ b/doc/nrf/libraries/bluetooth_services/mesh/vnd/silvair_enocean_srv.rst @@ -11,7 +11,7 @@ The Silvair EnOcean Proxy Server model integrates an EnOcean switch together wit It implements the `Silvair EnOcean Switch Mesh Proxy Server`_ specification. The model initializes the :ref:`bt_enocean_readme` library. -The EnOcean switch can be automatically commissioned if option :option:`CONFIG_BT_MESH_SILVAIR_ENOCEAN_AUTO_COMMISSION` is set. +The EnOcean switch can be automatically commissioned if option :kconfig:`CONFIG_BT_MESH_SILVAIR_ENOCEAN_AUTO_COMMISSION` is set. The Silvair EnOcean Proxy Server uses either one or two elements on a node. Each element handles its own button pair and has its own corresponding :ref:`bt_mesh_onoff_srv_readme` and :ref:`bt_mesh_lvl_srv_readme` models. @@ -55,7 +55,7 @@ None Persistent storage ================== -If :option:`CONFIG_BT_ENOCEAN_STORE` is enabled, the Silvair EnOcean Proxy Server stores the commissioned EnOcean device address. +If :kconfig:`CONFIG_BT_ENOCEAN_STORE` is enabled, the Silvair EnOcean Proxy Server stores the commissioned EnOcean device address. API documentation ================= diff --git a/include/bluetooth/rpc.rst b/doc/nrf/libraries/bluetooth_services/rpc.rst similarity index 54% rename from include/bluetooth/rpc.rst rename to doc/nrf/libraries/bluetooth_services/rpc.rst index 2cbfdd5ad73c..06b102987620 100644 --- a/include/bluetooth/rpc.rst +++ b/doc/nrf/libraries/bluetooth_services/rpc.rst @@ -7,14 +7,14 @@ Bluetooth Low Energy Remote Procedure Call :local: :depth: 2 -The nRF Connect SDK supports Bluetooth Low Energy (LE) stack serialization. +The nRF Connect SDK supports Bluetooth® Low Energy (LE) stack serialization. The full Bluetooth LE stack can run on another device or CPU, such as the nRF5340 DK network core using :ref:`nrfxlib:nrf_rpc`. .. note:: The |NCS| currently supports serialization of the :ref:`zephyr:bt_gap` and the :ref:`zephyr:bluetooth_connection_mgmt` only. - Due to the limited support, a special :option:`CONFIG_SUPPORT_BT_RPC` option was added and it allows enabling the :option:`CONFIG_BT_RPC` option. - Samples using other Bluetooth LE features, such as GATT, are currently not supported and they have the :option:`CONFIG_SUPPORT_BT_RPC` option disabled. - If you want to use the :option:`CONFIG_BT_RPC` option in your application, you must create a Kconfig file with following content: + Due to the limited support, a special :kconfig:`CONFIG_SUPPORT_BT_RPC` option was added and it allows enabling the :kconfig:`CONFIG_BT_RPC` option. + Samples using other Bluetooth LE features, such as GATT, are currently not supported and they have the :kconfig:`CONFIG_SUPPORT_BT_RPC` option disabled. + If you want to use the :kconfig:`CONFIG_BT_RPC` option in your application, you must create a Kconfig file with following content: .. code-block:: none @@ -35,7 +35,7 @@ Application core **************** To use the Bluetooth LE stack through nRF RPC, an additional configuration is needed. -When building samples for the application core, enable the :option:`CONFIG_BT_RPC` to run the Bluetooth LE stack on the network core. +When building samples for the application core, enable the :kconfig:`CONFIG_BT_RPC` to run the Bluetooth LE stack on the network core. This option builds :ref:`ble_rpc_host` automatically as a child image. For more details, see: :ref:`ug_nrf5340_building`. @@ -51,34 +51,34 @@ Requirements Some configuration options related to Bluetooth LE must be the same on the host (network core) and client (application core). Set the following options in the same way for the :ref:`ble_rpc_host` and application core sample: - * :option:`CONFIG_BT_CENTRAL` - * :option:`CONFIG_BT_PERIPHERAL` - * :option:`CONFIG_BT_WHITELIST` - * :option:`CONFIG_BT_USER_PHY_UPDATE` - * :option:`CONFIG_BT_USER_DATA_LEN_UPDATE` - * :option:`CONFIG_BT_PRIVACY` - * :option:`CONFIG_BT_SCAN_WITH_IDENTITY` - * :option:`CONFIG_BT_REMOTE_VERSION` - * :option:`CONFIG_BT_SMP` - * :option:`CONFIG_BT_CONN` - * :option:`CONFIG_BT_REMOTE_INFO` - * :option:`CONFIG_BT_FIXED_PASSKEY` - * :option:`CONFIG_BT_SMP_APP_PAIRING_ACCEPT` - * :option:`CONFIG_BT_EXT_ADV` - * :option:`CONFIG_BT_OBSERVER` - * :option:`CONFIG_BT_ECC` - * :option:`CONFIG_BT_DEVICE_NAME_DYNAMIC` - * :option:`CONFIG_BT_SMP_SC_PAIR_ONLY` - * :option:`CONFIG_BT_PER_ADV` - * :option:`CONFIG_BT_PER_ADV_SYNC` - * :option:`CONFIG_BT_MAX_CONN` - * :option:`CONFIG_BT_ID_MAX` - * :option:`CONFIG_BT_EXT_ADV_MAX_ADV_SET` - * :option:`CONFIG_BT_DEVICE_NAME_MAX` - * :option:`CONFIG_BT_DEVICE_NAME_MAX` - * :option:`CONFIG_BT_PER_ADV_SYNC_MAX` - * :option:`CONFIG_BT_DEVICE_NAME` - * :option:`CONFIG_CBKPROXY_OUT_SLOTS` on one core must be equal to :option:`CONFIG_CBKPROXY_IN_SLOTS` on the other. + * :kconfig:`CONFIG_BT_CENTRAL` + * :kconfig:`CONFIG_BT_PERIPHERAL` + * :kconfig:`CONFIG_BT_WHITELIST` + * :kconfig:`CONFIG_BT_USER_PHY_UPDATE` + * :kconfig:`CONFIG_BT_USER_DATA_LEN_UPDATE` + * :kconfig:`CONFIG_BT_PRIVACY` + * :kconfig:`CONFIG_BT_SCAN_WITH_IDENTITY` + * :kconfig:`CONFIG_BT_REMOTE_VERSION` + * :kconfig:`CONFIG_BT_SMP` + * :kconfig:`CONFIG_BT_CONN` + * :kconfig:`CONFIG_BT_REMOTE_INFO` + * :kconfig:`CONFIG_BT_FIXED_PASSKEY` + * :kconfig:`CONFIG_BT_SMP_APP_PAIRING_ACCEPT` + * :kconfig:`CONFIG_BT_EXT_ADV` + * :kconfig:`CONFIG_BT_OBSERVER` + * :kconfig:`CONFIG_BT_ECC` + * :kconfig:`CONFIG_BT_DEVICE_NAME_DYNAMIC` + * :kconfig:`CONFIG_BT_SMP_SC_PAIR_ONLY` + * :kconfig:`CONFIG_BT_PER_ADV` + * :kconfig:`CONFIG_BT_PER_ADV_SYNC` + * :kconfig:`CONFIG_BT_MAX_CONN` + * :kconfig:`CONFIG_BT_ID_MAX` + * :kconfig:`CONFIG_BT_EXT_ADV_MAX_ADV_SET` + * :kconfig:`CONFIG_BT_DEVICE_NAME_MAX` + * :kconfig:`CONFIG_BT_DEVICE_NAME_MAX` + * :kconfig:`CONFIG_BT_PER_ADV_SYNC_MAX` + * :kconfig:`CONFIG_BT_DEVICE_NAME` + * :kconfig:`CONFIG_CBKPROXY_OUT_SLOTS` on one core must be equal to :kconfig:`CONFIG_CBKPROXY_IN_SLOTS` on the other. To keep all the above configuration options in sync, create an overlay file that is shared between the application and network core. Then, you can invoke build command like this: diff --git a/include/bluetooth/scan.rst b/doc/nrf/libraries/bluetooth_services/scan.rst similarity index 89% rename from include/bluetooth/scan.rst rename to doc/nrf/libraries/bluetooth_services/scan.rst index c5b6e9dcdd4a..8c6ad645b60f 100644 --- a/include/bluetooth/scan.rst +++ b/doc/nrf/libraries/bluetooth_services/scan.rst @@ -7,7 +7,7 @@ Scanning module :local: :depth: 2 -The scanning module handles the Bluetooth Low Energy scanning for your application. +The scanning module handles the Bluetooth® Low Energy scanning for your application. You can use it to find advertising devices and establish connections with them. Using :ref:`filters `, you can narrow down the scan to devices of a specific type. @@ -109,7 +109,7 @@ After a scanning is started by the application, some peripheral devices can disc This might result in a loop of the connection and disconnection events. To avoid this loop, you can enable the connection attempts filter that limits number of the connection attempts. -Use the :option:`CONFIG_BT_SCAN_CONN_ATTEMPTS_FILTER` to enable this filter. +Use the :kconfig:`CONFIG_BT_SCAN_CONN_ATTEMPTS_FILTER` to enable this filter. This filter automatically tracks the connected devices and counts all disconnection events for them. If the disconnection count is greater than or equal to the number of allowed attempts, the scanning module ignores this device. @@ -119,17 +119,17 @@ It is recommended to use :cpp:func:`bt_scan_conn_attempts_filter_clear` before e If the filter array is full, the scanning module overwrites the oldest device with the new one. In the default configuration, the filter allows to add two devices and limits the connection tries to two. -You can increase the device number by setting the configuration option :option:`CONFIG_BT_SCAN_CONN_ATTEMPTS_FILTER_LEN`. -The option :option:`CONFIG_BT_SCAN_CONN_ATTEMPTS_COUNT` is responsible for the number of connection attempts. +You can increase the device number by setting the configuration option :kconfig:`CONFIG_BT_SCAN_CONN_ATTEMPTS_FILTER_LEN`. +The option :kconfig:`CONFIG_BT_SCAN_CONN_ATTEMPTS_COUNT` is responsible for the number of connection attempts. Blocklist ========= Devices can be added to the blocklist, which means that the scanning module ignores these devices and does not generate any events for them. -Use the option :option:`CONFIG_BT_SCAN_BLOCKLIST` to enable the blocklist. +Use the option :kconfig:`CONFIG_BT_SCAN_BLOCKLIST` to enable the blocklist. In the default configuration, the scanning module allows to add up to two devices to the blocklist. -You can increase the blocklist size by setting the option :option:`CONFIG_BT_SCAN_BLOCKLIST_LEN`. +You can increase the blocklist size by setting the option :kconfig:`CONFIG_BT_SCAN_BLOCKLIST_LEN`. Use the :cpp:func:`bt_scan_blocklist_device_add` function to add a new device to the blocklist. To remove all devices from the blocklist, use :cpp:func:`bt_scan_blocklist_clear`. @@ -141,11 +141,11 @@ Directed Advertising To receive directed advertising packets using the Scanning Module, enable one of the following options in Zephyr: -* :option:`CONFIG_BT_PRIVACY` - Scan with changing addresses -* :option:`CONFIG_BT_SCAN_WITH_IDENTITY` - Scan with a local identity address +* :kconfig:`CONFIG_BT_PRIVACY` - Scan with changing addresses +* :kconfig:`CONFIG_BT_SCAN_WITH_IDENTITY` - Scan with a local identity address -It is recommended to enable the :option:`CONFIG_BT_PRIVACY` option to support directed advertising only between bonded peers. -Use the :option:`CONFIG_BT_SCAN_WITH_IDENTITY` option only when the :option:`CONFIG_BT_PRIVACY` option is not available. +It is recommended to enable the :kconfig:`CONFIG_BT_PRIVACY` option to support directed advertising only between bonded peers. +Use the :kconfig:`CONFIG_BT_SCAN_WITH_IDENTITY` option only when the :kconfig:`CONFIG_BT_PRIVACY` option is not available. When the scanning module is set in advanced mode and :ref:`filters ` are set, you can use the ``filter_no_match`` event to check if directed advertising packets have been received. They will typically not match any filter as, by specification, they do not contain any advertising data. @@ -154,7 +154,7 @@ If there is no match, you can establish a connection without the need to disable The following code sample demonstrates the usage of the ``filter_no_match`` event: -.. literalinclude:: ../../samples/bluetooth/central_hids/src/main.c +.. literalinclude:: ../../../../samples/bluetooth/central_hids/src/main.c :language: c :start-after: include_startingpoint_scan_rst :end-before: include_endpoint_scan_rst diff --git a/include/bluetooth/services/ancs_client.rst b/doc/nrf/libraries/bluetooth_services/services/ancs_client.rst similarity index 97% rename from include/bluetooth/services/ancs_client.rst rename to doc/nrf/libraries/bluetooth_services/services/ancs_client.rst index 0194a4884e30..c99b84d9a40e 100644 --- a/include/bluetooth/services/ancs_client.rst +++ b/doc/nrf/libraries/bluetooth_services/services/ancs_client.rst @@ -21,7 +21,7 @@ The term "notification" is used in two different meanings: * An iOS notification is the data received from the Notification Provider. -* A GATT notification is a way to transfer data with Bluetooth Low Energy. +* A GATT notification is a way to transfer data with Bluetooth® Low Energy. In this module, iOS notifications are received through the GATT notifications. The full term (iOS notification or GATT notification) is used where required to avoid confusion. diff --git a/include/bluetooth/services/bas_client.rst b/doc/nrf/libraries/bluetooth_services/services/bas_client.rst similarity index 100% rename from include/bluetooth/services/bas_client.rst rename to doc/nrf/libraries/bluetooth_services/services/bas_client.rst diff --git a/include/bluetooth/services/bms.rst b/doc/nrf/libraries/bluetooth_services/services/bms.rst similarity index 95% rename from include/bluetooth/services/bms.rst rename to doc/nrf/libraries/bluetooth_services/services/bms.rst index a7763b2f48b5..52fc157404e3 100644 --- a/include/bluetooth/services/bms.rst +++ b/doc/nrf/libraries/bluetooth_services/services/bms.rst @@ -32,7 +32,7 @@ You can set this callback when initializing the module. Deleting the bonds ****************** -The Server deletes bonding information on Client's request right away when there is no active Bluetooth LE connection associated with a bond. +The Server deletes bonding information on Client's request right away when there is no active Bluetooth® LE connection associated with a bond. Otherwise, the Server removes the bond for a given peer when it disconnects. API documentation diff --git a/include/bluetooth/services/cts_client.rst b/doc/nrf/libraries/bluetooth_services/services/cts_client.rst similarity index 100% rename from include/bluetooth/services/cts_client.rst rename to doc/nrf/libraries/bluetooth_services/services/cts_client.rst diff --git a/include/bluetooth/services/dfu_smp.rst b/doc/nrf/libraries/bluetooth_services/services/dfu_smp.rst similarity index 100% rename from include/bluetooth/services/dfu_smp.rst rename to doc/nrf/libraries/bluetooth_services/services/dfu_smp.rst diff --git a/include/bluetooth/services/gadgets.rst b/doc/nrf/libraries/bluetooth_services/services/gadgets.rst similarity index 90% rename from include/bluetooth/services/gadgets.rst rename to doc/nrf/libraries/bluetooth_services/services/gadgets.rst index eedb2ce58f47..fe31a6c72a4b 100644 --- a/include/bluetooth/services/gadgets.rst +++ b/doc/nrf/libraries/bluetooth_services/services/gadgets.rst @@ -7,7 +7,7 @@ Alexa Gadgets Service :local: :depth: 2 -The Bluetooth LE GATT Alexa Gadgets Service is a custom service that manages Alexa Gadgets stream transactions. +The Bluetooth® LE GATT Alexa Gadgets Service is a custom service that manages Alexa Gadgets stream transactions. For details about the stream format, see Alexa Gadgets Bluetooth LE Packet `Alexa Gadgets Bluetooth LE Packet Format`_. The Alexa Gadgets Service is used in the :ref:`peripheral_alexa_gadgets` sample. diff --git a/include/bluetooth/services/gattp.rst b/doc/nrf/libraries/bluetooth_services/services/gattp.rst similarity index 100% rename from include/bluetooth/services/gattp.rst rename to doc/nrf/libraries/bluetooth_services/services/gattp.rst diff --git a/include/bluetooth/services/hids.rst b/doc/nrf/libraries/bluetooth_services/services/hids.rst similarity index 98% rename from include/bluetooth/services/hids.rst rename to doc/nrf/libraries/bluetooth_services/services/hids.rst index dc36b9696ce3..ce383c13394b 100644 --- a/include/bluetooth/services/hids.rst +++ b/doc/nrf/libraries/bluetooth_services/services/hids.rst @@ -10,7 +10,7 @@ GATT Human Interface Device (HID) Service This module implements the Human Interface Device Service with the corresponding set of characteristics. When initialized, it adds the HID Service and a set of characteristics, according to the HID Service specification and to the user -requirements, to the Zephyr Bluetooth stack database. +requirements, to the Zephyr Bluetooth® stack database. If enabled, notification of Input Report characteristics is performed when the application calls the corresponding :c:func:`bt_hids_inp_rep_send` function. diff --git a/include/bluetooth/services/hogp.rst b/doc/nrf/libraries/bluetooth_services/services/hogp.rst similarity index 99% rename from include/bluetooth/services/hogp.rst rename to doc/nrf/libraries/bluetooth_services/services/hogp.rst index 58ec6129c084..e88838900af6 100644 --- a/include/bluetooth/services/hogp.rst +++ b/doc/nrf/libraries/bluetooth_services/services/hogp.rst @@ -25,7 +25,7 @@ Configuration Apart from standard configuration parameters, there is one important setting: -:option:`CONFIG_BT_HOGP_REPORTS_MAX` +:kconfig:`CONFIG_BT_HOGP_REPORTS_MAX` Sets the maximum number of total reports supported by the library. The report memory is shared along all HIDS client objects, so this option should be set to the maximum total number of reports supported by the application. diff --git a/include/bluetooth/services/latency.rst b/doc/nrf/libraries/bluetooth_services/services/latency.rst similarity index 100% rename from include/bluetooth/services/latency.rst rename to doc/nrf/libraries/bluetooth_services/services/latency.rst diff --git a/include/bluetooth/services/latency_client.rst b/doc/nrf/libraries/bluetooth_services/services/latency_client.rst similarity index 100% rename from include/bluetooth/services/latency_client.rst rename to doc/nrf/libraries/bluetooth_services/services/latency_client.rst diff --git a/include/bluetooth/services/lbs.rst b/doc/nrf/libraries/bluetooth_services/services/lbs.rst similarity index 100% rename from include/bluetooth/services/lbs.rst rename to doc/nrf/libraries/bluetooth_services/services/lbs.rst diff --git a/include/bluetooth/services/nus.rst b/doc/nrf/libraries/bluetooth_services/services/nus.rst similarity index 88% rename from include/bluetooth/services/nus.rst rename to doc/nrf/libraries/bluetooth_services/services/nus.rst index fbc4a99420d3..a71e1244e97f 100644 --- a/include/bluetooth/services/nus.rst +++ b/doc/nrf/libraries/bluetooth_services/services/nus.rst @@ -7,7 +7,7 @@ Nordic UART Service (NUS) :local: :depth: 2 -The Bluetooth LE GATT Nordic UART Service is a custom service that receives and writes data and serves as a bridge to the UART interface. +The Bluetooth® LE GATT Nordic UART Service is a custom service that receives and writes data and serves as a bridge to the UART interface. The NUS Service is used in the :ref:`peripheral_uart` sample. diff --git a/include/bluetooth/services/nus_client.rst b/doc/nrf/libraries/bluetooth_services/services/nus_client.rst similarity index 100% rename from include/bluetooth/services/nus_client.rst rename to doc/nrf/libraries/bluetooth_services/services/nus_client.rst diff --git a/include/bluetooth/services/throughput.rst b/doc/nrf/libraries/bluetooth_services/services/throughput.rst similarity index 100% rename from include/bluetooth/services/throughput.rst rename to doc/nrf/libraries/bluetooth_services/services/throughput.rst diff --git a/include/caf/ble_adv.rst b/doc/nrf/libraries/caf/ble_adv.rst similarity index 70% rename from include/caf/ble_adv.rst rename to doc/nrf/libraries/caf/ble_adv.rst index a632fa1436cd..b3add384c761 100644 --- a/include/caf/ble_adv.rst +++ b/doc/nrf/libraries/caf/ble_adv.rst @@ -17,14 +17,14 @@ Configuration The following Kconfig options are available for this module: -* :option:`CONFIG_CAF_BLE_ADV` -* :option:`CONFIG_CAF_BLE_ADV_DEF_PATH` -* :option:`CONFIG_CAF_BLE_ADV_PM_EVENTS` -* :option:`CONFIG_CAF_BLE_ADV_DIRECT_ADV` -* :option:`CONFIG_CAF_BLE_ADV_FAST_ADV` -* :option:`CONFIG_CAF_BLE_ADV_FAST_ADV_TIMEOUT` -* :option:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR` -* :option:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR_GRACE_PERIOD` +* :kconfig:`CONFIG_CAF_BLE_ADV` +* :kconfig:`CONFIG_CAF_BLE_ADV_DEF_PATH` +* :kconfig:`CONFIG_CAF_BLE_ADV_PM_EVENTS` +* :kconfig:`CONFIG_CAF_BLE_ADV_DIRECT_ADV` +* :kconfig:`CONFIG_CAF_BLE_ADV_FAST_ADV` +* :kconfig:`CONFIG_CAF_BLE_ADV_FAST_ADV_TIMEOUT` +* :kconfig:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR` +* :kconfig:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR_GRACE_PERIOD` Read about some of these options in the following sections. @@ -34,9 +34,9 @@ Enabling the module To enable the |ble_adv|, complete the following steps: 1. Enable and configure the :ref:`CAF Bluetooth LE state module `. -#. Define the Bluetooth device name using the :option:`CONFIG_BT_DEVICE_NAME` Kconfig option. -#. Define the Bluetooth device appearance using the :option:`CONFIG_BT_DEVICE_APPEARANCE` Kconfig option. -#. Set the :option:`CONFIG_CAF_BLE_ADV` Kconfig option. +#. Define the Bluetooth device name using the :kconfig:`CONFIG_BT_DEVICE_NAME` Kconfig option. +#. Define the Bluetooth device appearance using the :kconfig:`CONFIG_BT_DEVICE_APPEARANCE` Kconfig option. +#. Set the :kconfig:`CONFIG_CAF_BLE_ADV` Kconfig option. #. Create a configuration file that defines Bluetooth LE advertising data. #. In the configuration file, define the following arrays of :c:struct:`bt_data`: @@ -67,7 +67,7 @@ To enable the |ble_adv|, complete the following steps: static const struct bt_data sd[] = {}; -#. Specify the path to the configuration file with the :option:`CONFIG_CAF_BLE_ADV_DEF_PATH` Kconfig option. +#. Specify the path to the configuration file with the :kconfig:`CONFIG_CAF_BLE_ADV_DEF_PATH` Kconfig option. .. note:: The configuration file should be included only by the configured module. @@ -77,7 +77,7 @@ Using directed advertising ========================== By default, the module uses indirect advertising. -Set the :option:`CONFIG_CAF_BLE_ADV_DIRECT_ADV` option to use directed advertising. +Set the :kconfig:`CONFIG_CAF_BLE_ADV_DIRECT_ADV` option to use directed advertising. The directed advertising can be used to call the selected peer device to connect as quickly as possible. .. note:: @@ -87,10 +87,10 @@ The directed advertising can be used to call the selected peer device to connect Changing advertising interval ============================= -Set the :option:`CONFIG_CAF_BLE_ADV_FAST_ADV` Kconfig option to make the Peripheral initially advertise with a shorter interval. +Set the :kconfig:`CONFIG_CAF_BLE_ADV_FAST_ADV` Kconfig option to make the Peripheral initially advertise with a shorter interval. This lets you speed up finding the Peripheral by Bluetooth Centrals. -* If the device uses indirect advertising, it will switch to slower advertising after the period of time defined in :option:`CONFIG_CAF_BLE_ADV_FAST_ADV_TIMEOUT` (in seconds). +* If the device uses indirect advertising, it will switch to slower advertising after the period of time defined in :kconfig:`CONFIG_CAF_BLE_ADV_FAST_ADV_TIMEOUT` (in seconds). * If the device uses directed advertising, the |ble_adv| will receive :c:struct:`ble_peer_event` with :c:member:`ble_peer_event.state` set to :c:enumerator:`PEER_STATE_CONN_FAILED` if the Central does not connect during the predefined period of fast directed advertising. The :c:struct:`ble_peer_event` is submitted by :ref:`caf_ble_state`. After the event is received, the device will switch to the low duty cycle directed advertising. @@ -100,11 +100,11 @@ Switching to slower advertising is done to reduce the energy consumption. Using Swift Pair ================ -You can use the :option:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR` option to enable the Swift Pair feature. +You can use the :kconfig:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR` option to enable the Swift Pair feature. The feature simplifies pairing the Bluetooth Peripheral with Windows 10 hosts. .. note:: - Make sure to add the Swift Pair data to advertising packets for unbonded device in the configuration file if you enable :option:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR` option. + Make sure to add the Swift Pair data to advertising packets for unbonded device in the configuration file if you enable :kconfig:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR` option. The Swift Pair data must be added as the last member of ``ad_unbonded`` array. Power-down @@ -112,7 +112,7 @@ Power-down When the system goes to the Power-down state, the advertising stops. -If the Swift Pair feature is enabled with :option:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR`, the device advertises without the Swift Pair data for additional :option:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR_GRACE_PERIOD` seconds to ensure that the user does not try to connect to the device that is no longer available. +If the Swift Pair feature is enabled with :kconfig:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR`, the device advertises without the Swift Pair data for additional :kconfig:`CONFIG_CAF_BLE_ADV_SWIFT_PAIR_GRACE_PERIOD` seconds to ensure that the user does not try to connect to the device that is no longer available. Implementation details ********************** @@ -124,7 +124,7 @@ The |ble_adv| uses Zephyr's :ref:`zephyr:settings_api` to store the information Reaction on Bluetooth peer operation ==================================== -If the application supports Bluetooth LE bond management (:option:`CONFIG_CAF_BLE_BOND_SUPPORTED`), the Bluetooth LE bond module defined for the application is used to control the Bluetooth bonds. +If the application supports Bluetooth LE bond management (:kconfig:`CONFIG_CAF_BLE_BOND_SUPPORTED`), the Bluetooth LE bond module defined for the application is used to control the Bluetooth bonds. The Bluetooth LE bond module broadcasts information related to bond control using :c:struct:`ble_peer_operation_event`. The |ble_adv| reacts on :c:struct:`ble_peer_operation_event` related to the Bluetooth peer change or erase advertising. @@ -136,7 +136,7 @@ The module performs one of the following operations: Avoiding connection requests from unbonded centrals when bonded =============================================================== -If :option:`CONFIG_BT_WHITELIST` is enabled and Bluetooth local identity that is in use already has a bond, the device will whitelist incoming scan response data requests and connection requests. +If :kconfig:`CONFIG_BT_WHITELIST` is enabled and Bluetooth local identity that is in use already has a bond, the device will whitelist incoming scan response data requests and connection requests. This is done to prevent Bluetooth Centrals other than the bonded one from connecting with the device. -.. |ble_adv| replace:: Bluetooth LE advertising module +.. |ble_adv| replace:: Bluetooth® LE advertising module diff --git a/include/caf/ble_smp.rst b/doc/nrf/libraries/caf/ble_smp.rst similarity index 76% rename from include/caf/ble_smp.rst rename to doc/nrf/libraries/caf/ble_smp.rst index c7adb2bd1a89..c707bdb6a9ff 100644 --- a/include/caf/ble_smp.rst +++ b/doc/nrf/libraries/caf/ble_smp.rst @@ -7,19 +7,19 @@ CAF: Simple Management Protocol module :local: :depth: 2 -The |smp| of the :ref:`lib_caf` (CAF) allows to perform the device firmware upgrade (DFU) over Bluetooth LE. +The |smp| of the :ref:`lib_caf` (CAF) allows to perform the device firmware upgrade (DFU) over Bluetooth® LE. Configuration ************* To use the module, you must enable the following Kconfig options: -* :option:`CONFIG_CAF_BLE_STATE` - This module enables :ref:`caf_ble_state` module. -* :option:`CONFIG_CAF_BLE_SMP` - This option enables |smp| over Bluetooth LE. -* :option:`CONFIG_MCUMGR_CMD_IMG_MGMT` - This option enables MCUmgr image management handlers, which are required for the DFU process. +* :kconfig:`CONFIG_CAF_BLE_STATE` - This module enables :ref:`caf_ble_state` module. +* :kconfig:`CONFIG_CAF_BLE_SMP` - This option enables |smp| over Bluetooth LE. +* :kconfig:`CONFIG_MCUMGR_CMD_IMG_MGMT` - This option enables MCUmgr image management handlers, which are required for the DFU process. For details, see :ref:`zephyr:device_mgmt` in the Zephyr documentation. -* :option:`CONFIG_MCUMGR_SMP_BT` - This option enables support for the SMP commands over Bluetooth. -* :option:`CONFIG_BOOTLOADER_MCUBOOT` - This option enables the MCUboot bootloader. +* :kconfig:`CONFIG_MCUMGR_SMP_BT` - This option enables support for the SMP commands over Bluetooth. +* :kconfig:`CONFIG_BOOTLOADER_MCUBOOT` - This option enables the MCUboot bootloader. The DFU over Simple Management Protocol in Zephyr is supported only with the MCUboot bootloader. Enabling remote OS management @@ -27,7 +27,7 @@ Enabling remote OS management The |smp| supports registering OS management handlers automatically, which you can enable using the following Kconfig option: -* :option:`CONFIG_MCUMGR_CMD_OS_MGMT` - This option enables MCUmgr OS management handlers. +* :kconfig:`CONFIG_MCUMGR_CMD_OS_MGMT` - This option enables MCUmgr OS management handlers. Use these handlers to remotely trigger the device reboot after the image transfer is completed. After the reboot, the device starts using the new firmware. One of the applications that support the remote reboot functionality is `nRF Connect for Mobile`_. diff --git a/include/caf/ble_state.rst b/doc/nrf/libraries/caf/ble_state.rst similarity index 80% rename from include/caf/ble_state.rst rename to doc/nrf/libraries/caf/ble_state.rst index 1cc887a7bec4..de8dfe680dda 100644 --- a/include/caf/ble_state.rst +++ b/doc/nrf/libraries/caf/ble_state.rst @@ -25,17 +25,17 @@ Configuration To use the module, you must enable the following Kconfig options: -* :option:`CONFIG_BT` -* :option:`CONFIG_BT_SMP` - This option enables Security Manager Protocol support. +* :kconfig:`CONFIG_BT` +* :kconfig:`CONFIG_BT_SMP` - This option enables Security Manager Protocol support. The |ble_state| on Bluetooth Peripheral requires at least the connection security level 2 (encryption). -* :option:`CONFIG_CAF_BLE_STATE` - This option enables the |ble_state| and selects the :option:`CONFIG_CAF_BLE_COMMON_EVENTS` Kconfig option, which enables Bluetooth LE common events in CAF. +* :kconfig:`CONFIG_CAF_BLE_STATE` - This option enables the |ble_state| and selects the :kconfig:`CONFIG_CAF_BLE_COMMON_EVENTS` Kconfig option, which enables Bluetooth LE common events in CAF. The following Kconfig options are also available for this module: -* :option:`CONFIG_CAF_BLE_STATE_EXCHANGE_MTU` - This option can be used for GATT client (:option:`CONFIG_BT_GATT_CLIENT`) to set the Maximum Transmission Unit (MTU) to the maximum possible size that the buffers can hold. +* :kconfig:`CONFIG_CAF_BLE_STATE_EXCHANGE_MTU` - This option can be used for GATT client (:kconfig:`CONFIG_BT_GATT_CLIENT`) to set the Maximum Transmission Unit (MTU) to the maximum possible size that the buffers can hold. This option is enabled by default. -* :option:`CONFIG_CAF_BLE_USE_LLPM` - This option enables the Low Latency Packet Mode (LLPM). - This option is enabled by default and depends on :option:`CONFIG_BT_CTLR_LLPM` and :option:`CONFIG_BT_LL_SOFTDEVICE`. +* :kconfig:`CONFIG_CAF_BLE_USE_LLPM` - This option enables the Low Latency Packet Mode (LLPM). + This option is enabled by default and depends on :kconfig:`CONFIG_BT_CTLR_LLPM` and :kconfig:`CONFIG_BT_LL_SOFTDEVICE`. Implementation details ********************** @@ -51,7 +51,7 @@ Connection state change The module propagates information about the connection state changes using :c:struct:`ble_peer_event`. In this event, :c:member:`ble_peer_event.id` is a pointer to the connection object and :c:member:`ble_peer_event.state` is the connection state. -.. figure:: /images/caf_ble_state_transitions.svg +.. figure:: images/caf_ble_state_transitions.svg :alt: Bluetooth connection state handling in CAF Bluetooth connection state handling in CAF @@ -87,10 +87,10 @@ After :c:struct:`ble_peer_event` about disconnection or connection failure is re Behavior with SoftDevice Link Layer =================================== -If Nordic Semiconductor's SoftDevice Bluetooth LE Link Layer is selected (:option:`CONFIG_BT_LL_SOFTDEVICE`) and the :option:`CONFIG_CAF_BLE_USE_LLPM` option is enabled, the |ble_state| sends a Bluetooth HCI command to enable the LLPM when Bluetooth is ready. +If Nordic Semiconductor's SoftDevice Bluetooth LE Link Layer is selected (:kconfig:`CONFIG_BT_LL_SOFTDEVICE`) and the :kconfig:`CONFIG_CAF_BLE_USE_LLPM` option is enabled, the |ble_state| sends a Bluetooth HCI command to enable the LLPM when Bluetooth is ready. If the SoftDevice Link Layer is selected, the |ble_state| also sets the TX power for connections. The TX power is set according to Zephyr's Kconfig options related to selecting the default TX power. This is necessary because the mentioned Kconfig options are not automatically applied by the Bluetooth stack if the SoftDevice Link Layer is selected. -.. |ble_state| replace:: Bluetooth LE state module +.. |ble_state| replace:: Bluetooth® LE state module diff --git a/include/caf/buttons.rst b/doc/nrf/libraries/caf/buttons.rst similarity index 75% rename from include/caf/buttons.rst rename to doc/nrf/libraries/caf/buttons.rst index 5ed9b1315058..f50a78dceee3 100644 --- a/include/caf/buttons.rst +++ b/doc/nrf/libraries/caf/buttons.rst @@ -16,8 +16,8 @@ Configuration To use the module, you must enable the following Kconfig options: -* :option:`CONFIG_CAF_BUTTONS` - This option enables the buttons module. -* :option:`CONFIG_GPIO` - This option enables Zephyr's :ref:`zephyr:gpio_api` driver, which is required for interacting with the GPIO pins. +* :kconfig:`CONFIG_CAF_BUTTONS` - This option enables the buttons module. +* :kconfig:`CONFIG_GPIO` - This option enables Zephyr's :ref:`zephyr:gpio_api` driver, which is required for interacting with the GPIO pins. When defining how buttons are connected, you must create a configuration file with the following arrays: @@ -42,7 +42,7 @@ For example, the file contents should look like follows: { .port = 1, .pin = 14 }, }; -You must define both arrays in this configuration file, and specify its location with the :option:`CONFIG_CAF_BUTTONS_DEF_PATH` Kconfig option. +You must define both arrays in this configuration file, and specify its location with the :kconfig:`CONFIG_CAF_BUTTONS_DEF_PATH` Kconfig option. .. note:: The configuration file should be included only by the configured module. @@ -50,22 +50,22 @@ You must define both arrays in this configuration file, and specify its location The following Kconfig options are available for this module: -* :option:`CONFIG_CAF_BUTTONS_DEF_PATH` -* :option:`CONFIG_CAF_BUTTONS_PM_EVENTS` -* :option:`CONFIG_CAF_BUTTONS_SCAN_INTERVAL` -* :option:`CONFIG_CAF_BUTTONS_DEBOUNCE_INTERVAL` -* :option:`CONFIG_CAF_BUTTONS_POLARITY_INVERSED` -* :option:`CONFIG_CAF_BUTTONS_EVENT_LIMIT` +* :kconfig:`CONFIG_CAF_BUTTONS_DEF_PATH` +* :kconfig:`CONFIG_CAF_BUTTONS_PM_EVENTS` +* :kconfig:`CONFIG_CAF_BUTTONS_SCAN_INTERVAL` +* :kconfig:`CONFIG_CAF_BUTTONS_DEBOUNCE_INTERVAL` +* :kconfig:`CONFIG_CAF_BUTTONS_POLARITY_INVERSED` +* :kconfig:`CONFIG_CAF_BUTTONS_EVENT_LIMIT` By default, a button press is indicated by a pin switch from the low to the high state. -You can change this with :option:`CONFIG_CAF_BUTTONS_POLARITY_INVERSED`, which will cause the application to react to an opposite pin change (from the high to the low state). +You can change this with :kconfig:`CONFIG_CAF_BUTTONS_POLARITY_INVERSED`, which will cause the application to react to an opposite pin change (from the high to the low state). Implementation details ********************** Depending on the configuration, the module can use from two to four states. -.. figure:: /images/caf_buttons_states.svg +.. figure:: images/caf_buttons_states.svg :alt: State transitions of the buttons module State transitions of the buttons module @@ -80,17 +80,17 @@ If no buttons are pressed the module switches to ``STATE_ACTIVE``. In this state, the module enables the GPIO interrupts and waits for the pin state to change. Whenever a button is pressed, the module switches to ``STATE_SCANNING``. -When the switch occurs, the module submits a work with a delay set to :option:`CONFIG_CAF_BUTTONS_DEBOUNCE_INTERVAL`. +When the switch occurs, the module submits a work with a delay set to :kconfig:`CONFIG_CAF_BUTTONS_DEBOUNCE_INTERVAL`. The work scans the keyboard matrix, or directly connected buttons (depends on configuration). If any button state change occurs, the module sends related event. -* If the button is kept pressed while the scanning is performed, the work will be resubmitted with a delay set to :option:`CONFIG_CAF_BUTTONS_SCAN_INTERVAL`. +* If the button is kept pressed while the scanning is performed, the work will be resubmitted with a delay set to :kconfig:`CONFIG_CAF_BUTTONS_SCAN_INTERVAL`. * If no button is pressed, the module switches back to ``STATE_ACTIVE``. Power management states ======================= -If the :option:`CONFIG_CAF_BUTTONS_PM_EVENTS` Kconfig option is enabled, the module can react to power management events and submit ``wake_up_event``. +If the :kconfig:`CONFIG_CAF_BUTTONS_PM_EVENTS` Kconfig option is enabled, the module can react to power management events and submit ``wake_up_event``. In that case, the following additional states are available: * ``STATE_SUSPENDING`` diff --git a/include/caf/caf_overview.rst b/doc/nrf/libraries/caf/caf_overview.rst similarity index 97% rename from include/caf/caf_overview.rst rename to doc/nrf/libraries/caf/caf_overview.rst index c5779cf30876..6c804acdaf58 100644 --- a/include/caf/caf_overview.rst +++ b/doc/nrf/libraries/caf/caf_overview.rst @@ -19,7 +19,7 @@ In an event-based application, parts of the application functionality are separa These events are defined either by CAF or by the application. They are submitted by modules and other modules can subscribe and react to them. -.. figure:: ../../doc/nrf/images/caf_overview.svg +.. figure:: images/caf_overview.svg :alt: Common Application Framework architecture example Common Application Framework architecture example @@ -38,7 +38,7 @@ Enabling CAF To enable CAF, complete the following steps: -1. Enable :option:`CONFIG_CAF` Kconfig option in your project configuration file. +1. Enable :kconfig:`CONFIG_CAF` Kconfig option in your project configuration file. #. Enable and initialize Event Manager. See :ref:`event_manager_configuration` for more details. #. Submit the first :c:struct:`module_state_event`. diff --git a/include/caf/click_detector.rst b/doc/nrf/libraries/caf/click_detector.rst similarity index 82% rename from include/caf/click_detector.rst rename to doc/nrf/libraries/caf/click_detector.rst index 660a5c38cf3b..cbc3a670ae2b 100644 --- a/include/caf/click_detector.rst +++ b/doc/nrf/libraries/caf/click_detector.rst @@ -14,13 +14,13 @@ Configuration To use the module, you must enable the following Kconfig options: -* :option:`CONFIG_CAF_CLICK_DETECTOR` - This option enables the |click_detector|. -* :option:`CONFIG_CAF_BUTTON_EVENTS` - This option enables the ``button_event`` that is required for the |click_detector| to work. +* :kconfig:`CONFIG_CAF_CLICK_DETECTOR` - This option enables the |click_detector|. +* :kconfig:`CONFIG_CAF_BUTTON_EVENTS` - This option enables the ``button_event`` that is required for the |click_detector| to work. -In addition to :option:`CONFIG_CAF_CLICK_DETECTOR`, the following Kconfig options are available for the module: +In addition to :kconfig:`CONFIG_CAF_CLICK_DETECTOR`, the following Kconfig options are available for the module: -* :option:`CONFIG_CAF_CLICK_DETECTOR_DEF_PATH` -* :option:`CONFIG_CAF_CLICK_DETECTOR_PM_EVENTS` +* :kconfig:`CONFIG_CAF_CLICK_DETECTOR_DEF_PATH` +* :kconfig:`CONFIG_CAF_CLICK_DETECTOR_PM_EVENTS` Adding module configuration file ================================ @@ -51,7 +51,7 @@ To do so, complete the following steps: .. note:: The :c:macro:`KEY_ID` macro is defined in :file:`include/caf/key_id.h`. -#. Specify the location of the file with the :option:`CONFIG_CAF_CLICK_DETECTOR_DEF_PATH` Kconfig option. +#. Specify the location of the file with the :kconfig:`CONFIG_CAF_CLICK_DETECTOR_DEF_PATH` Kconfig option. .. note:: The configuration file should be included only by the configured module. @@ -80,7 +80,7 @@ The exact values of time intervals for click types are defined in the :file:`sub Power management states ======================= -If the option :option:`CONFIG_CAF_CLICK_DETECTOR_PM_EVENTS` is enabled, the module can react to power management events. +If the option :kconfig:`CONFIG_CAF_CLICK_DETECTOR_PM_EVENTS` is enabled, the module can react to power management events. The module stops tracing of key states when ``power_down_event`` is received. The module starts operating again when ``wake_up_event`` is received. diff --git a/doc/nrf/images/caf_ble_state_transitions.svg b/doc/nrf/libraries/caf/images/caf_ble_state_transitions.svg similarity index 100% rename from doc/nrf/images/caf_ble_state_transitions.svg rename to doc/nrf/libraries/caf/images/caf_ble_state_transitions.svg diff --git a/doc/nrf/images/caf_ble_state_transitions.vsdx b/doc/nrf/libraries/caf/images/caf_ble_state_transitions.vsdx similarity index 100% rename from doc/nrf/images/caf_ble_state_transitions.vsdx rename to doc/nrf/libraries/caf/images/caf_ble_state_transitions.vsdx diff --git a/doc/nrf/images/caf_buttons_states.svg b/doc/nrf/libraries/caf/images/caf_buttons_states.svg similarity index 100% rename from doc/nrf/images/caf_buttons_states.svg rename to doc/nrf/libraries/caf/images/caf_buttons_states.svg diff --git a/doc/nrf/images/caf_buttons_states.vsdx b/doc/nrf/libraries/caf/images/caf_buttons_states.vsdx similarity index 100% rename from doc/nrf/images/caf_buttons_states.vsdx rename to doc/nrf/libraries/caf/images/caf_buttons_states.vsdx diff --git a/doc/nrf/images/caf_led_effect_structure.png b/doc/nrf/libraries/caf/images/caf_led_effect_structure.png similarity index 100% rename from doc/nrf/images/caf_led_effect_structure.png rename to doc/nrf/libraries/caf/images/caf_led_effect_structure.png diff --git a/doc/nrf/images/caf_led_effect_structure.svg b/doc/nrf/libraries/caf/images/caf_led_effect_structure.svg similarity index 100% rename from doc/nrf/images/caf_led_effect_structure.svg rename to doc/nrf/libraries/caf/images/caf_led_effect_structure.svg diff --git a/doc/nrf/images/caf_led_effect_structure.vsdx b/doc/nrf/libraries/caf/images/caf_led_effect_structure.vsdx similarity index 100% rename from doc/nrf/images/caf_led_effect_structure.vsdx rename to doc/nrf/libraries/caf/images/caf_led_effect_structure.vsdx diff --git a/doc/nrf/images/caf_overview.svg b/doc/nrf/libraries/caf/images/caf_overview.svg similarity index 100% rename from doc/nrf/images/caf_overview.svg rename to doc/nrf/libraries/caf/images/caf_overview.svg diff --git a/doc/nrf/images/caf_sensor_states.svg b/doc/nrf/libraries/caf/images/caf_sensor_states.svg similarity index 100% rename from doc/nrf/images/caf_sensor_states.svg rename to doc/nrf/libraries/caf/images/caf_sensor_states.svg diff --git a/doc/nrf/images/caf_sensor_states.vsdx b/doc/nrf/libraries/caf/images/caf_sensor_states.vsdx similarity index 100% rename from doc/nrf/images/caf_sensor_states.vsdx rename to doc/nrf/libraries/caf/images/caf_sensor_states.vsdx diff --git a/doc/nrf/libraries/lib_caf.rst b/doc/nrf/libraries/caf/index.rst similarity index 66% rename from doc/nrf/libraries/lib_caf.rst rename to doc/nrf/libraries/caf/index.rst index bd4cb9cc099f..1da094a7a75a 100644 --- a/doc/nrf/libraries/lib_caf.rst +++ b/doc/nrf/libraries/caf/index.rst @@ -8,5 +8,5 @@ Common Application Framework :glob: :caption: Subpages: - ../../../include/caf/caf_overview.rst - ../../../include/caf/* + caf_overview.rst + * diff --git a/include/caf/leds.rst b/doc/nrf/libraries/caf/leds.rst similarity index 94% rename from include/caf/leds.rst rename to doc/nrf/libraries/caf/leds.rst index 10d1cdad14cc..ab82e9866113 100644 --- a/include/caf/leds.rst +++ b/doc/nrf/libraries/caf/leds.rst @@ -22,31 +22,31 @@ To use the module, you must conplete the following requirements: 1. Enable the following Kconfig options: - * :option:`CONFIG_CAF_LEDS` - This option enables the LEDs module. - * :option:`CONFIG_LED` - This option enables the LED driver API. + * :kconfig:`CONFIG_CAF_LEDS` - This option enables the LEDs module. + * :kconfig:`CONFIG_LED` - This option enables the LED driver API. #. Complete one of the following steps to choose and configure the LED driver implementation: a. For the PWM-based implementation, Zephyr's :ref:`zephyr:pwm_api` driver is used for setting the LED color (that is, the brightness of the diodes). For this reason, set the following options: - * :option:`CONFIG_CAF_LEDS_PWM` - * :option:`CONFIG_LED_PWM` - * :option:`CONFIG_PWM` + * :kconfig:`CONFIG_CAF_LEDS_PWM` + * :kconfig:`CONFIG_LED_PWM` + * :kconfig:`CONFIG_PWM` b. For the GPIO-based implementation, Zephyr's :ref:`zephyr:gpio_api` driver is used for setting the LED color (that is, the brightness of the diodes). For this reason, set the following options: - * :option:`CONFIG_CAF_LEDS_GPIO` - * :option:`CONFIG_LED_GPIO` - * :option:`CONFIG_GPIO` + * :kconfig:`CONFIG_CAF_LEDS_GPIO` + * :kconfig:`CONFIG_LED_GPIO` + * :kconfig:`CONFIG_GPIO` #. Configure LEDs in DTS. See `Configuring LEDs in DTS`_ for details. The following Kconfig options are also available for this module: -* :option:`CONFIG_CAF_LEDS_PM_EVENTS` - This option enables the reaction to `Power management events`_. +* :kconfig:`CONFIG_CAF_LEDS_PM_EVENTS` - This option enables the reaction to `Power management events`_. .. note:: The GPIO-based LED driver implementation supports only turning LED on or off. @@ -278,7 +278,7 @@ The LED effect (:c:struct:`led_effect`) is described by the following characteri To achieve the desired LED effect, the LED color is updated periodically based on the LED steps defined for the given LED effect, which in turn are divided in multiple smaller updates called *substeps*. -.. figure:: /images/caf_led_effect_structure.svg +.. figure:: images/caf_led_effect_structure.svg :alt: Characteristics of a led_effect Characteristics of a led_effect @@ -293,7 +293,7 @@ If the flag is not set, the sequence stops and the given LED effect ends. Power management events ======================= -If the :option:`CONFIG_CAF_LEDS_PM_EVENTS` Kconfig option is enabled, the module can react to following power management events: +If the :kconfig:`CONFIG_CAF_LEDS_PM_EVENTS` Kconfig option is enabled, the module can react to following power management events: * ``power_down_event`` * ``wake_up_event`` diff --git a/include/caf/power_manager.rst b/doc/nrf/libraries/caf/power_manager.rst similarity index 89% rename from include/caf/power_manager.rst rename to doc/nrf/libraries/caf/power_manager.rst index 125b3d4033cb..b3186c856207 100644 --- a/include/caf/power_manager.rst +++ b/doc/nrf/libraries/caf/power_manager.rst @@ -13,22 +13,22 @@ The module achieves this reduction by switching to low power modes when the devi Configuration ************* -You can enable the |power_manager| by selecting the :option:`CONFIG_CAF_POWER_MANAGER` option in the configuration. +You can enable the |power_manager| by selecting the :kconfig:`CONFIG_CAF_POWER_MANAGER` option in the configuration. This module uses Zephyr's :ref:`zephyr:power_management_api` subsystem. Timeout configuration options ============================= -With the :option:`CONFIG_CAF_POWER_MANAGER_TIMEOUT` configuration option, you can set the period of time after which the application enters the low power mode. +With the :kconfig:`CONFIG_CAF_POWER_MANAGER_TIMEOUT` configuration option, you can set the period of time after which the application enters the low power mode. By default, the timeout is set to 120 seconds. -The :option:`CONFIG_CAF_POWER_MANAGER_ERROR_TIMEOUT` sets the period of time after which the device is turned off upon an internal error. +The :kconfig:`CONFIG_CAF_POWER_MANAGER_ERROR_TIMEOUT` sets the period of time after which the device is turned off upon an internal error. Optional boolean for keeping the system on ========================================== -The :option:`CONFIG_CAF_POWER_MANAGER_STAY_ON` lets the system stay on also when there are no active connections. +The :kconfig:`CONFIG_CAF_POWER_MANAGER_STAY_ON` lets the system stay on also when there are no active connections. For more information about configuration options, check the help in the configuration tool. @@ -100,7 +100,7 @@ Error The |power_manager| checks if any application modules have reported an error condition. When any application module switches to the error state (that is, broadcasts :c:enum:`MODULE_STATE_ERROR` through :c:struct:`module_state_event`), the |power_manager| puts the application into the error state. -Then, after the period of time defined by :option:`CONFIG_CAF_POWER_MANAGER_ERROR_TIMEOUT`, it puts the application to the off state. +Then, after the period of time defined by :kconfig:`CONFIG_CAF_POWER_MANAGER_ERROR_TIMEOUT`, it puts the application to the off state. During this period, other modules can report the error condition to the user (for example, :ref:`caf_leds` can keep working in the error state). Restricting power states @@ -128,7 +128,7 @@ Only after all modules confirmed that they have entered the low power state (by If a disconnection happens while the device is in the suspended state, the |power_manager| switches the application to the off state. However, the application can also be configured to keep the system in the suspended state when there are no active connections, instead of switching to the off state. -To select this behavior, use the :option:`CONFIG_CAF_POWER_MANAGER_STAY_ON` configuration option. +To select this behavior, use the :kconfig:`CONFIG_CAF_POWER_MANAGER_STAY_ON` configuration option. Wake-up scenarios ================= diff --git a/include/caf/sensor_sampler.rst b/doc/nrf/libraries/caf/sensor_sampler.rst similarity index 92% rename from include/caf/sensor_sampler.rst rename to doc/nrf/libraries/caf/sensor_sampler.rst index 57af9d7447fe..a38967e7f2d2 100644 --- a/include/caf/sensor_sampler.rst +++ b/doc/nrf/libraries/caf/sensor_sampler.rst @@ -21,16 +21,16 @@ To use the module, you must complete the following requirements: For more information about adding sensor device to devicetree, refer to :ref:`zephyr:use-dt-overlays`. #. Enable the following Kconfig options: - * :option:`CONFIG_CAF_SENSOR_SAMPLER` - This option enables the |sensor_sampler|. - * :option:`CONFIG_SENSOR` - This option enables Zephyr's :ref:`zephyr:sensor_api` driver, which is required for interacting with the sensors. + * :kconfig:`CONFIG_CAF_SENSOR_SAMPLER` - This option enables the |sensor_sampler|. + * :kconfig:`CONFIG_SENSOR` - This option enables Zephyr's :ref:`zephyr:sensor_api` driver, which is required for interacting with the sensors. Additionally, you need to configure the sensor that you want to use in your application and enable it in the sensor Kconfig option. The following Kconfig options are also available for the module: -* :option:`CONFIG_CAF_SENSOR_SAMPLER_DEF_PATH` -* :option:`CONFIG_CAF_SENSOR_SAMPLER_THREAD_STACK_SIZE` -* :option:`CONFIG_CAF_SENSOR_SAMPLER_THREAD_PRIORITY` +* :kconfig:`CONFIG_CAF_SENSOR_SAMPLER_DEF_PATH` +* :kconfig:`CONFIG_CAF_SENSOR_SAMPLER_THREAD_STACK_SIZE` +* :kconfig:`CONFIG_CAF_SENSOR_SAMPLER_THREAD_PRIORITY` Adding module configuration file ================================ @@ -78,7 +78,7 @@ To do so, complete the following steps: }, }; -#. Specify the location of the file with the :option:`CONFIG_CAF_SENSOR_SAMPLER_DEF_PATH` Kconfig option. +#. Specify the location of the file with the :kconfig:`CONFIG_CAF_SENSOR_SAMPLER_DEF_PATH` Kconfig option. .. note:: |only_configured_module_note| @@ -167,11 +167,11 @@ When started, it can do the following operations: The |sensor_sampler| samples sensors periodically, according to the configuration specified for each sensor. Sampling of the sensors is done from a dedicated preemptive thread. -You can change the thread priority by setting the :option:`CONFIG_CAF_SENSOR_SAMPLER_THREAD_PRIORITY` Kconfig option. +You can change the thread priority by setting the :kconfig:`CONFIG_CAF_SENSOR_SAMPLER_THREAD_PRIORITY` Kconfig option. Use the preemptive thread priority to make sure that the thread does not block other operations in the system. The dedicated thread uses its own thread stack. -You can change the size of the stack by setting the :option:`CONFIG_CAF_SENSOR_SAMPLER_THREAD_STACK_SIZE` Kconfig option. +You can change the size of the stack by setting the :kconfig:`CONFIG_CAF_SENSOR_SAMPLER_THREAD_STACK_SIZE` Kconfig option. The thread stack size must be big enough for the sensors used. Sensor state events @@ -187,7 +187,7 @@ Each sensor can be in one of the following states: The following figure shows the possible state transitions. -.. figure:: /images/caf_sensor_states.svg +.. figure:: images/caf_sensor_states.svg :alt: State transitions of the sensors used by the sensor sampler module State transitions of the sensors used by the sensor sampler module diff --git a/include/debug/cpu_load.rst b/doc/nrf/libraries/debug/cpu_load.rst similarity index 98% rename from include/debug/cpu_load.rst rename to doc/nrf/libraries/debug/cpu_load.rst index 3c5d6a7093ae..79b9ba9390f1 100644 --- a/include/debug/cpu_load.rst +++ b/doc/nrf/libraries/debug/cpu_load.rst @@ -17,7 +17,7 @@ To precisely measure the sleep period, the module requires the POWER peripheral The events are connected to a TIMER peripheral using PPI/DPPI. The sleep period is measured using the TIMER peripheral, which is clocked by default by the high frequency clock. -Alternatively, it can be clocked using low frequency clock (see :option:`CONFIG_CPU_LOAD_ALIGNED_CLOCKS`). +Alternatively, it can be clocked using low frequency clock (see :kconfig:`CONFIG_CPU_LOAD_ALIGNED_CLOCKS`). It is then compared against the system clock, which is clocked by the low frequency clock. The accuracy of measurements depends on the accuracy of the given clock sources. diff --git a/doc/nrf/libraries/lib_debug.rst b/doc/nrf/libraries/debug/index.rst similarity index 81% rename from doc/nrf/libraries/lib_debug.rst rename to doc/nrf/libraries/debug/index.rst index 35f6ade1c5a2..121d37e6832d 100644 --- a/doc/nrf/libraries/lib_debug.rst +++ b/doc/nrf/libraries/debug/index.rst @@ -8,4 +8,4 @@ Debug libraries :glob: :caption: Subpages: - ../../include/debug/* + * diff --git a/include/debug/ppi_trace.rst b/doc/nrf/libraries/debug/ppi_trace.rst similarity index 100% rename from include/debug/ppi_trace.rst rename to doc/nrf/libraries/debug/ppi_trace.rst diff --git a/include/dfu/dfu_target.rst b/doc/nrf/libraries/dfu/dfu_target.rst similarity index 94% rename from include/dfu/dfu_target.rst rename to doc/nrf/libraries/dfu/dfu_target.rst index 5e3dc096c8b6..a1ece6d04f35 100644 --- a/include/dfu/dfu_target.rst +++ b/doc/nrf/libraries/dfu/dfu_target.rst @@ -48,7 +48,7 @@ When the complete transfer is done, call the :c:func:`dfu_target_done` function On the next reboot, the device will run the new firmware. .. note:: - To maintain the writing progress in case the device reboots, enable the configuration options :option:`CONFIG_SETTINGS` and :option:`CONFIG_DFU_TARGET_STREAM_SAVE_PROGRESS`. + To maintain the writing progress in case the device reboots, enable the configuration options :kconfig:`CONFIG_SETTINGS` and :kconfig:`CONFIG_DFU_TARGET_STREAM_SAVE_PROGRESS`. The MCUboot target then uses the :ref:`zephyr:settings_api` subsystem in Zephyr to store the current progress used by the :c:func:`dfu_target_write` function across power failures and device resets. @@ -81,9 +81,9 @@ Configuration You can disable support for specific DFU targets with the following parameters: -* :option:`CONFIG_DFU_TARGET_MCUBOOT` -* :option:`CONFIG_DFU_TARGET_MODEM_DELTA` -* :option:`CONFIG_DFU_TARGET_FULL_MODEM` +* :kconfig:`CONFIG_DFU_TARGET_MCUBOOT` +* :kconfig:`CONFIG_DFU_TARGET_MODEM_DELTA` +* :kconfig:`CONFIG_DFU_TARGET_FULL_MODEM` API documentation ***************** diff --git a/include/dfu/fmfu_fdev.rst b/doc/nrf/libraries/dfu/fmfu_fdev.rst similarity index 95% rename from include/dfu/fmfu_fdev.rst rename to doc/nrf/libraries/dfu/fmfu_fdev.rst index a611a83da2b6..7cbf144763d0 100644 --- a/include/dfu/fmfu_fdev.rst +++ b/doc/nrf/libraries/dfu/fmfu_fdev.rst @@ -26,7 +26,7 @@ Serialization The modem firmware is serialized using the following CDDL scheme. -.. literalinclude:: ../../subsys/dfu/fmfu_fdev/cddl/modem_update.cddl +.. literalinclude:: ../../../../subsys/dfu/fmfu_fdev/cddl/modem_update.cddl :language: none The resulting serialized firmware file uses the :file:`.cbor` extension. diff --git a/include/mgmt/fmfu_mgmt.rst b/doc/nrf/libraries/dfu/fmfu_mgmt.rst similarity index 100% rename from include/mgmt/fmfu_mgmt.rst rename to doc/nrf/libraries/dfu/fmfu_mgmt.rst diff --git a/doc/nrf/libraries/lib_dfu.rst b/doc/nrf/libraries/dfu/index.rst similarity index 69% rename from doc/nrf/libraries/lib_dfu.rst rename to doc/nrf/libraries/dfu/index.rst index d0f3e73a3688..a5930ba7d7f0 100644 --- a/doc/nrf/libraries/lib_dfu.rst +++ b/doc/nrf/libraries/dfu/index.rst @@ -8,5 +8,4 @@ DFU libraries :glob: :caption: Subpages: - ../../include/dfu/* - ../../include/mgmt/* + * diff --git a/include/dfu/pcd.rst b/doc/nrf/libraries/dfu/pcd.rst similarity index 100% rename from include/dfu/pcd.rst rename to doc/nrf/libraries/dfu/pcd.rst diff --git a/doc/nrf/libraries.rst b/doc/nrf/libraries/index.rst similarity index 95% rename from doc/nrf/libraries.rst rename to doc/nrf/libraries/index.rst index 78be832058d4..33c377867726 100644 --- a/doc/nrf/libraries.rst +++ b/doc/nrf/libraries/index.rst @@ -12,4 +12,4 @@ Here you can find documentation for these libraries, including API documentation :glob: :caption: Subpages: - libraries/* + */index diff --git a/include/modem/at_cmd.rst b/doc/nrf/libraries/modem/at_cmd.rst similarity index 98% rename from include/modem/at_cmd.rst rename to doc/nrf/libraries/modem/at_cmd.rst index ceb53e74ccfb..bf61ed1b0b27 100644 --- a/include/modem/at_cmd.rst +++ b/doc/nrf/libraries/modem/at_cmd.rst @@ -35,7 +35,7 @@ Data is returned to the user if the return code is OK. In the case of a handler function, the return code is removed and the rest of the string is delivered to the handler function through a char pointer parameter. Allocation and deallocation of the buffer is handled by the AT command interface, and the content should not be considered valid outside of the handler. -Both schemes are limited to the maximum reception size defined by :option:`CONFIG_AT_CMD_RESPONSE_MAX_LEN`. +Both schemes are limited to the maximum reception size defined by :kconfig:`CONFIG_AT_CMD_RESPONSE_MAX_LEN`. Notifications are always handled by a callback function. This callback function is separate from the one that is used to handle data returned immediately after sending a command. diff --git a/include/modem/at_cmd_parser.rst b/doc/nrf/libraries/modem/at_cmd_parser.rst similarity index 100% rename from include/modem/at_cmd_parser.rst rename to doc/nrf/libraries/modem/at_cmd_parser.rst diff --git a/doc/nrf/lib/at_host/lib_at_host.rst b/doc/nrf/libraries/modem/at_host.rst similarity index 57% rename from doc/nrf/lib/at_host/lib_at_host.rst rename to doc/nrf/libraries/modem/at_host.rst index 1a0e3a320169..f7089bff1a68 100644 --- a/doc/nrf/lib/at_host/lib_at_host.rst +++ b/doc/nrf/libraries/modem/at_host.rst @@ -19,23 +19,23 @@ Specifically, if it is desirable for the client to use SMS functionality, the te The various configuration options used in the library are listed below: -* :option:`CONFIG_AT_HOST_LIBRARY` - Enables the AT Host library -* :option:`CONFIG_AT_HOST_UART_INIT_TIMEOUT` - Sets the timeout value to wait for a valid UART line on initialization -* :option:`CONFIG_AT_HOST_CMD_MAX_LEN` - Sets the maximum length for an AT command -* :option:`CONFIG_AT_HOST_THREAD_PRIO` - Sets the priority level for the AT host work queue thread +* :kconfig:`CONFIG_AT_HOST_LIBRARY` - Enables the AT Host library +* :kconfig:`CONFIG_AT_HOST_UART_INIT_TIMEOUT` - Sets the timeout value to wait for a valid UART line on initialization +* :kconfig:`CONFIG_AT_HOST_CMD_MAX_LEN` - Sets the maximum length for an AT command +* :kconfig:`CONFIG_AT_HOST_THREAD_PRIO` - Sets the priority level for the AT host work queue thread Configuration options for setting the UART: -* :option:`CONFIG_AT_HOST_UART_0` - Enables UART 0 -* :option:`CONFIG_AT_HOST_UART_1` - Enables UART 1 -* :option:`CONFIG_AT_HOST_UART_2` - Enables UART 2 +* :kconfig:`CONFIG_AT_HOST_UART_0` - Enables UART 0 +* :kconfig:`CONFIG_AT_HOST_UART_1` - Enables UART 1 +* :kconfig:`CONFIG_AT_HOST_UART_2` - Enables UART 2 Configuration options for setting the termination character: -* :option:`CONFIG_NULL_TERMINATION` - Enables ```` as the termination character -* :option:`CONFIG_CR_TERMINATION` - Enables ```` as the termination character -* :option:`CONFIG_LF_TERMINATION` - Enables ```` as the termination character -* :option:`CONFIG_CR_LF_TERMINATION` - Enables ```` as the termination character +* :kconfig:`CONFIG_NULL_TERMINATION` - Enables ```` as the termination character +* :kconfig:`CONFIG_CR_TERMINATION` - Enables ```` as the termination character +* :kconfig:`CONFIG_LF_TERMINATION` - Enables ```` as the termination character +* :kconfig:`CONFIG_CR_LF_TERMINATION` - Enables ```` as the termination character Usage ***** diff --git a/include/modem/at_monitor.rst b/doc/nrf/libraries/modem/at_monitor.rst similarity index 99% rename from include/modem/at_monitor.rst rename to doc/nrf/libraries/modem/at_monitor.rst index c5e3b0f9418b..26164c7350c7 100644 --- a/include/modem/at_monitor.rst +++ b/doc/nrf/libraries/modem/at_monitor.rst @@ -32,7 +32,7 @@ Initialization The application can initialize the AT monitor library in the following ways: * Manually by using the :c:func:`at_monitor_init` function. -* Automatically by using the ``SYS_INIT`` macro and by enabling :option:`CONFIG_AT_MONITOR_SYS_INIT`. +* Automatically by using the ``SYS_INIT`` macro and by enabling :kconfig:`CONFIG_AT_MONITOR_SYS_INIT`. Upon initialization, the AT monitor library registers itself as the receiver of AT notifications from the Modem library (using :c:func:`nrf_modem_at_notif_handler_set`). diff --git a/include/modem/at_notif.rst b/doc/nrf/libraries/modem/at_notif.rst similarity index 100% rename from include/modem/at_notif.rst rename to doc/nrf/libraries/modem/at_notif.rst diff --git a/include/modem/at_params.rst b/doc/nrf/libraries/modem/at_params.rst similarity index 100% rename from include/modem/at_params.rst rename to doc/nrf/libraries/modem/at_params.rst diff --git a/doc/nrf/libraries/lib_modem.rst b/doc/nrf/libraries/modem/index.rst similarity index 62% rename from doc/nrf/libraries/lib_modem.rst rename to doc/nrf/libraries/modem/index.rst index 623ae992873c..0bc669519e2b 100644 --- a/doc/nrf/libraries/lib_modem.rst +++ b/doc/nrf/libraries/modem/index.rst @@ -8,6 +8,4 @@ Modem libraries :glob: :caption: Subpages: - ../../include/modem/* - ../../lib/zzhc/* - ../../lib/at_host/* + * diff --git a/include/modem/lte_lc.rst b/doc/nrf/libraries/modem/lte_lc.rst similarity index 93% rename from include/modem/lte_lc.rst rename to doc/nrf/libraries/modem/lte_lc.rst index 5dd97481fdf7..0a22c2045e20 100644 --- a/include/modem/lte_lc.rst +++ b/doc/nrf/libraries/modem/lte_lc.rst @@ -16,7 +16,7 @@ The library also provides functionality that enables the application to receive Configuration ************* -To enable the link controller library, set the option :option:`CONFIG_LTE_LINK_CONTROL` option to ``y`` in the project configuration file :file:`prj.conf`. +To enable the link controller library, set the option :kconfig:`CONFIG_LTE_LINK_CONTROL` option to ``y`` in the project configuration file :file:`prj.conf`. Establishing an LTE connection ============================== @@ -99,7 +99,7 @@ The following list mentions some of the information that can be extracted from t To check if a desired feature is compatible with a certain modem firmware version, see nRF9160 `AT Commands Reference Guide`_. The library supports an auto initialization and connection feature that enables the library to initialize and connect to LTE prior to the start of the application. -To enable this feature, set the configuration option :option:`CONFIG_LTE_AUTO_INIT_AND_CONNECT` to ``y``. +To enable this feature, set the configuration option :kconfig:`CONFIG_LTE_AUTO_INIT_AND_CONNECT` to ``y``. If you enable this option, you need not run additional library APIs. Enabling power-saving features @@ -149,10 +149,10 @@ This saves the overhead related to the additional packet exchange. The timer values requested by the modem can be configured with the following options and API calls: -* :option:`CONFIG_LTE_PSM_REQ_RPTAU` -* :option:`CONFIG_LTE_PSM_REQ_RAT` -* :option:`CONFIG_LTE_EDRX_REQ_VALUE_LTE_M` -* :option:`CONFIG_LTE_EDRX_REQ_VALUE_NBIOT` +* :kconfig:`CONFIG_LTE_PSM_REQ_RPTAU` +* :kconfig:`CONFIG_LTE_PSM_REQ_RAT` +* :kconfig:`CONFIG_LTE_EDRX_REQ_VALUE_LTE_M` +* :kconfig:`CONFIG_LTE_EDRX_REQ_VALUE_NBIOT` * :c:func:`lte_lc_psm_param_set` * :c:func:`lte_lc_edrx_param_set` @@ -214,8 +214,8 @@ For instance, TAU pre-warning notifications can be used to schedule data transfe Modem sleep notifications can be used to schedule processing in the same operational window as the modem to limit the overall computation time of the nRF9160 SiP. To enable modem sleep and TAU pre-warning notifications, enable the following options: -* :option:`CONFIG_LTE_LC_MODEM_SLEEP_NOTIFICATIONS` -* :option:`CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS` +* :kconfig:`CONFIG_LTE_LC_MODEM_SLEEP_NOTIFICATIONS` +* :kconfig:`CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS` Additional configurations related to these features can be found in the API documentation for the link controller. diff --git a/include/modem/modem_attest_token.rst b/doc/nrf/libraries/modem/modem_attest_token.rst similarity index 92% rename from include/modem/modem_attest_token.rst rename to doc/nrf/libraries/modem/modem_attest_token.rst index 4e22ccde9978..44c6696d4869 100644 --- a/include/modem/modem_attest_token.rst +++ b/doc/nrf/libraries/modem/modem_attest_token.rst @@ -21,7 +21,7 @@ To use the library to obtain the attestation token, complete the following steps * Enable the Modem attestation token library. * Initialize the :ref:`nrf_modem_lib_readme` and :ref:`at_cmd_parser_readme` libraries. * Call the :c:func:`modem_attest_token_get` function to obtain the two base64url strings in the :c:struct:`nrf_attestation_token` structure. -* Enable token parsing (:option:`CONFIG_MODEM_ATTEST_TOKEN_PARSING`). +* Enable token parsing (:kconfig:`CONFIG_MODEM_ATTEST_TOKEN_PARSING`). * Call the :c:func:`modem_attest_token_parse` function to parse the token. The function :c:func:`modem_attest_token_parse` parses :c:struct:`nrf_attestation_token` and populates the :c:struct:`nrf_attestation_data` structure with the data. @@ -32,8 +32,8 @@ Configuration Configure the following options when using this library: -* :option:`CONFIG_MODEM_ATTEST_TOKEN` -* :option:`CONFIG_MODEM_ATTEST_TOKEN_PARSING` +* :kconfig:`CONFIG_MODEM_ATTEST_TOKEN` +* :kconfig:`CONFIG_MODEM_ATTEST_TOKEN_PARSING` API documentation ***************** diff --git a/include/modem/modem_info.rst b/doc/nrf/libraries/modem/modem_info.rst similarity index 100% rename from include/modem/modem_info.rst rename to doc/nrf/libraries/modem/modem_info.rst diff --git a/include/modem/modem_jwt.rst b/doc/nrf/libraries/modem/modem_jwt.rst similarity index 96% rename from include/modem/modem_jwt.rst rename to doc/nrf/libraries/modem/modem_jwt.rst index 236865cdcfe9..b0e9b5d27d02 100644 --- a/include/modem/modem_jwt.rst +++ b/doc/nrf/libraries/modem/modem_jwt.rst @@ -33,8 +33,8 @@ Configuration Configure the following options when using the library: -* :option:`CONFIG_MODEM_JWT` -* :option:`CONFIG_MODEM_JWT_MAX_LEN` +* :kconfig:`CONFIG_MODEM_JWT` +* :kconfig:`CONFIG_MODEM_JWT_MAX_LEN` API documentation ***************** diff --git a/include/modem/modem_key_mgmt.rst b/doc/nrf/libraries/modem/modem_key_mgmt.rst similarity index 96% rename from include/modem/modem_key_mgmt.rst rename to doc/nrf/libraries/modem/modem_key_mgmt.rst index d112a975503f..1603f142a158 100644 --- a/include/modem/modem_key_mgmt.rst +++ b/doc/nrf/libraries/modem/modem_key_mgmt.rst @@ -21,7 +21,7 @@ See :ref:`nrfxlib:security_tags` for more information about how security tags ar .. important:: Security credentials usually exceed the default AT command response length. - Therefore, you must set :option:`CONFIG_AT_CMD_RESPONSE_MAX_LEN` to a sufficiently high value when using this library. + Therefore, you must set :kconfig:`CONFIG_AT_CMD_RESPONSE_MAX_LEN` to a sufficiently high value when using this library. .. _cert_dwload: diff --git a/include/modem/nrf_modem_lib.rst b/doc/nrf/libraries/modem/nrf_modem_lib.rst similarity index 90% rename from include/modem/nrf_modem_lib.rst rename to doc/nrf/libraries/modem/nrf_modem_lib.rst index 6404af84fae3..71f8768a781e 100644 --- a/include/modem/nrf_modem_lib.rst +++ b/doc/nrf/libraries/modem/nrf_modem_lib.rst @@ -24,7 +24,7 @@ The library wrapper eases the task of initializing the Modem library by automati For more information, see :ref:`partition_mgr_integration`. The library wrapper can also initialize the Modem library during system initialization using :c:macro:`SYS_INIT`. -The :option:`CONFIG_NRF_MODEM_LIB_SYS_INIT` Kconfig option can be used to control the initialization. +The :kconfig:`CONFIG_NRF_MODEM_LIB_SYS_INIT` Kconfig option can be used to control the initialization. Some libraries in |NCS|, such as the :ref:`at_cmd_readme` and the :ref:`lte_lc_readme` have similar configuration options to initialize during system initialization and these options depend on the configuration option of the integration layer. If your application performs an update of the nRF9160 modem firmware, you must disable this functionality to have full control on the initialization of the library. @@ -45,7 +45,7 @@ Modem library socket API sets errnos as defined in :file:`nrf_errno.h`. The socket offloading support in the integration layer in |NCS| converts those errnos to the errnos that adhere to the selected C library implementation. The socket offloading functionality is enabled by default. -To disable the functionality, set the :option:`CONFIG_NET_SOCKETS_OFFLOAD` Kconfig option to ``n`` in your project configuration. +To disable the functionality, set the :kconfig:`CONFIG_NET_SOCKETS_OFFLOAD` Kconfig option to ``n`` in your project configuration. If you disable the socket offloading functionality, the socket calls will no longer be offloaded to the nRF9160 modem firmware. Instead, the calls will be relayed to the native Zephyr TCP/IP implementation. This can be useful to switch between an emulator and a real device while running networking code on these devices. @@ -84,12 +84,12 @@ The RAM area that the Modem library shares with the nRF9160 modem core is divide The size of the RX, TX and the Trace regions can be configured by the following Kconfig options of the integration layer: -* :option:`CONFIG_NRF_MODEM_LIB_SHMEM_RX_SIZE` for the RX region -* :option:`CONFIG_NRF_MODEM_LIB_SHMEM_TX_SIZE` for the TX region -* :option:`CONFIG_NRF_MODEM_LIB_SHMEM_TRACE_SIZE` for the Trace region +* :kconfig:`CONFIG_NRF_MODEM_LIB_SHMEM_RX_SIZE` for the RX region +* :kconfig:`CONFIG_NRF_MODEM_LIB_SHMEM_TX_SIZE` for the TX region +* :kconfig:`CONFIG_NRF_MODEM_LIB_SHMEM_TRACE_SIZE` for the Trace region The size of the Control region is fixed. -The Modem library exports the size value through :option:`CONFIG_NRF_MODEM_SHMEM_CTRL_SIZE`. +The Modem library exports the size value through :kconfig:`CONFIG_NRF_MODEM_SHMEM_CTRL_SIZE`. This value is automatically passed by the integration layer to the library during the initialization through :c:func:`nrf_modem_lib_init`. When the application is built using CMake, the :ref:`partition_manager` automatically reads the Kconfig options of the integration layer. @@ -116,10 +116,10 @@ Diagnostic functionality ************************ The Modem library integration layer in |NCS| provides some diagnostic functionalities to log the allocations on the Modem library heap and the TX memory region. -These functionalities can be turned on by the :option:`CONFIG_NRF_MODEM_LIB_DEBUG_ALLOC` and :option:`CONFIG_NRF_MODEM_LIB_DEBUG_SHM_TX_ALLOC` options. +These functionalities can be turned on by the :kconfig:`CONFIG_NRF_MODEM_LIB_DEBUG_ALLOC` and :kconfig:`CONFIG_NRF_MODEM_LIB_DEBUG_SHM_TX_ALLOC` options. The contents of both the Modem library heap and the TX memory region can be examined through the :c:func:`nrf_modem_lib_heap_diagnose` and :c:func:`nrf_modem_lib_shm_tx_diagnose` functions, respectively. -Additionally, it is possible to schedule a periodic report of the contents of these two areas of memory by using the :option:`CONFIG_NRF_MODEM_LIB_HEAP_DUMP_PERIODIC` and :option:`CONFIG_NRF_MODEM_LIB_SHM_TX_DUMP_PERIODIC` options, respectively. +Additionally, it is possible to schedule a periodic report of the contents of these two areas of memory by using the :kconfig:`CONFIG_NRF_MODEM_LIB_HEAP_DUMP_PERIODIC` and :kconfig:`CONFIG_NRF_MODEM_LIB_SHM_TX_DUMP_PERIODIC` options, respectively. The report will be printed by a dedicated work queue that is distinct from the system work queue at configurable time intervals. API documentation diff --git a/include/modem/pdn.rst b/doc/nrf/libraries/modem/pdn.rst similarity index 95% rename from include/modem/pdn.rst rename to doc/nrf/libraries/modem/pdn.rst index c566a4546af4..89301089d10c 100644 --- a/include/modem/pdn.rst +++ b/doc/nrf/libraries/modem/pdn.rst @@ -41,8 +41,8 @@ Multiple PDP contexts might share the same PDN connection if they are configured The library requires the following Kconfig options to be set to ``y``: -* :option:`CONFIG_AT_CMD` -* :option:`CONFIG_AT_NOTIF` +* :kconfig:`CONFIG_AT_CMD` +* :kconfig:`CONFIG_AT_NOTIF` Configuration ************* @@ -54,7 +54,7 @@ The default PDP context configuration consists of the following parameters: * Authentication method * Authentication credentials -The PDN library can override the default PDP context configuration by using the :option:`CONFIG_PDN_DEFAULTS_OVERRIDE` Kconfig option. +The PDN library can override the default PDP context configuration by using the :kconfig:`CONFIG_PDN_DEFAULTS_OVERRIDE` Kconfig option. Limitations *********** diff --git a/include/modem/sms.rst b/doc/nrf/libraries/modem/sms.rst similarity index 78% rename from include/modem/sms.rst rename to doc/nrf/libraries/modem/sms.rst index 038c70685bdf..2a5e85e0af94 100644 --- a/include/modem/sms.rst +++ b/doc/nrf/libraries/modem/sms.rst @@ -31,9 +31,9 @@ Configuration Configure the following Kconfig options when using this library: -* :option:`CONFIG_SMS` - Enables the SMS subscriber library. -* :option:`CONFIG_SMS_SUBSCRIBERS_MAX_CNT` - Sets the maximum number of SMS subscribers. -* :option:`CONFIG_AT_CMD_RESPONSE_MAX_LEN` - Defines the maximum size of the AT command response, which might limit the size of the received SMS message. Values over 512 bytes will not restrict the size of the received message as the maximum data length of the SMS is 140 bytes. This parameter is defined in the :ref:`at_cmd_readme` module. +* :kconfig:`CONFIG_SMS` - Enables the SMS subscriber library. +* :kconfig:`CONFIG_SMS_SUBSCRIBERS_MAX_CNT` - Sets the maximum number of SMS subscribers. +* :kconfig:`CONFIG_AT_CMD_RESPONSE_MAX_LEN` - Defines the maximum size of the AT command response, which might limit the size of the received SMS message. Values over 512 bytes will not restrict the size of the received message as the maximum data length of the SMS is 140 bytes. This parameter is defined in the :ref:`at_cmd_readme` module. Limitations *********** diff --git a/doc/nrf/lib/zzhc/zzhc.rst b/doc/nrf/libraries/modem/zzhc.rst similarity index 77% rename from doc/nrf/lib/zzhc/zzhc.rst rename to doc/nrf/libraries/modem/zzhc.rst index 54efc8ea5f3a..bca24fc9c88b 100644 --- a/doc/nrf/lib/zzhc/zzhc.rst +++ b/doc/nrf/libraries/modem/zzhc.rst @@ -38,30 +38,30 @@ Enabling the ZZHC library To enable the ZZHC library, edit the :file:`prj.conf` file according to the following steps: -1. Set :option:`CONFIG_ZZHC` to ``y``. +1. Set :kconfig:`CONFIG_ZZHC` to ``y``. This option enables the ZZHC library and ensures that China Telecom can approve the end product. The following required options are automatically selected when the ZZHC library is enabled: - * :option:`CONFIG_NRF_MODEM_LIB` - * :option:`CONFIG_SETTINGS` - * :option:`CONFIG_AT_CMD` - * :option:`CONFIG_AT_CMD_PARSER` - * :option:`CONFIG_AT_NOTIF` - * :option:`CONFIG_BASE64` - * :option:`CONFIG_JSON_LIBRARY` + * :kconfig:`CONFIG_NRF_MODEM_LIB` + * :kconfig:`CONFIG_SETTINGS` + * :kconfig:`CONFIG_AT_CMD` + * :kconfig:`CONFIG_AT_CMD_PARSER` + * :kconfig:`CONFIG_AT_NOTIF` + * :kconfig:`CONFIG_BASE64` + * :kconfig:`CONFIG_JSON_LIBRARY` -#. Set :option:`CONFIG_TRUSTED_EXECUTION_NONSECURE` to ``y``. +#. Set :kconfig:`CONFIG_TRUSTED_EXECUTION_NONSECURE` to ``y``. This option enables the Trusted Execution: Non-Secure firmware image. The ZZHC library only works when this option is enabled. -#. Set :option:`CONFIG_HEAP_MEM_POOL_SIZE` to the minimum heap size required (2560 bytes): ``CONFIG_HEAP_MEM_POOL_SIZE=2560``. -#. Set the following options required by :option:`CONFIG_NRF_MODEM_LIB`: +#. Set :kconfig:`CONFIG_HEAP_MEM_POOL_SIZE` to the minimum heap size required (2560 bytes): ``CONFIG_HEAP_MEM_POOL_SIZE=2560``. +#. Set the following options required by :kconfig:`CONFIG_NRF_MODEM_LIB`: * ``CONFIG_NETWORKING=y`` * ``CONFIG_NET_NATIVE=n`` * ``CONFIG_NET_SOCKETS=y`` * ``CONFIG_NET_SOCKETS_OFFLOAD=y`` -#. Set the following options required by :option:`CONFIG_SETTINGS`: +#. Set the following options required by :kconfig:`CONFIG_SETTINGS`: * ``CONFIG_FLASH=y`` * ``CONFIG_FLASH_PAGE_LAYOUT=y`` @@ -75,8 +75,8 @@ Configuring additional thread behavior You can configure the thread behavior using the following Kconfig options: -* To adjust the stack size for the thread, change :option:`CONFIG_ZZHC_STACK_SIZE`. -* To adjust the thread priority, change :option:`CONFIG_ZZHC_THREAD_PRIO`. +* To adjust the stack size for the thread, change :kconfig:`CONFIG_ZZHC_STACK_SIZE`. +* To adjust the thread priority, change :kconfig:`CONFIG_ZZHC_THREAD_PRIO`. Allowing for automatic registration to LTE-M or NB-IoT on boot -------------------------------------------------------------- diff --git a/doc/nrf/libraries/lib_mpsl.rst b/doc/nrf/libraries/mpsl/index.rst similarity index 87% rename from doc/nrf/libraries/lib_mpsl.rst rename to doc/nrf/libraries/mpsl/index.rst index 4c77692f57b6..910f63d21237 100644 --- a/doc/nrf/libraries/lib_mpsl.rst +++ b/doc/nrf/libraries/mpsl/index.rst @@ -8,4 +8,4 @@ Multiprotocol Service Layer libraries :caption: Subpages: :glob: - ../../include/mpsl/* + * diff --git a/include/mpsl/mpsl_assert.rst b/doc/nrf/libraries/mpsl/mpsl_assert.rst similarity index 90% rename from include/mpsl/mpsl_assert.rst rename to doc/nrf/libraries/mpsl/mpsl_assert.rst index 296349fade96..4d61999d0558 100644 --- a/include/mpsl/mpsl_assert.rst +++ b/doc/nrf/libraries/mpsl/mpsl_assert.rst @@ -10,7 +10,7 @@ Multiprotocol Service Layer assert The Multiprotocol Service Layer assert library makes it possible to add a custom assert handler to the :ref:`nrfxlib:mpsl` library. You can then use this assert handler to print custom error messages or log assert information. -:option:`CONFIG_MPSL_ASSERT_HANDLER` enables the custom assert handler. +:kconfig:`CONFIG_MPSL_ASSERT_HANDLER` enables the custom assert handler. If enabled, the application must provide the definition of :c:func:`mpsl_assert_handle`. The :c:func:`mpsl_assert_handle` function is invoked whenever the MPSL code encounters an unrecoverable error. diff --git a/include/net/aws_fota.rst b/doc/nrf/libraries/networking/aws_fota.rst similarity index 93% rename from include/net/aws_fota.rst rename to doc/nrf/libraries/networking/aws_fota.rst index 08b539eeeee3..facd6bad1b56 100644 --- a/include/net/aws_fota.rst +++ b/doc/nrf/libraries/networking/aws_fota.rst @@ -29,9 +29,9 @@ Configuration Configure the following parameters when using this library: -* :option:`CONFIG_AWS_FOTA_PAYLOAD_SIZE` -* :option:`CONFIG_AWS_FOTA_HOSTNAME_MAX_LEN` -* :option:`CONFIG_AWS_FOTA_FILE_PATH_MAX_LEN` +* :kconfig:`CONFIG_AWS_FOTA_PAYLOAD_SIZE` +* :kconfig:`CONFIG_AWS_FOTA_HOSTNAME_MAX_LEN` +* :kconfig:`CONFIG_AWS_FOTA_FILE_PATH_MAX_LEN` Implementation @@ -39,7 +39,7 @@ Implementation The following sequence diagram shows how a firmware over-the-air update is implemented through the use of `AWS IoT MQTT`_, `AWS IoT jobs`_, and `AWS Simple Storage Service (S3)`_. -.. figure:: /images/aws_fota_dfu_sequence.svg +.. figure:: images/aws_fota_dfu_sequence.svg :alt: AWS FOTA sequence diagram for doing FOTA through AWS jobs diff --git a/include/net/aws_iot.rst b/doc/nrf/libraries/networking/aws_iot.rst similarity index 78% rename from include/net/aws_iot.rst rename to doc/nrf/libraries/networking/aws_iot.rst index 6deca97266d6..e14d2f1d45aa 100644 --- a/include/net/aws_iot.rst +++ b/doc/nrf/libraries/networking/aws_iot.rst @@ -56,46 +56,46 @@ Configuring the required library options To establish a connection to the AWS IoT message broker, set the following options: -* :option:`CONFIG_AWS_IOT_SEC_TAG` -* :option:`CONFIG_AWS_IOT_BROKER_HOST_NAME` -* :option:`CONFIG_AWS_IOT_CLIENT_ID_STATIC` +* :kconfig:`CONFIG_AWS_IOT_SEC_TAG` +* :kconfig:`CONFIG_AWS_IOT_BROKER_HOST_NAME` +* :kconfig:`CONFIG_AWS_IOT_CLIENT_ID_STATIC` To configure the required library options, complete the following steps: 1. In the `AWS IoT console`_, navigate to :guilabel:`IoT core` > :guilabel:`Manage` > :guilabel:`things` and click on the entry for the *thing* created during the steps of :ref:`creating_a_thing_in_AWS_IoT`. -#. Navigate to :guilabel:`interact`, find the ``Rest API Endpoint`` and set the configurable option :option:`CONFIG_AWS_IOT_BROKER_HOST_NAME` to this address string. -#. Set the option :option:`CONFIG_AWS_IOT_CLIENT_ID_STATIC` to the name of the *thing* created during the aforementioned steps. -#. Set the security tag configuration :option:`CONFIG_AWS_IOT_SEC_TAG` to the security tag, chosen while `Programming the certificates to the on-board modem of the nRF9160-based kit`_. +#. Navigate to :guilabel:`interact`, find the ``Rest API Endpoint`` and set the configurable option :kconfig:`CONFIG_AWS_IOT_BROKER_HOST_NAME` to this address string. +#. Set the option :kconfig:`CONFIG_AWS_IOT_CLIENT_ID_STATIC` to the name of the *thing* created during the aforementioned steps. +#. Set the security tag configuration :kconfig:`CONFIG_AWS_IOT_SEC_TAG` to the security tag, chosen while `Programming the certificates to the on-board modem of the nRF9160-based kit`_. Configuring the optional library options ======================================== To subscribe to the various `AWS IoT Device Shadow Topics`_, set the following options: -* :option:`CONFIG_AWS_IOT_TOPIC_GET_ACCEPTED_SUBSCRIBE` -* :option:`CONFIG_AWS_IOT_TOPIC_GET_REJECTED_SUBSCRIBE` -* :option:`CONFIG_AWS_IOT_TOPIC_UPDATE_ACCEPTED_SUBSCRIBE` -* :option:`CONFIG_AWS_IOT_TOPIC_UPDATE_REJECTED_SUBSCRIBE` -* :option:`CONFIG_AWS_IOT_TOPIC_UPDATE_DELTA_SUBSCRIBE` -* :option:`CONFIG_AWS_IOT_TOPIC_DELETE_ACCEPTED_SUBSCRIBE` -* :option:`CONFIG_AWS_IOT_TOPIC_DELETE_REJECTED_SUBSCRIBE` +* :kconfig:`CONFIG_AWS_IOT_TOPIC_GET_ACCEPTED_SUBSCRIBE` +* :kconfig:`CONFIG_AWS_IOT_TOPIC_GET_REJECTED_SUBSCRIBE` +* :kconfig:`CONFIG_AWS_IOT_TOPIC_UPDATE_ACCEPTED_SUBSCRIBE` +* :kconfig:`CONFIG_AWS_IOT_TOPIC_UPDATE_REJECTED_SUBSCRIBE` +* :kconfig:`CONFIG_AWS_IOT_TOPIC_UPDATE_DELTA_SUBSCRIBE` +* :kconfig:`CONFIG_AWS_IOT_TOPIC_DELETE_ACCEPTED_SUBSCRIBE` +* :kconfig:`CONFIG_AWS_IOT_TOPIC_DELETE_REJECTED_SUBSCRIBE` To subscribe to non-AWS specific topics, complete the following steps: -* Specify the number of additional topics that needs to be subscribed to, by setting the :option:`CONFIG_AWS_IOT_APP_SUBSCRIPTION_LIST_COUNT` option +* Specify the number of additional topics that needs to be subscribed to, by setting the :kconfig:`CONFIG_AWS_IOT_APP_SUBSCRIPTION_LIST_COUNT` option * Pass a list containing application specific topics in the :c:func:`aws_iot_subscription_topics_add` function, after the :c:func:`aws_iot_init` function call and before the :c:func:`aws_iot_connect` function call The AWS IoT library also supports passing in the client ID at run time. To enable this feature, set the ``client_id`` entry in the :c:struct:`aws_iot_config` structure that is passed in the :c:func:`aws_iot_init` function when initializing the library, and set the following option: -* :option:`CONFIG_AWS_IOT_CLIENT_ID_APP` +* :kconfig:`CONFIG_AWS_IOT_CLIENT_ID_APP` .. note:: - If you are using a longer device ID that is either set by the option :option:`CONFIG_AWS_IOT_CLIENT_ID_STATIC` or passed in during initialization, it might be required to increase the value of the option :option:`CONFIG_AWS_IOT_CLIENT_ID_MAX_LEN` for proper initialization of the library. + If you are using a longer device ID that is either set by the option :kconfig:`CONFIG_AWS_IOT_CLIENT_ID_STATIC` or passed in during initialization, it might be required to increase the value of the option :kconfig:`CONFIG_AWS_IOT_CLIENT_ID_MAX_LEN` for proper initialization of the library. .. note:: The AWS IoT library is compatible with the :ref:`cloud_api_readme`, a generic API that enables multiple cloud backends to be interchanged, statically and at run time. - To enable the use of the cloud, API set the configurable option :option:`CONFIG_CLOUD_API`, in addition to the other selected library options. + To enable the use of the cloud, API set the configurable option :kconfig:`CONFIG_CLOUD_API`, in addition to the other selected library options. Initializing the library ************************ diff --git a/include/net/aws_jobs.rst b/doc/nrf/libraries/networking/aws_jobs.rst similarity index 95% rename from include/net/aws_jobs.rst rename to doc/nrf/libraries/networking/aws_jobs.rst index 755e307f8c25..a46890c872c8 100644 --- a/include/net/aws_jobs.rst +++ b/doc/nrf/libraries/networking/aws_jobs.rst @@ -24,7 +24,7 @@ Configuration Configure the following parameters when using this library: -* :option:`CONFIG_UPDATE_JOB_PAYLOAD_LEN` +* :kconfig:`CONFIG_UPDATE_JOB_PAYLOAD_LEN` API documentation diff --git a/include/net/azure_fota.rst b/doc/nrf/libraries/networking/azure_fota.rst similarity index 70% rename from include/net/azure_fota.rst rename to doc/nrf/libraries/networking/azure_fota.rst index cee2b100399c..e20852a998e6 100644 --- a/include/net/azure_fota.rst +++ b/doc/nrf/libraries/networking/azure_fota.rst @@ -33,7 +33,7 @@ The library uses ``fwVersion`` to determine whether the firmware should be downl Currently, a new version of the firmware is downloaded and applied only if the version is different from the current firmware version. Currently, the library does not use the ``protocol`` field. -Instead, the :option:`CONFIG_AZURE_FOTA_TLS` option is used at compile time to specify if HTTPS should be used as the transport protocol. +Instead, the :kconfig:`CONFIG_AZURE_FOTA_TLS` option is used at compile time to specify if HTTPS should be used as the transport protocol. The ``fwFragmentSize`` field specifies the maximum fragment size for the file that should be downloaded in each HTTP request. Below are the maximum total fragment sizes in different scenarios: @@ -53,12 +53,12 @@ Configuration Configure the following parameters when using this library: -* :option:`CONFIG_AZURE_FOTA_APP_VERSION` - Defines the application version string. Indicates the current firmware version on the development kit. -* :option:`CONFIG_AZURE_FOTA_APP_VERSION_AUTO` - Automatically generates the application version. If enabled, :option:`CONFIG_AZURE_FOTA_APP_VERSION` is ignored. -* :option:`CONFIG_AZURE_FOTA_TLS` - Enables HTTPS for downloads. By default, TLS is enabled and currently, the transport protocol must be configured at compile time. -* :option:`CONFIG_AZURE_FOTA_SEC_TAG` - Sets the security tag for TLS credentials when using HTTPS as the transport layer. See :ref:`azure_iot_hub_flash_certs` for more details. -* :option:`CONFIG_AZURE_FOTA_HOSTNAME_MAX_LEN` - Sets the host name buffer size. -* :option:`CONFIG_AZURE_FOTA_FILE_PATH_MAX_LEN` - Sets the file path buffer size. +* :kconfig:`CONFIG_AZURE_FOTA_APP_VERSION` - Defines the application version string. Indicates the current firmware version on the development kit. +* :kconfig:`CONFIG_AZURE_FOTA_APP_VERSION_AUTO` - Automatically generates the application version. If enabled, :kconfig:`CONFIG_AZURE_FOTA_APP_VERSION` is ignored. +* :kconfig:`CONFIG_AZURE_FOTA_TLS` - Enables HTTPS for downloads. By default, TLS is enabled and currently, the transport protocol must be configured at compile time. +* :kconfig:`CONFIG_AZURE_FOTA_SEC_TAG` - Sets the security tag for TLS credentials when using HTTPS as the transport layer. See :ref:`azure_iot_hub_flash_certs` for more details. +* :kconfig:`CONFIG_AZURE_FOTA_HOSTNAME_MAX_LEN` - Sets the host name buffer size. +* :kconfig:`CONFIG_AZURE_FOTA_FILE_PATH_MAX_LEN` - Sets the file path buffer size. Limitations diff --git a/include/net/azure_iot_hub.rst b/doc/nrf/libraries/networking/azure_iot_hub.rst similarity index 78% rename from include/net/azure_iot_hub.rst rename to doc/nrf/libraries/networking/azure_iot_hub.rst index 3047250d9947..a7396b51bc72 100644 --- a/include/net/azure_iot_hub.rst +++ b/doc/nrf/libraries/networking/azure_iot_hub.rst @@ -55,7 +55,7 @@ To provision the certificates and the private key to the nRF9160 modem, complete #. Select a desired security tag (any positive integer, for example, ``42``) and click :guilabel:`Update certificates`. .. note:: - The chosen security tag while provisioning the certificates must be same as the security tag configured by the :option:`CONFIG_AZURE_IOT_HUB_SEC_TAG` option. + The chosen security tag while provisioning the certificates must be same as the security tag configured by the :kconfig:`CONFIG_AZURE_IOT_HUB_SEC_TAG` option. Configuring the library @@ -69,9 +69,9 @@ Configuration without using DPS To connect to Azure IoT Hub without using DPS, complete the following minimum required configuration: 1. In the `Azure Portal`_, navigate to :guilabel:`IoT Hub` and select the desired IoT hub. -#. In the overview page, locate and copy the ``Hostname`` and configure :option:`CONFIG_AZURE_IOT_HUB_HOSTNAME` to this address. -#. Set the option :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` to the device ID. The device ID must match the device ID used while creating the certificates. -#. Set :option:`CONFIG_AZURE_IOT_HUB_SEC_TAG` to the security tag used in :ref:`azure_iot_hub_flash_certs`. +#. In the overview page, locate and copy the ``Hostname`` and configure :kconfig:`CONFIG_AZURE_IOT_HUB_HOSTNAME` to this address. +#. Set the option :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` to the device ID. The device ID must match the device ID used while creating the certificates. +#. Set :kconfig:`CONFIG_AZURE_IOT_HUB_SEC_TAG` to the security tag used in :ref:`azure_iot_hub_flash_certs`. .. _dps_config: @@ -84,11 +84,11 @@ To connect to Azure IoT Hub using DPS, complete the following steps: 1. `Set up an Azure IoT Hub Device Provisioning Service (DPS) instance`_ and obtain the ID scope. #. `Add certificates to the DPS instance`_. #. Create an *enrollment group* as described in `Device enrollments with Azure Portal`_ and link it to your IoT hub. Select the certificate added in the previous step as the *Primary certificate​​​​​​​*. -#. Enable :option:`CONFIG_AZURE_IOT_HUB_DPS`. +#. Enable :kconfig:`CONFIG_AZURE_IOT_HUB_DPS`. #. In the `Azure Portal`_, click :guilabel:`Device Provisioning Services` and select the DPS instance to use. -#. In the overview page, locate and copy the ``ID Scope`` and configure :option:`CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE` to this string. -#. Set the :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` option to device ID, unless :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` is enabled. The device ID must match the device ID used while creating the certificates. -#. Set :option:`CONFIG_AZURE_IOT_HUB_SEC_TAG` to the security tag used while :ref:`azure_iot_hub_flash_certs`. +#. In the overview page, locate and copy the ``ID Scope`` and configure :kconfig:`CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE` to this string. +#. Set the :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` option to device ID, unless :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` is enabled. The device ID must match the device ID used while creating the certificates. +#. Set :kconfig:`CONFIG_AZURE_IOT_HUB_SEC_TAG` to the security tag used while :ref:`azure_iot_hub_flash_certs`. Initializing the library @@ -96,9 +96,9 @@ Initializing the library The library is initialized by calling the :c:func:`azure_iot_hub_init` function. If the initialization fails, the application cannot use any APIs of the library. -Optionally, you can enable :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` and include a pointer to the :c:struct:`azure_iot_hub_config` structure containing the device ID in the :c:func:`azure_iot_hub_init` function call. +Optionally, you can enable :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` and include a pointer to the :c:struct:`azure_iot_hub_config` structure containing the device ID in the :c:func:`azure_iot_hub_init` function call. -Below is an example for setting the device ID at run time instead of compile time by configuring the :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` option: +Below is an example for setting the device ID at run time instead of compile time by configuring the :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` option: .. code-block:: c @@ -135,11 +135,11 @@ Configuration Configure the following parameters when using this library: -* :option:`CONFIG_AZURE_IOT_HUB_HOSTNAME` - Sets the Azure IoT Hub host name. It must be configured, since DPS is not enabled by default. -* :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` - Specifies the device ID, which is used when connecting to Azure IoT Hub or when DPS is enabled. -* :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` - Used to provide the device ID at run time. -* :option:`CONFIG_AZURE_IOT_HUB_DPS` - Enables Azure IoT Hub DPS. -* :option:`CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE` - Sets the Azure IoT Hub DPS ID scope that is used while provisioning the device. +* :kconfig:`CONFIG_AZURE_IOT_HUB_HOSTNAME` - Sets the Azure IoT Hub host name. It must be configured, since DPS is not enabled by default. +* :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` - Specifies the device ID, which is used when connecting to Azure IoT Hub or when DPS is enabled. +* :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` - Used to provide the device ID at run time. +* :kconfig:`CONFIG_AZURE_IOT_HUB_DPS` - Enables Azure IoT Hub DPS. +* :kconfig:`CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE` - Sets the Azure IoT Hub DPS ID scope that is used while provisioning the device. API documentation ***************** diff --git a/include/net/cloud.rst b/doc/nrf/libraries/networking/cloud.rst similarity index 100% rename from include/net/cloud.rst rename to doc/nrf/libraries/networking/cloud.rst diff --git a/include/net/coap_utils.rst b/doc/nrf/libraries/networking/coap_utils.rst similarity index 92% rename from include/net/coap_utils.rst rename to doc/nrf/libraries/networking/coap_utils.rst index 5926300313f5..d16bd5a3d277 100644 --- a/include/net/coap_utils.rst +++ b/doc/nrf/libraries/networking/coap_utils.rst @@ -26,7 +26,7 @@ Currently, the library only supports the User Datagram Protocol (UDP) protocol. Configuration ************* -To enable the CoAP utils library, set the :option:`CONFIG_COAP_UTILS` Kconfig option. +To enable the CoAP utils library, set the :kconfig:`CONFIG_COAP_UTILS` Kconfig option. API documentation ***************** diff --git a/include/net/download_client.rst b/doc/nrf/libraries/networking/download_client.rst similarity index 80% rename from include/net/download_client.rst rename to doc/nrf/libraries/networking/download_client.rst index b30992c17be4..443c4362eb10 100644 --- a/include/net/download_client.rst +++ b/doc/nrf/libraries/networking/download_client.rst @@ -9,7 +9,7 @@ Download client The download client library can be used to download files from an HTTP or a CoAP server. The download is carried out in a separate thread, and the application receives events such as :c:enumerator:`DOWNLOAD_CLIENT_EVT_FRAGMENT` that contain the data fragments as the download progresses. -The fragment size can be configured independently for HTTP and CoAP (block-wise transfer) using the :option:`CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE` and the :option:`CONFIG_DOWNLOAD_CLIENT_COAP_BLOCK_SIZE` options, respectively. +The fragment size can be configured independently for HTTP and CoAP (block-wise transfer) using the :kconfig:`CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE` and the :kconfig:`CONFIG_DOWNLOAD_CLIENT_COAP_BLOCK_SIZE` options, respectively. When the download completes, the library sends the :c:enumerator:`DOWNLOAD_CLIENT_EVT_DONE` event to the application. Protocols @@ -29,7 +29,7 @@ In the case of download via HTTPS, it is carried out through `Content-Range requ The library thus sends and receives as many requests and responses as the number of fragments that constitutes the download. For example, to download a file of size 47 kilobytes file with a fragment size of 2 kilobytes, a total of 24 HTTP GET requests are sent. It is therefore recommended to use the largest fragment size to minimize the network usage. -Make sure to configure the :option:`CONFIG_DOWNLOAD_CLIENT_BUF_SIZE` and the :option:`CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE` options so that the buffer is large enough to accommodate the entire HTTP header of the request and the response. +Make sure to configure the :kconfig:`CONFIG_DOWNLOAD_CLIENT_BUF_SIZE` and the :kconfig:`CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE` options so that the buffer is large enough to accommodate the entire HTTP header of the request and the response. The application must provision the TLS credentials and pass the security tag to the library when using HTTPS and calling the :c:func:`download_client_connect` function. To provision a TLS certificate to the modem, use :c:func:`modem_key_mgmt_write` and other :ref:`modem_key_mgmt` APIs. @@ -38,7 +38,7 @@ CoAP and CoAPS (DTLS 1.2) ========================= When downloading from a CoAP server, the library uses the CoAP block-wise transfer. -Make sure to configure the :option:`CONFIG_DOWNLOAD_CLIENT_BUF_SIZE` option and the :option:`CONFIG_DOWNLOAD_CLIENT_COAP_BLOCK_SIZE` option so that the buffer is large enough to accommodate the entire CoAP header and the CoAP block. +Make sure to configure the :kconfig:`CONFIG_DOWNLOAD_CLIENT_BUF_SIZE` option and the :kconfig:`CONFIG_DOWNLOAD_CLIENT_COAP_BLOCK_SIZE` option so that the buffer is large enough to accommodate the entire CoAP header and the CoAP block. The application must provision the TLS credentials and pass the security tag to the library when using CoAPS and calling :c:func:`download_client_connect`. diff --git a/include/net/fota_download.rst b/doc/nrf/libraries/networking/fota_download.rst similarity index 100% rename from include/net/fota_download.rst rename to doc/nrf/libraries/networking/fota_download.rst diff --git a/include/net/ftp_client.rst b/doc/nrf/libraries/networking/ftp_client.rst similarity index 88% rename from include/net/ftp_client.rst rename to doc/nrf/libraries/networking/ftp_client.rst index e16d594059c3..d370e7b50901 100644 --- a/include/net/ftp_client.rst +++ b/doc/nrf/libraries/networking/ftp_client.rst @@ -13,8 +13,8 @@ The file is downloaded in fragments of :c:enumerator:`NET_IPV4_MTU`. The size of a file can be fetched by LIST command. The FTP client library reports FTP control message and download data with two separate callback functions (:c:type:`ftp_client_callback_t` and :c:type:`ftp_client_callback_t`). -The library automatically sends KEEPALIVE message to the server through a timer if :option:`CONFIG_FTP_CLIENT_KEEPALIVE_TIME` is not zero. -The KEEPALIVE message is sent periodically at the completion of the time interval indicated by the value of :option:`CONFIG_FTP_CLIENT_KEEPALIVE_TIME`. +The library automatically sends KEEPALIVE message to the server through a timer if :kconfig:`CONFIG_FTP_CLIENT_KEEPALIVE_TIME` is not zero. +The KEEPALIVE message is sent periodically at the completion of the time interval indicated by the value of :kconfig:`CONFIG_FTP_CLIENT_KEEPALIVE_TIME`. If there is no username or password provided, the library performs a login as an anonymous user. diff --git a/include/net/icalendar_parser.rst b/doc/nrf/libraries/networking/icalendar_parser.rst similarity index 100% rename from include/net/icalendar_parser.rst rename to doc/nrf/libraries/networking/icalendar_parser.rst diff --git a/doc/nrf/images/aws_fota_dfu_sequence.png b/doc/nrf/libraries/networking/images/aws_fota_dfu_sequence.png similarity index 100% rename from doc/nrf/images/aws_fota_dfu_sequence.png rename to doc/nrf/libraries/networking/images/aws_fota_dfu_sequence.png diff --git a/doc/nrf/images/aws_fota_dfu_sequence.svg b/doc/nrf/libraries/networking/images/aws_fota_dfu_sequence.svg similarity index 100% rename from doc/nrf/images/aws_fota_dfu_sequence.svg rename to doc/nrf/libraries/networking/images/aws_fota_dfu_sequence.svg diff --git a/doc/nrf/images/aws_fota_dfu_sequence.uml.txt b/doc/nrf/libraries/networking/images/aws_fota_dfu_sequence.uml.txt similarity index 100% rename from doc/nrf/images/aws_fota_dfu_sequence.uml.txt rename to doc/nrf/libraries/networking/images/aws_fota_dfu_sequence.uml.txt diff --git a/doc/nrf/images/lib_lwm2m_client_utils.svg b/doc/nrf/libraries/networking/images/lib_lwm2m_client_utils.svg similarity index 100% rename from doc/nrf/images/lib_lwm2m_client_utils.svg rename to doc/nrf/libraries/networking/images/lib_lwm2m_client_utils.svg diff --git a/doc/nrf/libraries/lib_networking.rst b/doc/nrf/libraries/networking/index.rst similarity index 85% rename from doc/nrf/libraries/lib_networking.rst rename to doc/nrf/libraries/networking/index.rst index e9440d8e9860..9528dde0589f 100644 --- a/doc/nrf/libraries/lib_networking.rst +++ b/doc/nrf/libraries/networking/index.rst @@ -8,4 +8,4 @@ Libraries for networking :glob: :caption: Subpages: - ../../include/net/* + * diff --git a/include/net/lwm2m_client_utils.rst b/doc/nrf/libraries/networking/lwm2m_client_utils.rst similarity index 94% rename from include/net/lwm2m_client_utils.rst rename to doc/nrf/libraries/networking/lwm2m_client_utils.rst index a68d24ec56c5..0a8c4cdf6c45 100644 --- a/include/net/lwm2m_client_utils.rst +++ b/doc/nrf/libraries/networking/lwm2m_client_utils.rst @@ -22,7 +22,7 @@ Following are the fixed set of readily initialized objects that are available to These objects do not indicate a complete set of resources that a device is expected to support. Based on the use case, a user application can, and is expected to, define additional set of resources based on the capabilities of the device. -.. figure:: /images/lib_lwm2m_client_utils.svg +.. figure:: images/lib_lwm2m_client_utils.svg :alt: LwM2M client utils software stack Configuration and implementation @@ -34,15 +34,15 @@ To use NB-IoT, a bootstrap server, or the queue mode, follow the implementation Configure the following parameters when using this library: -* :option:`CONFIG_LWM2M_CLIENT_UTILS` enabled -* :option:`CONFIG_LWM2M_CLIENT_UTILS_DEVICE_OBJ_SUPPORT` enabled -* :option:`CONFIG_LWM2M_CLIENT_UTILS_SECURITY_OBJ_SUPPORT` enabled -* :option:`CONFIG_LWM2M_CLIENT_UTILS_CONN_MON_OBJ_SUPPORT` enabled -* :option:`CONFIG_LWM2M_CLIENT_UTILS_LOCATION_OBJ_SUPPORT` enabled -* :option:`CONFIG_LWM2M_CLIENT_UTILS_FIRMWARE_UPDATE_OBJ_SUPPORT` enabled +* :kconfig:`CONFIG_LWM2M_CLIENT_UTILS` enabled +* :kconfig:`CONFIG_LWM2M_CLIENT_UTILS_DEVICE_OBJ_SUPPORT` enabled +* :kconfig:`CONFIG_LWM2M_CLIENT_UTILS_SECURITY_OBJ_SUPPORT` enabled +* :kconfig:`CONFIG_LWM2M_CLIENT_UTILS_CONN_MON_OBJ_SUPPORT` enabled +* :kconfig:`CONFIG_LWM2M_CLIENT_UTILS_LOCATION_OBJ_SUPPORT` enabled +* :kconfig:`CONFIG_LWM2M_CLIENT_UTILS_FIRMWARE_UPDATE_OBJ_SUPPORT` enabled Support for the objects can be set individually but are enabled by default. -Disable the :option:`CONFIG_LWM2M_CLIENT_UTILS_DEVICE_OBJ_SUPPORT` Kconfig option only if you are implementing a ``reboot`` resource on your application because of a mandatory requirement. +Disable the :kconfig:`CONFIG_LWM2M_CLIENT_UTILS_DEVICE_OBJ_SUPPORT` Kconfig option only if you are implementing a ``reboot`` resource on your application because of a mandatory requirement. Defining custom objects *********************** @@ -68,7 +68,7 @@ To define custom objects, complete the following steps: #. Pass the resource information to the LwM2M client utils library to register callbacks for the resource and to publish the sensor data. The following example describes how you can define an object that follows the Generic Sensor definition from IPSO. -To enable the support for Generic Sensor set the Kconfig option :option:`CONFIG_LWM2M_IPSO_GENERIC_SENSOR` to ``y``. +To enable the support for Generic Sensor set the Kconfig option :kconfig:`CONFIG_LWM2M_IPSO_GENERIC_SENSOR` to ``y``. To define an object that follows the Generic Sensor definition, complete the following steps: diff --git a/include/net/multicell_location.rst b/doc/nrf/libraries/networking/multicell_location.rst similarity index 79% rename from include/net/multicell_location.rst rename to doc/nrf/libraries/networking/multicell_location.rst index 4b8244a703b6..139fbb39877d 100644 --- a/include/net/multicell_location.rst +++ b/doc/nrf/libraries/networking/multicell_location.rst @@ -37,30 +37,30 @@ The library has an API to handle provisioning of the required TLS certificates f Configuration ************* -To enable the multicell location library, enable the :option:`CONFIG_MULTICELL_LOCATION` Kconfig option. +To enable the multicell location library, enable the :kconfig:`CONFIG_MULTICELL_LOCATION` Kconfig option. The user must select nRF Cloud, HERE or Skyhook location services using one of the following options: -* :option:`CONFIG_MULTICELL_LOCATION_SERVICE_NRF_CLOUD` -* :option:`CONFIG_MULTICELL_LOCATION_SERVICE_HERE` -* :option:`CONFIG_MULTICELL_LOCATION_SERVICE_SKYHOOK`. +* :kconfig:`CONFIG_MULTICELL_LOCATION_SERVICE_NRF_CLOUD` +* :kconfig:`CONFIG_MULTICELL_LOCATION_SERVICE_HERE` +* :kconfig:`CONFIG_MULTICELL_LOCATION_SERVICE_SKYHOOK`. The next required step is to configure the authentication method. By default, API key is used for nRF Cloud, HERE and Skyhook. Depending on the selected service, one of the two options below must be configured: -* :option:`CONFIG_MULTICELL_LOCATION_NRF_CLOUD_API_KEY` -* :option:`CONFIG_MULTICELL_LOCATION_HERE_API_KEY` -* :option:`CONFIG_MULTICELL_LOCATION_SKYHOOK_API_KEY` +* :kconfig:`CONFIG_MULTICELL_LOCATION_NRF_CLOUD_API_KEY` +* :kconfig:`CONFIG_MULTICELL_LOCATION_HERE_API_KEY` +* :kconfig:`CONFIG_MULTICELL_LOCATION_SKYHOOK_API_KEY` Following are the options that can usually have default values: -* :option:`CONFIG_MULTICELL_LOCATION_HOSTNAME` -* :option:`CONFIG_MULTICELL_LOCATION_TLS_SEC_TAG` -* :option:`CONFIG_MULTICELL_LOCATION_SEND_BUF_SIZE` -* :option:`CONFIG_MULTICELL_LOCATION_RECV_BUF_SIZE` -* :option:`CONFIG_MULTICELL_LOCATION_HTTPS_PORT` +* :kconfig:`CONFIG_MULTICELL_LOCATION_HOSTNAME` +* :kconfig:`CONFIG_MULTICELL_LOCATION_TLS_SEC_TAG` +* :kconfig:`CONFIG_MULTICELL_LOCATION_SEND_BUF_SIZE` +* :kconfig:`CONFIG_MULTICELL_LOCATION_RECV_BUF_SIZE` +* :kconfig:`CONFIG_MULTICELL_LOCATION_HTTPS_PORT` Limitations *********** diff --git a/include/net/nrf_cloud.rst b/doc/nrf/libraries/networking/nrf_cloud.rst similarity index 82% rename from include/net/nrf_cloud.rst rename to doc/nrf/libraries/networking/nrf_cloud.rst index 5bb0bc4d404c..71bdcec54fd5 100644 --- a/include/net/nrf_cloud.rst +++ b/doc/nrf/libraries/networking/nrf_cloud.rst @@ -33,11 +33,11 @@ Connecting The application can use :c:func:`nrf_cloud_connect` to connect to the cloud. This API triggers a series of events and actions in the system. If the API fails, the application must retry to connect. -If the :option:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` Kconfig option is enabled, an nRF Cloud library thread monitors the connection socket. -When :option:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` is enabled, an additional event, :c:enum:`NRF_CLOUD_EVT_TRANSPORT_CONNECTING`, is sent to the application. +If the :kconfig:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` Kconfig option is enabled, an nRF Cloud library thread monitors the connection socket. +When :kconfig:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` is enabled, an additional event, :c:enum:`NRF_CLOUD_EVT_TRANSPORT_CONNECTING`, is sent to the application. The status field of :c:struct:`nrf_cloud_evt` contains the connection status that is defined by :c:enumerator:`nrf_cloud_connect_result`. The event :c:enumerator:`NRF_CLOUD_EVT_TRANSPORT_DISCONNECTED` also contains additional information in the status field that is defined by :c:enumerator:`nrf_cloud_disconnect_status`. -See :ref:`connect_to_cloud` for additional information on :option:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD`. +See :ref:`connect_to_cloud` for additional information on :kconfig:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD`. When the poll thread option is used directly with the nRF Cloud library, the enumeration values are prefixed with ``NRF``. First, the library tries to establish the transport for communicating with the cloud. @@ -98,20 +98,20 @@ After receiving :c:enumerator:`NRF_CLOUD_EVT_READY`, the application can start s Configuration options for device ID =================================== -* :option:`CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI` - If you enable this option, the ID is automatically generated using a prefix and the modem's IMEI (````). You can configure the prefix by using :option:`CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX`. The default format of the prefix is ``nrf-`` and it is valid only for Nordic devices such as Thingy:91 or nRF9160 DK. For custom hardware, use a prefix other than ``nrf-`` by modifying :option:`CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX`. +* :kconfig:`CONFIG_NRF_CLOUD_CLIENT_ID_SRC_IMEI` - If you enable this option, the ID is automatically generated using a prefix and the modem's IMEI (````). You can configure the prefix by using :kconfig:`CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX`. The default format of the prefix is ``nrf-`` and it is valid only for Nordic devices such as Thingy:91 or nRF9160 DK. For custom hardware, use a prefix other than ``nrf-`` by modifying :kconfig:`CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX`. -* :option:`CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID` - If you enable this option, the ID is automatically generated using the modem's 128-bit internal UUID, which results in a 32-character string with no hyphens. This option requires modem firmware v1.3.0 or higher. +* :kconfig:`CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID` - If you enable this option, the ID is automatically generated using the modem's 128-bit internal UUID, which results in a 32-character string with no hyphens. This option requires modem firmware v1.3.0 or higher. -* :option:`CONFIG_NRF_CLOUD_CLIENT_ID_SRC_COMPILE_TIME` - If you enable this option, the ID is set at compile time using the value specified by :option:`CONFIG_NRF_CLOUD_CLIENT_ID`. +* :kconfig:`CONFIG_NRF_CLOUD_CLIENT_ID_SRC_COMPILE_TIME` - If you enable this option, the ID is set at compile time using the value specified by :kconfig:`CONFIG_NRF_CLOUD_CLIENT_ID`. -* :option:`CONFIG_NRF_CLOUD_CLIENT_ID_SRC_RUNTIME` - If you enable this option, the ID is set at run time. If the nRF Cloud library is used directly, set the NULL-terminated ID string in :c:struct:`nrf_cloud_init_param` when calling :c:func:`nrf_cloud_init`. If the generic Cloud API is used, set the ID in :c:struct:`cloud_backend_config` and then call :c:func:`cloud_init`. +* :kconfig:`CONFIG_NRF_CLOUD_CLIENT_ID_SRC_RUNTIME` - If you enable this option, the ID is set at run time. If the nRF Cloud library is used directly, set the NULL-terminated ID string in :c:struct:`nrf_cloud_init_param` when calling :c:func:`nrf_cloud_init`. If the generic Cloud API is used, set the ID in :c:struct:`cloud_backend_config` and then call :c:func:`cloud_init`. .. _lib_nrf_cloud_fota: Firmware over-the-air (FOTA) updates ************************************ The nRF Cloud library supports FOTA updates for your nRF9160-based device. -When the library is included by the application, the :option:`CONFIG_NRF_CLOUD_FOTA` option is enabled by default, and the FOTA functionality is made available to the application. +When the library is included by the application, the :kconfig:`CONFIG_NRF_CLOUD_FOTA` option is enabled by default, and the FOTA functionality is made available to the application. For FOTA updates to work, the device must provide the information about the supported FOTA types to nRF Connect for Cloud. The device passes this information by writing a ``fota_v2`` field containing an array of FOTA types into the ``serviceInfo`` field in the device's shadow. @@ -211,7 +211,7 @@ The return values for a failure scenario of the :c:func:`cloud_init` function ar * -ENOMEM - Error building MQTT topics. The given client ID of the device could be too long. .. note:: - If :option:`CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES` is enabled, error values could be different or have different error descriptions. + If :kconfig:`CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES` is enabled, error values could be different or have different error descriptions. .. _connect_to_cloud: @@ -219,19 +219,19 @@ Connecting to the Cloud ======================= The nRF Cloud library offers two ways to handle backend connections when the :c:func:`cloud_connect` function is called. -If you enable the :option:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` Kconfig option, a cloud backend thread monitors the connection socket. +If you enable the :kconfig:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` Kconfig option, a cloud backend thread monitors the connection socket. If you disable the option, the user application must monitor the socket. The dual functionalities of the :c:func:`cloud_connect` function in the two scenarios are described below: -* :option:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` - If you enable this option, the function does not block and returns success if the connection monitoring thread has started. Below are some of the error codes that can be returned: +* :kconfig:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` - If you enable this option, the function does not block and returns success if the connection monitoring thread has started. Below are some of the error codes that can be returned: * :c:enumerator:`CLOUD_CONNECT_RES_ERR_NOT_INITD` - Cloud backend is not initialized * :c:enumerator:`CLOUD_CONNECT_RES_ERR_ALREADY_CONNECTED` - Connection process has already been started Upon success, the monitoring thread sends an event of type :c:enumerator:`CLOUD_EVT_CONNECTING` to the user’s cloud event handler, with the ``err`` field set to success. If an error occurs, another event of the same type is sent, with the ``err`` field set to indicate the cause. These additional errors are described in the following section. -* :option:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` - If you disable this option, the function blocks and returns success when the MQTT connection to the cloud completes. The connection socket is set in the backend binding and it becomes available for the application to use. Below are some of the error codes that can be returned: +* :kconfig:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` - If you disable this option, the function blocks and returns success when the MQTT connection to the cloud completes. The connection socket is set in the backend binding and it becomes available for the application to use. Below are some of the error codes that can be returned: * :c:enumerator:`CLOUD_CONNECT_RES_ERR_NOT_INITD`. * :c:enumerator:`CLOUD_CONNECT_RES_ERR_NETWORK` - Host cannot be found with the available network interfaces. @@ -264,7 +264,7 @@ The user application can generate a disconnect request with the :c:func:`cloud_d A successful disconnection is indicated by the :c:enumerator:`CLOUD_EVT_DISCONNECTED` event. The ``err`` field in the event message is set to :c:enumerator:`CLOUD_DISCONNECT_USER_REQUEST`. If an unexpected disconnect event is received, the ``err`` field contains the cause. -If :option:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` is not enabled, the only cause of disconnection is :c:enumerator:`CLOUD_DISCONNECT_MISC`. +If :kconfig:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD` is not enabled, the only cause of disconnection is :c:enumerator:`CLOUD_DISCONNECT_MISC`. The user application must use the connection socket to determine a reason. The following events can cause disconnection if the backend thread is monitoring the socket: diff --git a/include/net/nrf_cloud_agps.rst b/doc/nrf/libraries/networking/nrf_cloud_agps.rst similarity index 96% rename from include/net/nrf_cloud_agps.rst rename to doc/nrf/libraries/networking/nrf_cloud_agps.rst index 1af8178d05f8..4f5657918324 100644 --- a/include/net/nrf_cloud_agps.rst +++ b/doc/nrf/libraries/networking/nrf_cloud_agps.rst @@ -23,8 +23,8 @@ Configuration Configure the following options to enable or disable the use of this library: -* :option:`CONFIG_NRF_CLOUD` -* :option:`CONFIG_NRF_CLOUD_AGPS` +* :kconfig:`CONFIG_NRF_CLOUD` +* :kconfig:`CONFIG_NRF_CLOUD_AGPS` See :ref:`configure_application` for information on how to change configuration options. @@ -60,7 +60,7 @@ If the GPS service has already started before the device enters the RRC idle mod Limitations *********** -.. include:: ../../samples/nrf9160/agps/README.rst +.. include:: ../../../../samples/nrf9160/agps/README.rst :start-after: agpslimitation_start :end-before: agpslimitation_end diff --git a/include/net/nrf_cloud_cell_pos.rst b/doc/nrf/libraries/networking/nrf_cloud_cell_pos.rst similarity index 94% rename from include/net/nrf_cloud_cell_pos.rst rename to doc/nrf/libraries/networking/nrf_cloud_cell_pos.rst index fc55d57b86a8..8bcb9a79bcc0 100644 --- a/include/net/nrf_cloud_cell_pos.rst +++ b/doc/nrf/libraries/networking/nrf_cloud_cell_pos.rst @@ -18,8 +18,8 @@ Configuration Configure the following options to enable or disable the use of this library: -* :option:`CONFIG_NRF_CLOUD` -* :option:`CONFIG_NRF_CLOUD_CELL_POS` +* :kconfig:`CONFIG_NRF_CLOUD` +* :kconfig:`CONFIG_NRF_CLOUD_CELL_POS` Request and process cellular positioning data diff --git a/include/net/nrf_cloud_pgps.rst b/doc/nrf/libraries/networking/nrf_cloud_pgps.rst similarity index 93% rename from include/net/nrf_cloud_pgps.rst rename to doc/nrf/libraries/networking/nrf_cloud_pgps.rst index 4fc942a7a86c..62b0c8ad80a9 100644 --- a/include/net/nrf_cloud_pgps.rst +++ b/doc/nrf/libraries/networking/nrf_cloud_pgps.rst @@ -42,32 +42,32 @@ Configuration Configure the following options to enable or disable the use of this library: -* :option:`CONFIG_NRF_CLOUD` -* :option:`CONFIG_NRF_CLOUD_PGPS` +* :kconfig:`CONFIG_NRF_CLOUD` +* :kconfig:`CONFIG_NRF_CLOUD_PGPS` Configure these additional options to refine the behavior of P-GPS: -* :option:`CONFIG_NRF_CLOUD_PGPS_PREDICTION_PERIOD` -* :option:`CONFIG_NRF_CLOUD_PGPS_NUM_PREDICTIONS` -* :option:`CONFIG_NRF_CLOUD_PGPS_REPLACEMENT_THRESHOLD` -* :option:`CONFIG_NRF_CLOUD_PGPS_DOWNLOAD_FRAGMENT_SIZE` +* :kconfig:`CONFIG_NRF_CLOUD_PGPS_PREDICTION_PERIOD` +* :kconfig:`CONFIG_NRF_CLOUD_PGPS_NUM_PREDICTIONS` +* :kconfig:`CONFIG_NRF_CLOUD_PGPS_REPLACEMENT_THRESHOLD` +* :kconfig:`CONFIG_NRF_CLOUD_PGPS_DOWNLOAD_FRAGMENT_SIZE` Configure both of the following options if you need your application to use A-GPS as well, for coarse time and position data and to get the fastest TTFF: -* :option:`CONFIG_NRF_CLOUD_AGPS` -* :option:`CONFIG_AGPS` +* :kconfig:`CONFIG_NRF_CLOUD_AGPS` +* :kconfig:`CONFIG_AGPS` If A-GPS is not desired (due to data costs, low power requirements, or expected frequent loss of cloud connectivity), both options listed above must be disabled. For an application that uses P-GPS, the following options must be configured for storing settings, for having accurate clock time, and for having a location to store predictions: -* :option:`CONFIG_FLASH` -* :option:`CONFIG_FCB` -* :option:`CONFIG_SETTINGS_FCB` -* :option:`CONFIG_DATE_TIME` -* :option:`CONFIG_BOOTLOADER_MCUBOOT` -* :option:`CONFIG_IMG_MANAGER` -* :option:`CONFIG_MCUBOOT_IMG_MANAGER` +* :kconfig:`CONFIG_FLASH` +* :kconfig:`CONFIG_FCB` +* :kconfig:`CONFIG_SETTINGS_FCB` +* :kconfig:`CONFIG_DATE_TIME` +* :kconfig:`CONFIG_BOOTLOADER_MCUBOOT` +* :kconfig:`CONFIG_IMG_MANAGER` +* :kconfig:`CONFIG_MCUBOOT_IMG_MANAGER` See :ref:`configure_application` for information on how to change configuration options. @@ -157,7 +157,7 @@ If the use case involves possible long-distance travel between fix attempts, suc The application can also call :c:func:`nrf_cloud_pgps_preemptive_updates` to discard expired predictions and replace them with newer ones, prior to the expiration of the entire set of predictions. This can be useful for customer use cases where cloud connections are available infrequently. -The :option:`CONFIG_NRF_CLOUD_PGPS_REPLACEMENT_THRESHOLD` sets the minimum number of valid predictions remaining before such an update occurs. +The :kconfig:`CONFIG_NRF_CLOUD_PGPS_REPLACEMENT_THRESHOLD` sets the minimum number of valid predictions remaining before such an update occurs. For best performance, applications can call the P-GPS functions mentioned in this section from workqueue handlers rather than directly from various callback functions. diff --git a/doc/nrf/libraries/lib_nfc.rst b/doc/nrf/libraries/nfc/index.rst similarity index 81% rename from doc/nrf/libraries/lib_nfc.rst rename to doc/nrf/libraries/nfc/index.rst index cf2a84b164f8..c8ad672446bc 100644 --- a/doc/nrf/libraries/lib_nfc.rst +++ b/doc/nrf/libraries/nfc/index.rst @@ -12,7 +12,4 @@ See the :ref:`ug_nfc` user guide for an overview of the technology and informati :glob: :caption: Subpages: - nfc/lib_nfc_t2t - nfc/lib_nfc_t4t - nfc/lib_nfc_ndef - nfc/lib_nfc_tnep + **/index diff --git a/include/nfc/ndef/ch_msg.rst b/doc/nrf/libraries/nfc/ndef/ch_msg.rst similarity index 92% rename from include/nfc/ndef/ch_msg.rst rename to doc/nrf/libraries/nfc/ndef/ch_msg.rst index 785d8553949e..44a4aac6598b 100644 --- a/include/nfc/ndef/ch_msg.rst +++ b/doc/nrf/libraries/nfc/ndef/ch_msg.rst @@ -8,7 +8,7 @@ Connection Handover messages and records :depth: 2 Connection Handover records and the corresponding messages are used to negotiate and activate an alternative communication carrier. -The negotiated communication carrier can then be used to perform certain activities between the two devices, such as Bluetooth pairing. +The negotiated communication carrier can then be used to perform certain activities between the two devices, such as Bluetooth® pairing. Connection Handover records *************************** @@ -41,7 +41,7 @@ This library is used in the :ref:`peripheral_nfc_pairing` sample. The following code sample demonstrates how to create a Handover Select message with one Alternative Carrier record that has a reference to the :ref:`Bluetooth LE OOB record `: -.. literalinclude:: ../../../samples/bluetooth/peripheral_nfc_pairing/src/main.c +.. literalinclude:: ../../../../../samples/bluetooth/peripheral_nfc_pairing/src/main.c :language: c :start-after: include_startingpoint_pair_msg_rst :end-before: include_endpoint_pair_msg_rst diff --git a/include/nfc/ndef/ch_rec_parser.rst b/doc/nrf/libraries/nfc/ndef/ch_rec_parser.rst similarity index 95% rename from include/nfc/ndef/ch_rec_parser.rst rename to doc/nrf/libraries/nfc/ndef/ch_rec_parser.rst index 597c66a93316..c192c5d822b5 100644 --- a/include/nfc/ndef/ch_rec_parser.rst +++ b/doc/nrf/libraries/nfc/ndef/ch_rec_parser.rst @@ -19,7 +19,7 @@ This library should be used together with the :ref:`nfc_ndef_parser_readme` in t The following code sample demonstrates how to use this module: -.. literalinclude:: ../../../samples/nfc/tag_reader/src/main.c +.. literalinclude:: ../../../../../samples/nfc/tag_reader/src/main.c :language: c :start-after: include_startingpoint_ch_rec_parser_rst :end-before: include_endpoint_ch_rec_parser_rst diff --git a/doc/nrf/libraries/nfc/lib_nfc_ndef.rst b/doc/nrf/libraries/nfc/ndef/index.rst similarity index 96% rename from doc/nrf/libraries/nfc/lib_nfc_ndef.rst rename to doc/nrf/libraries/nfc/ndef/index.rst index da7d61b40cc4..4ee13f575f65 100644 --- a/doc/nrf/libraries/nfc/lib_nfc_ndef.rst +++ b/doc/nrf/libraries/nfc/ndef/index.rst @@ -26,4 +26,4 @@ The NFC NDEF libraries are used in the following samples: :glob: :caption: Subpages: - ../../include/nfc/ndef/* + * diff --git a/include/nfc/ndef/le_oob_rec.rst b/doc/nrf/libraries/nfc/ndef/le_oob_rec.rst similarity index 89% rename from include/nfc/ndef/le_oob_rec.rst rename to doc/nrf/libraries/nfc/ndef/le_oob_rec.rst index cafb38629290..d9d076064cb0 100644 --- a/include/nfc/ndef/le_oob_rec.rst +++ b/doc/nrf/libraries/nfc/ndef/le_oob_rec.rst @@ -7,7 +7,7 @@ Bluetooth LE OOB records :local: :depth: 2 -A Bluetooth LE device that has an NFC interface (a tag or a polling device) can use NFC to send or receive data required for connecting and pairing in the Bluetooth domain. +A Bluetooth® LE device that has an NFC interface (a tag or a polling device) can use NFC to send or receive data required for connecting and pairing in the Bluetooth domain. This data should be presented in the form of a Bluetooth LE pairing message. A Bluetooth LE pairing message that works with Android devices contains one Bluetooth LE OOB record. diff --git a/include/nfc/ndef/le_oob_rec_parser.rst b/doc/nrf/libraries/nfc/ndef/le_oob_rec_parser.rst similarity index 84% rename from include/nfc/ndef/le_oob_rec_parser.rst rename to doc/nrf/libraries/nfc/ndef/le_oob_rec_parser.rst index 881f31c8235a..6a9d0d3dc2d8 100644 --- a/include/nfc/ndef/le_oob_rec_parser.rst +++ b/doc/nrf/libraries/nfc/ndef/le_oob_rec_parser.rst @@ -7,7 +7,7 @@ Parser for Bluetooth LE OOB records :local: :depth: 2 -This library provides a parser for Bluetooth LE OOB records that can be used to decode NDEF records generated by the :ref:`nfc_ndef_le_oob` library. +This library provides a parser for Bluetooth® LE OOB records that can be used to decode NDEF records generated by the :ref:`nfc_ndef_le_oob` library. The output of this library is a descriptor with the same content as the one that would be used to encode the data with the :ref:`nfc_ndef_le_oob` library. This library should be used together with the :ref:`nfc_ndef_parser_readme` in the following way: @@ -18,7 +18,7 @@ This library should be used together with the :ref:`nfc_ndef_parser_readme` in t The following code sample demonstrates how to use this module: -.. literalinclude:: ../../../samples/nfc/tag_reader/src/main.c +.. literalinclude:: ../../../../../samples/nfc/tag_reader/src/main.c :language: c :start-after: include_startingpoint_le_oob_rec_parser_rst :end-before: include_endpoint_le_oob_rec_parser_rst diff --git a/include/nfc/ndef/msg.rst b/doc/nrf/libraries/nfc/ndef/msg.rst similarity index 100% rename from include/nfc/ndef/msg.rst rename to doc/nrf/libraries/nfc/ndef/msg.rst diff --git a/include/nfc/ndef/msg_parser.rst b/doc/nrf/libraries/nfc/ndef/msg_parser.rst similarity index 100% rename from include/nfc/ndef/msg_parser.rst rename to doc/nrf/libraries/nfc/ndef/msg_parser.rst diff --git a/include/nfc/ndef/text_rec.rst b/doc/nrf/libraries/nfc/ndef/text_rec.rst similarity index 100% rename from include/nfc/ndef/text_rec.rst rename to doc/nrf/libraries/nfc/ndef/text_rec.rst diff --git a/include/nfc/ndef/uri_msg.rst b/doc/nrf/libraries/nfc/ndef/uri_msg.rst similarity index 100% rename from include/nfc/ndef/uri_msg.rst rename to doc/nrf/libraries/nfc/ndef/uri_msg.rst diff --git a/doc/nrf/libraries/nfc/lib_nfc_t2t.rst b/doc/nrf/libraries/nfc/t2t/index.rst similarity index 94% rename from doc/nrf/libraries/nfc/lib_nfc_t2t.rst rename to doc/nrf/libraries/nfc/t2t/index.rst index 99d63c03e919..b59e83356bfd 100644 --- a/doc/nrf/libraries/nfc/lib_nfc_t2t.rst +++ b/doc/nrf/libraries/nfc/t2t/index.rst @@ -16,4 +16,4 @@ Note that these require an NFC polling device. :glob: :caption: Subpages: - ../../include/nfc/t2t/* + * diff --git a/include/nfc/t2t/t2t_parser.rst b/doc/nrf/libraries/nfc/t2t/t2t_parser.rst similarity index 100% rename from include/nfc/t2t/t2t_parser.rst rename to doc/nrf/libraries/nfc/t2t/t2t_parser.rst diff --git a/include/nfc/t4t/apdu.rst b/doc/nrf/libraries/nfc/t4t/apdu.rst similarity index 100% rename from include/nfc/t4t/apdu.rst rename to doc/nrf/libraries/nfc/t4t/apdu.rst diff --git a/include/nfc/t4t/cc_file.rst b/doc/nrf/libraries/nfc/t4t/cc_file.rst similarity index 100% rename from include/nfc/t4t/cc_file.rst rename to doc/nrf/libraries/nfc/t4t/cc_file.rst diff --git a/include/nfc/t4t/hl_procedure.rst b/doc/nrf/libraries/nfc/t4t/hl_procedure.rst similarity index 100% rename from include/nfc/t4t/hl_procedure.rst rename to doc/nrf/libraries/nfc/t4t/hl_procedure.rst diff --git a/doc/nrf/libraries/nfc/lib_nfc_t4t.rst b/doc/nrf/libraries/nfc/t4t/index.rst similarity index 94% rename from doc/nrf/libraries/nfc/lib_nfc_t4t.rst rename to doc/nrf/libraries/nfc/t4t/index.rst index 2203a105be73..b5f8a154a62a 100644 --- a/doc/nrf/libraries/nfc/lib_nfc_t4t.rst +++ b/doc/nrf/libraries/nfc/t4t/index.rst @@ -17,4 +17,4 @@ Note that these require an NFC polling device. :glob: :caption: Subpages: - ../../include/nfc/t4t/* + * diff --git a/include/nfc/t4t/isodep.rst b/doc/nrf/libraries/nfc/t4t/isodep.rst similarity index 100% rename from include/nfc/t4t/isodep.rst rename to doc/nrf/libraries/nfc/t4t/isodep.rst diff --git a/include/nfc/t4t/ndef_file.rst b/doc/nrf/libraries/nfc/t4t/ndef_file.rst similarity index 90% rename from include/nfc/t4t/ndef_file.rst rename to doc/nrf/libraries/nfc/t4t/ndef_file.rst index 0e43e67d2aba..63af5849eb34 100644 --- a/include/nfc/t4t/ndef_file.rst +++ b/doc/nrf/libraries/nfc/t4t/ndef_file.rst @@ -13,7 +13,7 @@ To generate an NDEF message, you can use the :ref:`nfc_ndef_msg` and :ref:`nfc_n The following code sample demonstrates how to encode the NDEF file for NFC Type 4 Tag: -.. literalinclude:: ../../../samples/nfc/writable_ndef_msg/src/ndef_file_m.c +.. literalinclude:: ../../../../../samples/nfc/writable_ndef_msg/src/ndef_file_m.c :language: c :start-after: include_startingpoint_ndef_file_rst :end-before: include_endpoint_ndef_file_rst diff --git a/include/nfc/tnep/ch.rst b/doc/nrf/libraries/nfc/tnep/ch.rst similarity index 92% rename from include/nfc/tnep/ch.rst rename to doc/nrf/libraries/nfc/tnep/ch.rst index 748efe47f10a..ea28df475fd6 100644 --- a/include/nfc/tnep/ch.rst +++ b/doc/nrf/libraries/nfc/tnep/ch.rst @@ -28,7 +28,7 @@ Static handover In the static handover, the Handover Requester only reads a Handover Select Message from the NFC Tag Device. TNEP is not used in this communication form. -.. figure:: /images/nfc_static_connection_handover.svg +.. figure:: images/nfc_static_connection_handover.svg :alt: Static handover Negotiated handover @@ -38,7 +38,7 @@ In the negotiated handover, the Handover Requester provides a Handover Request M The Handover Selector replies with a Handover Select Message that contains the list of carriers that they both support. Connection Handover NDEF messages are exchanged as defined by TNEP. -.. figure:: /images/nfc_negotiated_connection_handover.svg +.. figure:: images/nfc_negotiated_connection_handover.svg :alt: Negotiated handover Device Role @@ -62,7 +62,7 @@ NFC Tag Device The following code sample demonstrates how to use this module with an NFC Tag Device: -.. literalinclude:: ../../../samples/bluetooth/peripheral_nfc_pairing/src/main.c +.. literalinclude:: ../../../../../samples/bluetooth/peripheral_nfc_pairing/src/main.c :language: c :start-after: include_startingpoint_nfc_tnep_ch_tag_rst :end-before: include_endpoint_nfc_tnep_ch_tag_rst @@ -74,7 +74,7 @@ NFC Poller Device The following code sample demonstrates how to use this module with an NFC Poller Device: -.. literalinclude:: ../../../samples/bluetooth/central_nfc_pairing/src/main.c +.. literalinclude:: ../../../../../samples/bluetooth/central_nfc_pairing/src/main.c :language: c :start-after: include_startingpoint_nfc_tnep_ch_poller_rst :end-before: include_endpoint_nfc_tnep_ch_poller_rst diff --git a/doc/nrf/images/nfc_negotiated_connection_handover.svg b/doc/nrf/libraries/nfc/tnep/images/nfc_negotiated_connection_handover.svg similarity index 100% rename from doc/nrf/images/nfc_negotiated_connection_handover.svg rename to doc/nrf/libraries/nfc/tnep/images/nfc_negotiated_connection_handover.svg diff --git a/doc/nrf/images/nfc_negotiated_connection_handover.vsdx b/doc/nrf/libraries/nfc/tnep/images/nfc_negotiated_connection_handover.vsdx similarity index 100% rename from doc/nrf/images/nfc_negotiated_connection_handover.vsdx rename to doc/nrf/libraries/nfc/tnep/images/nfc_negotiated_connection_handover.vsdx diff --git a/doc/nrf/images/nfc_static_connection_handover.svg b/doc/nrf/libraries/nfc/tnep/images/nfc_static_connection_handover.svg similarity index 100% rename from doc/nrf/images/nfc_static_connection_handover.svg rename to doc/nrf/libraries/nfc/tnep/images/nfc_static_connection_handover.svg diff --git a/doc/nrf/images/nfc_static_connection_handover.vsdx b/doc/nrf/libraries/nfc/tnep/images/nfc_static_connection_handover.vsdx similarity index 100% rename from doc/nrf/images/nfc_static_connection_handover.vsdx rename to doc/nrf/libraries/nfc/tnep/images/nfc_static_connection_handover.vsdx diff --git a/doc/nrf/libraries/nfc/lib_nfc_tnep.rst b/doc/nrf/libraries/nfc/tnep/index.rst similarity index 94% rename from doc/nrf/libraries/nfc/lib_nfc_tnep.rst rename to doc/nrf/libraries/nfc/tnep/index.rst index 458ae6f3c643..96b9d0efe7f8 100644 --- a/doc/nrf/libraries/nfc/lib_nfc_tnep.rst +++ b/doc/nrf/libraries/nfc/tnep/index.rst @@ -14,4 +14,4 @@ The |NCS| provides libraries to implement TNEP for both the polling device and t :glob: :caption: Subpages: - ../../include/nfc/tnep/* + * diff --git a/include/nfc/tnep/poller.rst b/doc/nrf/libraries/nfc/tnep/poller.rst similarity index 100% rename from include/nfc/tnep/poller.rst rename to doc/nrf/libraries/nfc/tnep/poller.rst diff --git a/include/nfc/tnep/tag.rst b/doc/nrf/libraries/nfc/tnep/tag.rst similarity index 96% rename from include/nfc/tnep/tag.rst rename to doc/nrf/libraries/nfc/tnep/tag.rst index e21e49506c93..d91e10410f55 100644 --- a/include/nfc/tnep/tag.rst +++ b/doc/nrf/libraries/nfc/tnep/tag.rst @@ -53,14 +53,14 @@ You can also encode additional NDEF records into the Initial TNEP message in the See the following code for an example of the Initial message encoding: -.. literalinclude:: ../../../samples/nfc/tnep_tag/src/main.c +.. literalinclude:: ../../../../../samples/nfc/tnep_tag/src/main.c :language: c :start-after: include_startingpoint_initial_msg_cb_rst :end-before: include_endpoint_initial_cb_msg_rst The following code shows how to create the Initial NDEF message: -.. literalinclude:: ../../../samples/nfc/tnep_tag/src/main.c +.. literalinclude:: ../../../../../samples/nfc/tnep_tag/src/main.c :language: c :start-after: include_startingpoint_initial_msg_rst :end-before: include_endpoint_initial_msg_rst @@ -112,7 +112,7 @@ If the application does not reply before the expiration on the time period speci The following code demonstrates how to exchange NDEF messages using the tag library after initialization: -.. literalinclude:: ../../../samples/nfc/tnep_tag/src/main.c +.. literalinclude:: ../../../../../samples/nfc/tnep_tag/src/main.c :language: c :start-after: include_startingpoint_tnep_service_rst :end-before: include_endpoint_tnep_service_rst diff --git a/include/bl_crypto.rst b/doc/nrf/libraries/others/bl_crypto.rst similarity index 84% rename from include/bl_crypto.rst rename to doc/nrf/libraries/others/bl_crypto.rst index 195286270621..6041d71b27ab 100644 --- a/include/bl_crypto.rst +++ b/doc/nrf/libraries/others/bl_crypto.rst @@ -33,15 +33,15 @@ When using the library, you can choose between the following backends: To configure which backend is used for hashing, set one of the following configuration options: -* :option:`CONFIG_SB_CRYPTO_OBERON_SHA256` -* :option:`CONFIG_SB_CRYPTO_CC310_SHA256` -* :option:`CONFIG_SB_CRYPTO_CLIENT_SHA256` +* :kconfig:`CONFIG_SB_CRYPTO_OBERON_SHA256` +* :kconfig:`CONFIG_SB_CRYPTO_CC310_SHA256` +* :kconfig:`CONFIG_SB_CRYPTO_CLIENT_SHA256` To configure which backend is used for firmware verification, set one of the following configuration options: -* :option:`CONFIG_SB_CRYPTO_CC310_ECDSA_SECP256R1` -* :option:`CONFIG_SB_CRYPTO_OBERON_ECDSA_SECP256R1` -* :option:`CONFIG_SB_CRYPTO_CLIENT_ECDSA_SECP256R1` +* :kconfig:`CONFIG_SB_CRYPTO_CC310_ECDSA_SECP256R1` +* :kconfig:`CONFIG_SB_CRYPTO_OBERON_ECDSA_SECP256R1` +* :kconfig:`CONFIG_SB_CRYPTO_CLIENT_ECDSA_SECP256R1` diff --git a/include/bl_storage.rst b/doc/nrf/libraries/others/bl_storage.rst similarity index 93% rename from include/bl_storage.rst rename to doc/nrf/libraries/others/bl_storage.rst index 593d00506bc5..8ee8a4d32a6d 100644 --- a/include/bl_storage.rst +++ b/doc/nrf/libraries/others/bl_storage.rst @@ -40,10 +40,10 @@ This functionality is implemented as a monotonic version counter that contains a Each update to the counter is written to the next available slot. When reading the counter, the bootloader storage library iterates over each slot and returns the largest value. -The number of available slots, thus the number of different version numbers that can be stored, is configurable through :option:`CONFIG_SB_NUM_VER_COUNTER_SLOTS`. +The number of available slots, thus the number of different version numbers that can be stored, is configurable through :kconfig:`CONFIG_SB_NUM_VER_COUNTER_SLOTS`. The monotonic counter is enabled by default. -You can disable it through :option:`CONFIG_SB_MONOTONIC_COUNTER`. +You can disable it through :kconfig:`CONFIG_SB_MONOTONIC_COUNTER`. If the counter is enabled, the :ref:`doc_bl_validation` library checks it against an image's version during :c:func:`bl_validate_firmware`. diff --git a/include/bl_validation.rst b/doc/nrf/libraries/others/bl_validation.rst similarity index 100% rename from include/bl_validation.rst rename to doc/nrf/libraries/others/bl_validation.rst diff --git a/include/date_time.rst b/doc/nrf/libraries/others/date_time.rst similarity index 86% rename from include/date_time.rst rename to doc/nrf/libraries/others/date_time.rst index ec97bdda1207..a1923880c485 100644 --- a/include/date_time.rst +++ b/doc/nrf/libraries/others/date_time.rst @@ -8,7 +8,7 @@ Date-Time :depth: 2 The date-time library maintains the current date-time information in UTC format. -The option :option:`CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS` determines the frequency with which the library updates the date-time information. +The option :kconfig:`CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS` determines the frequency with which the library updates the date-time information. The information is fetched in the following prioritized order: @@ -27,13 +27,13 @@ See the API documentation for more information on these functions. .. note:: - The first date-time update cycle (after boot) does not occur until the time set by the :option:`CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS` has elapsed. + The first date-time update cycle (after boot) does not occur until the time set by the :kconfig:`CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS` has elapsed. It is recommended to call the :c:func:`date_time_update_async` function after the device has connected to LTE, to get the initial date-time information. Configuration ************* -:option:`CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS` +:kconfig:`CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS` Configure this option to control the frequency with which the library fetches the time information. diff --git a/include/dk_buttons_and_leds.rst b/doc/nrf/libraries/others/dk_buttons_and_leds.rst similarity index 100% rename from include/dk_buttons_and_leds.rst rename to doc/nrf/libraries/others/dk_buttons_and_leds.rst diff --git a/include/ei_wrapper.rst b/doc/nrf/libraries/others/ei_wrapper.rst similarity index 85% rename from include/ei_wrapper.rst rename to doc/nrf/libraries/others/ei_wrapper.rst index c9389588d3b4..d6ce82153bba 100644 --- a/include/ei_wrapper.rst +++ b/doc/nrf/libraries/others/ei_wrapper.rst @@ -24,14 +24,14 @@ Before using the wrapper, you need to :ref:`add the machine learning model /modules/lib/memfault-firmware-sdk/``. -To include Memfault in your build, enable the Kconfig option :option:`CONFIG_MEMFAULT`. +To include Memfault in your build, enable the Kconfig option :kconfig:`CONFIG_MEMFAULT`. The APIs in Memfault SDK can then be linked into your application. -In addition, you must configure a Memfault project key using :option:`CONFIG_MEMFAULT_NCS_PROJECT_KEY`. +In addition, you must configure a Memfault project key using :kconfig:`CONFIG_MEMFAULT_NCS_PROJECT_KEY`. To get access to all the benefits, like up to 100 free devices connected, register at the `Memfault registration page`_. @@ -57,7 +57,7 @@ Configuration files .. memfault_config_files_start -If you just want to do a quick test with a sample, disable the :option:`CONFIG_MEMFAULT_USER_CONFIG_ENABLE` option in the :file:`prj.conf` to avoid adding the user configuration files. +If you just want to do a quick test with a sample, disable the :kconfig:`CONFIG_MEMFAULT_USER_CONFIG_ENABLE` option in the :file:`prj.conf` to avoid adding the user configuration files. Otherwise, follow the instructions below. Memfault SDK requires three files in the include path during the build process. @@ -82,20 +82,20 @@ Configuration options in Memfault SDK Following are some of the configuration options that Memfault SDK define: -* :option:`CONFIG_MEMFAULT_SHELL` -* :option:`CONFIG_MEMFAULT_RAM_BACKED_COREDUMP` -* :option:`CONFIG_MEMFAULT_RAM_BACKED_COREDUMP_SIZE` -* :option:`CONFIG_MEMFAULT_COREDUMP_COLLECT_DATA_REGIONS` -* :option:`CONFIG_MEMFAULT_COREDUMP_COLLECT_BSS_REGIONS` -* :option:`CONFIG_MEMFAULT_HTTP_ENABLE` -* :option:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD_INTERVAL_SECS` -* :option:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD_USE_DEDICATED_WORKQUEUE` -* :option:`CONFIG_MEMFAULT_EVENT_STORAGE_SIZE` -* :option:`CONFIG_MEMFAULT_CLEAR_RESET_REG` -* :option:`CONFIG_MEMFAULT_METRICS` -* :option:`CONFIG_MEMFAULT_METRICS_DEFAULT_SET_ENABLE` -* :option:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD` -* :option:`CONFIG_MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM` +* :kconfig:`CONFIG_MEMFAULT_SHELL` +* :kconfig:`CONFIG_MEMFAULT_RAM_BACKED_COREDUMP` +* :kconfig:`CONFIG_MEMFAULT_RAM_BACKED_COREDUMP_SIZE` +* :kconfig:`CONFIG_MEMFAULT_COREDUMP_COLLECT_DATA_REGIONS` +* :kconfig:`CONFIG_MEMFAULT_COREDUMP_COLLECT_BSS_REGIONS` +* :kconfig:`CONFIG_MEMFAULT_HTTP_ENABLE` +* :kconfig:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD_INTERVAL_SECS` +* :kconfig:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD_USE_DEDICATED_WORKQUEUE` +* :kconfig:`CONFIG_MEMFAULT_EVENT_STORAGE_SIZE` +* :kconfig:`CONFIG_MEMFAULT_CLEAR_RESET_REG` +* :kconfig:`CONFIG_MEMFAULT_METRICS` +* :kconfig:`CONFIG_MEMFAULT_METRICS_DEFAULT_SET_ENABLE` +* :kconfig:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD` +* :kconfig:`CONFIG_MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM` You can find more details on each option using ``menuconfig``, ``guiconfig``, and in the Kconfig sources in ``modules/lib/memfault-firmware-sdk/ports/zephyr/Kconfig``. @@ -112,20 +112,20 @@ Configuration options in |NCS| The Kconfig options for Memfault that are defined in |NCS| provide some additional features compared to the options that are already implemented in Memfault SDK: -* :option:`CONFIG_MEMFAULT_NCS_PROJECT_KEY` -* :option:`CONFIG_MEMFAULT_NCS_PROVISION_CERTIFICATES` -* :option:`CONFIG_MEMFAULT_NCS_INTERNAL_FLASH_BACKED_COREDUMP` -* :option:`CONFIG_MEMFAULT_NCS_LTE_METRICS` -* :option:`CONFIG_MEMFAULT_NCS_STACK_METRICS` +* :kconfig:`CONFIG_MEMFAULT_NCS_PROJECT_KEY` +* :kconfig:`CONFIG_MEMFAULT_NCS_PROVISION_CERTIFICATES` +* :kconfig:`CONFIG_MEMFAULT_NCS_INTERNAL_FLASH_BACKED_COREDUMP` +* :kconfig:`CONFIG_MEMFAULT_NCS_LTE_METRICS` +* :kconfig:`CONFIG_MEMFAULT_NCS_STACK_METRICS` The |NCS| integration of `Memfault SDK`_ provides default values for some metadata that are required to identify the firmware when it is sent to Memfault cloud. These defaults can be controlled by using the configuration options below: -* :option:`CONFIG_MEMFAULT_NCS_DEVICE_ID` -* :option:`CONFIG_MEMFAULT_NCS_HW_VERSION` -* :option:`CONFIG_MEMFAULT_NCS_FW_TYPE` -* :option:`CONFIG_MEMFAULT_NCS_FW_VERSION_STATIC` -* :option:`CONFIG_MEMFAULT_NCS_FW_VERSION_PREFIX` +* :kconfig:`CONFIG_MEMFAULT_NCS_DEVICE_ID` +* :kconfig:`CONFIG_MEMFAULT_NCS_HW_VERSION` +* :kconfig:`CONFIG_MEMFAULT_NCS_FW_TYPE` +* :kconfig:`CONFIG_MEMFAULT_NCS_FW_VERSION_STATIC` +* :kconfig:`CONFIG_MEMFAULT_NCS_FW_VERSION_PREFIX` API documentation diff --git a/include/profiler.rst b/doc/nrf/libraries/others/profiler.rst similarity index 95% rename from include/profiler.rst rename to doc/nrf/libraries/others/profiler.rst index 1c49034a2f5d..7a0b1183397b 100644 --- a/include/profiler.rst +++ b/doc/nrf/libraries/others/profiler.rst @@ -22,12 +22,12 @@ Configuration Apart from standard configuration parameters, there is one required setting: -:option:`CONFIG_PROFILER` +:kconfig:`CONFIG_PROFILER` Set this option to add the Profiler source code to the application. - If you use the Event Manager, you can also set this option by selecting :option:`CONFIG_EVENT_MANAGER_PROFILER_ENABLED`. + If you use the Event Manager, you can also set this option by selecting :kconfig:`CONFIG_EVENT_MANAGER_PROFILER_ENABLED`. Call :c:func:`profiler_init` during the application start to initialize the Profiler. -If you set :option:`CONFIG_EVENT_MANAGER_PROFILER_ENABLED`, the Profiler is automatically initialized when you initialize the :ref:`event_manager`. +If you set :kconfig:`CONFIG_EVENT_MANAGER_PROFILER_ENABLED`, the Profiler is automatically initialized when you initialize the :ref:`event_manager`. Profiling custom events @@ -97,7 +97,7 @@ Select the custom backend to use dedicated tools written in Python for event vis To save profiling data, the tools use CSV files (for event occurrences) and JSON files (for event descriptions). The scripts can be found under :file:`scripts/profiler/` in the |NCS| folder structure. -Set :option:`CONFIG_PROFILER_NORDIC` to enable this backend. +Set :kconfig:`CONFIG_PROFILER_NORDIC` to enable this backend. To use the tools, run the scripts on the command line: diff --git a/include/ram_pwrdn.rst b/doc/nrf/libraries/others/ram_pwrdn.rst similarity index 100% rename from include/ram_pwrdn.rst rename to doc/nrf/libraries/others/ram_pwrdn.rst diff --git a/include/secure_services.rst b/doc/nrf/libraries/others/secure_services.rst similarity index 60% rename from include/secure_services.rst rename to doc/nrf/libraries/others/secure_services.rst index 99f14725780a..d80860454489 100644 --- a/include/secure_services.rst +++ b/doc/nrf/libraries/others/secure_services.rst @@ -10,12 +10,12 @@ Secure Services Secure Services are functions implemented in the Secure Firmware (:ref:`secure_partition_manager`), but made available to be called from the Non-Secure Firmware. Calling functions in this API requires that the service is enabled in the :ref:`secure_partition_manager`. -See :option:`CONFIG_SPM_SECURE_SERVICES` in the :ref:`secure_partition_manager`'s menuconfig. +See :kconfig:`CONFIG_SPM_SECURE_SERVICES` in the :ref:`secure_partition_manager`'s menuconfig. Some services are enabled by default. .. Remove parts with regards to debugging and programming when NRF91-313 is resolved -By default :option:`CONFIG_SPM_BLOCK_NON_SECURE_RESET` is disabled. This is to make sure that your debugger will be able to issue a system reset during the development stage and that devices which do not have pin-reset routed can do a re-flashing routine correctly. This option should be turned off when you are putting a product into production to increase the security of your device. +By default :kconfig:`CONFIG_SPM_BLOCK_NON_SECURE_RESET` is disabled. This is to make sure that your debugger will be able to issue a system reset during the development stage and that devices which do not have pin-reset routed can do a re-flashing routine correctly. This option should be turned off when you are putting a product into production to increase the security of your device. API documentation ***************** diff --git a/include/spm.rst b/doc/nrf/libraries/others/spm.rst similarity index 100% rename from include/spm.rst rename to doc/nrf/libraries/others/spm.rst diff --git a/include/st25r3911b_nfc.rst b/doc/nrf/libraries/others/st25r3911b_nfc.rst similarity index 100% rename from include/st25r3911b_nfc.rst rename to doc/nrf/libraries/others/st25r3911b_nfc.rst diff --git a/include/supl_os_client.rst b/doc/nrf/libraries/others/supl_os_client.rst similarity index 98% rename from include/supl_os_client.rst rename to doc/nrf/libraries/others/supl_os_client.rst index db0f80cefaba..c10f4f5d56e6 100644 --- a/include/supl_os_client.rst +++ b/doc/nrf/libraries/others/supl_os_client.rst @@ -95,7 +95,7 @@ Make sure to maintain the folder structure that is used in the zip file. Configuration ============= -To enable the SUPL client library, set :option:`CONFIG_SUPL_CLIENT_LIB` to ``y``. +To enable the SUPL client library, set :kconfig:`CONFIG_SUPL_CLIENT_LIB` to ``y``. See :ref:`configure_application` for information on how to change configuration options. Resource initialization and ownership @@ -159,7 +159,7 @@ It is assumed that the GNSS socket is already available. The following message sequence chart (MSC) describes the flow of communication in a SUPL session. -.. figure:: /images/supl_msc.svg +.. figure:: images/supl_msc.svg :alt: SUPL Session MSC .. _supl_session_msc_desc: diff --git a/doc/nrf/libraries/lib_shell.rst b/doc/nrf/libraries/shell/index.rst similarity index 81% rename from doc/nrf/libraries/lib_shell.rst rename to doc/nrf/libraries/shell/index.rst index b28eab38babb..5e92cf083f0b 100644 --- a/doc/nrf/libraries/lib_shell.rst +++ b/doc/nrf/libraries/shell/index.rst @@ -8,4 +8,4 @@ Shell libraries :glob: :caption: Subpages: - ../../include/shell/* + * diff --git a/include/shell/shell_bt_nus.rst b/doc/nrf/libraries/shell/shell_bt_nus.rst similarity index 96% rename from include/shell/shell_bt_nus.rst rename to doc/nrf/libraries/shell/shell_bt_nus.rst index 08717f2c846e..9ce3221c3ba7 100644 --- a/include/shell/shell_bt_nus.rst +++ b/doc/nrf/libraries/shell/shell_bt_nus.rst @@ -7,7 +7,7 @@ Nordic UART Service (NUS) shell transport :local: :depth: 2 -The Bluetooth LE GATT Nordic UART Service shell transport allows you to receive shell commands remotely over *Bluetooth*. +The Bluetooth® LE GATT Nordic UART Service shell transport allows you to receive shell commands remotely over *Bluetooth*. It uses the :ref:`nus_service_readme`. The NUS Service shell transport is used in the :ref:`shell_bt_nus` sample. diff --git a/doc/nrf/libraries/lib_tfm.rst b/doc/nrf/libraries/tfm/index.rst similarity index 82% rename from doc/nrf/libraries/lib_tfm.rst rename to doc/nrf/libraries/tfm/index.rst index 071d93fba48d..53850ac1df7e 100644 --- a/doc/nrf/libraries/lib_tfm.rst +++ b/doc/nrf/libraries/tfm/index.rst @@ -8,4 +8,4 @@ TF-M libraries :glob: :caption: Subpages: - ../../include/tfm/* + * diff --git a/include/tfm/tfm_ioctl_api.rst b/doc/nrf/libraries/tfm/tfm_ioctl_api.rst similarity index 89% rename from include/tfm/tfm_ioctl_api.rst rename to doc/nrf/libraries/tfm/tfm_ioctl_api.rst index 146cbce0fa2d..f647e4be206c 100644 --- a/include/tfm/tfm_ioctl_api.rst +++ b/doc/nrf/libraries/tfm/tfm_ioctl_api.rst @@ -21,12 +21,12 @@ Wrapper functions for these accesses are defined in :file:`tfm_ioctl_ns_api.c` a The supported platform services are defined by :c:struct:`fm_platform_ioctl_request_types_t` in :file:`tfm_ioctl_api.h`. -.. literalinclude:: tfm_ioctl_api.h +.. literalinclude:: ../../../../include/tfm/tfm_ioctl_api.h :language: c :start-at: /** @brief Supported request types. :end-before: /** @brief Argument list for each platform read service. -Set the :option:``CONFIG_TFM_PARTITION_PLATFORM`` Kconfig option to enable the services. +Set the :kconfig:``CONFIG_TFM_PARTITION_PLATFORM`` Kconfig option to enable the services. See the :ref:`tfm_hello_world` sample for example usage. diff --git a/doc/nrf/images/zigbee_signal_handler_00_stack_init.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_00_stack_init.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_00_stack_init.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_00_stack_init.png diff --git a/doc/nrf/images/zigbee_signal_handler_00_stack_init.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_00_stack_init.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_00_stack_init.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_00_stack_init.uml diff --git a/doc/nrf/images/zigbee_signal_handler_01_production_config.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_01_production_config.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_01_production_config.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_01_production_config.png diff --git a/doc/nrf/images/zigbee_signal_handler_01_production_config.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_01_production_config.svg similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_01_production_config.svg rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_01_production_config.svg diff --git a/doc/nrf/images/zigbee_signal_handler_01_production_config.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_01_production_config.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_01_production_config.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_01_production_config.uml diff --git a/doc/nrf/images/zigbee_signal_handler_01_production_config.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_01_production_config.vsdx similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_01_production_config.vsdx rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_01_production_config.vsdx diff --git a/doc/nrf/images/zigbee_signal_handler_02_startup.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_02_startup.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_02_startup.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_02_startup.png diff --git a/doc/nrf/images/zigbee_signal_handler_02_startup.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_02_startup.svg similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_02_startup.svg rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_02_startup.svg diff --git a/doc/nrf/images/zigbee_signal_handler_02_startup.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_02_startup.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_02_startup.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_02_startup.uml diff --git a/doc/nrf/images/zigbee_signal_handler_02_startup.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_02_startup.vsdx similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_02_startup.vsdx rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_02_startup.vsdx diff --git a/doc/nrf/images/zigbee_signal_handler_03_first_start.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_03_first_start.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_03_first_start.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_03_first_start.png diff --git a/doc/nrf/images/zigbee_signal_handler_03_first_start.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_03_first_start.svg similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_03_first_start.svg rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_03_first_start.svg diff --git a/doc/nrf/images/zigbee_signal_handler_03_first_start.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_03_first_start.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_03_first_start.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_03_first_start.uml diff --git a/doc/nrf/images/zigbee_signal_handler_03_first_start.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_03_first_start.vsdx similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_03_first_start.vsdx rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_03_first_start.vsdx diff --git a/doc/nrf/images/zigbee_signal_handler_04_reboot.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_04_reboot.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_04_reboot.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_04_reboot.png diff --git a/doc/nrf/images/zigbee_signal_handler_04_reboot.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_04_reboot.svg similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_04_reboot.svg rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_04_reboot.svg diff --git a/doc/nrf/images/zigbee_signal_handler_04_reboot.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_04_reboot.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_04_reboot.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_04_reboot.uml diff --git a/doc/nrf/images/zigbee_signal_handler_04_reboot.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_04_reboot.vsdx similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_04_reboot.vsdx rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_04_reboot.vsdx diff --git a/doc/nrf/images/zigbee_signal_handler_05_formation.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_05_formation.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_05_formation.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_05_formation.png diff --git a/doc/nrf/images/zigbee_signal_handler_05_formation.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_05_formation.svg similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_05_formation.svg rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_05_formation.svg diff --git a/doc/nrf/images/zigbee_signal_handler_05_formation.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_05_formation.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_05_formation.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_05_formation.uml diff --git a/doc/nrf/images/zigbee_signal_handler_05_formation.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_05_formation.vsdx similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_05_formation.vsdx rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_05_formation.vsdx diff --git a/doc/nrf/images/zigbee_signal_handler_06_steering.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_06_steering.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_06_steering.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_06_steering.png diff --git a/doc/nrf/images/zigbee_signal_handler_06_steering.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_06_steering.svg similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_06_steering.svg rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_06_steering.svg diff --git a/doc/nrf/images/zigbee_signal_handler_06_steering.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_06_steering.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_06_steering.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_06_steering.uml diff --git a/doc/nrf/images/zigbee_signal_handler_06_steering.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_06_steering.vsdx similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_06_steering.vsdx rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_06_steering.vsdx diff --git a/doc/nrf/images/zigbee_signal_handler_07_idle.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_07_idle.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_07_idle.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_07_idle.png diff --git a/doc/nrf/images/zigbee_signal_handler_07_idle.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_07_idle.svg similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_07_idle.svg rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_07_idle.svg diff --git a/doc/nrf/images/zigbee_signal_handler_07_idle.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_07_idle.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_07_idle.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_07_idle.uml diff --git a/doc/nrf/images/zigbee_signal_handler_07_idle.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_07_idle.vsdx similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_07_idle.vsdx rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_07_idle.vsdx diff --git a/doc/nrf/images/zigbee_signal_handler_08_deep_sleep.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_08_deep_sleep.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_08_deep_sleep.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_08_deep_sleep.png diff --git a/doc/nrf/images/zigbee_signal_handler_08_deep_sleep.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_08_deep_sleep.svg similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_08_deep_sleep.svg rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_08_deep_sleep.svg diff --git a/doc/nrf/images/zigbee_signal_handler_08_deep_sleep.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_08_deep_sleep.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_08_deep_sleep.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_08_deep_sleep.uml diff --git a/doc/nrf/images/zigbee_signal_handler_08_deep_sleep.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_08_deep_sleep.vsdx similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_08_deep_sleep.vsdx rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_08_deep_sleep.vsdx diff --git a/doc/nrf/images/zigbee_signal_handler_09_leave.png b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_09_leave.png similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_09_leave.png rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_09_leave.png diff --git a/doc/nrf/images/zigbee_signal_handler_09_leave.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_09_leave.svg similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_09_leave.svg rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_09_leave.svg diff --git a/doc/nrf/images/zigbee_signal_handler_09_leave.uml b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_09_leave.uml similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_09_leave.uml rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_09_leave.uml diff --git a/doc/nrf/images/zigbee_signal_handler_09_leave.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_09_leave.vsdx similarity index 100% rename from doc/nrf/images/zigbee_signal_handler_09_leave.vsdx rename to doc/nrf/libraries/zigbee/images/zigbee_signal_handler_09_leave.vsdx diff --git a/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin.svg new file mode 100644 index 000000000000..1b29afaa9780 --- /dev/null +++ b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin.svg @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + Drawing + + Nordic Blue.1368 + start_network_rejoin() + + start_network_rejoin() + + Dynamic connector.1421 + + + + Nordic Blue.1422 + Schedule stop_network_rejoin(ZB_TRUE) after ZB_DEV_REJOIN_TIM... + + Schedule stop_network_rejoin(ZB_TRUE) after ZB_DEV_REJOIN_TIMEOUT_MS + + Hexagon.1423 + role == end device + + role == end device + + Dynamic connector.1424 + yes + + yes + + Nordic Blue.1425 + Schedule network steering after 2^n sec + + Schedule network steering after 2^n sec + + Dynamic connector.1426 + + + + Diamond.1428 + + + + Circle.1430 + + + + Dynamic connector.1431 + + + + Dynamic connector.1432 + no + + no + + Nordic Blue.1505 + n++ + + n++ + + Dynamic connector.1506 + + + + Dynamic connector + + + + Hexagon.1474 + wait_for_user_input + + wait_for_user_input + + Dynamic connector.1511 + false + + false + + Diamond.1513 + + + + Dynamic connector.1514 + true + + true + + Dynamic connector.1518 + + + + diff --git a/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin.vsdx new file mode 100644 index 000000000000..d5cc111d2458 Binary files /dev/null and b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin.vsdx differ diff --git a/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_stop.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_stop.svg new file mode 100644 index 000000000000..cbfb49cda779 --- /dev/null +++ b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_stop.svg @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + Drawing + + Nordic Blue.1497 + stop_network_rejoin(was_scheduled) + + stop_network_rejoin(was_scheduled) + + Nordic Blue.1498 + wait_for_user_input=was_scheduled + + wait_for_user_input=was_scheduled + + Dynamic connector.1499 + + + + Circle.1500 + + + + Dynamic connector.1501 + + + + diff --git a/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_stop.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_stop.vsdx new file mode 100644 index 000000000000..9fd7371e1c33 Binary files /dev/null and b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_stop.vsdx differ diff --git a/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_user_input.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_user_input.svg new file mode 100644 index 000000000000..708beed93a35 --- /dev/null +++ b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_user_input.svg @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + Drawing + + Nordic Blue.1375 + user_input_indicate() + + user_input_indicate() + + Circle.1470 + User action (e.g. button press) + + User action (e.g. button press) + + Hexagon.1474 + wait_for_user_input + + wait_for_user_input + + Dynamic connector.1475 + true + + true + + Dynamic connector.1476 + + + + Dynamic connector.1477 + + + + Dynamic connector.1479 + false + + false + + Nordic Blue.1502 + wait_for_user_input=false + + wait_for_user_input=false + + Diamond.1428 + + + + Circle.1430 + + + + Dynamic connector.1431 + + + + Dynamic connector + + + + Nordic Blue.1508 + start_network_rejoin() + + start_network_rejoin() + + Dynamic connector.1509 + + + + diff --git a/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_user_input.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_user_input.vsdx new file mode 100644 index 000000000000..f54fc86c280d Binary files /dev/null and b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_10_rejoin_user_input.vsdx differ diff --git a/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_overview.svg b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_overview.svg new file mode 100644 index 000000000000..a71b3b3dc89a --- /dev/null +++ b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_overview.svg @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + Drawing + + Nordic Blueslate.1724 + Stack start + + Stack start + + Nordic Blueslate.1728 + BDB initialization (two scenarios) + + BDB initialization (two scenarios) + + Nordic Blueslate.1729 + Network formation + + Network formation + + Nordic Blueslate.1730 + Network joining + + Network joining + + Dynamic connector.1733 + + + + Dynamic connector.1734 + + + + Dynamic connector.1735 + + + + Dynamic connector.1737 + + + + Nordic Blueslate.1739 + Zigbee stack sleep routines + + Zigbee stack sleep routines + + Nordic Blueslate.1742 + Network leaving + + Network leaving + + Dynamic connector.1743 + + + + Dynamic connector.1744 + + + + Dynamic connector.1745 + + + + Dynamic connector.1746 + + + + Sheet.1747 + Device in network + + Device in network + + Dynamic connector.1748 + + + + Dynamic connector.1749 + + + + Dynamic connector.1776 + + + + Dynamic connector.1777 + + + + Dynamic connector.1778 + + + + diff --git a/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_overview.vsdx b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_overview.vsdx new file mode 100644 index 000000000000..70e93ed173a8 Binary files /dev/null and b/doc/nrf/libraries/zigbee/images/zigbee_signal_handler_overview.vsdx differ diff --git a/doc/nrf/libraries/lib_zigbee.rst b/doc/nrf/libraries/zigbee/index.rst similarity index 86% rename from doc/nrf/libraries/lib_zigbee.rst rename to doc/nrf/libraries/zigbee/index.rst index 5addb8f2c5a6..87f9d9d6c9aa 100644 --- a/doc/nrf/libraries/lib_zigbee.rst +++ b/doc/nrf/libraries/zigbee/index.rst @@ -16,6 +16,4 @@ For information on how to use the supplied libraries, see :ref:`ug_zigbee_config :glob: :caption: Subpages: - zigbee/lib_zigbee_osif - ../../include/zigbee/* - zigbee/lib_zigbee_shell + * diff --git a/doc/nrf/libraries/zigbee/lib_zigbee_osif.rst b/doc/nrf/libraries/zigbee/osif.rst similarity index 60% rename from doc/nrf/libraries/zigbee/lib_zigbee_osif.rst rename to doc/nrf/libraries/zigbee/osif.rst index 5a7bb7067b4f..d59f38f916ae 100644 --- a/doc/nrf/libraries/zigbee/lib_zigbee_osif.rst +++ b/doc/nrf/libraries/zigbee/osif.rst @@ -16,29 +16,29 @@ Configuration The ZBOSS OSIF layer implements a series of functions used by ZBOSS and is included in the |NCS|'s Zigbee subsystem. -The ZBOSS OSIF layer is automatically enabled when you enable the ZBOSS library with the :option:`CONFIG_ZIGBEE` Kconfig option. +The ZBOSS OSIF layer is automatically enabled when you enable the ZBOSS library with the :kconfig:`CONFIG_ZIGBEE` Kconfig option. You can also configure the following OSIF-related Kconfig options: -* :option:`CONFIG_ZIGBEE_APP_CB_QUEUE_LENGTH` - Defines the length of the application callback and alarm queue. +* :kconfig:`CONFIG_ZIGBEE_APP_CB_QUEUE_LENGTH` - Defines the length of the application callback and alarm queue. This queue is used to pass application callbacks and alarms from other threads or interrupts to the ZBOSS main loop context. -* :option:`CONFIG_ZIGBEE_DEBUG_FUNCTIONS` - Includes functions to suspend and resume the ZBOSS thread. +* :kconfig:`CONFIG_ZIGBEE_DEBUG_FUNCTIONS` - Includes functions to suspend and resume the ZBOSS thread. .. note:: These functions are useful for debugging, but they can cause instability of the device. -* :option:`CONFIG_ZIGBEE_HAVE_SERIAL` - Enables the UART serial abstract for the ZBOSS OSIF layer and allows to configure the serial glue layer. -* :option:`CONFIG_ZIGBEE_USE_BUTTONS` - Enables the buttons abstract for the ZBOSS OSIF layer. +* :kconfig:`CONFIG_ZIGBEE_HAVE_SERIAL` - Enables the UART serial abstract for the ZBOSS OSIF layer and allows to configure the serial glue layer. +* :kconfig:`CONFIG_ZIGBEE_USE_BUTTONS` - Enables the buttons abstract for the ZBOSS OSIF layer. You can use this option if you want to test ZBOSS examples directly in the |NCS|. -* :option:`CONFIG_ZIGBEE_USE_DIMMABLE_LED` - Dimmable LED (PWM) abstract for the ZBOSS OSIF layer. +* :kconfig:`CONFIG_ZIGBEE_USE_DIMMABLE_LED` - Dimmable LED (PWM) abstract for the ZBOSS OSIF layer. You can use this option if you want to test ZBOSS examples directly in the |NCS|. -* :option:`CONFIG_ZIGBEE_USE_LEDS` - LEDs abstract for the ZBOSS OSIF layer. +* :kconfig:`CONFIG_ZIGBEE_USE_LEDS` - LEDs abstract for the ZBOSS OSIF layer. You can use this option if you want to test ZBOSS examples directly in the |NCS|. -* :option:`CONFIG_ZIGBEE_USE_SOFTWARE_AES` - Configures the ZBOSS OSIF layer to use the software encryption. +* :kconfig:`CONFIG_ZIGBEE_USE_SOFTWARE_AES` - Configures the ZBOSS OSIF layer to use the software encryption. Additionally, the following Kconfig option is available when setting :ref:`zigbee_ug_logging_logger_options`: -* :option:`CONFIG_ZBOSS_OSIF_LOG_LEVEL` - Configures the custom logger options for the ZBOSS OSIF layer. +* :kconfig:`CONFIG_ZBOSS_OSIF_LOG_LEVEL` - Configures the custom logger options for the ZBOSS OSIF layer. API documentation ***************** diff --git a/doc/nrf/libraries/zigbee/lib_zigbee_shell.rst b/doc/nrf/libraries/zigbee/shell.rst similarity index 99% rename from doc/nrf/libraries/zigbee/lib_zigbee_shell.rst rename to doc/nrf/libraries/zigbee/shell.rst index 0598ace7536c..2c5ebfb8a55f 100644 --- a/doc/nrf/libraries/zigbee/lib_zigbee_shell.rst +++ b/doc/nrf/libraries/zigbee/shell.rst @@ -23,10 +23,10 @@ To change this and other Zephyr's shell settings (for example, the prompt or the To configure the Zigbee shell library, use the following options: -* :option:`CONFIG_ZIGBEE_SHELL` -* :option:`CONFIG_ZIGBEE_SHELL_ENDPOINT` -* :option:`CONFIG_ZIGBEE_SHELL_DEBUG_CMD` -* :option:`CONFIG_ZIGBEE_SHELL_LOG_LEVEL` +* :kconfig:`CONFIG_ZIGBEE_SHELL` +* :kconfig:`CONFIG_ZIGBEE_SHELL_ENDPOINT` +* :kconfig:`CONFIG_ZIGBEE_SHELL_DEBUG_CMD` +* :kconfig:`CONFIG_ZIGBEE_SHELL_LOG_LEVEL` For detailed steps about configuring the library in a Zigbee sample or application, see :ref:`ug_zigbee_configuring_components_logger_ep`. diff --git a/include/zigbee/zigbee_app_utils.rst b/doc/nrf/libraries/zigbee/zigbee_app_utils.rst similarity index 86% rename from include/zigbee/zigbee_app_utils.rst rename to doc/nrf/libraries/zigbee/zigbee_app_utils.rst index bcbab4a1c436..f905ed087737 100644 --- a/include/zigbee/zigbee_app_utils.rst +++ b/doc/nrf/libraries/zigbee/zigbee_app_utils.rst @@ -135,7 +135,12 @@ Complete zigbee_default_signal_handler implementation In its complete implementation, the `zboss_signal_handler()`_ allows the application to control a broader set of basic functionalities, including joining, commissioning, and network formation. -The following sections describe the logic implemented inside :c:func:`zigbee_default_signal_handler`. +.. figure:: images/zigbee_signal_handler_overview.svg + :alt: Zigbee default signal handler logic (simplified) + + Zigbee default signal handler logic (simplified) + +The following sections describe the logic implemented inside :c:func:`zigbee_default_signal_handler` and correspond to the shapes in the figure. .. _zarco_signal_handler_startup: @@ -149,16 +154,16 @@ When the stack is started through :c:func:`zigbee_enable`, the stack generates t The reception of these signals determines the behavior of the default signal handler: -* Upon reception of `ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY`_, the default signal handler prints out a log with the signal status and exit. +* Upon reception of `ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY`_, the default signal handler prints out a log with the signal status, and then exits. -.. figure:: /images/zigbee_signal_handler_01_production_config.svg +.. figure:: images/zigbee_signal_handler_01_production_config.svg :alt: ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY signal handler ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY signal handler -* Upon reception of `ZB_ZDO_SIGNAL_SKIP_STARTUP`_ signal, the default signal handler performs the BDB initialization procedure, and then exit. +* Upon reception of `ZB_ZDO_SIGNAL_SKIP_STARTUP`_ signal, the default signal handler performs the BDB initialization procedure, and then exits. -.. figure:: /images/zigbee_signal_handler_02_startup.svg +.. figure:: images/zigbee_signal_handler_02_startup.svg :alt: ZB_ZDO_SIGNAL_SKIP_STARTUP signal handler ZB_ZDO_SIGNAL_SKIP_STARTUP signal handler @@ -195,7 +200,7 @@ For factory new devices, the default signal handler performs the following actio Once handling of the signal is finished, the stack generates the `ZB_BDB_SIGNAL_STEERING`_ signal, and continues to :ref:`zarco_signal_handler_network`. -.. figure:: /images/zigbee_signal_handler_03_first_start.svg +.. figure:: images/zigbee_signal_handler_03_first_start.svg :alt: Scenario for factory new devices (ZB_BDB_SIGNAL_DEVICE_FIRST_START) Scenario for factory new devices (ZB_BDB_SIGNAL_DEVICE_FIRST_START) @@ -207,20 +212,20 @@ Commissioned device scenario For devices that have been already commissioned, the default handler performs the following actions: -* Not perform additional actions if the device implements a coordinator role. +* For devices that implement the coordinator role, the handler does not perform additional actions. * This keeps the network closed for new Zigbee devices even if the coordinator is reset. -* Not perform additional actions if the device successfully rejoins Zigbee network. +* For devices that successfully rejoin the Zigbee network, the handler does not perform additional actions. * This does not open the network for new devices if one of existing devices is reset. * If :ref:`zarco_network_rejoin` is running, it is cancelled. -* For routers and end devices, if they did not join the Zigbee network successfully, :ref:`zarco_network_rejoin` is started by calling :c:func:`start_network_rejoin`. +* For routers and end devices, if they did not join the Zigbee network successfully, the handler starts :ref:`zarco_network_rejoin` by calling :c:func:`start_network_rejoin`. Once finished, the stack generates the `ZB_BDB_SIGNAL_STEERING`_ signal, and continues to :ref:`zarco_signal_handler_network`. -.. figure:: /images/zigbee_signal_handler_04_reboot.svg +.. figure:: images/zigbee_signal_handler_04_reboot.svg :alt: Scenario for already commissioned devices (ZB_BDB_SIGNAL_DEVICE_REBOOT) Scenario for already commissioned devices (ZB_BDB_SIGNAL_DEVICE_REBOOT) @@ -228,14 +233,14 @@ Once finished, the stack generates the `ZB_BDB_SIGNAL_STEERING`_ signal, and con .. _zarco_signal_handler_network: Zigbee network formation and commissioning -++++++++++++++++++++++++++++++++++++++++++ +------------------------------------------ According to the logic implemented inside the default signal handler, the devices can either form a network or join an existing network: 1. Coordinators first form a network. Attempts to form the network continue infinitely, with a one-second delay between each attempt. - .. figure:: /images/zigbee_signal_handler_05_formation.svg + .. figure:: images/zigbee_signal_handler_05_formation.svg :alt: Forming a network following the generation of ZB_BDB_SIGNAL_FORMATION Forming a network following the generation of ZB_BDB_SIGNAL_FORMATION @@ -246,7 +251,7 @@ According to the logic implemented inside the default signal handler, the device * When a device has joined and :ref:`zarco_network_rejoin` is running, the procedure is cancelled. * If no device has joined and the procedure is not running, the procedure is started. - .. figure:: /images/zigbee_signal_handler_06_steering.svg + .. figure:: images/zigbee_signal_handler_06_steering.svg :alt: Forming a network following the generation of ZB_BDB_SIGNAL_STEERING Forming a network following the generation of ZB_BDB_SIGNAL_STEERING @@ -261,7 +266,7 @@ When leaving the network, the default handler calls :c:func:`start_network_rejoi Once :c:func:`start_network_rejoin` is called, the stack generates the `ZB_BDB_SIGNAL_STEERING`_ signal and continues to :ref:`zarco_signal_handler_network`. -.. figure:: /images/zigbee_signal_handler_09_leave.svg +.. figure:: images/zigbee_signal_handler_09_leave.svg :alt: Leaving the network following ZB_ZDO_SIGNAL_LEAVE Leaving the network following ZB_ZDO_SIGNAL_LEAVE @@ -277,29 +282,42 @@ It is used in :c:func:`zigbee_default_signal_handler` by default. If the network is left by a router or an end device, the device tries to join any open network. -* The router uses the default signal handler to try to join or rejoin the network until it succeeds. -* The end device uses the default signal handler to try to join or rejoin the network for a finite period of time, because the end devices are often powered by batteries. +The Zigbee rejoin procedure retries to join a network with each try after ``2^n`` seconds, where ``n`` is the number of retries. +The period is limited to the time specified in ``REJOIN_INTERVAL_MAX_S``, which by default equals 15 minutes. - * The procedure to join or rejoin the network is restarted after the device reset or power cycle. - * The procedure to join or rejoin the network can be restarted by calling :c:func:`user_input_indicate`, but it needs to be implemented in the application (for example, by calling :c:func:`user_input_indicate` when a button is pressed). - The procedure is restarted only if the device does not join and the procedure is not running. +When :c:func:`start_network_rejoin` is called, the rejoin procedure is started. -The Zigbee rejoin procedure retries to join a network with each try after a specified amount of time: ``2^n`` seconds, where ``n`` is the number of retries. +.. figure:: images/zigbee_signal_handler_10_rejoin.svg + :alt: Starting the rejoin procedure -The period is limited to 15 minutes if the result is higher than that. + Starting the rejoin procedure -* When :c:func:`start_network_rejoin` is called, the rejoin procedure is started, and depending on the device role: +When ``stop_network_rejoin(was_scheduled)`` is called, the network rejoin is canceled and the alarms scheduled by :c:func:`start_network_rejoin` are canceled. - * For the end device, the application alarm is scheduled with ``stop_network_rejoin(ZB_TRUE)``, to be called after the amount of time specified in ``ZB_DEV_REJOIN_TIMEOUT_MS``. - Once called, the alarm stops the rejoin. +.. figure:: images/zigbee_signal_handler_10_rejoin_stop.svg + :alt: Stopping the rejoin procedure -* When ``stop_network_rejoin(was_scheduled)`` is called, the network rejoin is canceled and the alarms scheduled by :c:func:`start_network_rejoin` are canceled. + Stopping the rejoin procedure - * Additionally for the end device, if :c:func:`stop_network_rejoin` is called with ``was_scheduled`` set to ``ZB_TRUE``, :c:func:`user_input_indicate` can restart the rejoin procedure. +The rejoin procedure is different for routers and end devices in the following aspects: -* For end devices only, :c:func:`user_input_indicate` restarts the rejoin procedure if the device did not join the network and is not trying to join a network. +* The router uses the default signal handler to try to join or rejoin the network until it succeeds. +* The end device uses the default signal handler to try to join or rejoin the network for a finite period of time, because the end devices are often powered by batteries. + + * The procedure to join or rejoin the network is restarted after the device resets or power cycles. + * The procedure to join or rejoin the network can be restarted by calling :c:func:`user_input_indicate`, but it needs to be implemented in the application (for example, by calling :c:func:`user_input_indicate` when a button is pressed). + The procedure is restarted only if the device was unable to join and the procedure is not running. + + For the end device, the application alarm is scheduled with ``stop_network_rejoin(ZB_TRUE)``, to be called after the amount of time specified in ``ZB_DEV_REJOIN_TIMEOUT_MS``. + + If :c:func:`stop_network_rejoin` is called with ``was_scheduled`` set to ``ZB_TRUE``, :c:func:`user_input_indicate` can restart the rejoin procedure. + :c:func:`user_input_indicate` restarts the rejoin procedure if the device did not join the network and is not trying to join a network. It is safe to call this function from an interrupt and to call it multiple times. + .. figure:: images/zigbee_signal_handler_10_rejoin_user_input.svg + :alt: User input restarting the the rejoin procedure + + User input restarting the the rejoin procedure .. note:: The Zigbee network rejoin procedure is managed from multiple signals in :c:func:`zigbee_default_signal_handler`. @@ -317,7 +335,7 @@ The minimal inactivity duration that causes the signal to be generated is define By default, the inactivity duration equals approximately 15 ms. The value can be modified by the ``zb_sleep_set_threshold`` API. -.. figure:: /images/zigbee_signal_handler_07_idle.svg +.. figure:: images/zigbee_signal_handler_07_idle.svg :alt: Generation of the ZB_COMMON_SIGNAL_CAN_SLEEP signal Generation of the ZB_COMMON_SIGNAL_CAN_SLEEP signal @@ -332,7 +350,7 @@ If so, it allows the Zigbee stack to enter the sleep state and suspend the Zigbe If the default behavior is not applicable for the application, you can customize the sleep functionality by overwriting the :c:func:`zb_osif_sleep` weak function and implementing a custom logic for handling the stack sleep state. -.. figure:: /images/zigbee_signal_handler_08_deep_sleep.svg +.. figure:: images/zigbee_signal_handler_08_deep_sleep.svg :alt: Implementing a custom logic for putting the stack into the sleep mode Implementing a custom logic for putting the stack into the sleep mode @@ -443,9 +461,9 @@ Use the following code as reference, with a call to :c:func:`zigbee_default_sign Configuration ************* -To enable the Zigbee application utilities library, set the :option:`CONFIG_ZIGBEE_APP_UTILS` Kconfig option. +To enable the Zigbee application utilities library, set the :kconfig:`CONFIG_ZIGBEE_APP_UTILS` Kconfig option. -To configure the logging level of the library, use the :option:`CONFIG_ZIGBEE_APP_UTILS_LOG_LEVEL` Kconfig option. +To configure the logging level of the library, use the :kconfig:`CONFIG_ZIGBEE_APP_UTILS_LOG_LEVEL` Kconfig option. For detailed steps about configuring the library in a Zigbee sample or application, see :ref:`ug_zigbee_configuring_components_application_utilities`. diff --git a/include/zigbee/zigbee_error_handler.rst b/doc/nrf/libraries/zigbee/zigbee_error_handler.rst similarity index 80% rename from include/zigbee/zigbee_error_handler.rst rename to doc/nrf/libraries/zigbee/zigbee_error_handler.rst index 304f3ae168d4..4dba4b4ecdab 100644 --- a/include/zigbee/zigbee_error_handler.rst +++ b/doc/nrf/libraries/zigbee/zigbee_error_handler.rst @@ -20,8 +20,8 @@ Configuration To use this library, include its header in your application and pass the error code that should be checked using its macros. -Additionally, if you want the error code to be printed to log, enable the :option:`CONFIG_LOG` and :option:`CONFIG_ZBOSS_ERROR_PRINT_TO_LOG` Kconfig options. -The :option:`CONFIG_ZBOSS_ERROR_PRINT_TO_LOG` option automatically enables the :option:`CONFIG_ZIGBEE_ERROR_TO_STRING_ENABLED` Kconfig option, which obtains the ZBOSS error code name. +Additionally, if you want the error code to be printed to log, enable the :kconfig:`CONFIG_LOG` and :kconfig:`CONFIG_ZBOSS_ERROR_PRINT_TO_LOG` Kconfig options. +The :kconfig:`CONFIG_ZBOSS_ERROR_PRINT_TO_LOG` option automatically enables the :kconfig:`CONFIG_ZIGBEE_ERROR_TO_STRING_ENABLED` Kconfig option, which obtains the ZBOSS error code name. The library also provides a macro for checking the value returned by the :c:func:`bdb_start_top_level_commissioning` function. diff --git a/include/zigbee/zigbee_fota.rst b/doc/nrf/libraries/zigbee/zigbee_fota.rst similarity index 76% rename from include/zigbee/zigbee_fota.rst rename to doc/nrf/libraries/zigbee/zigbee_fota.rst index 189da1727954..1b498a507944 100644 --- a/include/zigbee/zigbee_fota.rst +++ b/doc/nrf/libraries/zigbee/zigbee_fota.rst @@ -39,10 +39,10 @@ The library uses :ref:`nrfxlib:zboss`'s ZCL API to download the image. After the OTA Upgrade Client downloads the Zigbee OTA image header, the stack verifies the following mandatory fields: -* Manufacturer ID - Defined by the :option:`CONFIG_ZIGBEE_FOTA_MANUFACTURER_ID` Kconfig option. -* Image type - Defined by the :option:`CONFIG_ZIGBEE_FOTA_IMAGE_TYPE` Kconfig option; it may be different than the MCUboot image type value. -* Hardware version - Defined by the :option:`CONFIG_ZIGBEE_FOTA_HW_VERSION` Kconfig option. -* Firmware version - Defined by the :option:`CONFIG_MCUBOOT_IMAGE_VERSION` Kconfig option; see :ref:`ug_zigbee_configuring_components_ota` for details. +* Manufacturer ID - Defined by the :kconfig:`CONFIG_ZIGBEE_FOTA_MANUFACTURER_ID` Kconfig option. +* Image type - Defined by the :kconfig:`CONFIG_ZIGBEE_FOTA_IMAGE_TYPE` Kconfig option; it may be different than the MCUboot image type value. +* Hardware version - Defined by the :kconfig:`CONFIG_ZIGBEE_FOTA_HW_VERSION` Kconfig option. +* Firmware version - Defined by the :kconfig:`CONFIG_MCUBOOT_IMAGE_VERSION` Kconfig option; see :ref:`ug_zigbee_configuring_components_ota` for details. If all values are accepted, the OTA Upgrade Client downloads the first fragment of the firmware image. @@ -63,21 +63,21 @@ When the consumer of the library receives this event, it should issue a reboot c Configuration ************* -To enable the Zigbee FOTA library, set the :option:`CONFIG_ZIGBEE_FOTA` Kconfig option. +To enable the Zigbee FOTA library, set the :kconfig:`CONFIG_ZIGBEE_FOTA` Kconfig option. To configure the Zigbee FOTA library, use the following options: -* :option:`CONFIG_ZIGBEE_FOTA_HW_VERSION` -* :option:`CONFIG_ZIGBEE_FOTA_DATA_BLOCK_SIZE` -* :option:`CONFIG_ZIGBEE_FOTA_ENDPOINT` -* :option:`CONFIG_ZIGBEE_FOTA_PROGRESS_EVT` -* :option:`CONFIG_ZIGBEE_FOTA_MANUFACTURER_ID` -* :option:`CONFIG_ZIGBEE_FOTA_IMAGE_TYPE` -* :option:`CONFIG_ZIGBEE_FOTA_COMMENT` -* :option:`CONFIG_ENABLE_ZIGBEE_FOTA_MIN_HW_VERSION` -* :option:`CONFIG_ZIGBEE_FOTA_MIN_HW_VERSION` -* :option:`CONFIG_ENABLE_ZIGBEE_FOTA_MAX_HW_VERSION` -* :option:`CONFIG_ZIGBEE_FOTA_MAX_HW_VERSION` +* :kconfig:`CONFIG_ZIGBEE_FOTA_HW_VERSION` +* :kconfig:`CONFIG_ZIGBEE_FOTA_DATA_BLOCK_SIZE` +* :kconfig:`CONFIG_ZIGBEE_FOTA_ENDPOINT` +* :kconfig:`CONFIG_ZIGBEE_FOTA_PROGRESS_EVT` +* :kconfig:`CONFIG_ZIGBEE_FOTA_MANUFACTURER_ID` +* :kconfig:`CONFIG_ZIGBEE_FOTA_IMAGE_TYPE` +* :kconfig:`CONFIG_ZIGBEE_FOTA_COMMENT` +* :kconfig:`CONFIG_ENABLE_ZIGBEE_FOTA_MIN_HW_VERSION` +* :kconfig:`CONFIG_ZIGBEE_FOTA_MIN_HW_VERSION` +* :kconfig:`CONFIG_ENABLE_ZIGBEE_FOTA_MAX_HW_VERSION` +* :kconfig:`CONFIG_ZIGBEE_FOTA_MAX_HW_VERSION` For detailed steps about configuring the library in a Zigbee sample or application, see :ref:`ug_zigbee_configuring_components_ota`. @@ -86,7 +86,7 @@ Limitations The Zigbee FOTA library has the following limitations: -* The endpoint definition in the library includes the endpoint ID, defined with :option:`CONFIG_ZIGBEE_FOTA_ENDPOINT`. +* The endpoint definition in the library includes the endpoint ID, defined with :kconfig:`CONFIG_ZIGBEE_FOTA_ENDPOINT`. When using the Zigbee FOTA library, this endpoint ID cannot be used for other endpoints. * The Zigbee FOTA upgrades are currently only supported on the nRF52840 DK (PCA10056). * The Zigbee FOTA library does not currently support bootloader upgrades. diff --git a/include/zigbee/zigbee_logger_eprxzcl.rst b/doc/nrf/libraries/zigbee/zigbee_logger_eprxzcl.rst similarity index 94% rename from include/zigbee/zigbee_logger_eprxzcl.rst rename to doc/nrf/libraries/zigbee/zigbee_logger_eprxzcl.rst index 96c9fb4172b4..316ece7cfb94 100644 --- a/include/zigbee/zigbee_logger_eprxzcl.rst +++ b/doc/nrf/libraries/zigbee/zigbee_logger_eprxzcl.rst @@ -72,9 +72,9 @@ For example, enabling the Zigbee endpoint logger library with the :ref:`zigbee_l Configuration ************* -To enable the Zigbee endpoint logger library, set the :option:`CONFIG_ZIGBEE_LOGGER_EP` Kconfig option. +To enable the Zigbee endpoint logger library, set the :kconfig:`CONFIG_ZIGBEE_LOGGER_EP` Kconfig option. -To configure the logging level of the library, use the :option:`CONFIG_ZIGBEE_LOGGER_EP_LOG_LEVEL` Kconfig option. +To configure the logging level of the library, use the :kconfig:`CONFIG_ZIGBEE_LOGGER_EP_LOG_LEVEL` Kconfig option. For detailed steps about configuring the library in a Zigbee sample or application, see :ref:`ug_zigbee_configuring_components_logger_ep`. diff --git a/include/zigbee/zigbee_zcl_scenes.rst b/doc/nrf/libraries/zigbee/zigbee_zcl_scenes.rst similarity index 77% rename from include/zigbee/zigbee_zcl_scenes.rst rename to doc/nrf/libraries/zigbee/zigbee_zcl_scenes.rst index 32a9732528bc..b96192387ff2 100644 --- a/include/zigbee/zigbee_zcl_scenes.rst +++ b/doc/nrf/libraries/zigbee/zigbee_zcl_scenes.rst @@ -24,7 +24,7 @@ If you are implementing clusters that are not included in this list, you must im Configuration ************* -To enable the Zigbee ZCL scene helper library, set the :option:`CONFIG_ZIGBEE_SCENES` Kconfig option. +To enable the Zigbee ZCL scene helper library, set the :kconfig:`CONFIG_ZIGBEE_SCENES` Kconfig option. Because the library uses Zephyr's :ref:`settings_api` subsystem, the application must call the following functions for the library to work correctly: @@ -55,12 +55,12 @@ You must implement these functions in the following manner: } } -Setting the :option:`CONFIG_ZIGBEE_SCENES` option allows you to configure the following library-specific Kconfig options: +Setting the :kconfig:`CONFIG_ZIGBEE_SCENES` option allows you to configure the following library-specific Kconfig options: -* :option:`CONFIG_ZIGBEE_SCENES_ENDPOINT` - This option sets the endpoint number on which the device implements the ZCL scene cluster. -* :option:`CONFIG_ZIGBEE_SCENE_TABLE_SIZE` - This options sets the value for the amount of scenes that can be configured. +* :kconfig:`CONFIG_ZIGBEE_SCENES_ENDPOINT` - This option sets the endpoint number on which the device implements the ZCL scene cluster. +* :kconfig:`CONFIG_ZIGBEE_SCENE_TABLE_SIZE` - This options sets the value for the amount of scenes that can be configured. -To configure the logging level of the library, use the :option:`CONFIG_ZIGBEE_SCENES_LOG_LEVEL` Kconfig option. +To configure the logging level of the library, use the :kconfig:`CONFIG_ZIGBEE_SCENES_LOG_LEVEL` Kconfig option. API documentation ***************** diff --git a/doc/nrf/links.txt b/doc/nrf/links.txt index def30da970a2..b57b7b85e08d 100644 --- a/doc/nrf/links.txt +++ b/doc/nrf/links.txt @@ -90,14 +90,16 @@ .. _`SMP over Bluetooth`: https://github.com/apache/mynewt-mcumgr/blob/master/transport/smp-bluetooth.md -.. _`Android CHIPTool`: https://github.com/nrfconnect/sdk-connectedhomeip/tree/5b90f5/src/android/CHIPTool -.. _`Commissioning nRF Connect Accessory using Android CHIPTool`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/5b90f5/docs/guides/nrfconnect_android_commissioning.md -.. _`Working with Python Controller`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/5b90f5/src/controller/python/README.md -.. _`Performing Device Firmware Upgrade in Matter device`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/5b90f5/docs/guides/nrfconnect_examples_software_update.md -.. _`Matter Protocol Overview`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/5b90f5/README.md -.. _`nRF Connect platform overview`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/5b90f5/docs/guides/nrfconnect_platform_overview.md -.. _`other controller setups`: https://github.com/nrfconnect/sdk-connectedhomeip/tree/5b90f5/src/controller +.. _`Android CHIPTool`: https://github.com/nrfconnect/sdk-connectedhomeip/tree/27bce6d/src/android/CHIPTool +.. _`Commissioning nRF Connect Accessory using Android CHIPTool`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/27bce6d/docs/guides/nrfconnect_android_commissioning.md +.. _`Working with Python Controller`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/27bce6d/docs/guides/python_chip_controller_building.md +.. _`Performing Device Firmware Upgrade in Matter device`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/27bce6d/docs/guides/nrfconnect_examples_software_update.md +.. _`Matter Protocol Overview`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/27bce6d/README.md +.. _`nRF Connect platform overview`: https://github.com/nrfconnect/sdk-connectedhomeip/blob/27bce6d/docs/guides/nrfconnect_platform_overview.md +.. _`other controller setups`: https://github.com/nrfconnect/sdk-connectedhomeip/tree/27bce6d/src/controller .. _`ZCL Advanced Platform`: https://github.com/project-chip/zap +.. _`Matter nRF Connect releases`: https://github.com/nrfconnect/sdk-connectedhomeip/releases +.. _`Building Android CHIPTool`: https://github.com/project-chip/connectedhomeip/blob/27bce6d/docs/guides/android_chiptool_building.md .. _`nRF Cloud JSON protocol schemas`: https://github.com/nRFCloud/application-protocols diff --git a/doc/nrf/nrf.doxyfile.in b/doc/nrf/nrf.doxyfile.in index 12737f4ddb29..8dd973d6fe41 100644 --- a/doc/nrf/nrf.doxyfile.in +++ b/doc/nrf/nrf.doxyfile.in @@ -227,7 +227,7 @@ ALIASES = "rst=\verbatim embed:rst" \ "r=\verbatim embed:rst:leading-asterisk" \ "er=\endverbatim" -ALIASES += option{1}="\verbatim embed:rst:inline :option:`\1` \endverbatim" +ALIASES += kconfig{1}="\verbatim embed:rst:inline :kconfig:`\1` \endverbatim" ALIASES += "req=\xrefitem req \"Requirement\" \"Requirements\" " # This tag can be used to specify a number of word-keyword mappings (TCL only). @@ -790,7 +790,8 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = @NRF_BASE@/applications/connectivity_bridge/src/events/module_state_event.h +EXCLUDE = @NRF_BASE@/applications/connectivity_bridge/src/events/module_state_event.h \ + @NRF_BASE@/applications/matter_weather_station/src # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/doc/nrf/release_notes.rst b/doc/nrf/release_notes.rst index 196def0b0467..5bd852e441fe 100644 --- a/doc/nrf/release_notes.rst +++ b/doc/nrf/release_notes.rst @@ -12,7 +12,7 @@ This page is included only in the latest documentation, because it might contain A "99" at the end of the version number of this documentation indicates continuous updates on the master branch since the previous major.minor release. When looking at this latest documentation, be aware of the following aspects: - * Changes between releases are tracked on the :ref:`ncs_release_notes_latest` page, but the master branch might contain additional changes that are not listed on that page. + * Changes between releases are tracked on the :ref:`ncs_release_notes_changelog` page, but the master branch might contain additional changes that are not listed on that page. * The release note pages that are available in the latest documentation might differ slightly from the release notes that were included in the respective |NCS| release at its release date. Therefore, to see the official version of the release notes for a specific |NCS| release, switch to the documentation for the corresponding |NCS| version using the selector in the upper left-hand corner. @@ -20,7 +20,7 @@ This page is included only in the latest documentation, because it might contain :maxdepth: 1 :caption: Subpages: - releases/release-notes-latest + releases/release-notes-changelog releases/release-notes-1.6.1 releases/release-notes-1.6.0 releases/release-notes-1.5.1 diff --git a/doc/nrf/releases/release-notes-1.1.0.rst b/doc/nrf/releases/release-notes-1.1.0.rst index fe324e5d0e7f..a9611b64f3a0 100644 --- a/doc/nrf/releases/release-notes-1.1.0.rst +++ b/doc/nrf/releases/release-notes-1.1.0.rst @@ -337,7 +337,7 @@ nRF BLE Controller * Improved the default static memory pool allocation. The controller now determines its static memory pool size based on the maximum Link Layer packet length. - This is determined by the Kconfig macro :option:`CONFIG_BT_CTLR_DATA_LENGTH_MAX` (if defined), or else the minimum packet length (which is 27 B). + This is determined by the Kconfig macro :kconfig:`CONFIG_BT_CTLR_DATA_LENGTH_MAX` (if defined), or else the minimum packet length (which is 27 B). The memory pool is large enough to facilitate one master and one slave link. * Added support for connection intervals less than the standard minimum of 7.5 ms. @@ -392,7 +392,7 @@ Bluetooth Low Energy * Added "Numeric Comparison" pairing support and aligned LED usage in peripheral samples. * Added nRF52840 Dongle support in :ref:`peripheral_lbs`. -* Fixed default connections configuration when selecting :option:`CONFIG_BT_LL_SOFTDEVICE`. +* Fixed default connections configuration when selecting :kconfig:`CONFIG_BT_LL_SOFTDEVICE`. NFC @@ -514,15 +514,15 @@ Subsystems Bluetooth Low Energy -------------------- -* :option:`CONFIG_BT_HCI_TX_STACK_SIZE` must be set to 1536 when selecting :option:`CONFIG_BT_LL_SOFTDEVICE`. +* :kconfig:`CONFIG_BT_HCI_TX_STACK_SIZE` must be set to 1536 when selecting :kconfig:`CONFIG_BT_LL_SOFTDEVICE`. * The :ref:`nrfxlib:softdevice_controller` 0.3.0-3.prealpha might assert when receiving a packet with an CRC error on LE Coded PHY after performing a DLE procedure where RX Octets is changed to a value above 140. -* :option:`CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE` must be set to 2048 when selecting :option:`CONFIG_BT_LL_SOFTDEVICE` on :ref:`central_uart` and :ref:`central_bas`. -* :option:`CONFIG_NFCT_IRQ_PRIORITY` must be set to 5 or less when selecting :option:`CONFIG_BT_LL_SOFTDEVICE` on :ref:`peripheral_hids_keyboard`. -* When selecting :option:`CONFIG_BT_LL_SOFTDEVICE`: +* :kconfig:`CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE` must be set to 2048 when selecting :kconfig:`CONFIG_BT_LL_SOFTDEVICE` on :ref:`central_uart` and :ref:`central_bas`. +* :kconfig:`CONFIG_NFCT_IRQ_PRIORITY` must be set to 5 or less when selecting :kconfig:`CONFIG_BT_LL_SOFTDEVICE` on :ref:`peripheral_hids_keyboard`. +* When selecting :kconfig:`CONFIG_BT_LL_SOFTDEVICE`: If a directed high duty cycle advertiser times out, the application might have to wait a short time before starting a new connectable advertiser. Otherwise, starting the advertiser will fail. * Bluetooth Low Energy peripheral samples are unstable in some conditions (when pairing and bonding are performed and then disconnections/re-connections happen). -* When running the :ref:`bluetooth_central_dfu_smp` sample, the :option:`CONFIG_BT_SMP` configuration must be aligned between this sample and the Zephyr counterpart (:ref:`zephyr:smp_svr_sample`). +* When running the :ref:`bluetooth_central_dfu_smp` sample, the :kconfig:`CONFIG_BT_SMP` configuration must be aligned between this sample and the Zephyr counterpart (:ref:`zephyr:smp_svr_sample`). However, security is not enabled by default in the Zephyr sample. * The central samples (:ref:`central_uart`, :ref:`bluetooth_central_hids`) do not support any pairing methods with MITM protection. * On some operating systems, the nrf_desktop application is unable to reconnect to a host. diff --git a/doc/nrf/releases/release-notes-1.2.0.rst b/doc/nrf/releases/release-notes-1.2.0.rst index dadc1bf211a8..a995ef4bf203 100644 --- a/doc/nrf/releases/release-notes-1.2.0.rst +++ b/doc/nrf/releases/release-notes-1.2.0.rst @@ -556,7 +556,7 @@ Bluetooth Low Energy NFC requires this API to work correctly. * When the :ref:`peripheral_hids_mouse` sample is used with the Zephyr Bluetooth LE Controller, directed advertising does not time out and the regular advertising cannot be started. * The :ref:`bluetooth_central_hids` sample cannot connect to a peripheral that uses directed advertising. -* When running the :ref:`bluetooth_central_dfu_smp` sample, the :option:`CONFIG_BT_SMP` configuration must be aligned between this sample and the Zephyr counterpart (:ref:`zephyr:smp_svr_sample`). +* When running the :ref:`bluetooth_central_dfu_smp` sample, the :kconfig:`CONFIG_BT_SMP` configuration must be aligned between this sample and the Zephyr counterpart (:ref:`zephyr:smp_svr_sample`). However, security is not enabled by default in the Zephyr sample. * The central samples (:ref:`central_uart`, :ref:`bluetooth_central_hids`) do not support any pairing methods with MITM protection. * On some operating systems, the nrf_desktop application is unable to reconnect to a host. diff --git a/doc/nrf/releases/release-notes-1.3.0.rst b/doc/nrf/releases/release-notes-1.3.0.rst index 65b856e5ef1f..171cea7995f4 100644 --- a/doc/nrf/releases/release-notes-1.3.0.rst +++ b/doc/nrf/releases/release-notes-1.3.0.rst @@ -370,7 +370,7 @@ Secure Partition Manager (SPM) * Added support for disabling some services in the :ref:`secure_services` sample. It now works in more bootloader configurations. -* Disabled :option:`CONFIG_SPM_SERVICE_PREVALIDATE` in the :ref:`lib_spm` library, because this option requires the immutable bootloader. +* Disabled :kconfig:`CONFIG_SPM_SERVICE_PREVALIDATE` in the :ref:`lib_spm` library, because this option requires the immutable bootloader. * Updated the :ref:`lib_spm` library to make it compatible with nRF5340 (with or without `anomaly 19`_). CPU load measurement @@ -589,7 +589,7 @@ Bluetooth Low Energy NFC requires this API to work correctly. (fixed) * When the :ref:`peripheral_hids_mouse` sample is used with the Zephyr Bluetooth LE Controller, directed advertising does not time out and the regular advertising cannot be started. (fixed) * The :ref:`bluetooth_central_hids` sample cannot connect to a peripheral that uses directed advertising. (fixed) -* When running the :ref:`bluetooth_central_dfu_smp` sample, the :option:`CONFIG_BT_SMP` configuration must be aligned between this sample and the Zephyr counterpart (:ref:`zephyr:smp_svr_sample`). +* When running the :ref:`bluetooth_central_dfu_smp` sample, the :kconfig:`CONFIG_BT_SMP` configuration must be aligned between this sample and the Zephyr counterpart (:ref:`zephyr:smp_svr_sample`). However, security is not enabled by default in the Zephyr sample. (fixed) * On some operating systems, the nrf_desktop application is unable to reconnect to a host. (fixed) diff --git a/doc/nrf/releases/release-notes-1.4.0.rst b/doc/nrf/releases/release-notes-1.4.0.rst index e0fb3a50127d..90e63fc501d1 100644 --- a/doc/nrf/releases/release-notes-1.4.0.rst +++ b/doc/nrf/releases/release-notes-1.4.0.rst @@ -92,7 +92,7 @@ nRF9160 * :ref:`lib_download_client` library: - * Added CoAP block-wise transfer support, which can be enabled with :option:`CONFIG_COAP`. + * Added CoAP block-wise transfer support, which can be enabled with :kconfig:`CONFIG_COAP`. * Updated functions that end with ``_connect()`` and ``_start()`` to parse complete URLs, with port and schema. * Removed ``port`` field in :c:struct:`download_client_cfg`. The port number can now be passed together with the URL. @@ -178,9 +178,9 @@ nRF9160 * :ref:`lib_nrf_cloud` library: * Added saving of a valid session flag to settings after all subscriptions have completed, so that the persistent session is only used when the flag is valid. - * Replaced ``CONFIG_CLOUD_PERSISTENT_SESSIONS`` usage with Zephyr's :option:`CONFIG_MQTT_CLEAN_SESSION`. + * Replaced ``CONFIG_CLOUD_PERSISTENT_SESSIONS`` usage with Zephyr's :kconfig:`CONFIG_MQTT_CLEAN_SESSION`. * Made the MQTT client ID prefix configurable. - * Added an option to set send time-out for the socket used by nRF Cloud library (:option:`CONFIG_NRF_CLOUD_SEND_TIMEOUT`). + * Added an option to set send time-out for the socket used by nRF Cloud library (:kconfig:`CONFIG_NRF_CLOUD_SEND_TIMEOUT`). nRF5 ==== @@ -284,7 +284,7 @@ Bluetooth Mesh * :ref:`bt_mesh_light_ctl_readme` - These models allow remote control and configuration of CTLs on a mesh device. * :ref:`bt_mesh_scene_readme` - These models allow storing the model state of the entire mesh network as a *scene*, which can be recalled at a later time. * Added support for Mesh Device Properties v2.0. - * Added :option:`CONFIG_BT_TINYCRYPT_ECC` option in :file:`prj.conf` files for samples that support nRF5340 (:ref:`bluetooth_mesh_light` or :ref:`bluetooth_mesh_light_switch`). + * Added :kconfig:`CONFIG_BT_TINYCRYPT_ECC` option in :file:`prj.conf` files for samples that support nRF5340 (:ref:`bluetooth_mesh_light` or :ref:`bluetooth_mesh_light_switch`). * Updated: diff --git a/doc/nrf/releases/release-notes-1.5.0.rst b/doc/nrf/releases/release-notes-1.5.0.rst index ac02e8c23b5d..4129e2c7f2c0 100644 --- a/doc/nrf/releases/release-notes-1.5.0.rst +++ b/doc/nrf/releases/release-notes-1.5.0.rst @@ -104,7 +104,7 @@ nRF9160 * :ref:`lib_nrf_cloud` library: * nRF Connect for Cloud FOTA replaced AWS Jobs as the FOTA mechanism for devices connected to nRF Connect for Cloud. - * Removed :option:`CONFIG_CLOUD_API` dependency from :option:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD`. + * Removed :kconfig:`CONFIG_CLOUD_API` dependency from :kconfig:`CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD`. * Added a new API :c:func:`nrf_cloud_send` that can be used for sending pre-encoded data to specified endpoint topics in nRF Connect for Cloud. * :ref:`at_cmd_parser_readme` library - The library can now parse AT command strings with negative numbers in the range supported by the int32_t type. @@ -154,7 +154,7 @@ nRF5340 SoC * :ref:`esb_readme` subsystem - Added support for nRF5340 (CPUNET) in the ESB subsystem. * :ref:`lib_spm` subsystem - Added support for nRF5340 peripherals in non-secure applications. * :ref:`ble_samples` - Added configuration overlays for child image to the required Bluetooth LE samples so that no Kconfig updates in the :ref:`zephyr:bluetooth-hci-rpmsg-sample` sample are needed by default. - * :ref:`nrf5340_empty_app_core` sample - Disabled the kernel memory pool option :option:`CONFIG_KERNEL_MEM_POOL` to reduce the memory footprint. + * :ref:`nrf5340_empty_app_core` sample - Disabled the kernel memory pool option :kconfig:`CONFIG_KERNEL_MEM_POOL` to reduce the memory footprint. * ``bl_boot`` library - Disabled clock interrupts before booting the application. This change fixes an issue where the :ref:`bootloader` sample would not be able to boot a Zephyr application on the nRF5340 SoC. @@ -369,7 +369,7 @@ Crypto * :ref:`nrfxlib:nrf_security`: * Added Kconfig options for TLS/DTLS and x509 certificates. - * Added Kconfig options for ``PK`` and ``PK_WRITE`` (:option:`CONFIG_MBEDTLS_PK_C` and :option:`CONFIG_MBEDTLS_PK_WRITE_C`). + * Added Kconfig options for ``PK`` and ``PK_WRITE`` (:kconfig:`CONFIG_MBEDTLS_PK_C` and :kconfig:`CONFIG_MBEDTLS_PK_WRITE_C`). * Rewrote the stripping mechanism of the library to not use the ``POST_BUILD`` option in a custom build rule. The library stripping mechanism was non-functional in certain versions of |SES| Nordic Edition. @@ -435,11 +435,11 @@ The following list summarizes the most important changes inherited from upstream * Allowed the final data chunk in the image to be unaligned in the serial-recovery protocol. * Updated the ``CONFIG_BOOT_DIRECT_XIP_REVERT`` option to be valid only in xip-mode. * Added an offset parameter to the tinycrypt ctr mode so that it can be properly used as a streaming cipher. - * Configured the bootloader to use a minimal CBPRINTF (:option:`CONFIG_CBPRINTF_NANO`) implementation. - * Configured logging to use :option:`CONFIG_LOG_MINIMAL` by default. + * Configured the bootloader to use a minimal CBPRINTF (:kconfig:`CONFIG_CBPRINTF_NANO`) implementation. + * Configured logging to use :kconfig:`CONFIG_LOG_MINIMAL` by default. * Fixed a vulnerability with nokogiri<=1.11.0.rc4. * Introduced a bootutil_public library that contains code common to MCUboot and the DFU application. - See :option:`CONFIG_MCUBOOT_BOOTUTIL_LIB`. + See :kconfig:`CONFIG_MCUBOOT_BOOTUTIL_LIB`. * Image tool: @@ -460,7 +460,7 @@ The following list summarizes the most important changes inherited from upstream In this case, it was not possible to update the device and mcumgr would return error code 6 (``MGMT_ERR_EBADSTATE``). * Added support for invoking shell commands (shell management) from the mcumgr command line. * Added optional verification of an uploaded direct-xip binary, which will reject any binary that cannot boot from the base address of the offered upload slot. - This verification can be enabled through :option:`CONFIG_IMG_MGMT_REJECT_DIRECT_XIP_MISMATCHED_SLOT`. + This verification can be enabled through :kconfig:`CONFIG_IMG_MGMT_REJECT_DIRECT_XIP_MISMATCHED_SLOT`. Zephyr ====== @@ -543,7 +543,7 @@ The following list summarizes the most important changes inherited from upstream * Updated :c:func:`k_timer_user_data_get` to take a ``const struct k_timer *timer`` instead of a non-\ ``const`` pointer. * Added a :c:macro:`K_DELAYED_WORK_DEFINE` macro. - * Added a :option:`CONFIG_MEM_SLAB_TRACE_MAX_UTILIZATION` option. + * Added a :kconfig:`CONFIG_MEM_SLAB_TRACE_MAX_UTILIZATION` option. If enabled, :c:func:`k_mem_slab_max_used_get` can be used to get a memory slab's maximum utilization in blocks. * Bug fixes: @@ -636,8 +636,8 @@ The following list summarizes the most important changes inherited from upstream * Flash: * Modified the nRF QSPI NOR driver so that it also supports nRF53 Series SoCs. - * Added missing selection of :option:`CONFIG_FLASH_HAS_PAGE_LAYOUT` for the SPI NOR and AT45 family flash drivers. - * Refactored the nRF QSPI NOR driver so that it no longer depends on :option:`CONFIG_MULTITHREADING`. + * Added missing selection of :kconfig:`CONFIG_FLASH_HAS_PAGE_LAYOUT` for the SPI NOR and AT45 family flash drivers. + * Refactored the nRF QSPI NOR driver so that it no longer depends on :kconfig:`CONFIG_MULTITHREADING`. * Removed ``CONFIG_NORDIC_QSPI_NOR_QE_BIT``. Use the ``quad-enable-requirements`` devicetree property instead. * Added JESD216 support to the nRF QSPI NOR driver. @@ -735,14 +735,14 @@ The following list summarizes the most important changes inherited from upstream * Added support for RX packet queueing in TCP2. * Added network management events for DHCPv4. * Added periodic throughput printout to the :ref:`zephyr:sockets-echo-server-sample` sample. - * Added an experimental option to set preemptive priority for networking threads (:option:`CONFIG_NET_TC_THREAD_PREEMPTIVE`). - * Added a Kconfig option that enables a hostname update on link address change (:option:`CONFIG_NET_HOSTNAME_UNIQUE_UPDATE`). + * Added an experimental option to set preemptive priority for networking threads (:kconfig:`CONFIG_NET_TC_THREAD_PREEMPTIVE`). + * Added a Kconfig option that enables a hostname update on link address change (:kconfig:`CONFIG_NET_HOSTNAME_UNIQUE_UPDATE`). * Added multiple fixes to the DHCP implementation. * Added support for the Distributed Switch Architecture (DSA). * LwM2M: - * Made the endpoint name length configurable with Kconfig (see :option:`CONFIG_LWM2M_RD_CLIENT_ENDPOINT_NAME_MAX_LENGTH`). + * Made the endpoint name length configurable with Kconfig (see :kconfig:`CONFIG_LWM2M_RD_CLIENT_ENDPOINT_NAME_MAX_LENGTH`). * Fixed PUSH FOTA block transfer with Opaque content format. * Added various improvements to the bootstrap procedure. * Fixed token generation. @@ -764,22 +764,22 @@ The following list summarizes the most important changes inherited from upstream * Added new OpenThread options: * ``CONFIG_OPENTHREAD_NCP_BUFFER_SIZE`` - * :option:`CONFIG_OPENTHREAD_NUM_MESSAGE_BUFFERS` - * :option:`CONFIG_OPENTHREAD_MAX_STATECHANGE_HANDLERS` - * :option:`CONFIG_OPENTHREAD_TMF_ADDRESS_CACHE_ENTRIES` - * :option:`CONFIG_OPENTHREAD_MAX_CHILDREN` - * :option:`CONFIG_OPENTHREAD_MAX_IP_ADDR_PER_CHILD` - * :option:`CONFIG_OPENTHREAD_LOG_PREPEND_LEVEL_ENABLE` - * :option:`CONFIG_OPENTHREAD_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE` - * :option:`CONFIG_OPENTHREAD_MAC_SOFTWARE_RETRANSMIT_ENABLE` + * :kconfig:`CONFIG_OPENTHREAD_NUM_MESSAGE_BUFFERS` + * :kconfig:`CONFIG_OPENTHREAD_MAX_STATECHANGE_HANDLERS` + * :kconfig:`CONFIG_OPENTHREAD_TMF_ADDRESS_CACHE_ENTRIES` + * :kconfig:`CONFIG_OPENTHREAD_MAX_CHILDREN` + * :kconfig:`CONFIG_OPENTHREAD_MAX_IP_ADDR_PER_CHILD` + * :kconfig:`CONFIG_OPENTHREAD_LOG_PREPEND_LEVEL_ENABLE` + * :kconfig:`CONFIG_OPENTHREAD_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE` + * :kconfig:`CONFIG_OPENTHREAD_MAC_SOFTWARE_RETRANSMIT_ENABLE` * ``CONFIG_OPENTHREAD_PLATFORM_USEC_TIMER_ENABLE`` - * :option:`CONFIG_OPENTHREAD_RADIO_LINK_IEEE_802_15_4_ENABLE` - * :option:`CONFIG_OPENTHREAD_RADIO_LINK_TREL_ENABLE` - * :option:`CONFIG_OPENTHREAD_CSL_SAMPLE_WINDOW` - * :option:`CONFIG_OPENTHREAD_CSL_RECEIVE_TIME_AHEAD` - * :option:`CONFIG_OPENTHREAD_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE` - * :option:`CONFIG_OPENTHREAD_PLATFORM_INFO` - * :option:`CONFIG_OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE` + * :kconfig:`CONFIG_OPENTHREAD_RADIO_LINK_IEEE_802_15_4_ENABLE` + * :kconfig:`CONFIG_OPENTHREAD_RADIO_LINK_TREL_ENABLE` + * :kconfig:`CONFIG_OPENTHREAD_CSL_SAMPLE_WINDOW` + * :kconfig:`CONFIG_OPENTHREAD_CSL_RECEIVE_TIME_AHEAD` + * :kconfig:`CONFIG_OPENTHREAD_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE` + * :kconfig:`CONFIG_OPENTHREAD_PLATFORM_INFO` + * :kconfig:`CONFIG_OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE` * Added support for RCP co-processor mode. * Fixed multicast packet reception. @@ -800,7 +800,7 @@ The following list summarizes the most important changes inherited from upstream * CoAP: * Added a retransmission counter to the :c:struct:`coap_pending` structure to simplify the retransmission logic. - * Added a Kconfig option to randomize the initial ACK time-out, as specified in RFC 7252 (:option:`CONFIG_COAP_RANDOMIZE_ACK_TIMEOUT`). + * Added a Kconfig option to randomize the initial ACK time-out, as specified in RFC 7252 (:kconfig:`CONFIG_COAP_RANDOMIZE_ACK_TIMEOUT`). * Fixed encoding of long options (larger than 268 bytes). * Bluetooth Mesh: @@ -835,12 +835,12 @@ The following list summarizes the most important changes inherited from upstream * Added a :c:macro:`FS_MOUNT_FLAG_NO_FORMAT` flag to the FatFs options. This flag removes formatting capabilities from the FAT/exFAT file system driver and prevents unformatted devices to be formatted, to FAT or exFAT, on mount attempt. * Added support for the following :c:func:`fs_mount` flags: :c:macro:`FS_MOUNT_FLAG_READ_ONLY`, :c:macro:`FS_MOUNT_FLAG_NO_FORMAT` - * Updated the FS API to not perform a runtime check of a driver interface when the :option:`CONFIG_NO_RUNTIME_CHECKS` option is enabled. + * Updated the FS API to not perform a runtime check of a driver interface when the :kconfig:`CONFIG_NO_RUNTIME_CHECKS` option is enabled. * DFU: * Added shell module for MCUboot enabled application. - See :option:`CONFIG_MCUBOOT_SHELL`. + See :kconfig:`CONFIG_MCUBOOT_SHELL`. * Reworked the implementation to use MCUboot's bootutil_public library instead of the Zephyr implementation of the same API. * IPC: @@ -853,7 +853,7 @@ The following list summarizes the most important changes inherited from upstream * Renamed sanitycheck to Twister. * Ensured that shields can be placed in other BOARD_ROOT folders. * Added basic support for Clang 10 with x86. - * Fixed a bug that prevented compiling the :ref:`bootloader` with :option:`CONFIG_SB_SIGNING_PUBLIC_KEY` + * Fixed a bug that prevented compiling the :ref:`bootloader` with :kconfig:`CONFIG_SB_SIGNING_PUBLIC_KEY` * System: @@ -880,7 +880,7 @@ The following list summarizes the most important changes inherited from upstream * Modules: - * Introduced a :option:`CONFIG_MBEDTLS_MEMORY_DEBUG` option for mbedtls. + * Introduced a :kconfig:`CONFIG_MBEDTLS_MEMORY_DEBUG` option for mbedtls. * Updated LVGL to v7.6.1. * Updated libmetal and openamp to v2020.10. * Updated nrfx in hal-nordic to version 2.4.0. @@ -992,7 +992,7 @@ Applications and samples * :ref:`serial_lte_modem` - Added documentation for new commands. Fixed the syntax and examples of some existing commands. - * Added a note about :option:`CONFIG_MQTT_KEEPALIVE` option to the :ref:`aws_iot`, :ref:`azure_iot_hub`, and :ref:`cloud_client` samples. + * Added a note about :kconfig:`CONFIG_MQTT_KEEPALIVE` option to the :ref:`aws_iot`, :ref:`azure_iot_hub`, and :ref:`cloud_client` samples. * Bluetooth: * Added a note about child-image overlay to the :ref:`bluetooth_central_hr_coded` and :ref:`peripheral_hr_coded` samples. diff --git a/doc/nrf/releases/release-notes-1.6.0.rst b/doc/nrf/releases/release-notes-1.6.0.rst index 40cb00c6a55d..a57735d5936e 100644 --- a/doc/nrf/releases/release-notes-1.6.0.rst +++ b/doc/nrf/releases/release-notes-1.6.0.rst @@ -118,7 +118,7 @@ nRF9160 * :ref:`lib_nrf_cloud` library: * Added cellular positioning support to the :ref:`lib_nrf_cloud_cell_pos` library. - * Added Kconfig option :option:`CONFIG_NRF_CLOUD_CELL_POS` to obtain cell-based location from nRF Cloud instead of using the modem's GPS. + * Added Kconfig option :kconfig:`CONFIG_NRF_CLOUD_CELL_POS` to obtain cell-based location from nRF Cloud instead of using the modem's GPS. * Added function :c:func:`nrf_cloud_modem_fota_completed`, which is to be called by the application after it re-initializes the modem (instead of rebooting) after a modem FOTA update. * Updated to include the FOTA type value in the :c:enumerator:`NRF_CLOUD_EVT_FOTA_DONE` event. * Updated configuration options for setting the source of the MQTT client ID (nRF Cloud device ID). @@ -132,7 +132,7 @@ nRF9160 * Added :file:`overlay-agps-pgps.conf` to enable A-GPS and P-GPS support. * Updated to handle new Kconfig options: - * :option:`CONFIG_NRF_CLOUD_CELL_POS` + * :kconfig:`CONFIG_NRF_CLOUD_CELL_POS` * :ref:`asset_tracker_v2` application: @@ -206,8 +206,8 @@ nRF9160 * Removed provisioning using :ref:`modem_key_mgmt` and :file:`certificates.h`, because this is not the recommended way of provisioning private certificates. * Renamed the following Kconfig options: - * ``CONFIG_CLOUD_CERT_SEC_TAG`` renamed to :option:`CONFIG_CERT_SEC_TAG`. - * ``CONFIG_USE_CLOUD_CLIENT_ID`` renamed to :option:`CONFIG_USE_CUSTOM_CLIENT_ID`. + * ``CONFIG_CLOUD_CERT_SEC_TAG`` renamed to :kconfig:`CONFIG_CERT_SEC_TAG`. + * ``CONFIG_USE_CLOUD_CLIENT_ID`` renamed to :kconfig:`CONFIG_USE_CUSTOM_CLIENT_ID`. * ``CONFIG_CLOUD_CLIENT_ID`` renamed to ``CONFIG_CLIENT_ID``. * ``CONFIG_NRF_CLOUD_CLIENT_ID_PREFIX`` renamed to ``CONFIG_CLIENT_ID_PREFIX``. @@ -257,7 +257,7 @@ Bluetooth mesh * Updated the :ref:`bt_mesh_light_xyl_srv_readme` model to publish its state values that were loaded from flash after powering up. * Replaced the linked list of scene entries in the model contexts, with a lookup in ROM-allocated scene entries. * Updated so the transition pointer can be NULL, if no transition time parameters are provided in APIs. - * Renamed Kconfig option ``CONFIG_BT_MESH_LIGHT_CTRL_STORE_TIMEOUT`` to :option:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`, and default value is set to 0. + * Renamed Kconfig option ``CONFIG_BT_MESH_LIGHT_CTRL_STORE_TIMEOUT`` to :kconfig:`CONFIG_BT_MESH_MODEL_SRV_STORE_TIMEOUT`, and default value is set to 0. * Updated the :ref:`bt_mesh_light_ctrl_srv_readme` model with a timer, allowing it to resume operation after a certain delay. * Updated the proportional-integral (PI) feedback regulator to use instant transition time to relieve the application from overhead. * Fixed an issue where an undefined state for some sensor properties is a valid state, and should be handled without giving errors. @@ -273,7 +273,7 @@ Bluetooth mesh * Fixed an issue where :ref:`bt_mesh_light_ctrl_srv_readme` should disable control when the lightness is set by receiving a message. * Added persistent storage to the :ref:`bt_mesh_scheduler_readme` to restore previously configured entries on power-up. * Fixed an issue where CTL temperature bindings should use rounding operation for division in the binding formula. - * Samples are using :option:`CONFIG_NVS` instead of :option:`CONFIG_FCB` as the default storage backend. + * Samples are using :kconfig:`CONFIG_NVS` instead of :kconfig:`CONFIG_FCB` as the default storage backend. * Fixed an issue in :ref:`bt_mesh_light_ctrl_srv_readme` by always setting the transition time to a Fade Standby Manual state time when a Light Off event is received. * Fixed an issue by reporting maximum remaining time for all components for CTL state transition time when GET is processed. * Fixed an issue where a deleted :ref:`bt_mesh_scene_srv_readme` did not delete all its pages from the file system. diff --git a/doc/nrf/releases/release-notes-latest.rst b/doc/nrf/releases/release-notes-changelog.rst similarity index 73% rename from doc/nrf/releases/release-notes-latest.rst rename to doc/nrf/releases/release-notes-changelog.rst index 91d270fec702..ed05c4c61127 100644 --- a/doc/nrf/releases/release-notes-latest.rst +++ b/doc/nrf/releases/release-notes-changelog.rst @@ -1,22 +1,17 @@ -.. _ncs_release_notes_latest: +.. _ncs_release_notes_changelog: -Changes in |NCS| v1.6.99 -######################## +Changelog for |NCS| v1.6.99 +########################### .. contents:: :local: :depth: 2 -The most relevant changes that are present on the master branch of the |NCS|, as compared to the latest release, are tracked in this file. +The most relevant changes that are present on the master branch of the |NCS|, as compared to the latest official release, are tracked in this file. .. note:: This file is a work in progress and might not cover all relevant changes. -Highlights -********** - -There are no entries for this section yet. - Known issues ************ @@ -56,7 +51,9 @@ nRF9160 * Added a separate document page to explain data mode mechanism and how it works. * Removed datatype in all sending AT commands. If no sending data is specified, switch data mode to receive and send any arbitrary data. * Added a separate document page to describe the FOTA service. - * Added IPv6 support to Socket and ICMP services. + * Added IPv6 support to all SLM services. + * Added the GNSS service to replace the existing GPS test functionality. + * Added the optional support of location services from nRF Cloud, like A-GPS, P-GPS, and cellular positioning. * :ref:`asset_tracker_v2` application: @@ -70,6 +67,10 @@ nRF9160 * The library has been deprecated in favor of the :ref:`at_monitor_readme` library. + * ``thingy91_nrf9160_ns`` board: + + * The ``thingy91_nrf9160ns`` board has been renamed to ``thingy91_nrf9160_ns`` for consistency with the changes inherited from upstream Zephyr. + nRF5 ==== @@ -85,15 +86,17 @@ Bluetooth LE * Updated: - * :ref:`ble_samples` - Changed the Bluetooth sample Central DFU SMP name to :ref:`Central SMP Client `. + * :ref:`ble_samples` - Changed the Bluetooth® sample Central DFU SMP name to :ref:`Central SMP Client `. Matter ------ * Added: - * :ref:`Weather station ` sample. + * :ref:`Thngy:53 Weather station ` application. * :ref:`Template ` sample with a guide about :ref:`ug_matter_creating_accessory`. + * :ref:`ug_matter_tools` page with information about building options for Matter controllers. + * PA/LNA GPIO interface support for RF front-end modules (FEM) in Matter. Zigbee ------ @@ -103,6 +106,9 @@ Zigbee * :ref:`lib_zigbee_zcl_scenes` library with documentation. This library was separated from the Zigbee light bulb sample. + * :ref:`zigbee_template_sample` sample. + This minimal Zigbee router application can be used as the starting point for developing custom Zigbee devices. + Common ====== @@ -174,6 +180,13 @@ For a complete list of |NCS| specific commits, run: The current |NCS| release is based on Zephyr v2.6.0-rc1. See the :ref:`zephyr:zephyr_2.6` Release Notes for an overview of the most important changes inherited from upstream Zephyr. +The following list summarizes the most important changes inherited from upstream Zephyr: + +* The ``nrf9160dk_nrf9160ns`` and the ``nrf5340dk_nrf5340_cpuappns`` boards have been renamed respectively to ``nrf9160dk_nrf9160_ns`` and ``nrf5340dk_nrf5340_cpuapp_ns``. +* A config option for ``memcpy`` that skips the word-based loop before the byte-based loop was added. + It is now enabled by default if :kconfig:`SIZE_OPTIMIZATIONS` is set. + As result, any application-specific assumptions about ``memcpy`` read or write size behavior should be rechecked if this option is enabled. + Matter (Project CHIP) ===================== @@ -185,8 +198,12 @@ The following list summarizes the most important changes inherited from the upst * Support for Certificate-Authenticated Session Establishment (CASE) for communication among operational Matter nodes. * Support for OpenThread's DNS Client to enable Matter node discovery on Thread devices. + * Fixed the known issue KRKNWK-10387 where Matter service was needlessly advertised over Bluetooth LE during DFU. + Now if Matter pairing mode is not opened and the Bluetooth LE advertising is needed due to DFU requirements, only the SMP service is advertised. Documentation ============= -There are no entries for this section yet. +* Updated: + + * Renamed :ref:`ncs_release_notes_changelog`. diff --git a/doc/nrf/samples.rst b/doc/nrf/samples.rst index 0a9029e09105..f2e6366fb7a7 100644 --- a/doc/nrf/samples.rst +++ b/doc/nrf/samples.rst @@ -15,7 +15,7 @@ Those samples are a good starting point for understanding how to put together yo .. note:: All samples in the |NCS| are configured to perform a system reset if a fatal error occurs. This behavior is different from how fatal errors are handled in the Zephyr samples. - You can change the default behavior by updating the configuration option :option:`CONFIG_RESET_ON_FATAL_ERROR`. + You can change the default behavior by updating the configuration option :kconfig:`CONFIG_RESET_ON_FATAL_ERROR`. .. toctree:: :maxdepth: 1 diff --git a/doc/nrf/samples/samples_matter.rst b/doc/nrf/samples/samples_matter.rst index 68945c36f5f9..c0236cae1336 100644 --- a/doc/nrf/samples/samples_matter.rst +++ b/doc/nrf/samples/samples_matter.rst @@ -3,6 +3,11 @@ Matter samples ############## +The |NCS| provides the following samples showcasing the :ref:`Matter ` protocol. +The samples can be built for various boards and can be configured for different usage scenarios. + +In addition to these samples, check also the :ref:`Thingy:53 Matter weather station ` application. + .. toctree:: :maxdepth: 1 :caption: Subpages diff --git a/doc/nrf/shortcuts.txt b/doc/nrf/shortcuts.txt index d030628651dd..bed9d1a6d69c 100644 --- a/doc/nrf/shortcuts.txt +++ b/doc/nrf/shortcuts.txt @@ -40,9 +40,9 @@ .. |fota_upgrades_def| replace:: You can upgrade the firmware of the device over the air, thus without a wired connection. Such an upgrade is called a FOTA (firmware over-the-air) upgrade. -.. |fota_upgrades_req_mcuboot| replace:: To upgrade the application, you must use :doc:`mcuboot:index` as the upgradable bootloader (:option:`CONFIG_BOOTLOADER_MCUBOOT` must be enabled). +.. |fota_upgrades_req_mcuboot| replace:: To upgrade the application, you must use :doc:`mcuboot:index` as the upgradable bootloader (:kconfig:`CONFIG_BOOTLOADER_MCUBOOT` must be enabled). -.. |fota_upgrades_building| replace:: To create a binary file for an application upgrade, make sure that :option:`CONFIG_BOOTLOADER_MCUBOOT` is enabled and build the application as usual. +.. |fota_upgrades_building| replace:: To create a binary file for an application upgrade, make sure that :kconfig:`CONFIG_BOOTLOADER_MCUBOOT` is enabled and build the application as usual. The build will create several binary files (see :ref:`mcuboot:mcuboot_ncs`). .. |Google_CCLicense| replace:: Portions of this page are reproduced from work created and `shared by Google`_, and used according to terms described in the `Creative Commons 4.0 Attribution License`_. diff --git a/doc/nrf/templates/mesh_model_server_client_template.rst b/doc/nrf/templates/mesh_model_server_client_template.rst index 81021c7cdcd4..33704deebd39 100644 --- a/doc/nrf/templates/mesh_model_server_client_template.rst +++ b/doc/nrf/templates/mesh_model_server_client_template.rst @@ -46,11 +46,11 @@ Configuration* The following configuration parameters are associated with the XYZ Server/XYZ Client model: -* ``:option:PARAM_1`` - Short description of the first parameter. -* ``:option:PARAM_2`` - Short description of the second parameter. +* ``:kconfig:PARAM_1`` - Short description of the first parameter. +* ``:kconfig:PARAM_2`` - Short description of the second parameter. .. tip:: - List Kconfig options associated with the model, and link to them using the `:option:` reference. + List Kconfig options associated with the model, and link to them using the `:kconfig:` reference. This section is optional, because not all models have Kconfig parameters that allow configuration. Do not go into details here, as the link will allow the reader to get the required information. However, do provide a short description of each option. diff --git a/doc/nrf/templates/sample_README.rst b/doc/nrf/templates/sample_README.rst index deb20112c8d1..532e7aee606f 100644 --- a/doc/nrf/templates/sample_README.rst +++ b/doc/nrf/templates/sample_README.rst @@ -124,7 +124,7 @@ Configuration options* .. note:: * You do not need to list all configuration options of the sample, but only the ones that are important for the sample and make sense for the user to know about. - * The syntax below allows sample configuration options to link to the option descriptions in the same way as the library configuration options link to the corresponding Kconfig descriptions (``:option:`SAMPLE_CONFIG```, which results in :option:`SAMPLE_CONFIG`). + * The syntax below allows sample configuration options to link to the option descriptions in the same way as the library configuration options link to the corresponding Kconfig descriptions (``:kconfig:`SAMPLE_CONFIG```, which results in :kconfig:`SAMPLE_CONFIG`). * For each configuration option, list the symbol name and the string describing it. Check and configure the following configuration options for the sample: @@ -143,13 +143,13 @@ Additional configuration* .. note:: * Add this section to describe and link to any library configuration options that might be important to run this sample. - You can link to options with ``:option:`CONFIG_XXX```. + You can link to options with ``:kconfig:`CONFIG_XXX```. * You do not need to list all possible configuration options, but only the ones that are relevant. Check and configure the following library options that are used by the sample: -* :option:`CONFIG_BT_DEVICE_NAME` - Defines the Bluetooth device name. -* :option:`CONFIG_BT_LBS` - Enables the :ref:`lbs_readme`. +* :kconfig:`CONFIG_BT_DEVICE_NAME` - Defines the Bluetooth® device name. +* :kconfig:`CONFIG_BT_LBS` - Enables the :ref:`lbs_readme`. Configuration files* ==================== @@ -223,16 +223,10 @@ Troubleshooting* If the LEDs do not start blinking, check if the music is loud enough. - -Known issues and limitations* -***************************** - -The sample only works with good music. - References* *********** -* Music chapter in the Bluetooth Spec (-> always link) +* Music chapter in the Bluetooth® Spec (-> always link) * Disco ball datasheet .. tip:: diff --git a/doc/nrf/ug_ble_controller.rst b/doc/nrf/ug_ble_controller.rst index 907dcc36becd..9058d7907f95 100644 --- a/doc/nrf/ug_ble_controller.rst +++ b/doc/nrf/ug_ble_controller.rst @@ -7,7 +7,7 @@ Bluetooth LE Controller :local: :depth: 2 -When you develop a Bluetooth Low Energy (LE) application, you must include a Bluetooth LE Controller. +When you develop a Bluetooth® Low Energy (LE) application, you must include a Bluetooth® LE Controller. A Bluetooth LE Controller is the layer of the Bluetooth stack that handles the physical layer packets and all associated timing. It implements the Link Layer, which is the low-level, real-time protocol that controls the Bluetooth LE communication. @@ -35,7 +35,7 @@ The SoftDevice Controller is distributed as a set of precompiled, linkable libra There are different variants of the libraries that support different feature sets. Which variant you should choose depends on the chip that you are using, the features that you need, and the amount of available memory. -Nordic's SoftDevice Controller supports an extensive standard feature set from the Bluetooth 5.2 specification and a number of extensions for high-performance applications like Low Latency Packet mode (LLPM). +Nordic's SoftDevice Controller supports an extensive standard feature set from the Bluetooth® 5.2 specification and a number of extensions for high-performance applications like Low Latency Packet mode (LLPM). See the :ref:`SoftDevice Controller documentation ` for a detailed list of supported features. @@ -59,4 +59,4 @@ Most :ref:`Bluetooth LE samples ` in the |NCS| can use either Bluet An exception is the :ref:`ble_llpm` sample, which requires the SoftDevice Controller that supports LLPM. By default, all samples except for the Bluetooth mesh samples are currently configured to use SoftDevice Controller. -To use the Zephyr Bluetooth LE Controller instead, set :option:`CONFIG_BT_LL_SW_SPLIT` to ``y`` in the :file:`prj.conf` file (see :ref:`configure_application`) and make sure to build from a clean build directory. +To use the Zephyr Bluetooth LE Controller instead, set :kconfig:`CONFIG_BT_LL_SW_SPLIT` to ``y`` in the :file:`prj.conf` file (see :ref:`configure_application`) and make sure to build from a clean build directory. diff --git a/doc/nrf/ug_bootloader_adding.rst b/doc/nrf/ug_bootloader_adding.rst index f63885588751..ccbcea3a1a36 100644 --- a/doc/nrf/ug_bootloader_adding.rst +++ b/doc/nrf/ug_bootloader_adding.rst @@ -39,7 +39,7 @@ The following sections describe how to add either |NSIB| or MCUboot as an immuta Adding |NSIB| as an immutable bootloader ======================================== -To build |NSIB| with a Zephyr or |NCS| sample, enable the :option:`CONFIG_SECURE_BOOT` in the application's ``prj.conf`` file, in an associated Kconfig fragment, or using the command line: +To build |NSIB| with a Zephyr or |NCS| sample, enable the :kconfig:`CONFIG_SECURE_BOOT` in the application's ``prj.conf`` file, in an associated Kconfig fragment, or using the command line: .. code-block:: console @@ -53,7 +53,7 @@ To ensure that the immutable bootloader occupies as little flash memory as possi .. code-block:: console - west build -b nrf52840dk_nrf5840 zephyr/samples/hello_world -- \ + west build -b nrf52840dk_nrf52840 zephyr/samples/hello_world -- \ -DCONFIG_SECURE_BOOT=y \ -Db0_CONF_FILE=prj_minimal.conf @@ -64,7 +64,7 @@ See :ref:`ug_bootloader_config` for more information about using Kconfig fragmen Adding a custom signature key file ---------------------------------- -To add a signature key file to this bootloader, set the :option:`CONFIG_SB_SIGNING_KEY_FILE` option in the application's ``prj.conf`` file, in an associated Kconfig fragment, or using the command line: +To add a signature key file to this bootloader, set the :kconfig:`CONFIG_SB_SIGNING_KEY_FILE` option in the application's ``prj.conf`` file, in an associated Kconfig fragment, or using the command line: .. tabs:: @@ -137,9 +137,9 @@ See :ref:`ug_fw_update_keys` for information on how to generate custom keys for Additionally, the |NSIB| supports the following methods for signing images with private keys: -* :ref:`ug_fw_update_keys_python` - The default method, using the :option:`CONFIG_SB_SIGNING_PYTHON`. -* :ref:`ug_fw_update_keys_openssl` - Uses the :option:`CONFIG_SB_SIGNING_OPENSSL`. -* :ref:`Using a custom command ` - Uses the :option:`CONFIG_SB_SIGNING_CUSTOM`. +* :ref:`ug_fw_update_keys_python` - The default method, using the :kconfig:`CONFIG_SB_SIGNING_PYTHON`. +* :ref:`ug_fw_update_keys_openssl` - Uses the :kconfig:`CONFIG_SB_SIGNING_OPENSSL`. +* :ref:`Using a custom command ` - Uses the :kconfig:`CONFIG_SB_SIGNING_CUSTOM`. Both Python and OpenSSL methods are handled internally by the build system, whereas using custom commands requires more configuration steps. @@ -181,7 +181,7 @@ To use a custom signing command with this bootloader, set the following options .. code-block:: console - west build -b nrf52840dk_nrf5840 zephyr/samples/hello_world -- \ + west build -b nrf52840dk_nrf52840 zephyr/samples/hello_world -- \ -DCONFIG_SECURE_BOOT=y \ -DCONFIG_SB_SIGNING_CUSTOM=y \ -DCONFIG_SB_SIGNING_PUBLIC_KEY=\"/path/to/pub.pem\" \ @@ -193,7 +193,7 @@ To use a custom signing command with this bootloader, set the following options The public key string must be an absolute path to the location of the public key file, as mentioned previously in :ref:`ug_bootloader_adding_immutable_keys`. -See :option:`CONFIG_SB_SIGNING_COMMAND` for specifics about what a usable signing command must do. +See :kconfig:`CONFIG_SB_SIGNING_COMMAND` for specifics about what a usable signing command must do. The command string can include its own arguments like a typical terminal command, including arguments specific to the build system: .. parsed-literal:: @@ -201,7 +201,7 @@ The command string can include its own arguments like a typical terminal command my_command *[options]* ** ** -See the description of :option:`CONFIG_SB_SIGNING_COMMAND` for which arguments can be be sent to the build system in this way. +See the description of :kconfig:`CONFIG_SB_SIGNING_COMMAND` for which arguments can be be sent to the build system in this way. .. note:: @@ -302,7 +302,7 @@ To enable this configuration, apply the :file:`overlay-minimal-external-crypto.c .. code-block:: - west build -b nrf52840dk_nrf5840 zephyr/samples/hello_world -- \ + west build -b nrf52840dk_nrf52840 zephyr/samples/hello_world -- \ -DCONFIG_BOOTLOADER_MCUBOOT=y \ -Dmcuboot_OVERLAY_CONFIG=overlay-minimal-external-crypto.conf @@ -326,7 +326,7 @@ The process to use specific signature keys with MCUboot used as the upgradable b Generating pre-signed variants ------------------------------ -Enable the :option:`CONFIG_BUILD_S1_VARIANT` option when building the upgradable bootloader to automatically generate :ref:`pre-signed variants ` of the image for both slots: +Enable the :kconfig:`CONFIG_BUILD_S1_VARIANT` option when building the upgradable bootloader to automatically generate :ref:`pre-signed variants ` of the image for both slots: .. code-block:: diff --git a/doc/nrf/ug_bootloader_config.rst b/doc/nrf/ug_bootloader_config.rst index 2b1596f13540..f0ac6baced78 100644 --- a/doc/nrf/ug_bootloader_config.rst +++ b/doc/nrf/ug_bootloader_config.rst @@ -27,7 +27,7 @@ For example, you can assign custom project configurations for both the bootloade -Dmcuboot_CONF_FILE=prj_upgradable.conf \ -DCONF_FILE=prj_app.conf -In the example above, :file:`prj_app.conf` includes :option:`CONFIG_SECURE_BOOT` and ``CONFIG_BOOTLOADER_MCUBOOT`` to enable the immutable and upgradable bootloaders by default. +In the example above, :file:`prj_app.conf` includes :kconfig:`CONFIG_SECURE_BOOT` and ``CONFIG_BOOTLOADER_MCUBOOT`` to enable the immutable and upgradable bootloaders by default. You can use custom project configuration files in combination with temporary configuration options associated with a single build, set using either the command line or Kconfig fragments. @@ -40,7 +40,7 @@ For example, you can assign the :file:`my-custom-fragment.conf` fragment to the .. code-block:: console - west build -b nrf52840dk_nrf5840 zephyr/samples/hello_world -- \ + west build -b nrf52840dk_nrf52840 zephyr/samples/hello_world -- \ -DCONFIG_SECURE_BOOT=y \ -DCONFIG_BOOTLOADER_MCUBOOT=y \ -Db0_OVERLAY_CONFIG=my-custom-fragment.conf @@ -49,7 +49,7 @@ In the same way, you can replace ``b0`` with ``mcuboot`` to apply the :file:`my- .. code-block:: console - west build -b nrf52840dk_nrf5840 zephyr/samples/hello_world -- \ + west build -b nrf52840dk_nrf52840 zephyr/samples/hello_world -- \ -DCONFIG_SECURE_BOOT=y \ -DCONFIG_BOOTLOADER_MCUBOOT=y \ -Dmcuboot_OVERLAY_CONFIG=my-custom-fragment.conf diff --git a/doc/nrf/ug_bootloader_testing.rst b/doc/nrf/ug_bootloader_testing.rst index 98f6ce756cac..41b9561b1cf8 100644 --- a/doc/nrf/ug_bootloader_testing.rst +++ b/doc/nrf/ug_bootloader_testing.rst @@ -6,7 +6,7 @@ Testing the bootloader chain To test either of the bootloaders and the secure bootloader chain, build and program them with any sample as described in :ref:`Adding a bootloader chain `. By default, both |NSIB| and MCUboot print information to their serial output on boot. -This output includes information about the validation of images in its slots, as well as firmware-specific information if using :option:`CONFIG_FW_INFO` with the |NSIB|. +This output includes information about the validation of images in its slots, as well as firmware-specific information if using :kconfig:`CONFIG_FW_INFO` with the |NSIB|. To see this output: 1. |connect_terminal| diff --git a/doc/nrf/ug_bt_mesh.rst b/doc/nrf/ug_bt_mesh.rst index c67d48c3f278..4e3d6549d01b 100644 --- a/doc/nrf/ug_bt_mesh.rst +++ b/doc/nrf/ug_bt_mesh.rst @@ -3,10 +3,10 @@ Bluetooth mesh ############## -The |NCS| provides support for developing applications using the Bluetooth mesh protocol. +The |NCS| provides support for developing applications using the Bluetooth® mesh protocol. The support is based on Zephyr's :ref:`bluetooth_mesh` implementation. -The `Bluetooth mesh profile specification`_ is developed and published by the Bluetooth SIG. +The `Bluetooth mesh profile specification`_ is developed and published by the Bluetooth® Special Interest Group (SIG). It allows one-to-one, one-to-many, and many-to-many communication, using the Bluetooth LE protocol to exchange messages between the nodes on the network. All nodes in a Bluetooth mesh network can communicate with each other, as long as there's a chain of nodes between them to relay the messages. The messages are encrypted with two layers of 128-bit AES-CCM encryption, allowing secure communication between thousands of devices. diff --git a/doc/nrf/ug_bt_mesh_architecture.rst b/doc/nrf/ug_bt_mesh_architecture.rst index 6493fc7d51c1..562cf4021db7 100644 --- a/doc/nrf/ug_bt_mesh_architecture.rst +++ b/doc/nrf/ug_bt_mesh_architecture.rst @@ -7,7 +7,7 @@ Bluetooth mesh stack architecture :local: :depth: 2 -The Bluetooth mesh stack in |NCS| is an extension of the Zephyr Bluetooth mesh stack. +The Bluetooth® mesh stack in |NCS| is an extension of the Zephyr Bluetooth® mesh stack. The Zephyr Bluetooth mesh stack implements the Bluetooth mesh profile specification (see :ref:`zephyr:bluetooth_mesh`), while |NCS| provides additional model implementations from the Bluetooth mesh model specification on top of the :ref:`zephyr:bluetooth_mesh_access` API. .. figure:: /images/bt_mesh_basic_architecture.svg diff --git a/doc/nrf/ug_bt_mesh_concepts.rst b/doc/nrf/ug_bt_mesh_concepts.rst index cbb354bad5d5..5ea53cd25a4c 100644 --- a/doc/nrf/ug_bt_mesh_concepts.rst +++ b/doc/nrf/ug_bt_mesh_concepts.rst @@ -7,11 +7,11 @@ Bluetooth mesh concepts :local: :depth: 2 -Bluetooth mesh is a profile specification developed and published by the Bluetooth Special Interest Group (SIG). +Bluetooth® mesh is a profile specification developed and published by the Bluetooth® Special Interest Group (SIG). This document explains the basic concepts of the Bluetooth mesh and gives an overview of the operation and capabilities of the profile, as well as the life cycle of a mesh device. For more information about the |NCS| implementation of the Bluetooth mesh, see :ref:`Bluetooth mesh architecture documentation `. -The Bluetooth mesh is based on the Bluetooth LE part of the Bluetooth 4.0 Specification, and shares the lowest layers with this protocol. +The Bluetooth mesh is based on the Bluetooth LE part of the Bluetooth® 4.0 Specification, and shares the lowest layers with this protocol. On-air, the Bluetooth mesh physical representation is compatible with existing Bluetooth LE devices, as mesh messages are contained inside the payload of Bluetooth LE *advertisement* packets. However, Bluetooth mesh specifies a completely new host stack, and although some concepts are shared, Bluetooth mesh is incompatible with the Bluetooth Host. diff --git a/doc/nrf/ug_bt_mesh_configuring.rst b/doc/nrf/ug_bt_mesh_configuring.rst index dffc2f078546..747439eb58c9 100644 --- a/doc/nrf/ug_bt_mesh_configuring.rst +++ b/doc/nrf/ug_bt_mesh_configuring.rst @@ -7,29 +7,29 @@ Configuring Bluetooth mesh in |NCS| :local: :depth: 2 -The Bluetooth mesh support is controlled by :option:`CONFIG_BT_MESH`, which depends on the following configuration options: +The Bluetooth® mesh support is controlled by :kconfig:`CONFIG_BT_MESH`, which depends on the following configuration options: -* :option:`CONFIG_BT` - Enables the Bluetooth subsystem. -* :option:`CONFIG_BT_OBSERVER` - Enables the Bluetooth Observer role. -* :option:`CONFIG_BT_PERIPHERAL` - Enables the Bluetooth Peripheral role. +* :kconfig:`CONFIG_BT` - Enables the Bluetooth subsystem. +* :kconfig:`CONFIG_BT_OBSERVER` - Enables the Bluetooth Observer role. +* :kconfig:`CONFIG_BT_PERIPHERAL` - Enables the Bluetooth Peripheral role. The Bluetooth mesh subsystem currently performs best with :ref:`Zephyr's Bluetooth LE Controller `. -To force |NCS| to build with this controller, enable :option:`CONFIG_BT_LL_SW_SPLIT`. +To force |NCS| to build with this controller, enable :kconfig:`CONFIG_BT_LL_SW_SPLIT`. Optional features configuration ******************************* Optional features in the Bluetooth mesh stack must be explicitly enabled: -* :option:`CONFIG_BT_MESH_RELAY` - Enables message relaying. -* :option:`CONFIG_BT_MESH_FRIEND` - Enables the Friend role. -* :option:`CONFIG_BT_MESH_LOW_POWER` - Enabels the Low Power role. -* :option:`CONFIG_BT_MESH_PROVISIONER` - Enables the Provisioner role. -* :option:`CONFIG_BT_MESH_GATT_PROXY` - Enables the GATT Proxy Server role. -* :option:`CONFIG_BT_MESH_PB_GATT` - Enables the GATT provisioning bearer. -* :option:`CONFIG_BT_MESH_CDB` - Enables the Configuration Database subsystem. +* :kconfig:`CONFIG_BT_MESH_RELAY` - Enables message relaying. +* :kconfig:`CONFIG_BT_MESH_FRIEND` - Enables the Friend role. +* :kconfig:`CONFIG_BT_MESH_LOW_POWER` - Enabels the Low Power role. +* :kconfig:`CONFIG_BT_MESH_PROVISIONER` - Enables the Provisioner role. +* :kconfig:`CONFIG_BT_MESH_GATT_PROXY` - Enables the GATT Proxy Server role. +* :kconfig:`CONFIG_BT_MESH_PB_GATT` - Enables the GATT provisioning bearer. +* :kconfig:`CONFIG_BT_MESH_CDB` - Enables the Configuration Database subsystem. -The persistent storage of the Bluetooth mesh provisioning and configuration data is enabled by :option:`CONFIG_BT_SETTINGS`. +The persistent storage of the Bluetooth mesh provisioning and configuration data is enabled by :kconfig:`CONFIG_BT_SETTINGS`. See the :ref:`zephyr:bluetooth-persistent-storage` section of :ref:`zephyr:bluetooth-arch` for details. Mesh models diff --git a/doc/nrf/ug_bt_mesh_model_config_app.rst b/doc/nrf/ug_bt_mesh_model_config_app.rst index 3f5e11ed638a..08ba8653f1b6 100644 --- a/doc/nrf/ug_bt_mesh_model_config_app.rst +++ b/doc/nrf/ug_bt_mesh_model_config_app.rst @@ -7,7 +7,7 @@ Configuring mesh models using the nRF Mesh mobile app :local: :depth: 2 -The Bluetooth mesh :ref:`samples ` use the nRF Mesh mobile app to perform provisioning and configuration. +The Bluetooth® mesh :ref:`samples ` use the nRF Mesh mobile app to perform provisioning and configuration. Binding a model to an application key ************************************* diff --git a/doc/nrf/ug_bt_mesh_reserved_ids.rst b/doc/nrf/ug_bt_mesh_reserved_ids.rst index b188cd07aecc..de129645bcf4 100644 --- a/doc/nrf/ug_bt_mesh_reserved_ids.rst +++ b/doc/nrf/ug_bt_mesh_reserved_ids.rst @@ -9,7 +9,7 @@ Reserved vendor model IDs and opcodes This page contains information about vendor model IDs and opcodes allocated by Nordic Semiconductor. -As the Bluetooth SIG member, Nordic Semiconductor has been assigned the Company ID *0x0059*. +As a Bluetooth® Special Interest Group (SIG) member, Nordic Semiconductor has been assigned the Company ID *0x0059*. You can find this information on the `Bluetooth SIG company identifiers`_ page. Reserved vendor model IDs @@ -40,7 +40,7 @@ The table below lists all vendor-assigned model identifiers allocated by Nordic Reserved opcodes **************** -The table below lists the manufactor-specific opcodes allocated by Nordic Semiconductor: +The table below lists the manufacturer-specific opcodes allocated by Nordic Semiconductor: +-----------------------------------+--------+ | Message name | Opcode | diff --git a/doc/nrf/ug_bt_mesh_supported_features.rst b/doc/nrf/ug_bt_mesh_supported_features.rst index e5fe54f9685b..c879f3f55959 100644 --- a/doc/nrf/ug_bt_mesh_supported_features.rst +++ b/doc/nrf/ug_bt_mesh_supported_features.rst @@ -3,7 +3,7 @@ Supported Bluetooth mesh features ################################# -The Bluetooth mesh in |NCS| supports all mandatory features of the `Bluetooth mesh profile specification`_ and the `Bluetooth mesh model specification`_, as well as most of the optional features. +The Bluetooth® mesh in |NCS| supports all mandatory features of the `Bluetooth mesh profile specification`_ and the `Bluetooth mesh model specification`_, as well as most of the optional features. The following features are supported by Zephyr's :ref:`zephyr:bluetooth_mesh`: diff --git a/doc/nrf/ug_bt_mesh_vendor_model.rst b/doc/nrf/ug_bt_mesh_vendor_model.rst index 606bda331093..4800a1d491bf 100644 --- a/doc/nrf/ug_bt_mesh_vendor_model.rst +++ b/doc/nrf/ug_bt_mesh_vendor_model.rst @@ -3,7 +3,7 @@ Creating a new model #################### -You may create your own vendor-specific models for Bluetooth mesh. +You may create your own vendor-specific models for Bluetooth® mesh. These will enable your devices to provide custom behavior not covered by the already defined standard models. The following sections describe the basics of creating new models for the Bluetooth mesh in |NCS|, based on the concepts and principles defined in :ref:`mesh_concepts` and :ref:`Access API `. It is recommended that you have read and understood these concepts and principles, before proceeding with the model development. diff --git a/doc/nrf/ug_bt_mesh_vendor_model_chat_sample_walk_through.rst b/doc/nrf/ug_bt_mesh_vendor_model_chat_sample_walk_through.rst index 769419e3eebe..77df355d47f1 100644 --- a/doc/nrf/ug_bt_mesh_vendor_model_chat_sample_walk_through.rst +++ b/doc/nrf/ug_bt_mesh_vendor_model_chat_sample_walk_through.rst @@ -72,7 +72,7 @@ This is done through the :c:member:`bt_mesh_model_cb.reset` handler: :end-before: include_endpoint_chat_cli_rst_6 .. note:: - The :c:member:`bt_mesh_model_cb.settings_set` handler, and both :c:func:`bt_mesh_model_data_store` calls, are only compiled if :option:`CONFIG_BT_SETTINGS` is enabled, making it possible to exclude this functionality if the persistent storage is not enabled. + The :c:member:`bt_mesh_model_cb.settings_set` handler, and both :c:func:`bt_mesh_model_data_store` calls, are only compiled if :kconfig:`CONFIG_BT_SETTINGS` is enabled, making it possible to exclude this functionality if the persistent storage is not enabled. The following code initializes the model callbacks structure: diff --git a/doc/nrf/ug_bt_mesh_vendor_model_dev_overview.rst b/doc/nrf/ug_bt_mesh_vendor_model_dev_overview.rst index 0a5c5f7b1d44..cdbe992e776e 100644 --- a/doc/nrf/ug_bt_mesh_vendor_model_dev_overview.rst +++ b/doc/nrf/ug_bt_mesh_vendor_model_dev_overview.rst @@ -7,7 +7,7 @@ Vendor model development overview :local: :depth: 2 -To implement a new Bluetooth mesh model, apply the steps described in this step-by-step model development process overview. +To implement a new Bluetooth® mesh model, apply the steps described in this step-by-step model development process overview. Defining a model identifier *************************** @@ -22,7 +22,7 @@ As defined by the `Bluetooth mesh profile specification`_, the vendor model iden #define YOUR_COMPANY_ID 0x1234 #define YOUR_MODEL_ID 0x5678 -The Company ID must be registered with the Bluetooth SIG, and the vendor owning the Company ID may freely allocate the model IDs for its Company ID. +The Company ID must be registered with the Bluetooth® Special Interest Group (SIG), and the vendor owning the Company ID may freely allocate the model IDs for its Company ID. See `Bluetooth SIG company identifiers`_ for a list of Company IDs. Adding the model to the node composition data @@ -297,7 +297,7 @@ These callbacks are defined in :c:struct:`bt_mesh_model_cb`. :c:member:`bt_mesh_model_cb.settings_set` This handler is called when the model data is restored from the persistent storage. If you need to store data in the persistent storage, use the :c:func:`bt_mesh_model_data_store` function. - To use the persitent storage, it needs to be enabled with :option:`CONFIG_BT_SETTINGS`. + To use the persitent storage, it needs to be enabled with :kconfig:`CONFIG_BT_SETTINGS`. For more information on persistent storage, see :ref:`zephyr:settings_api`. :c:member:`bt_mesh_model_cb.start` diff --git a/doc/nrf/ug_edge_impulse.rst b/doc/nrf/ug_edge_impulse.rst index 7d668d1c547f..2bab5f167758 100644 --- a/doc/nrf/ug_edge_impulse.rst +++ b/doc/nrf/ug_edge_impulse.rst @@ -57,16 +57,16 @@ Complete the following steps to configure the building process: 1. Make sure that the following Kconfig options are enabled: - * :option:`CONFIG_CPLUSPLUS` - * :option:`CONFIG_STD_CPP11` - * :option:`CONFIG_LIB_CPLUSPLUS` - * :option:`CONFIG_NEWLIB_LIBC` - * :option:`CONFIG_NEWLIB_LIBC_FLOAT_PRINTF` - * :option:`CONFIG_FPU` - -#. Enable building the downloaded library by setting the :option:`CONFIG_EDGE_IMPULSE` Kconfig option. + * :kconfig:`CONFIG_CPLUSPLUS` + * :kconfig:`CONFIG_STD_CPP11` + * :kconfig:`CONFIG_LIB_CPLUSPLUS` + * :kconfig:`CONFIG_NEWLIB_LIBC` + * :kconfig:`CONFIG_NEWLIB_LIBC_FLOAT_PRINTF` + * :kconfig:`CONFIG_FPU` + +#. Enable building the downloaded library by setting the :kconfig:`CONFIG_EDGE_IMPULSE` Kconfig option. Setting this option also enables the :ref:`ei_wrapper`. -#. Enable and specify the Uniform Resource Identifier (URI) in the :option:`CONFIG_EDGE_IMPULSE_URI` Kconfig option. +#. Enable and specify the Uniform Resource Identifier (URI) in the :kconfig:`CONFIG_EDGE_IMPULSE_URI` Kconfig option. You can set it to one of the following values: * An absolute path to a file in the local file system. @@ -86,7 +86,7 @@ Downloading model directly from Edge Impulse studio As an example of downloadable URI, you can configure the |NCS| build system to download your model directly from the Edge Impulse studio. Complete the following steps to do this: -1. Set :option:`CONFIG_EDGE_IMPULSE_URI` to the URI from Edge Impulse studio: +1. Set :kconfig:`CONFIG_EDGE_IMPULSE_URI` to the URI from Edge Impulse studio: .. parsed-literal:: :class: highlight diff --git a/doc/nrf/ug_fw_update.rst b/doc/nrf/ug_fw_update.rst index e786c969c081..6d1886a85ea0 100644 --- a/doc/nrf/ug_fw_update.rst +++ b/doc/nrf/ug_fw_update.rst @@ -140,7 +140,7 @@ Key revocation can be a useful security measure for devices that have already be If a private key has been compromised or lost, you can invalidate its public key by uploading a new firmware image signed by another key known to the bootloader. These keys are kept internally by the bootloader, so the list of available public keys cannot change once it is deployed. -See :option:`CONFIG_SB_PUBLIC_KEY_FILES` for details on how this mechanism is implemented. +See :kconfig:`CONFIG_SB_PUBLIC_KEY_FILES` for details on how this mechanism is implemented. You can add this feature to your own project and check its functionality as follows: diff --git a/doc/nrf/ug_logging.rst b/doc/nrf/ug_logging.rst index 733d5f79e956..eadd82865100 100644 --- a/doc/nrf/ug_logging.rst +++ b/doc/nrf/ug_logging.rst @@ -35,8 +35,8 @@ You can use the Zephyr system logger in |NCS| for the following use cases: * Internal system logs - Useful for analyzing detailed system performance, for example issues with threads stack sizes. * Logs from external components - Useful for gathering messages from sample applications and custom modules. -The logger can be enabled with the :option:`CONFIG_LOG` Kconfig option. -This option is automatically set alongside the minimal logging implementation (:option:`CONFIG_LOG_MINIMAL`) with the :option:`CONFIG_NCS_SAMPLES_DEFAULTS` Kconfig option, which is enabled by default for all samples in |NCS|. +The logger can be enabled with the :kconfig:`CONFIG_LOG` Kconfig option. +This option is automatically set alongside the minimal logging implementation (:kconfig:`CONFIG_LOG_MINIMAL`) with the :kconfig:`CONFIG_NCS_SAMPLES_DEFAULTS` Kconfig option, which is enabled by default for all samples in |NCS|. For more information about configuring Zephyr's logger, see :ref:`zephyr:logging_api`. .. _ug_logging_net_application: @@ -83,8 +83,8 @@ UART The UART interface can be configured as a logging backend using the following Kconfig options: -* :option:`CONFIG_LOG_BACKEND_UART` - This option enables the UART logging backend. -* :option:`CONFIG_LOG_BACKEND_UART_SYST_ENABLE` - This option is used to output logs in system format. +* :kconfig:`CONFIG_LOG_BACKEND_UART` - This option enables the UART logging backend. +* :kconfig:`CONFIG_LOG_BACKEND_UART_SYST_ENABLE` - This option is used to output logs in system format. For information about how to see UART output, see :ref:`putty`. @@ -95,17 +95,17 @@ RTT SEGGER's J-Link RTT backend logging can be handled with the following Kconfig options: -* :option:`CONFIG_LOG_BACKEND_RTT` - This option enables RTT logging backend. -* :option:`CONFIG_LOG_BACKEND_RTT_MODE_DROP` - This option enables the mode in which messages that do not fit the buffer are dropped. -* :option:`CONFIG_LOG_BACKEND_RTT_MODE_BLOCK` - This option enables the mode in which the device is blocked until a message is transferred. -* :option:`CONFIG_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE` - This option defines the size of the buffer used for storing data prepared for sending. -* :option:`CONFIG_LOG_BACKEND_RTT_RETRY_CNT` - This option defines the number of retries before a message is dropped. -* :option:`CONFIG_LOG_BACKEND_RTT_RETRY_DELAY_MS` - This option defines the time interval between transmission retries. -* :option:`CONFIG_LOG_BACKEND_RTT_SYST_ENABLE` - This option is used to output logs in the system format. -* :option:`CONFIG_LOG_BACKEND_RTT_MESSAGE_SIZE` - This option defines the maximum message size. -* :option:`CONFIG_LOG_BACKEND_RTT_BUFFER` - This option selects the index of the buffer used for logger output. -* :option:`CONFIG_LOG_BACKEND_RTT_BUFFER_SIZE` - This option defines the size of the buffer used for logger output. -* :option:`CONFIG_LOG_BACKEND_RTT_FORCE_PRINTK` - This option enables processing of ``printk`` calls in the logger buffers instead of the RTT buffer. +* :kconfig:`CONFIG_LOG_BACKEND_RTT` - This option enables RTT logging backend. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_MODE_DROP` - This option enables the mode in which messages that do not fit the buffer are dropped. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_MODE_BLOCK` - This option enables the mode in which the device is blocked until a message is transferred. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE` - This option defines the size of the buffer used for storing data prepared for sending. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_RETRY_CNT` - This option defines the number of retries before a message is dropped. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_RETRY_DELAY_MS` - This option defines the time interval between transmission retries. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_SYST_ENABLE` - This option is used to output logs in the system format. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_MESSAGE_SIZE` - This option defines the maximum message size. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_BUFFER` - This option selects the index of the buffer used for logger output. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_BUFFER_SIZE` - This option defines the size of the buffer used for logger output. +* :kconfig:`CONFIG_LOG_BACKEND_RTT_FORCE_PRINTK` - This option enables processing of ``printk`` calls in the logger buffers instead of the RTT buffer. For information about how to run SEGGER's J-Link RTT on your PC and see the logs, see :ref:`testing_rtt`. @@ -117,8 +117,8 @@ Spinel Using `Spinel protocol`_ as a logging backend is specific to OpenThread's :ref:`thread_architectures_designs_cp_ncp` and :ref:`thread_architectures_designs_cp_rcp` architectures. The Spinel protocol can be configured as a logging backend using the following Kconfig options: -* :option:`CONFIG_LOG_BACKEND_SPINEL` - This option enables the Spinel logging backend. -* :option:`CONFIG_LOG_BACKEND_SPINEL_BUFFER_SIZE` - This option defines the size of buffer used for logger output. +* :kconfig:`CONFIG_LOG_BACKEND_SPINEL` - This option enables the Spinel logging backend. +* :kconfig:`CONFIG_LOG_BACKEND_SPINEL_BUFFER_SIZE` - This option defines the size of buffer used for logger output. To communicate using the Spinel protocol and gather logs, you need one of the following tools: @@ -137,7 +137,7 @@ Shell When you enable Zephyr's :ref:`zephyr:shell_api`, it by default becomes a logging backend. You can disable this backend by using the following Kconfig option: -* :option:`CONFIG_SHELL_LOG_BACKEND` - This option enables and disables the shell logging backend. +* :kconfig:`CONFIG_SHELL_LOG_BACKEND` - This option enables and disables the shell logging backend. .. note:: The UART and RTT logging backends can also be configured as shell backends. diff --git a/doc/nrf/ug_matter.rst b/doc/nrf/ug_matter.rst index 125036ae5fad..12f158cb6e45 100644 --- a/doc/nrf/ug_matter.rst +++ b/doc/nrf/ug_matter.rst @@ -11,14 +11,14 @@ Matter (Project CHIP) .. matter_intro_start `Matter`_ (formerly Project Connected Home over IP or Project CHIP) is an open-source application layer that aims at creating a unified communication standard across smart home devices, mobile applications, and cloud services. -It supports a wide range of existing technologies, including Wi-Fi, Thread, and Bluetooth LE, and uses IPv6-based transport protocols like TCP and UDP to ensure connectivity between different kinds of networks. +It supports a wide range of existing technologies, including Wi-Fi, Thread, and Bluetooth® LE, and uses IPv6-based transport protocols like TCP and UDP to ensure connectivity between different kinds of networks. Matter is in an early development stage and must be treated as an experimental feature. .. matter_intro_end The |NCS| allows you to develop applications that are compatible with Matter. -See :ref:`matter_samples` for the list of available samples. +See :ref:`matter_samples` for the list of available samples or :ref:`Matter Weather Station ` for specific Matter application. If you are new to Matter, check also the tutorials on `DevZone`_. .. note:: @@ -30,4 +30,5 @@ If you are new to Matter, check also the tutorials on `DevZone`_. ug_matter_architecture.rst ug_matter_configuring.rst + ug_matter_tools.rst ug_matter_creating_accessory.rst diff --git a/doc/nrf/ug_matter_architecture.rst b/doc/nrf/ug_matter_architecture.rst index b7a5dfd26bd1..cbcb8c674561 100644 --- a/doc/nrf/ug_matter_architecture.rst +++ b/doc/nrf/ug_matter_architecture.rst @@ -23,7 +23,7 @@ That is, the code used for the |NCS| and Matter integration is stored in the Mat Both instances depend on each other, but their development is independent to ensure that they both support the latest stable version of one another. Matter is located on the top application layer of the integration model, looking from the networking point of view. -The |NCS| and Zephyr provide the Bluetooth LE and Thread stacks, which must be integrated with the Matter stack using a special intermediate layer. +The |NCS| and Zephyr provide the Bluetooth® LE and Thread stacks, which must be integrated with the Matter stack using a special intermediate layer. The |NCS|'s Multiprotocol Service Layer (MPSL) driver allows running Bluetooth LE and Thread concurrently on the same radio chip. .. figure:: images/matter_nrfconnect_overview_simplified_ncs.svg diff --git a/doc/nrf/ug_matter_configuring.rst b/doc/nrf/ug_matter_configuring.rst index 1449fb42c96f..1daf59e77729 100644 --- a/doc/nrf/ug_matter_configuring.rst +++ b/doc/nrf/ug_matter_configuring.rst @@ -15,7 +15,7 @@ To pair and control the Matter accessory device remotely over such a network, yo A Matter controller is a role within the Matter environment. This controller interacts with the accessory devices using the following protocols: -* Bluetooth LE during the commissioning process - to securely pass the network credentials and provision the accessory device into the Thread network. +* Bluetooth® LE during the commissioning process - to securely pass the network credentials and provision the accessory device into the Thread network. * Regular IPv6 communication after the accessory device joins the Thread network - to interact with each other by exchanging application messages. For example, to report temperature measurements of a sensor. @@ -36,11 +36,11 @@ Matter controller types The Matter controller implementation for the nRF Connect platform can be of the following types: -* Python Controller for Linux -* Mobile Controller for Android +* Python controller for Linux +* Mobile controller for Android -.. note:: - In the Matter upstream repository, you can find information and resources for implementing `other controller setups`_ (for example, for iOS). +These controller types are also described in :ref:`ug_matter_tools` and are recommended in the |NCS|. +In the Matter upstream repository, you can find information and resources for implementing `other controller setups`_ (for example, for iOS). Matter development environment setup options ******************************************** @@ -80,7 +80,7 @@ To use this setup, you need the following hardware: * 1x PC with Ubuntu (20.04 or newer) or 1x smartphone with Android 8+ * 1x Raspberry Pi Model 3B+ or newer (along with a SD card with at least 8 GB of memory) * 1x Wi-Fi Access Point supporting IPv6 (without the IPv6 Router Advertisement Guard enabled on the router) -* 1x nRF52840 DK or nRF5840 Dongle - for the Radio Co-Processor (RCP) device +* 1x nRF52840 DK or nRF52840 Dongle - for the Radio Co-Processor (RCP) device * 1x nRF52840 DK or nRF5340 DK - for the Matter accessory device (programmed with one of :ref:`matter_samples`) For information about how to configure and use the required components, complete steps from the following user guides: @@ -88,8 +88,8 @@ For information about how to configure and use the required components, complete * Configuring the Thread Border Router on a Raspberry Pi - see :ref:`ug_thread_tools_tbr` in the |NCS| documentation * Depending on the Matter controller type: - * Testing with the Python Matter Controller - see `Working with Python Controller`_ in the Matter documentation - * Testing with the Android Mobile Controller - see `Commissioning nRF Connect Accessory using Android CHIPTool`_ in the Matter documentation + * Python Matter controller - See :ref:`ug_matter_tools` for building instructions and `Working with Python Controller`_ in the Matter documentation for information about testing. + * Android Mobile controller - See :ref:`ug_matter_tools` for building instructions and `Commissioning nRF Connect Accessory using Android CHIPTool`_ in the Matter documentation for information about testing. Running Thread Border Router and Matter controller on the same device ===================================================================== @@ -107,13 +107,13 @@ To use this setup, you need the following hardware: * 1x PC with Ubuntu (20.04 or newer) or Raspberry Pi Model 3B+ or newer with Ubuntu (20.04 or newer) instead of Raspbian OS * 1x Bluetooth LE dongle (can be embedded inside the PC, like it is on Raspberry Pi) -* 1x nRF52840 DK or nRF5840 Dongle - for the Radio Co-Processor (RCP) device +* 1x nRF52840 DK or nRF52840 Dongle - for the Radio Co-Processor (RCP) device * 1x nRF52840 DK or nRF5340 DK - for the Matter accessory device (programmed with one of :ref:`matter_samples`) For information about how to configure and use the required components, see the following user guides: * Configuring Thread Border Router on a PC or a Raspberry Pi - see :ref:`ug_thread_tools_tbr` in the |NCS| documentation -* Testing with the Python Matter Controller - see `Working with Python Controller`_ in the Matter documentation +* Python Matter controller - See :ref:`ug_matter_tools` for building instructions and `Working with Python Controller`_ in the Matter documentation for information about testing. .. note:: The Python Matter controller is currently not supported for building on Raspbian OS. diff --git a/doc/nrf/ug_matter_tools.rst b/doc/nrf/ug_matter_tools.rst new file mode 100644 index 000000000000..e35baa66a2ce --- /dev/null +++ b/doc/nrf/ug_matter_tools.rst @@ -0,0 +1,88 @@ +.. _ug_matter_tools: + +Matter tools +############ + +.. contents:: + :local: + :depth: 2 + +Use tools listed on this page to test :ref:`matter_samples` and develop Matter applications in the |NCS|. + +GN tool +******* + +To build and develop Matter applications, you need the `GN`_ meta-build system. +This system generates the Ninja files that the |NCS| uses. + +If you are updating from the |NCS| version earlier than v1.5.0, see the :ref:`GN installation instructions `. + +Matter controller tools +*********************** + +The Matter controller is a role within the :ref:`Matter development environment `. +The controller device is used to pair and control the Matter accessory device remotely over a network, interacting with it using Bluetooth LE and the regular IPv6 communication. + +The following figure shows the available Matter controllers in the |NCS|. + +.. figure:: images/matter_protocols_controllers.svg + :width: 600 + :alt: Controllers used by Matter + + Controllers used by Matter + +Python controller for Linux +=========================== + +The Python Matter controller allows you to test Matter applications on a PC running Linux. +You can use it either on a separate device from Thread Border Router or on the same device as Thread Border Router, depending on which :ref:`development environment setup option ` you choose. + +To use this controller type, you need to build it first using one of the following options: + +* Use the prebuilt tool package from the `Matter nRF Connect releases`_ GitHub page. + Make sure that the package is compatible with your |NCS| version. +* Build it manually from the source files available in the :file:`modules/lib/matter/src/controller/python` directory and using the building instructions from the `Working with Python Controller`_ page in the Matter documentation. + +For instructions about how to test using the Python Controller for Linux, see `Working with Python Controller`_. + +Mobile controller for Android +============================= + +The Mobile Controller for Android allows you to test Matter applications using an Android smartphone. +You can use it in the :ref:`development environment setup option ` where Thread Border Router and Matter controller are running on separate devices. + +To use this controller type, you need to build it first using one of the following options: + +* Use the prebuilt tool package from the `Matter nRF Connect releases`_ GitHub page. + Make sure that the package is compatible with your |NCS| version. +* Build it manually from the source files available in the :file:`modules/lib/matter/src/android/CHIPTool` directory and using the building instructions from the `Building Android CHIPTool`_ page in the Matter documentation. + +For instructions about how to test using the Mobile Controller for Android, see `Commissioning nRF Connect Accessory using Android CHIPTool`_. + +Thread tools +************ + +Because Matter is based on the Thread network, you can use the following :ref:`ug_thread_tools` when working with Matter in the |NCS|. + +Thread Border Router +==================== + +.. include:: ug_thread_tools.rst + :start-after: tbr_shortdesc_start + :end-before: tbr_shortdesc_end + +See the :ref:`ug_thread_tools_tbr` documentation for configuration instructions. + +nRF Sniffer for 802.15.4 +======================== + +.. include:: ug_thread_tools.rst + :start-after: sniffer_shortdesc_start + :end-before: sniffer_shortdesc_end + +nRF Thread Topology Monitor +=========================== + +.. include:: ug_thread_tools.rst + :start-after: ttm_shortdesc_start + :end-before: ttm_shortdesc_end diff --git a/doc/nrf/ug_multi_image.rst b/doc/nrf/ug_multi_image.rst index 9c3234fb692a..05d0fb532b19 100644 --- a/doc/nrf/ug_multi_image.rst +++ b/doc/nrf/ug_multi_image.rst @@ -73,8 +73,8 @@ When building the child image from the source or using a prebuilt HEX file, the This means that you can enable and integrate an additional image just by using the default configuration. To change the default configuration and configure how a child image is handled, locate the BUILD_STRATEGY configuration options for the child image in the parent image configuration. -For example, to use a prebuilt HEX file of the :ref:`secure_partition_manager` instead of building it, select :option:`CONFIG_SPM_BUILD_STRATEGY_USE_HEX_FILE` instead of the default :option:`CONFIG_SPM_BUILD_STRATEGY_FROM_SOURCE`, and specify the HEX file in :option:`CONFIG_SPM_HEX_FILE`. -To ignore an MCUboot child image, select :option:`CONFIG_MCUBOOT_BUILD_STRATEGY_SKIP_BUILD` instead of :option:`CONFIG_MCUBOOT_BUILD_STRATEGY_FROM_SOURCE`. +For example, to use a prebuilt HEX file of the :ref:`secure_partition_manager` instead of building it, select :kconfig:`CONFIG_SPM_BUILD_STRATEGY_USE_HEX_FILE` instead of the default :kconfig:`CONFIG_SPM_BUILD_STRATEGY_FROM_SOURCE`, and specify the HEX file in :kconfig:`CONFIG_SPM_HEX_FILE`. +To ignore an MCUboot child image, select :kconfig:`CONFIG_MCUBOOT_BUILD_STRATEGY_SKIP_BUILD` instead of :kconfig:`CONFIG_MCUBOOT_BUILD_STRATEGY_FROM_SOURCE`. .. _ug_multi_image_defining: @@ -341,7 +341,7 @@ Memory placement **************** In a multi-image build, all images must be placed in memory so that they do not overlap. -The flash memory start address for each image must be specified by, for example, :option:`CONFIG_FLASH_LOAD_OFFSET`. +The flash memory start address for each image must be specified by, for example, :kconfig:`CONFIG_FLASH_LOAD_OFFSET`. Hardcoding the image locations like this works fine for simple use cases like a bootloader that prepares a device, where there are no further requirements on where in memory each image must be placed. However, more advanced use cases require a memory layout where images are located in a specific order relative to one another. diff --git a/doc/nrf/ug_multiprotocol_support.rst b/doc/nrf/ug_multiprotocol_support.rst index c8495580ccff..8b673a54ec3c 100644 --- a/doc/nrf/ug_multiprotocol_support.rst +++ b/doc/nrf/ug_multiprotocol_support.rst @@ -22,12 +22,12 @@ Enabling multiprotocol support To enable the multiprotocol support for either Thread or Zigbee, set the following Kconfig option: -* :option:`CONFIG_BT_LL_SOFTDEVICE_DEFAULT` +* :kconfig:`CONFIG_BT_LL_SOFTDEVICE_DEFAULT` This option activates the :ref:`nrfxlib:softdevice_controller`, which by default supports the multiprotocol features. Disabling the SoftDevice Controller also disables the multiprotocol support. -After enabling this option, the application can start configuring Bluetooth LE's API options alongside Thread's or Zigbee's in the respective :file:`.conf` file. +After enabling this option, the application can start configuring Bluetooth® LE's API options alongside Thread's or Zigbee's in the respective :file:`.conf` file. Multiprotocol limitations in application development **************************************************** diff --git a/doc/nrf/ug_nfc.rst b/doc/nrf/ug_nfc.rst index 635aa53bc2e0..6c97b8003433 100644 --- a/doc/nrf/ug_nfc.rst +++ b/doc/nrf/ug_nfc.rst @@ -8,7 +8,7 @@ Near Field Communication (NFC) :depth: 2 Near Field Communication (NFC) is a technology for wireless transfer of small amounts of data between two devices. -It uses very simple communication protocols and therefore allows quicker connection than Bluetooth Low Energy. +It uses very simple communication protocols and, therefore, allows quicker connection than Bluetooth® Low Energy. However, because NFC uses magnetic induction to enable communication, the devices must be very close (< 10 cm) to connect. The following image gives a simplified overview of how NFC works. diff --git a/doc/nrf/ug_nrf52.rst b/doc/nrf/ug_nrf52.rst index 4d487068635a..4ec67596fb7e 100644 --- a/doc/nrf/ug_nrf52.rst +++ b/doc/nrf/ug_nrf52.rst @@ -15,7 +15,7 @@ Introduction ************ The nRF52 Series of System-on-Chip (SoC) devices embed a powerful yet low-power Arm Cortex-M4 processor with our industry leading 2.4 GHz RF transceivers. -All of the nRF52 Series SoCs have support for Bluetooth 5 features, in addition to multiprotocol capabilities. +All of the nRF52 Series SoCs have support for Bluetooth® 5 features, in addition to multiprotocol capabilities. See `nRF52 Series`_ for the technical documentation on the nRF52 Series chips and associated kits. @@ -213,7 +213,7 @@ To perform a FOTA upgrade, complete the following steps: * You must enable the mcumgr module, which handles the transport protocol over Bluetooth Low Energy. To enable this module in your application, complete the following steps: - a. Enable :option:`CONFIG_MCUMGR_CMD_OS_MGMT`, :option:`CONFIG_MCUMGR_CMD_IMG_MGMT`, and :option:`CONFIG_MCUMGR_SMP_BT`. + a. Enable :kconfig:`CONFIG_MCUMGR_CMD_OS_MGMT`, :kconfig:`CONFIG_MCUMGR_CMD_IMG_MGMT`, and :kconfig:`CONFIG_MCUMGR_SMP_BT`. #. Call ``os_mgmt_register_group()`` and ``img_mgmt_register_group()`` in your application. #. Call ``smp_bt_register()`` in your application to initialize the mcumgr Bluetooth Low Energy transport. diff --git a/doc/nrf/ug_nrf5340.rst b/doc/nrf/ug_nrf5340.rst index 0dc4902f1295..5f82f8b9590d 100644 --- a/doc/nrf/ug_nrf5340.rst +++ b/doc/nrf/ug_nrf5340.rst @@ -69,7 +69,10 @@ Trusted Firmware-M (TF-M) In Zephyr, the application core is divided into two different build targets: * ``nrf5340dk_nrf5340_cpuapp`` for the secure domain -* ``nrf5340dk_nrf5340_cpuappns`` for the non-secure domain +* ``nrf5340dk_nrf5340_cpuapp_ns`` for the non-secure domain + +.. note:: + In |NCS| releases before v1.6.1, the build target ``nrf5340dk_nrf5340_cpuapp_ns`` was named ``nrf5340dk_nrf5340_cpuappns``. Inter-core communication ======================== @@ -87,7 +90,7 @@ The OpenAMP library uses the IPM SHIM layer, which in turn uses the IPC driver i .. |note| replace:: The following instructions are for the application core. To upgrade the firmware on the network core, perform the steps for FOTA upgrade described below, replacing :file:`app_update.bin`, which is the file used when upgrading firmware on the application core, with :file:`net_core_app_update.bin`. - In addition, ensure that :option:`CONFIG_PCD_APP` is enabled for the MCUboot child image. + In addition, ensure that :kconfig:`CONFIG_PCD_APP` is enabled for the MCUboot child image. For more details, see :ref:`nc_bootloader`. Protocols and use cases @@ -112,7 +115,7 @@ Bluetooth Low Energy * - :ref:`ble_rpc_host` (supported for development) - Some Bluetooth Low Energy samples, for example, :ref:`zephyr:bluetooth-beacon-sample` -When using Bluetooth Low Energy on the nRF5340, you have two options: +When using Bluetooth® Low Energy on the nRF5340, you have two options: * Split the Bluetooth LE Controller and the host part of the Bluetooth LE stack and run them on different cores. * Run the full Bluetooth LE stack on the network core (currently supported for development only). @@ -224,13 +227,13 @@ Direct use of the radio peripheral Samples that directly use the radio peripheral can run on the network core of the nRF5340. They do not require any functionality from the application core. -However, on nRF5340, the application core is responsible for starting the network core and connecting its GPIO pins (see :option:`CONFIG_BOARD_ENABLE_CPUNET` and the code in :file:`zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340_cpunet_reset.c`). +However, on nRF5340, the application core is responsible for starting the network core and connecting its GPIO pins (see :kconfig:`CONFIG_BOARD_ENABLE_CPUNET` and the code in :file:`zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340_cpunet_reset.c`). Therefore, you must always program the application core, even if the firmware is supposed to run only on the network core. You can use the :ref:`nrf5340_empty_app_core` sample for this purpose. Configure the network core application to automatically include this sample as a child image. This is the default configuration for the listed network core samples. -For more information, see :option:`CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE` and :ref:`ug_nrf5340_multi_image`. +For more information, see :kconfig:`CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE` and :ref:`ug_nrf5340_multi_image`. No radio communication @@ -254,7 +257,7 @@ Samples that do not need radio communication can run on the application core of They do not require any firmware on the network core. Therefore, the network core can remain empty. -If you want to enable the network core anyway, set the :option:`CONFIG_BOARD_ENABLE_CPUNET` option in the image for the application core. +If you want to enable the network core anyway, set the :kconfig:`CONFIG_BOARD_ENABLE_CPUNET` option in the image for the application core. .. _ug_nrf5340_multi_image: @@ -280,9 +283,9 @@ For other samples, the images are built separately. The build configuration depends on the following Kconfig options that must be set in the configuration of the parent image: -* :option:`CONFIG_BT_RPMSG_NRF53` - set to ``y`` in all Bluetooth LE samples for the application core -* :option:`CONFIG_NRF_802154_SER_HOST` - set to ``y`` in all Thread, Zigbee, and Matter samples for the application core -* :option:`CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE` - set to ``y`` in all network core samples that require the :ref:`nrf5340_empty_app_core` sample +* :kconfig:`CONFIG_BT_RPMSG_NRF53` - set to ``y`` in all Bluetooth LE samples for the application core +* :kconfig:`CONFIG_NRF_802154_SER_HOST` - set to ``y`` in all Thread, Zigbee, and Matter samples for the application core +* :kconfig:`CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE` - set to ``y`` in all network core samples that require the :ref:`nrf5340_empty_app_core` sample The combination of these options determines which (if any) sample is included in the build of the parent image: @@ -292,16 +295,16 @@ The combination of these options determines which (if any) sample is included in * - Enabled options - Child image sample for the network core - Child image sample for the application core - * - :option:`CONFIG_BT_RPMSG_NRF53` + * - :kconfig:`CONFIG_BT_RPMSG_NRF53` - :ref:`zephyr:bluetooth-hci-rpmsg-sample` - --- - * - :option:`CONFIG_NRF_802154_SER_HOST` + * - :kconfig:`CONFIG_NRF_802154_SER_HOST` - :ref:`zephyr:nrf-ieee802154-rpmsg-sample` - --- - * - :option:`CONFIG_BT_RPMSG_NRF53` and :option:`CONFIG_NRF_802154_SER_HOST` + * - :kconfig:`CONFIG_BT_RPMSG_NRF53` and :kconfig:`CONFIG_NRF_802154_SER_HOST` - :ref:`multiprotocol-rpmsg-sample` - --- - * - :option:`CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE` + * - :kconfig:`CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE` - --- - :ref:`nrf5340_empty_app_core` @@ -335,7 +338,7 @@ To program a multi-image HEX file, you must add the project files for the networ Separate images --------------- -To build and program only the application core, follow the instructions in :ref:`gs_programming_ses` and use ``nrf5340dk_nrf5340_cpuapp`` or ``nrf5340dk_nrf5340_cpuappns`` as build target. +To build and program only the application core, follow the instructions in :ref:`gs_programming_ses` and use ``nrf5340dk_nrf5340_cpuapp`` or ``nrf5340dk_nrf5340_cpuapp_ns`` as build target. To build and program a dedicated network sample, follow the instructions in :ref:`gs_programming_ses` and use ``nrf5340dk_nrf5340_cpunet`` as the build target. @@ -357,7 +360,7 @@ You must manually add a network core project to the application core project to Follow these steps to build and program a multi-image build to the nRF5340 application core and network core: 1. Follow the instructions in :ref:`gs_programming_ses` and open the application core sample (for example, :ref:`peripheral_lbs`) in |SES|. - Use ``nrf5340dk_nrf5340_cpuapp`` or ``nrf5340dk_nrf5340_cpuappns`` as the build target. + Use ``nrf5340dk_nrf5340_cpuapp`` or ``nrf5340dk_nrf5340_cpuapp_ns`` as the build target. #. Build the sample as described in :ref:`gs_programming_ses`. This creates both the application core image and the network core image. #. Select :guilabel:`File` > :guilabel:`New Project`. diff --git a/doc/nrf/ug_nrf9160.rst b/doc/nrf/ug_nrf9160.rst index f34b2a23fb1d..cbbbec32342a 100644 --- a/doc/nrf/ug_nrf9160.rst +++ b/doc/nrf/ug_nrf9160.rst @@ -39,7 +39,10 @@ The secure bootloader chain starts the :ref:`nrf9160_ug_secure_partition_manager In Zephyr, :ref:`zephyr:nrf9160dk_nrf9160` is divided into two different build targets: * ``nrf9160dk_nrf9160`` for firmware in the secure domain -* ``nrf9160dk_nrf9160ns`` for firmware in the non-secure domain +* ``nrf9160dk_nrf9160_ns`` for firmware in the non-secure domain + +.. note:: + In |NCS| releases before v1.6.1, the build target ``nrf9160dk_nrf9160_ns`` was named ``nrf9160dk_nrf9160ns``. Make sure to select a suitable build target when building your application. @@ -61,8 +64,8 @@ All nRF9160 samples require the :ref:`secure_partition_manager` sample. It provides a reference implementation of a Secure Partition Manager firmware. This firmware is required to set up the nRF9160 DK so that it can run user applications in the non-secure domain. -The Secure Partition Manager sample is automatically included in the build for the ``nrf9160dk_nrf9160ns`` build target. -To disable the automatic inclusion of the Secure Partition Manager sample, set the option :option:`CONFIG_SPM` to "n" in the project configuration. +The Secure Partition Manager sample is automatically included in the build for the ``nrf9160dk_nrf9160_ns`` build target. +To disable the automatic inclusion of the Secure Partition Manager sample, set the option :kconfig:`CONFIG_SPM` to "n" in the project configuration. Trusted Firmware-M (TF-M) support --------------------------------- @@ -80,13 +83,13 @@ Application ----------- The user application runs in the non-secure domain. -Therefore, it must be built for the ``nrf9160dk_nrf9160ns`` build target. +Therefore, it must be built for the ``nrf9160dk_nrf9160_ns`` build target. The application image might require other images to be present. Depending on the configuration, all these images can be built at the same time in a :ref:`multi-image build `. -All nRF9160 samples include the :ref:`secure_partition_manager` sample, which can be enabled or disabled with the :option:`CONFIG_SPM` option. -Some also include the :ref:`bootloader` sample (:option:`CONFIG_SECURE_BOOT`) and :doc:`mcuboot:index` (:option:`CONFIG_BOOTLOADER_MCUBOOT`). +All nRF9160 samples include the :ref:`secure_partition_manager` sample, which can be enabled or disabled with the :kconfig:`CONFIG_SPM` option. +Some also include the :ref:`bootloader` sample (:kconfig:`CONFIG_SECURE_BOOT`) and :doc:`mcuboot:index` (:kconfig:`CONFIG_BOOTLOADER_MCUBOOT`). LTE modem @@ -168,7 +171,7 @@ Then, enable the LTE band lock feature and the band lock mask in the configurati CONFIG_LTE_LOCK_BAND_MASK="10000001000000001100" The band lock mask allows you to set the bands on which you want the modem to operate. -Each bit in the :option:`CONFIG_LTE_LOCK_BAND_MASK` option represents one band. +Each bit in the :kconfig:`CONFIG_LTE_LOCK_BAND_MASK` option represents one band. The maximum length of the string is 88 characters (bit string, 88 bits). The band lock is a non-volatile setting that must be set before activating the modem. @@ -192,7 +195,7 @@ Network mode The modem supports LTE-M (Cat-M1) and Narrowband Internet of Things (NB-IoT or LTE Cat-NB). By default, the modem starts in LTE-M mode. -When using the LTE Link Control driver, you can select LTE-M with :option:`CONFIG_LTE_NETWORK_MODE_LTE_M` or NB-IoT with :option:`CONFIG_LTE_NETWORK_MODE_NBIOT`. +When using the LTE Link Control driver, you can select LTE-M with :kconfig:`CONFIG_LTE_NETWORK_MODE_LTE_M` or NB-IoT with :kconfig:`CONFIG_LTE_NETWORK_MODE_NBIOT`. To start in NB-IoT mode without the driver, send the following command before starting the modem protocols (by using ``AT+CFUN=1``):: @@ -257,7 +260,7 @@ To perform a FOTA upgrade, complete the following steps: In addition, the following requirements apply: * |fota_upgrades_req_mcuboot| - * If you want to upgrade the upgradable bootloader, the :ref:`bootloader` must be used (:option:`CONFIG_SECURE_BOOT`). + * If you want to upgrade the upgradable bootloader, the :ref:`bootloader` must be used (:kconfig:`CONFIG_SECURE_BOOT`). * If you want to upgrade the modem firmware through modem delta updates, neither MCUboot nor the immutable bootloader are required, because the modem firmware upgrade is handled by the modem itself. * If you want to perform a full modem firmware upgrade, an |external_flash_size| is required. @@ -270,7 +273,7 @@ To perform a FOTA upgrade, complete the following steps: |fota_upgrades_building| The :file:`app_update.bin` file is the file that should be uploaded to the server. - To create binary files for a bootloader upgrade, make sure that :option:`CONFIG_SECURE_BOOT` and :option:`CONFIG_BUILD_S1_VARIANT` are enabled and build MCUboot as usual. + To create binary files for a bootloader upgrade, make sure that :kconfig:`CONFIG_SECURE_BOOT` and :kconfig:`CONFIG_BUILD_S1_VARIANT` are enabled and build MCUboot as usual. The build will create a binary file for each variant of the upgradable bootloader, one for each bootloader slot. See :ref:`upgradable_bootloader` for more information. @@ -328,7 +331,7 @@ For example, when building a non-secure application for nRF9160 DK v1.0.0, use ` When building with |SES|, specify the board revision as additional CMake option (see :ref:`cmake_options` for instructions). For example, for nRF9160 DK v1.0.0, add the following CMake option:: - -DBOARD=nrf9160dk_nrf9160ns@1.0.0 + -DBOARD=nrf9160dk_nrf9160_ns@1.0.0 See :ref:`zephyr:application_board_version` and :ref:`zephyr:nrf9160dk_additional_hardware` for more information. diff --git a/doc/nrf/ug_pelion.rst b/doc/nrf/ug_pelion.rst index 58f8438a4334..b0b71b554fec 100644 --- a/doc/nrf/ug_pelion.rst +++ b/doc/nrf/ug_pelion.rst @@ -43,12 +43,12 @@ Enable and configure Mbed TLS The Pelion Device Management library depends on a properly configured Mbed TLS library. To simplify the development within the |NCS|, you can use a predefined set of Mbed TLS configuration options. -To enable the set that is compatible with :ref:`nrfxlib:nrf_security`, use the :option:`CONFIG_PELION_NRF_SECURITY` Kconfig option. +To enable the set that is compatible with :ref:`nrfxlib:nrf_security`, use the :kconfig:`CONFIG_PELION_NRF_SECURITY` Kconfig option. Make sure to properly configure the memory region used by Mbed TLS library for dynamic allocations. Memory for this library is allocated from either the libc heap or a dedicated buffer, depending on the configuration. -For more information about using the dedicated buffer for Mbed TLS heap, see help for the :option:`CONFIG_MBEDTLS_ENABLE_HEAP` and :option:`CONFIG_MBEDTLS_HEAP_SIZE` Kconfig options. -If :option:`CONFIG_MBEDTLS_ENABLE_HEAP` is disabled and Mbed TLS configuration files do not add any overrides, the libc heap is used. +For more information about using the dedicated buffer for Mbed TLS heap, see help for the :kconfig:`CONFIG_MBEDTLS_ENABLE_HEAP` and :kconfig:`CONFIG_MBEDTLS_HEAP_SIZE` Kconfig options. +If :kconfig:`CONFIG_MBEDTLS_ENABLE_HEAP` is disabled and Mbed TLS configuration files do not add any overrides, the libc heap is used. Provision the device with credentials ===================================== @@ -114,12 +114,12 @@ For more information, see :ref:`zephyr:thread_protocol_interface` in the Zephyr Pelion configuration ******************** -To enable the Pelion Device Management library in the |NCS|, use the :option:`CONFIG_PELION_CLIENT` Kconfig option. +To enable the Pelion Device Management library in the |NCS|, use the :kconfig:`CONFIG_PELION_CLIENT` Kconfig option. You can control the Pelion Device Management library features using Kconfig options that are defined within the Pelion Device Management library repository. The following options are among the most important ones: -* :option:`CONFIG_PELION_UPDATE` - This option enables the device firmware update (DFU) feature. -* :option:`CONFIG_PELION_TRANSPORT_MODE_TCP`, :option:`CONFIG_PELION_TRANSPORT_MODE_UDP`, :option:`CONFIG_PELION_TRANSPORT_MODE_UDP_QUEUE` - These options select the transport protocol used by the library. +* :kconfig:`CONFIG_PELION_UPDATE` - This option enables the device firmware update (DFU) feature. +* :kconfig:`CONFIG_PELION_TRANSPORT_MODE_TCP`, :kconfig:`CONFIG_PELION_TRANSPORT_MODE_UDP`, :kconfig:`CONFIG_PELION_TRANSPORT_MODE_UDP_QUEUE` - These options select the transport protocol used by the library. To see all options, check the Pelion Device Management library subtree in configuration system (menuconfig) or read the `Zephyr integration tutorial`_ in the Pelion documentation. diff --git a/doc/nrf/ug_radio_fem.rst b/doc/nrf/ug_radio_fem.rst index 42a22cd865a6..73804a337041 100644 --- a/doc/nrf/ug_radio_fem.rst +++ b/doc/nrf/ug_radio_fem.rst @@ -24,9 +24,6 @@ These methods are only available to protocol drivers that are using FEM features They are also valid for cases where an application uses just one protocol, but benefits from features provided by MPSL. To avoid conflicts, check the protocol documentation to see if it uses FEM support provided by MPSL. -Work is underway to make the protocols shipped with |NCS| use FEM. -At the moment, :ref:`ug_thread` and :ref:`ug_zigbee` support the :ref:`nRF21540 DK ` and the nRF21540 EK for nRF52 Series devices, but there is no multiprotocol support or support for nRF5340 yet. - |NCS| provides a friendly wrapper that configures FEM based on devicetree (DTS) and Kconfig information. To enable FEM support, you must enable FEM and MPSL, and add an ``nrf_radio_fem`` node in the devicetree file. The node can also be provided by the devicetree file of the target devkit or by an overlay file. @@ -42,7 +39,7 @@ Before you add the devicetree node in your application, complete the following s 1. Add support for the MPSL library in your application. The MPSL library provides API to configure FEM. See :ref:`nrfxlib:mpsl_lib` in the nrfxlib documentation for details. -#. Enable support for MPSL implementation in |NCS| by setting the :option:`CONFIG_MPSL` Kconfig option to ``y``. +#. Enable support for MPSL implementation in |NCS| by setting the :kconfig:`CONFIG_MPSL` Kconfig option to ``y``. .. _ug_radio_fem_nrf21540_gpio: @@ -191,3 +188,91 @@ Then there is no need to define a GPIO to control the PDN signal. The line ``pdn Generally, if pin ``X`` is not used, the ``X-gpios = < .. >;`` property can be removed. This applies to all properties with a ``-gpios`` suffix, for both nRF21540 and SKY66112-11. + +.. _ug_radio_fem_boards: + +Supported boards +**************** + +Two nRF21540 boards are available, showcasing the possibilities of the nRF21540 FEM: + +* :ref:`nRF21540 DK ` +* nRF21540 EK, described in sections below + +While the front-end module feature is supported on the nRF52 Series, it is yet not supported on the nRF53 Series. +Work is underway to make the protocols shipped with |NCS| use FEM. +At the moment, :ref:`ug_thread` and :ref:`ug_zigbee` support both the nRF21540 DK and the nRF21540 EK for the nRF52 Series devices. + +.. _ug_radio_fem_nrf21540_ek: + +nRF21540 EK +=========== + +The nRF21540 EK (Evaluation Kit) is an RF front-end module (FEM) for Bluetooth Low Energy, Bluetooth mesh, 2.4 GHz proprietary, Thread, and Zigbee range extension. +When combined with an nRF52 or nRF53 Series SoC, the nRF21540 RF FEM’s +21 dBm TX output power and 13 dB RX gain ensure a superior link budget for up to 16x range extension. + +Overview +-------- + +The nRF21540 complementary device has a 50 Ω SMA transceiver interface and 2x 50 Ω SMA antenna interfaces. +This enables connecting an SoC or a signal generator to the input. +It also enables connecting the outputs to measurement tools or to antennas directly. +The FEM can be configured through the pins available on the Arduino headers. + +The nRF21540's gain control, antenna switching, and modes are controlled via GPIO or SPI, or a combination of both. +GPIO and SPI are accessible through the Arduino Uno Rev3 compatible headers. +The shield also features two additional SMA connectors hooked to the dual antenna ports from the RF FEM, to monitor the performance of the RF FEM using any equipment desired. +The FEM SMA input can be connected to the nRF52 or nRF53 Series SoC RF output with a coaxial RF cable with SMA\SWF connectors. + +.. figure:: /images/nrf21540_ek.png + :width: 350px + :align: center + :alt: nRF21540_EK + + nRF21540 EK shield + +Pin assignment of the nRF21540 EK +--------------------------------- + ++-----------------------+----------+-----------------+ +| Shield connector pin | SIGNAL | FEM function | ++=======================+==========+=================+ +| D2 | GPIO | Mode Select | ++-----------------------+----------+-----------------+ +| D3 | GPIO | RX Enable | ++-----------------------+----------+-----------------+ +| D4 | GPIO | Antenna Select | ++-----------------------+----------+-----------------+ +| D5 | GPIO | TX Enable | ++-----------------------+----------+-----------------+ +| D9 | GPIO | Power Down | ++-----------------------+----------+-----------------+ +| D10 | SPI CS | Chip Select | ++-----------------------+----------+-----------------+ +| D11 | SPI MOSI | Serial Data In | ++-----------------------+----------+-----------------+ +| D12 | SPI MISO | Serial Data Out | ++-----------------------+----------+-----------------+ +| D13 | SPI SCK | Serial Clock | ++-----------------------+----------+-----------------+ + +Programming +----------- + +Set ``-DSHIELD=nrf21540_ek`` when you invoke ``west build`` or ``cmake`` in your Zephyr application. + +Alternatively, add the shield in the project's :file:`CMakeLists.txt` file: + +.. code-block:: none + + set(SHIELD nrf21540_ek) + +To build with SES, in the :guilabel:`Extended Settings` specify ``-DSHIELD=nrf21540_ek``. +See :ref:`cmake_options`. + +References +---------- + +* `nRF21540 DK product page`_ +* `nRF21540 Product Specification`_ +* `nRF21540`_ diff --git a/doc/nrf/ug_tfm.rst b/doc/nrf/ug_tfm.rst index 3ccb79103a2f..34b05fb63fec 100644 --- a/doc/nrf/ug_tfm.rst +++ b/doc/nrf/ug_tfm.rst @@ -36,26 +36,26 @@ TF-M is one of the images that are built as part of a multi-image application. If TF-M is used in the application, SPM will not be included in it. For more information about multi-image builds, see :ref:`ug_multi_image`. -To add TF-M to your build, enable the :option:`CONFIG_BUILD_WITH_TFM` configuration option by adding it to your :file:`prj.conf` file. -To build a :ref:`minimal version ` of TF-M, you must also enable the :option:`CONFIG_TFM_MINIMAL` configuration. +To add TF-M to your build, enable the :kconfig:`CONFIG_BUILD_WITH_TFM` configuration option by adding it to your :file:`prj.conf` file. +To build a :ref:`minimal version ` of TF-M, you must also enable the :kconfig:`CONFIG_TFM_MINIMAL` configuration. .. note:: - If you use menuconfig to enable :option:`CONFIG_BUILD_WITH_TFM`, you must also enable its dependencies. + If you use menuconfig to enable :kconfig:`CONFIG_BUILD_WITH_TFM`, you must also enable its dependencies. You must build TF-M using a non-secure build target. The following targets are currently supported: -* ``nrf5340dk_nrf5340_cpuappns`` -* ``nrf9160dk_nrf9160ns`` +* ``nrf5340dk_nrf5340_cpuapp_ns`` +* ``nrf9160dk_nrf9160_ns`` -When building for ``nrf9160dk_nrf9160ns``, UART1 must be disabled in the non-secure application, because it is used by the TF-M secure application. +When building for ``nrf9160dk_nrf9160_ns``, UART1 must be disabled in the non-secure application, because it is used by the TF-M secure application. Otherwise, the non-secure application will fail to run. The recommended way to do this is to copy the .overlay file from the :ref:`tfm_hello_world` sample. Enabling secure services ======================== -When using the :ref:`nrfxlib:nrf_security`, if :option:`CONFIG_BUILD_WITH_TFM` is enabled together with :option:`CONFIG_NORDIC_SECURITY_BACKEND`, the TF-M secure image will enable the use of the hardware acceleration of Arm CryptoCell. +When using the :ref:`nrfxlib:nrf_security`, if :kconfig:`CONFIG_BUILD_WITH_TFM` is enabled together with :kconfig:`CONFIG_NORDIC_SECURITY_BACKEND`, the TF-M secure image will enable the use of the hardware acceleration of Arm CryptoCell. In such case, the Kconfig configurations in the Nordic Security Backend control the features enabled through TF-M. You can configure what crypto modules to include in TF-M by using the ``TFM_CRYPTO_`` Kconfig options found in file :file:`zephyr/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules`. @@ -74,9 +74,9 @@ The secure services supported by this minimal version allow for generating rando This corresponds to the feature set provided by the :ref:`secure_partition_manager`. -The minimal version of TF-M is enabled by setting the :option:`CONFIG_TFM_MINIMAL` option. +The minimal version of TF-M is enabled by setting the :kconfig:`CONFIG_TFM_MINIMAL` option. -When :option:`CONFIG_TFM_MINIMAL` is set, the configurability of TF-M is severely limited. +When :kconfig:`CONFIG_TFM_MINIMAL` is set, the configurability of TF-M is severely limited. Hence, it is not possible to modify the TF-M minimal configuration to create your own variant of the minimal configuration. Instead, the default configuration must be used as a starting point. diff --git a/doc/nrf/ug_thingy91.rst b/doc/nrf/ug_thingy91.rst index 3cb6785f8e1b..4199b57abbae 100644 --- a/doc/nrf/ug_thingy91.rst +++ b/doc/nrf/ug_thingy91.rst @@ -14,7 +14,7 @@ Nordic Thingy:91 is a battery-operated prototyping platform for cellular IoT sys Thingy:91 integrates the following components: * nRF9160 SiP - supporting LTE-M, NB-IoT, and Global Positioning System (GPS) -* nRF52840 SoC - supporting Bluetooth Low Energy and Near Field Communication (NFC) +* nRF52840 SoC - supporting Bluetooth® Low Energy and Near Field Communication (NFC) You can find more information on the product in the `Thingy:91 product page`_ and in the `Nordic Thingy:91 User Guide`_. The |NCS| provides support for developing applications on the Thingy:91. @@ -153,21 +153,22 @@ You can also program the Thingy:91 by using the images obtained by building the To set up your system to be able to build a compatible firmware image, follow the :ref:`getting_started` guide for |NCS|. The build targets of interest for Thingy:91 in |NCS| are as follows: -+---------------+--------------------------------------------------+ -|Component | Build target | -+===============+==================================================+ -|nRF9160 SiP |``thingy91_nrf9160`` for the secure version | -| | | -| |``thingy91_nrf9160ns`` for the non-secure version | -+---------------+--------------------------------------------------+ -|nRF52840 SoC |``thingy91_nrf52840`` | -+---------------+--------------------------------------------------+ ++---------------+---------------------------------------------------+ +|Component | Build target | ++===============+===================================================+ +|nRF9160 SiP |``thingy91_nrf9160`` for the secure version | +| | | +| |``thingy91_nrf9160_ns`` for the non-secure version | ++---------------+---------------------------------------------------+ +|nRF52840 SoC |``thingy91_nrf52840`` | ++---------------+---------------------------------------------------+ -You must use the build target ``thingy91_nrf9160`` or ``thingy91_nrf9160ns`` when building the application code for the nRF9160 SiP and the build target ``thingy91_nrf52840`` when building the application code for the onboard nRF52840 SoC. +You must use the build target ``thingy91_nrf9160`` or ``thingy91_nrf9160_ns`` when building the application code for the nRF9160 SiP and the build target ``thingy91_nrf52840`` when building the application code for the onboard nRF52840 SoC. .. note:: - In |NCS| releases before v1.3.0, these build targets were named ``nrf9160_pca20035``, ``nrf9160_pca20035ns``, and ``nrf52840_pca20035``. + * In |NCS| releases before v1.3.0, these build targets were named ``nrf9160_pca20035``, ``nrf9160_pca20035ns``, and ``nrf52840_pca20035``. + * In |NCS| releases ranging from v1.3.0 to v1.6.1, the build target ``thingy91_nrf9160_ns`` was named ``thingy91_nrf9160ns``. .. note:: @@ -223,7 +224,7 @@ Building and programming using SEGGER Embedded Studio .. figure:: images/ses_thingy_configuration.png :alt: Opening the Asset tracker application - Opening the Asset tracker application for the thingy91_nrf9160ns build target + Opening the Asset tracker application for the thingy91_nrf9160_ns build target .. note:: @@ -293,7 +294,7 @@ To build and program the source code from the command line, complete the followi west build -b *build_target* -d *destination_directory_name* - The parameter *build_target* should be ``thingy91_nrf9160`` or ``thingy91_nrf9160ns`` if building for the nRF9160 SiP component and ``thingy91_nrf52840`` if building for the nRF52840 SoC component. + The parameter *build_target* should be ``thingy91_nrf9160`` or ``thingy91_nrf9160_ns`` if building for the nRF9160 SiP component and ``thingy91_nrf52840`` if building for the nRF52840 SoC component. .. note:: diff --git a/doc/nrf/ug_thread.rst b/doc/nrf/ug_thread.rst index 08181d251d0a..ab97e8bd4478 100644 --- a/doc/nrf/ug_thread.rst +++ b/doc/nrf/ug_thread.rst @@ -14,7 +14,7 @@ The OpenThread stack is integrated into Zephyr. .. thread_intro_end -You can use Thread in parallel with Bluetooth Low Energy. +You can use Thread in parallel with Bluetooth® Low Energy. See :ref:`ug_multiprotocol_support` for more information. See :ref:`openthread_samples` for the list of available Thread samples. diff --git a/doc/nrf/ug_thread_architectures.rst b/doc/nrf/ug_thread_architectures.rst index 05319e0ef626..e0a8e24eb917 100644 --- a/doc/nrf/ug_thread_architectures.rst +++ b/doc/nrf/ug_thread_architectures.rst @@ -81,7 +81,7 @@ This platform design is suitable for the following development kits: Single-chip, multiprotocol (SoC) ================================ -nRF52 and nRF53 Series devices support multiple wireless technologies, including IEEE 802.15.4 and Bluetooth Low Energy (Bluetooth LE). +nRF52 and nRF53 Series devices support multiple wireless technologies, including IEEE 802.15.4 and Bluetooth® Low Energy (Bluetooth LE). In a single-chip, multiprotocol design, the application layer and OpenThread run on the same processor. diff --git a/doc/nrf/ug_thread_certification.rst b/doc/nrf/ug_thread_certification.rst index ea36657a36f0..a372ba3e64a8 100644 --- a/doc/nrf/ug_thread_certification.rst +++ b/doc/nrf/ug_thread_certification.rst @@ -72,7 +72,7 @@ Complete the following steps to prepare for the certification tests: .. note:: The configuration option selects the precompiled OpenThread libraries. - The overlay file enables :ref:`multiprotocol support ` with Bluetooth LE advertising. + The overlay file enables :ref:`multiprotocol support ` with Bluetooth® LE advertising. #. Prepare Thread Test Harness. diff --git a/doc/nrf/ug_thread_configuring.rst b/doc/nrf/ug_thread_configuring.rst index cf4b1fb2de5d..990a21de3080 100644 --- a/doc/nrf/ug_thread_configuring.rst +++ b/doc/nrf/ug_thread_configuring.rst @@ -26,9 +26,9 @@ Enabling OpenThread in |NCS| To use the Thread protocol in |NCS|, set the following Kconfig options: -* :option:`CONFIG_NETWORKING` - This option enables the generic link layer and the IP networking support. -* :option:`CONFIG_NET_L2_OPENTHREAD` - This option enables the OpenThread stack required for the correct operation of the Thread protocol and allows you to use it. -* :option:`CONFIG_MPSL` - This option enables the :ref:`nrfxlib:mpsl` (MPSL) implementation, which provides services for both :ref:`single-protocol and multi-protocol implementations `. +* :kconfig:`CONFIG_NETWORKING` - This option enables the generic link layer and the IP networking support. +* :kconfig:`CONFIG_NET_L2_OPENTHREAD` - This option enables the OpenThread stack required for the correct operation of the Thread protocol and allows you to use it. +* :kconfig:`CONFIG_MPSL` - This option enables the :ref:`nrfxlib:mpsl` (MPSL) implementation, which provides services for both :ref:`single-protocol and multi-protocol implementations `. .. _ug_thread_configuring_basic_building: @@ -42,18 +42,18 @@ Building the OpenThread libraries from source gives you full flexibility in conf Using pre-built variants can be useful for certification purposes. Configure OpenThread to build from source - Set :option:`CONFIG_OPENTHREAD_SOURCES` to build the libraries from source. + Set :kconfig:`CONFIG_OPENTHREAD_SOURCES` to build the libraries from source. This option is selected by default. This alternative allows you to define :ref:`ug_thread_configuring_additional` one by one. - By default, the :ref:`thread_ug_feature_sets` option is set to custom (:option:`CONFIG_OPENTHREAD_USER_CUSTOM_LIBRARY`), which allows you to create your own OpenThread stack configuration. + By default, the :ref:`thread_ug_feature_sets` option is set to custom (:kconfig:`CONFIG_OPENTHREAD_USER_CUSTOM_LIBRARY`), which allows you to create your own OpenThread stack configuration. However, you can select other feature sets as a basis. When building the OpenThread libraries from source, you can also :ref:`update the pre-built OpenThread libraries `. Configure OpenThread to use pre-built libraries - Set :option:`CONFIG_OPENTHREAD_LIBRARY_1_1` to use pre-built libraries. - Select one of the :ref:`thread_ug_feature_sets` by enabling :option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER`, :option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_FTD`, or :option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MTD`. + Set :kconfig:`CONFIG_OPENTHREAD_LIBRARY_1_1` to use pre-built libraries. + Select one of the :ref:`thread_ug_feature_sets` by enabling :kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER`, :kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_FTD`, or :kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MTD`. This alternative disables building OpenThread from source files and links pre-built libraries instead. @@ -64,17 +64,17 @@ Additional configuration options Depending on your configuration needs, you can also set the following options: -* :option:`CONFIG_NET_SOCKETS` - This option enables API similar to BSD Sockets on top of the native Zephyr networking API. +* :kconfig:`CONFIG_NET_SOCKETS` - This option enables API similar to BSD Sockets on top of the native Zephyr networking API. This configuration is needed for managing networking protocols. -* :option:`CONFIG_NET_SHELL` - This option enables Zephyr's :ref:`zephyr:net_shell`. +* :kconfig:`CONFIG_NET_SHELL` - This option enables Zephyr's :ref:`zephyr:net_shell`. This configuration is needed for managing the network, based on Zephyr's IP stack, from the command line. -* :option:`CONFIG_OPENTHREAD_SHELL` - This option enables OpenThread CLI (see `OpenThread CLI Reference`_). -* :option:`CONFIG_COAP` - This option enables Zephyr's :ref:`zephyr:coap_sock_interface` support. -* :option:`CONFIG_COAP_UTILS` - This option enables the :ref:`CoAP utils library `. -* :option:`CONFIG_OPENTHREAD_COAP` - This option enables OpenThread's native CoAP API. -* :option:`CONFIG_OPENTHREAD_CHANNEL` - By default set to ``11``. +* :kconfig:`CONFIG_OPENTHREAD_SHELL` - This option enables OpenThread CLI (see `OpenThread CLI Reference`_). +* :kconfig:`CONFIG_COAP` - This option enables Zephyr's :ref:`zephyr:coap_sock_interface` support. +* :kconfig:`CONFIG_COAP_UTILS` - This option enables the :ref:`CoAP utils library `. +* :kconfig:`CONFIG_OPENTHREAD_COAP` - This option enables OpenThread's native CoAP API. +* :kconfig:`CONFIG_OPENTHREAD_CHANNEL` - By default set to ``11``. You can set any value ranging from ``11`` to ``26``. -* :option:`CONFIG_OPENTHREAD_PANID` - By default set to ``43981``. +* :kconfig:`CONFIG_OPENTHREAD_PANID` - By default set to ``43981``. You can set any value ranging from ``0`` to ``65535``. See the following files for more options that you might want to change: @@ -110,7 +110,7 @@ Hardware-accelerated cryptography You can enable hardware-accelerated cryptography by using the :ref:`nrfxlib:nrf_security`. To do this, modify the setting of the following Kconfig option: -* :option:`CONFIG_OPENTHREAD_MBEDTLS` - Disable this option to disable the default mbedTLS configuration for OpenThread. +* :kconfig:`CONFIG_OPENTHREAD_MBEDTLS` - Disable this option to disable the default mbedTLS configuration for OpenThread. The nrf_security module is enabled by default when mbedTLS for OpenThread is disabled. For more configuration options, read the module documentation. @@ -123,9 +123,9 @@ Thread 1.2 Specification options The OpenThread stack can be configured to operate in compliance with either the Thread 1.1 Specification or the :ref:`Thread 1.2 Specification `. You can change the stack version by using the following Kconfig options: -* :option:`CONFIG_OPENTHREAD_THREAD_VERSION_1_1` - Selects the Thread stack version that is compliant with the Thread 1.1 Specification. +* :kconfig:`CONFIG_OPENTHREAD_THREAD_VERSION_1_1` - Selects the Thread stack version that is compliant with the Thread 1.1 Specification. This option is enabled by default if no other option is selected. -* :option:`CONFIG_OPENTHREAD_THREAD_VERSION_1_2` - Selects the Thread stack version that is compliant with the Thread 1.2 Specification. +* :kconfig:`CONFIG_OPENTHREAD_THREAD_VERSION_1_2` - Selects the Thread stack version that is compliant with the Thread 1.2 Specification. By selecting support for Thread 1.2, you enable the following features in addition to the :ref:`Thread 1.1 features `: @@ -136,12 +136,12 @@ By selecting support for Thread 1.2, you enable the following features in additi Moreover, Thread 1.2 also comes with the following features that are supported for development, but not production: -* Domain Unicast Addresses - Set :option:`CONFIG_OPENTHREAD_DUA` to enable this feature. -* Multicast Listener Registration - Set :option:`CONFIG_OPENTHREAD_MLR` to enable this feature. -* Backbone Router - Set :option:`CONFIG_OPENTHREAD_BACKBONE_ROUTER` to enable this feature. -* Link Metrics - Set :option:`CONFIG_OPENTHREAD_LINK_METRICS_INITIATOR` to enable the link metrics initiator functionality. - Set :option:`CONFIG_OPENTHREAD_LINK_METRICS_SUBJECT` to enable the link metrics subject functionality. -* Coordinated Sampled Listening (CSL) Receiver - Set :option:`CONFIG_OPENTHREAD_CSL_RECEIVER` to enable this feature. +* Domain Unicast Addresses - Set :kconfig:`CONFIG_OPENTHREAD_DUA` to enable this feature. +* Multicast Listener Registration - Set :kconfig:`CONFIG_OPENTHREAD_MLR` to enable this feature. +* Backbone Router - Set :kconfig:`CONFIG_OPENTHREAD_BACKBONE_ROUTER` to enable this feature. +* Link Metrics - Set :kconfig:`CONFIG_OPENTHREAD_LINK_METRICS_INITIATOR` to enable the link metrics initiator functionality. + Set :kconfig:`CONFIG_OPENTHREAD_LINK_METRICS_SUBJECT` to enable the link metrics subject functionality. +* Coordinated Sampled Listening (CSL) Receiver - Set :kconfig:`CONFIG_OPENTHREAD_CSL_RECEIVER` to enable this feature. .. note:: The Link Metrics and Coordinated Sampled Listening features are not supported for nRF53 Series devices yet. @@ -161,22 +161,22 @@ Configuring this process is optional, because the :ref:`openthread_samples` in | If you want to manually enable the Thread network Commissioner role on a device, set the following Kconfig option to the provided value: -* :option:`CONFIG_OPENTHREAD_COMMISSIONER` to ``y``. +* :kconfig:`CONFIG_OPENTHREAD_COMMISSIONER` to ``y``. To enable the Thread network Joiner role on a device, set the following Kconfig option to the provided value: -* :option:`CONFIG_OPENTHREAD_JOINER` to ``y``. +* :kconfig:`CONFIG_OPENTHREAD_JOINER` to ``y``. You can also configure how the commissioning process is to be started. The following options are available: * Start automatically after the Joiner powers up. - To configure this option, configure the :option:`CONFIG_OPENTHREAD_JOINER_AUTOSTART` option for the Joiner device. + To configure this option, configure the :kconfig:`CONFIG_OPENTHREAD_JOINER_AUTOSTART` option for the Joiner device. * Start from the application. * Trigger by Command Line Interface commands. In this case, the shell stack size must be increased to at least 3 KB by setting the following option: - * :option:`CONFIG_SHELL_STACK_SIZE` to ``3168``. + * :kconfig:`CONFIG_SHELL_STACK_SIZE` to ``3168``. For more details about the commissioning process, see `Thread Commissioning on OpenThread portal`_. @@ -187,8 +187,8 @@ OpenThread stack logging options You can enable the OpenThread stack logging for your project with the following options: -* :option:`CONFIG_LOG` - This option enables Zephyr's :ref:`zephyr:logging_api`. -* :option:`CONFIG_OPENTHREAD_DEBUG` - This option enables logging for the OpenThread stack. +* :kconfig:`CONFIG_LOG` - This option enables Zephyr's :ref:`zephyr:logging_api`. +* :kconfig:`CONFIG_OPENTHREAD_DEBUG` - This option enables logging for the OpenThread stack. Both options must be enabled to allow logging. @@ -196,25 +196,25 @@ After setting these options, you can choose one of several :ref:`logging backend .. note:: If you are working with Thread samples, enabling logging and logging backend is optional. - By default, all Thread samples have logging enabled in the :file:`overlay-ot-defaults.conf` file and are configured to provide output at the informational level (:option:`CONFIG_OPENTHREAD_LOG_LEVEL_INFO`). + By default, all Thread samples have logging enabled in the :file:`overlay-ot-defaults.conf` file and are configured to provide output at the informational level (:kconfig:`CONFIG_OPENTHREAD_LOG_LEVEL_INFO`). Logging levels -------------- Select one of the following logging levels to customize the logging output: -* :option:`CONFIG_OPENTHREAD_LOG_LEVEL_CRIT` - This option enables critical error logging only. -* :option:`CONFIG_OPENTHREAD_LOG_LEVEL_WARN` - This option enables warning logging in addition to critical errors. -* :option:`CONFIG_OPENTHREAD_LOG_LEVEL_NOTE` - This option additionally enables notice logging. -* :option:`CONFIG_OPENTHREAD_LOG_LEVEL_INFO` - This option additionally enables informational logging. -* :option:`CONFIG_OPENTHREAD_LOG_LEVEL_DEBG` - This option additionally enables debug logging. +* :kconfig:`CONFIG_OPENTHREAD_LOG_LEVEL_CRIT` - This option enables critical error logging only. +* :kconfig:`CONFIG_OPENTHREAD_LOG_LEVEL_WARN` - This option enables warning logging in addition to critical errors. +* :kconfig:`CONFIG_OPENTHREAD_LOG_LEVEL_NOTE` - This option additionally enables notice logging. +* :kconfig:`CONFIG_OPENTHREAD_LOG_LEVEL_INFO` - This option additionally enables informational logging. +* :kconfig:`CONFIG_OPENTHREAD_LOG_LEVEL_DEBG` - This option additionally enables debug logging. The more detailed logging level you select, the more logging buffers you need to be able to see all messages. The buffer size must also be increased. Use the following Kconfig options for this purpose: -* :option:`CONFIG_LOG_STRDUP_BUF_COUNT` - This option specifies the number of logging buffers. -* :option:`CONFIG_LOG_STRDUP_MAX_STRING` - This option specifies the size of logging buffers. +* :kconfig:`CONFIG_LOG_STRDUP_BUF_COUNT` - This option specifies the number of logging buffers. +* :kconfig:`CONFIG_LOG_STRDUP_MAX_STRING` - This option specifies the size of logging buffers. Zephyr L2 logging options @@ -222,19 +222,19 @@ Zephyr L2 logging options If you want to get logging output related to Zephyr's L2 layer, enable one of the following Kconfig options: -* :option:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_ERR` - Enables logging only for errors. -* :option:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_WRN` - Enables logging for errors and warnings. -* :option:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF` - Enables logging for informational messages, errors, and warnings. -* :option:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_DBG` - Enables logging for debug messages, informational messages, errors, and warnings. +* :kconfig:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_ERR` - Enables logging only for errors. +* :kconfig:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_WRN` - Enables logging for errors and warnings. +* :kconfig:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF` - Enables logging for informational messages, errors, and warnings. +* :kconfig:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_DBG` - Enables logging for debug messages, informational messages, errors, and warnings. Choosing one of these options enables writing the appropriate information in the L2 debug log. -Additionally, enabling :option:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_DBG` allows you to set the :option:`CONFIG_OPENTHREAD_L2_DEBUG` option, which in turn has the following settings: +Additionally, enabling :kconfig:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_DBG` allows you to set the :kconfig:`CONFIG_OPENTHREAD_L2_DEBUG` option, which in turn has the following settings: -* :option:`CONFIG_OPENTHREAD_L2_DEBUG_DUMP_15_4` - Enables dumping 802.15.4 frames in the debug log output. -* :option:`CONFIG_OPENTHREAD_L2_DEBUG_DUMP_IPV6` - Enables dumping IPv6 frames in the debug log output. +* :kconfig:`CONFIG_OPENTHREAD_L2_DEBUG_DUMP_15_4` - Enables dumping 802.15.4 frames in the debug log output. +* :kconfig:`CONFIG_OPENTHREAD_L2_DEBUG_DUMP_IPV6` - Enables dumping IPv6 frames in the debug log output. -You can disable writing to log with the :option:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_OFF` option. +You can disable writing to log with the :kconfig:`CONFIG_OPENTHREAD_L2_LOG_LEVEL_OFF` option. .. _thread_ug_device_type: @@ -244,14 +244,14 @@ Device type options You can configure OpenThread devices to run as a specific :ref:`device type `. Full Thread Device (FTD) - Set :option:`CONFIG_OPENTHREAD_FTD` to configure the device as FTD. + Set :kconfig:`CONFIG_OPENTHREAD_FTD` to configure the device as FTD. This is the default configuration. Minimal Thread Device (MTD) - Set :option:`CONFIG_OPENTHREAD_MTD` to configure the device as MTD. + Set :kconfig:`CONFIG_OPENTHREAD_MTD` to configure the device as MTD. By default, the MTD operates as Minimal End Device (MED). - To make it operate as Sleepy End Device (SED), enabling :option:`CONFIG_OPENTHREAD_MTD_SED`. + To make it operate as Sleepy End Device (SED), enabling :kconfig:`CONFIG_OPENTHREAD_MTD_SED`. .. _thread_ug_prebuilt: @@ -262,7 +262,7 @@ The |NCS| provides a set of :ref:`nrfxlib:ot_libs`. These pre-built libraries are available in nrfxlib and provide features and optional functionalities from the OpenThread stack. You can use these libraries for building applications with support for the complete Thread 1.1 Specification. -To use a pre-built library, configure OpenThread to use pre-built libraries by setting the :option:`CONFIG_OPENTHREAD_LIBRARY_1_1` Kconfig option and select one of the provided :ref:`thread_ug_feature_sets`. +To use a pre-built library, configure OpenThread to use pre-built libraries by setting the :kconfig:`CONFIG_OPENTHREAD_LIBRARY_1_1` Kconfig option and select one of the provided :ref:`thread_ug_feature_sets`. .. _thread_ug_feature_sets: @@ -274,12 +274,12 @@ These feature sets are mainly used for pre-built libraries, but you can also use The |NCS| provides the following feature sets: -* :option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER` - Enable the complete set of OpenThread features for the Thread 1.1 Specification. -* :option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_FTD` - Enable optimized OpenThread features for FTD (Thread 1.1). -* :option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MTD` - Enable optimized OpenThread features for MTD (Thread 1.1). -* :option:`CONFIG_OPENTHREAD_USER_CUSTOM_LIBRARY` - Create a custom feature set for compilation when :ref:`building using OpenThread sources `. +* :kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER` - Enable the complete set of OpenThread features for the Thread 1.1 Specification. +* :kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_FTD` - Enable optimized OpenThread features for FTD (Thread 1.1). +* :kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MTD` - Enable optimized OpenThread features for MTD (Thread 1.1). +* :kconfig:`CONFIG_OPENTHREAD_USER_CUSTOM_LIBRARY` - Create a custom feature set for compilation when :ref:`building using OpenThread sources `. This option is the default. - If you select :option:`CONFIG_OPENTHREAD_LIBRARY_1_1`, choose a different feature set. + If you select :kconfig:`CONFIG_OPENTHREAD_LIBRARY_1_1`, choose a different feature set. .. note:: When :ref:`building OpenThread from source `, you can select another feature set as base. @@ -422,37 +422,37 @@ Be aware of the following limitations when customizing the configuration of a pr The following list shows some of the configuration options that you might want to customize: -* :option:`CONFIG_OPENTHREAD_FTD` or :option:`CONFIG_OPENTHREAD_MTD` - Select the :ref:`device type `. - The :option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MTD` feature set supports only the MTD device type. +* :kconfig:`CONFIG_OPENTHREAD_FTD` or :kconfig:`CONFIG_OPENTHREAD_MTD` - Select the :ref:`device type `. + The :kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MTD` feature set supports only the MTD device type. The other feature sets support both device types. -* :option:`CONFIG_OPENTHREAD_COPROCESSOR` and :option:`CONFIG_OPENTHREAD_COPROCESSOR_NCP` - Select the OpenThread architecture to use. +* :kconfig:`CONFIG_OPENTHREAD_COPROCESSOR` and :kconfig:`CONFIG_OPENTHREAD_COPROCESSOR_NCP` - Select the OpenThread architecture to use. See :ref:`thread_architectures_designs_cp`. -* :option:`CONFIG_OPENTHREAD_MANUAL_START` - Choose whether to configure and join the Thread network automatically. +* :kconfig:`CONFIG_OPENTHREAD_MANUAL_START` - Choose whether to configure and join the Thread network automatically. If you set this option to ``n``, also check and configure the network parameters that are used, for example: - * :option:`CONFIG_OPENTHREAD_CHANNEL` - * :option:`CONFIG_OPENTHREAD_NETWORKKEY` - * :option:`CONFIG_OPENTHREAD_NETWORK_NAME` - * :option:`CONFIG_OPENTHREAD_PANID` - * :option:`CONFIG_OPENTHREAD_XPANID` + * :kconfig:`CONFIG_OPENTHREAD_CHANNEL` + * :kconfig:`CONFIG_OPENTHREAD_NETWORKKEY` + * :kconfig:`CONFIG_OPENTHREAD_NETWORK_NAME` + * :kconfig:`CONFIG_OPENTHREAD_PANID` + * :kconfig:`CONFIG_OPENTHREAD_XPANID` .. _thread_ug_feature_updating_libs: Updating pre-built OpenThread libraries ======================================= -You can update the :ref:`nrfxlib:ot_libs` in nrfxlib when using any Thread sample if you configure the sample to build the OpenThread stack from source with :option:`CONFIG_OPENTHREAD_SOURCES`. +You can update the :ref:`nrfxlib:ot_libs` in nrfxlib when using any Thread sample if you configure the sample to build the OpenThread stack from source with :kconfig:`CONFIG_OPENTHREAD_SOURCES`. Use this functionality for :ref:`certification ` of your configuration of the OpenThread libraries, for example. .. note:: The libraries destination directory can differ. - When you selected :option:`CONFIG_OPENTHREAD_USER_CUSTOM_LIBRARY`, the location depends on the chosen :ref:`nrf_security backend `, either :option:`CONFIG_CC3XX_BACKEND` or :option:`CONFIG_OBERON_BACKEND`. + When you selected :kconfig:`CONFIG_OPENTHREAD_USER_CUSTOM_LIBRARY`, the location depends on the chosen :ref:`nrf_security backend `, either :kconfig:`CONFIG_CC3XX_BACKEND` or :kconfig:`CONFIG_OBERON_BACKEND`. Updating libraries without debug symbols ---------------------------------------- You can install the release version of the latest nrfxlib libraries without the debug symbols. -This is handled with the :option:`CONFIG_OPENTHREAD_BUILD_OUTPUT_STRIPPED` Kconfig option. +This is handled with the :kconfig:`CONFIG_OPENTHREAD_BUILD_OUTPUT_STRIPPED` Kconfig option. This option is disabled by default. Run the following command to update the nrfxlib libraries: @@ -464,7 +464,7 @@ Run the following command to update the nrfxlib libraries: This command builds two versions of the libraries, with and without debug symbols, and installs only the version without debug symbols. |board_note_for_updating_libs| -The :option:`CONFIG_OPENTHREAD_BUILD_OUTPUT_STRIPPED` Kconfig option will be disabled again after this command completes. +The :kconfig:`CONFIG_OPENTHREAD_BUILD_OUTPUT_STRIPPED` Kconfig option will be disabled again after this command completes. Updating libraries to debug version ----------------------------------- diff --git a/doc/nrf/ug_thread_ot_memory.rst b/doc/nrf/ug_thread_ot_memory.rst index c6102039e985..ba53c9260e5a 100644 --- a/doc/nrf/ug_thread_ot_memory.rst +++ b/doc/nrf/ug_thread_ot_memory.rst @@ -25,13 +25,13 @@ Moreover, take into account the following considerations: * The multiprotocol samples were optimized with the overlay :file:`overlay-minimal_multiprotocol.conf`. * To enable the multiprotocol support, the following options were used: - * :option:`CONFIG_MPSL` set to ``y`` (default setting for all samples) - * :option:`CONFIG_BT_LL_SOFTDEVICE_DEFAULT` set to ``y`` - * :option:`CONFIG_BT` set to ``y`` - * :option:`CONFIG_BT_PERIPHERAL` set to ``y`` - * :option:`CONFIG_BT_DEVICE_NAME` set to ``"NCS DUT"`` - * :option:`CONFIG_BT_DEVICE_APPEARANCE` set to ``833`` - * :option:`CONFIG_BT_MAX_CONN` set to ``1`` + * :kconfig:`CONFIG_MPSL` set to ``y`` (default setting for all samples) + * :kconfig:`CONFIG_BT_LL_SOFTDEVICE_DEFAULT` set to ``y`` + * :kconfig:`CONFIG_BT` set to ``y`` + * :kconfig:`CONFIG_BT_PERIPHERAL` set to ``y`` + * :kconfig:`CONFIG_BT_DEVICE_NAME` set to ``"NCS DUT"`` + * :kconfig:`CONFIG_BT_DEVICE_APPEARANCE` set to ``833`` + * :kconfig:`CONFIG_BT_MAX_CONN` set to ``1`` * Values for the :ref:`Thread CLI sample `, which works with all OpenThread calls, are the highest possible for the OpenThread stack using the master image library configuration. diff --git a/doc/nrf/ug_thread_supported_features.rst b/doc/nrf/ug_thread_supported_features.rst index ca3a730e5876..14c59d08636d 100644 --- a/doc/nrf/ug_thread_supported_features.rst +++ b/doc/nrf/ug_thread_supported_features.rst @@ -42,9 +42,6 @@ By default, |NCS| supports Thread 1.1, but you can enable and configure Thread 1 Limitations for Thread 1.2 support ================================== -The Thread 1.2 Specification support has the following limitations: +The Thread 1.2 Specification support has the following limitation: -* The current implementation does not guarantee that all retransmitted frames will be secured when using the radio driver transmission security capabilities. - For this reason, OpenThread retransmissions are disabled by default when the :option:`CONFIG_NRF_802154_ENCRYPTION` Kconfig option is enabled. - You can enable the retransmissions at your own risk. -* Due to code size limitation, the combination of complete set of Thread 1.2 features with the Bluetooth LE multiprotocol support is not possible for the nRF52833 DKs. +* Due to code size limitation, the combination of complete set of Thread 1.2 features with the Bluetooth® LE multiprotocol support is not possible for the nRF52833 DKs. diff --git a/doc/nrf/ug_thread_tools.rst b/doc/nrf/ug_thread_tools.rst index 7ef6eac2a1b9..7906eedb4a40 100644 --- a/doc/nrf/ug_thread_tools.rst +++ b/doc/nrf/ug_thread_tools.rst @@ -14,29 +14,41 @@ The tools listed on this page can be helpful when developing your Thread applica nRF Sniffer for 802.15.4 ************************ +.. sniffer_shortdesc_start + The nRF Sniffer for 802.15.4 is a tool for learning about and debugging applications that are using protocols based on IEEE 802.15.4, like Thread or Zigbee. It provides a near real-time display of 802.15.4 packets that are sent back and forth between devices, even when the link is encrypted. See `nRF Sniffer for 802.15.4`_ for documentation. +.. sniffer_shortdesc_end + .. _ug_thread_tools_ttm: nRF Thread Topology Monitor *************************** +.. ttm_shortdesc_start + nRF Thread Topology Monitor is a desktop application that connects to a Thread network through a serial connection to visualize the topology of Thread devices. It allows you to scan for new devices in real time, check their parameters, and inspect network processes through the log. See `nRF Thread Topology Monitor`_ for documentation. +.. ttm_shortdesc_end + .. _ug_thread_tools_tbr: Thread Border Router ******************** +.. tbr_shortdesc_start + The Thread Border Router is a specific type of Border Router device that provides connectivity from the IEEE 802.15.4 network to adjacent networks on other physical layers (such as Wi-Fi or Ethernet). Border Routers provide services for devices within the IEEE 802.15.4 network, including routing services for off-network operations. +.. tbr_shortdesc_end + Typically, a Border Router solution consists of the following parts: * An application based on the :ref:`thread_architectures_designs_cp_ncp` design or its :ref:`thread_architectures_designs_cp_rcp` variant compatible with the IEEE 802.15.4 standard. diff --git a/doc/nrf/ug_unity_testing.rst b/doc/nrf/ug_unity_testing.rst index 3a637f3bd243..b34388a315ac 100644 --- a/doc/nrf/ug_unity_testing.rst +++ b/doc/nrf/ug_unity_testing.rst @@ -21,7 +21,7 @@ Setting up a unit test An example for a unit test can be found in :file:`tests/unity/example_test`. The file `tests/unity/example_test/CMakeLists.txt`_ shows how to set up the generation of the test runner file and mocks. -To run the unit test, enable the Unity module (:option:`CONFIG_UNITY`) and the module under test. +To run the unit test, enable the Unity module (:kconfig:`CONFIG_UNITY`) and the module under test. The module under test and all dependencies are enabled and compiled into the binary, even the mocked modules. The linker replaces all calls to the mocked API with a mock implementation using the wrapping feature. diff --git a/doc/nrf/ug_zigbee_architectures.rst b/doc/nrf/ug_zigbee_architectures.rst index 6f90c48c68ce..eb6419362966 100644 --- a/doc/nrf/ug_zigbee_architectures.rst +++ b/doc/nrf/ug_zigbee_architectures.rst @@ -59,7 +59,7 @@ This platform design is suitable for the following development kits: Single-chip, multiprotocol (SoC) ================================ -With the nRF devices supporting multiple wireless technologies, including IEEE 802.15.4 and Bluetooth Low Energy (Bluetooth LE), the application layer and the Zigbee and Bluetooth LE stack run on the same chip. +With the nRF devices supporting multiple wireless technologies, including IEEE 802.15.4 and Bluetooth® Low Energy (Bluetooth LE), the application layer and the Zigbee and Bluetooth LE stack run on the same chip. This design has the following advantages: diff --git a/doc/nrf/ug_zigbee_configuring.rst b/doc/nrf/ug_zigbee_configuring.rst index 9620644628cc..4b2df0c49b8b 100644 --- a/doc/nrf/ug_zigbee_configuring.rst +++ b/doc/nrf/ug_zigbee_configuring.rst @@ -17,7 +17,7 @@ Required libraries and drivers Zigbee requires the following modules to properly operate in the |NCS|: * :ref:`nrfxlib:zboss` available in nrfxlib, with the :ref:`lib_zigbee_osif` subsystem acting as the linking layer between the ZBOSS stack and the |NCS|. - The ZBOSS library is enabled by the :option:`CONFIG_ZIGBEE` Kconfig option. + The ZBOSS library is enabled by the :kconfig:`CONFIG_ZIGBEE` Kconfig option. For more information about the ZBOSS stack, see also the `external ZBOSS development guide and API documentation`_. * :ref:`zephyr:ieee802154_interface` radio driver - This library is automatically enabled when working with Zigbee on Nordic Semiconductor's development kits. @@ -26,14 +26,14 @@ Zigbee requires the following modules to properly operate in the |NCS|: Mandatory configuration *********************** -To use the Zigbee protocol, set the :option:`CONFIG_ZIGBEE` Kconfig option. +To use the Zigbee protocol, set the :kconfig:`CONFIG_ZIGBEE` Kconfig option. Setting this option enables all the peripherals required for the correct operation of the Zigbee protocol and allows you to use them. After that, you have to define the Zigbee device role for the Zigbee application or sample by setting one of the following Kconfig options: -* Router role: :option:`CONFIG_ZIGBEE_ROLE_ROUTER` -* End Device role: :option:`CONFIG_ZIGBEE_ROLE_END_DEVICE` -* Coordinator role: :option:`CONFIG_ZIGBEE_ROLE_COORDINATOR` +* Router role: :kconfig:`CONFIG_ZIGBEE_ROLE_ROUTER` +* End Device role: :kconfig:`CONFIG_ZIGBEE_ROLE_END_DEVICE` +* Coordinator role: :kconfig:`CONFIG_ZIGBEE_ROLE_COORDINATOR` Setting any of these options enables the respective ZBOSS role library. This is needed because End Devices use different libraries than Routers and Coordinators. @@ -69,9 +69,9 @@ Power saving during sleep With the sleepy behavior enabled, the unused part of RAM memory is powered off, which allows to lower the power consumption even more. The sleep current of MCU can be lowered to about 1.8 uA by completing the following steps: -1. Turn off UART by setting :option:`CONFIG_SERIAL` to ``n``. +1. Turn off UART by setting :kconfig:`CONFIG_SERIAL` to ``n``. #. For current measurements for the :ref:`nRF52840 DK ` (PCA10056), the :ref:`nRF52833 DK ` (PCA10100), or the :ref:`nRF5340 ` (PCA10095), set **SW6** to ``nRF ONLY`` position to get the desired results. -#. Enable the :option:`CONFIG_RAM_POWER_DOWN_LIBRARY` Kconfig option. +#. Enable the :kconfig:`CONFIG_RAM_POWER_DOWN_LIBRARY` Kconfig option. Optional configuration ********************** @@ -83,11 +83,11 @@ Device operational channel You can enable one of the following alternative options to select the channel on which the Zigbee device can operate: - * :option:`CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_SINGLE` - Single mode is enabled by default. + * :kconfig:`CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_SINGLE` - Single mode is enabled by default. The default channel is set to 16. - To set a different channel, edit the :option:`CONFIG_ZIGBEE_CHANNEL` option to the desired value. - * :option:`CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_MULTI` - In this mode, you get all the channels enabled by default. - To configure a custom set of channels in the range from 11 to 26, edit the :option:`CONFIG_ZIGBEE_CHANNEL_MASK` option. + To set a different channel, edit the :kconfig:`CONFIG_ZIGBEE_CHANNEL` option to the desired value. + * :kconfig:`CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_MULTI` - In this mode, you get all the channels enabled by default. + To configure a custom set of channels in the range from 11 to 26, edit the :kconfig:`CONFIG_ZIGBEE_CHANNEL_MASK` option. For example, you can set channels 13, 16, and 21. You must have at least one channel enabled with this option. @@ -126,15 +126,15 @@ The ZBOSS stack can be started using one of the following options: The dedicated thread can be configured using the following options: -* :option:`CONFIG_ZBOSS_DEFAULT_THREAD_PRIORITY` - Defines thread priority; set to 3 by default. -* :option:`CONFIG_ZBOSS_DEFAULT_THREAD_STACK_SIZE` - Defines the size of the thread stack; set to 2048 by default. +* :kconfig:`CONFIG_ZBOSS_DEFAULT_THREAD_PRIORITY` - Defines thread priority; set to 3 by default. +* :kconfig:`CONFIG_ZBOSS_DEFAULT_THREAD_STACK_SIZE` - Defines the size of the thread stack; set to 2048 by default. .. _zigbee_ug_logging: Custom logging per module ========================= -Logging is handled with the :option:`CONFIG_LOG` option. +Logging is handled with the :kconfig:`CONFIG_LOG` option. This option enables logging for both the stack and Zephyr's :ref:`zephyr:logging_api` API. .. _zigbee_ug_logging_stack_logs: @@ -145,9 +145,9 @@ Stack logs The stack logs are independent from Zephyr's :ref:`zephyr:logging_api` API. To customize them, use the following options: -* :option:`CONFIG_ZBOSS_ERROR_PRINT_TO_LOG` - Allows the application to log ZBOSS error names; enabled by default. -* :option:`CONFIG_ZBOSS_TRACE_MASK` - Sets the modules from which ZBOSS will log the debug messages with :option:`CONFIG_ZBOSS_TRACE_LOG_LEVEL`; no module is set by default. -* :option:`CONFIG_ZBOSS_TRAF_DUMP` - Enables logging of the received 802.15.4 frames over ZBOSS trace log if :option:`CONFIG_ZBOSS_TRACE_LOG_LEVEL` is set; disabled by default. +* :kconfig:`CONFIG_ZBOSS_ERROR_PRINT_TO_LOG` - Allows the application to log ZBOSS error names; enabled by default. +* :kconfig:`CONFIG_ZBOSS_TRACE_MASK` - Sets the modules from which ZBOSS will log the debug messages with :kconfig:`CONFIG_ZBOSS_TRACE_LOG_LEVEL`; no module is set by default. +* :kconfig:`CONFIG_ZBOSS_TRAF_DUMP` - Enables logging of the received 802.15.4 frames over ZBOSS trace log if :kconfig:`CONFIG_ZBOSS_TRACE_LOG_LEVEL` is set; disabled by default. The stack logs are provided in a binary format (hex dump). @@ -162,12 +162,12 @@ This level is used by default by the application. You can configure custom logger options for each Zigbee and ZBOSS module. To do this, configure the related Kconfig option for one or more modules: -* :option:`CONFIG_ZBOSS_TRACE_LOG_LEVEL` -* :option:`CONFIG_ZBOSS_OSIF_LOG_LEVEL` -* :option:`CONFIG_ZIGBEE_SHELL_LOG_LEVEL` -* :option:`CONFIG_ZIGBEE_APP_UTILS_LOG_LEVEL` -* :option:`CONFIG_ZIGBEE_LOGGER_EP_LOG_LEVEL` -* :option:`CONFIG_ZIGBEE_SCENES_LOG_LEVEL` +* :kconfig:`CONFIG_ZBOSS_TRACE_LOG_LEVEL` +* :kconfig:`CONFIG_ZBOSS_OSIF_LOG_LEVEL` +* :kconfig:`CONFIG_ZIGBEE_SHELL_LOG_LEVEL` +* :kconfig:`CONFIG_ZIGBEE_APP_UTILS_LOG_LEVEL` +* :kconfig:`CONFIG_ZIGBEE_LOGGER_EP_LOG_LEVEL` +* :kconfig:`CONFIG_ZIGBEE_SCENES_LOG_LEVEL` For each of the modules, you can set the following logging options: @@ -177,7 +177,7 @@ For each of the modules, you can set the following logging options: * ``LOG_LEVEL_INF`` - Enables logging for informational messages, errors, and warnings. * ``LOG_LEVEL_DBG`` - Enables logging for debug messages, informational messages, errors, and warnings. -For example, setting :option:`CONFIG_ZBOSS_TRACE_LOG_LEVEL_INF` will enable logging of informational messages, errors, and warnings for the ZBOSS Trace module. +For example, setting :kconfig:`CONFIG_ZBOSS_TRACE_LOG_LEVEL_INF` will enable logging of informational messages, errors, and warnings for the ZBOSS Trace module. Reduced power consumption ========================= diff --git a/doc/nrf/ug_zigbee_configuring_libraries.rst b/doc/nrf/ug_zigbee_configuring_libraries.rst index 7da30202d4b5..a1ead891142f 100644 --- a/doc/nrf/ug_zigbee_configuring_libraries.rst +++ b/doc/nrf/ug_zigbee_configuring_libraries.rst @@ -16,7 +16,7 @@ Configuring ZBOSS OSIF ********************** The Zigbee ZBOSS OSIF layer subsystem acts as the linking layer between the :ref:`nrfxlib:zboss` and the |NCS|. -The layer is automatically enabled when you enable the ZBOSS library with the :option:`CONFIG_ZIGBEE` Kconfig option. +The layer is automatically enabled when you enable the ZBOSS library with the :kconfig:`CONFIG_ZIGBEE` Kconfig option. For more information about the library, see :ref:`lib_zigbee_osif`. @@ -26,9 +26,9 @@ Configuring Zigbee application utilities **************************************** The :ref:`lib_zigbee_application_utilities` library provides a set of components that are ready for use in Zigbee applications. -To enable and use this library, set the :option:`CONFIG_ZIGBEE_APP_UTILS` Kconfig option. +To enable and use this library, set the :kconfig:`CONFIG_ZIGBEE_APP_UTILS` Kconfig option. -For additional logs for this library, configure the :option:`CONFIG_ZIGBEE_APP_UTILS_LOG_LEVEL` Kconfig option. +For additional logs for this library, configure the :kconfig:`CONFIG_ZIGBEE_APP_UTILS_LOG_LEVEL` Kconfig option. See :ref:`zigbee_ug_logging_logger_options` for more information. Default signal handler @@ -56,15 +56,15 @@ Configuring Zigbee FOTA The Zigbee Over The Air Device Firmware Upgrade (:ref:`lib_zigbee_fota`) library provides a mechanism to upgrade the firmware of the device through the Zigbee network. -To enable and configure the library, you must set the :option:`CONFIG_ZIGBEE_FOTA` Kconfig option. +To enable and configure the library, you must set the :kconfig:`CONFIG_ZIGBEE_FOTA` Kconfig option. Other :ref:`Zigbee FOTA Kconfig options ` can be used with default values. Because the Zigbee OTA DFU performs the upgrade using the :ref:`lib_dfu_target` library, the are several non-Zigbee options that must be set to configure the update process: -* :option:`CONFIG_MCUBOOT_IMAGE_VERSION` - This option specifies the current image version. -* :option:`CONFIG_DFU_TARGET_MCUBOOT` - This option enables updates that are performed by MCUboot. -* :option:`CONFIG_IMG_MANAGER` - This option enables the support for managing the DFU image downloaded using MCUboot. -* :option:`CONFIG_IMG_ERASE_PROGRESSIVELY` - This option instructs MCUboot to erase the flash memory progressively. +* :kconfig:`CONFIG_MCUBOOT_IMAGE_VERSION` - This option specifies the current image version. +* :kconfig:`CONFIG_DFU_TARGET_MCUBOOT` - This option enables updates that are performed by MCUboot. +* :kconfig:`CONFIG_IMG_MANAGER` - This option enables the support for managing the DFU image downloaded using MCUboot. +* :kconfig:`CONFIG_IMG_ERASE_PROGRESSIVELY` - This option instructs MCUboot to erase the flash memory progressively. This allows to avoid long wait times at the beginning of the DFU process. Configuring these options and updating the default values (at least updating the ``image_version`` to the application version) allows you to use Zigbee FOTA in the :ref:`zigbee_light_switch_sample` sample. @@ -133,10 +133,10 @@ Options for generating Zigbee FOTA upgrade image By enabling the Zigbee OTA DFU, the west tool will automatically generate the upgrade image. To specify the target device of the generated image, use the following Kconfig options: -* :option:`CONFIG_ZIGBEE_FOTA_COMMENT` - This option allows to specify a human-readable image name. -* :option:`CONFIG_ENABLE_ZIGBEE_FOTA_MIN_HW_VERSION` and :option:`CONFIG_ZIGBEE_FOTA_MIN_HW_VERSION` - These options allow to specify the minimum hardware version of the device that will accept the generated image. +* :kconfig:`CONFIG_ZIGBEE_FOTA_COMMENT` - This option allows to specify a human-readable image name. +* :kconfig:`CONFIG_ENABLE_ZIGBEE_FOTA_MIN_HW_VERSION` and :kconfig:`CONFIG_ZIGBEE_FOTA_MIN_HW_VERSION` - These options allow to specify the minimum hardware version of the device that will accept the generated image. No value makes these options unused. -* :option:`CONFIG_ENABLE_ZIGBEE_FOTA_MAX_HW_VERSION` and :option:`CONFIG_ZIGBEE_FOTA_MAX_HW_VERSION` - These options allow to specify the maximum hardware version of the device that will accept the generated image. +* :kconfig:`CONFIG_ENABLE_ZIGBEE_FOTA_MAX_HW_VERSION` and :kconfig:`CONFIG_ZIGBEE_FOTA_MAX_HW_VERSION` - These options allow to specify the maximum hardware version of the device that will accept the generated image. No value makes these options unused. The manufacturer ID, image type and version of the generated image are obtained from the application settings. @@ -152,8 +152,8 @@ The Zigbee endpoint logger library provides an endpoint handler for parsing and To enable the endpoint logger library in your application, complete the following steps: -1. Enable the library by setting the :option:`CONFIG_ZIGBEE_LOGGER_EP` Kconfig option. -2. Define the logging level for the library by setting the :option:`CONFIG_ZIGBEE_LOGGER_EP_LOG_LEVEL` Kconfig option. +1. Enable the library by setting the :kconfig:`CONFIG_ZIGBEE_LOGGER_EP` Kconfig option. +2. Define the logging level for the library by setting the :kconfig:`CONFIG_ZIGBEE_LOGGER_EP_LOG_LEVEL` Kconfig option. See :ref:`zigbee_ug_logging_logger_options` for more information. 3. Include the required header file :file:`include/zigbee/zigbee_logger_eprxzcl.h` into your project. 4. Register :c:func:`zigbee_logger_eprxzcl_ep_handler` as handler for the given *your_ep_number* endpoint using :c:macro:`ZB_AF_SET_ENDPOINT_HANDLER`, after the device context is registered with :c:macro:`ZB_AF_REGISTER_DEVICE_CTX`, but before starting the Zigbee stack: @@ -167,7 +167,7 @@ To enable the endpoint logger library in your application, complete the followin For applications that implement multiple handlers, :c:func:`zigbee_logger_eprxzcl_ep_handler` can be registered as handler for each endpoint. .. note:: - If :ref:`lib_zigbee_shell` is already enabled and configured for the given endpoint, set the :option:`CONFIG_ZIGBEE_SHELL_DEBUG_CMD` Kconfig option to enable the endpoint logger instead of registering a handler. + If :ref:`lib_zigbee_shell` is already enabled and configured for the given endpoint, set the :kconfig:`CONFIG_ZIGBEE_SHELL_DEBUG_CMD` Kconfig option to enable the endpoint logger instead of registering a handler. This is because the Zigbee shell library registers its own handler for the endpoint. For more information about the library, see :ref:`lib_zigbee_logger_endpoint`. @@ -179,7 +179,7 @@ Configuring Zigbee ZCL scene helper The Zigbee ZCL scene helper library provides a set of functions that implement the callbacks required by the ZCL scene cluster in the application. -To enable the Zigbee ZCL scene helper library, set the :option:`CONFIG_ZIGBEE_SCENES` Kconfig option. +To enable the Zigbee ZCL scene helper library, set the :kconfig:`CONFIG_ZIGBEE_SCENES` Kconfig option. Because the library uses Zephyr's :ref:`settings_api` subsystem, the application must call the following functions for the library to work correctly: @@ -201,15 +201,15 @@ The Zigbee shell library implements a set of :ref:`Zigbee shell commands timeout >= cfg->interval) { + if ((drv_data->cfg.nav_mode != GPS_NAV_MODE_SINGLE_FIX) && + (cfg->timeout >= cfg->interval)) { LOG_ERR("The timeout must be less than the interval"); return -EINVAL; } diff --git a/drivers/gps/nrf9160_gps/Kconfig b/drivers/gps/nrf9160_gps/Kconfig index 16b8ef044371..521aa8128350 100644 --- a/drivers/gps/nrf9160_gps/Kconfig +++ b/drivers/gps/nrf9160_gps/Kconfig @@ -72,27 +72,27 @@ endchoice config NRF9160_GPS_SET_MAGPIO bool "Let the driver set MAGPIO configuration" - default y if BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS + default y if BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS if NRF9160_GPS_SET_MAGPIO config NRF9160_GPS_MAGPIO_STRING string "MAGPIO string" - default "AT\%XMAGPIO=1,0,0,1,1,1565,1586" if BOARD_NRF9160DK_NRF9160NS - default "AT\%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586" if BOARD_THINGY91_NRF9160NS + default "AT\%XMAGPIO=1,0,0,1,1,1565,1586" if BOARD_NRF9160DK_NRF9160_NS + default "AT\%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586" if BOARD_THINGY91_NRF9160_NS endif # NRF9160_GPS_SET_MAGPIO config NRF9160_GPS_SET_COEX0 bool "Let the driver set COEX0 configuration" - default y if BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS + default y if BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS if NRF9160_GPS_SET_COEX0 config NRF9160_GPS_COEX0_STRING string "COEX0 string" - default "AT\%XCOEX0=1,1,1565,1586" if (BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS) && NRF9160_GPS_ANTENNA_ONBOARD - default "AT\%XCOEX0" if (BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS) && NRF9160_GPS_ANTENNA_EXTERNAL + default "AT\%XCOEX0=1,1,1565,1586" if (BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS) && NRF9160_GPS_ANTENNA_ONBOARD + default "AT\%XCOEX0" if (BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS) && NRF9160_GPS_ANTENNA_EXTERNAL endif # NRF9160_GPS_SET_COEX0 diff --git a/ext/curl/include/curl/easy.h b/ext/curl/include/curl/easy.h index 9aef1339620a..0a1813f9f09d 100644 --- a/ext/curl/include/curl/easy.h +++ b/ext/curl/include/curl/easy.h @@ -38,6 +38,12 @@ struct curl_blob { CURL_EXTERN CURL *curl_easy_init(void); CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); + +#if defined(CONFIG_NRF_CURL_INTEGRATION) +CURL_EXTERN void curl_easy_nrf_set_kill_signal( + CURL *curl, struct k_poll_signal *kill_signal); +#endif + CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); CURL_EXTERN void curl_easy_cleanup(CURL *curl); diff --git a/ext/curl/include/curl/nrf_curl.h b/ext/curl/include/curl/nrf_curl.h index 0db6e82bf451..248ffc6de4da 100644 --- a/ext/curl/include/curl/nrf_curl.h +++ b/ext/curl/include/curl/nrf_curl.h @@ -6,5 +6,5 @@ #ifndef NRF_CURL_H #define NRF_CURL_H -int curl_tool_main(int argc, char *argv[]); +int curl_tool_main(int argc, char *argv[], struct k_poll_signal *kill_signal); #endif diff --git a/ext/curl/lib/easy.c b/ext/curl/lib/easy.c index 068a277e1560..05e5e3339725 100644 --- a/ext/curl/lib/easy.c +++ b/ext/curl/lib/easy.c @@ -586,6 +586,20 @@ static CURLcode easy_transfer(struct Curl_multi *multi) while(!done && !mcode) { int still_running = 0; +#if defined(CONFIG_NRF_IPERF3_INTEGRATION) + if (multi->kill_signal != NULL) { + int set, res; + + k_poll_signal_check(multi->kill_signal, &set, &res); + if (set) { + k_poll_signal_reset(multi->kill_signal); + printk("\nKill signal received - exiting\n"); + result = CURLE_ABORTED_BY_CALLBACK; + break; + } + } +#endif + mcode = curl_multi_poll(multi, NULL, 0, 1000, NULL); if(!mcode) @@ -678,6 +692,10 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events) sigpipe_ignore(data, &pipe_st); +#if defined(CONFIG_NRF_CURL_INTEGRATION) + multi->kill_signal = data->kill_signal; +#endif + /* run the transfer */ result = events ? easy_events(multi) : easy_transfer(multi); @@ -729,6 +747,17 @@ void curl_easy_cleanup(struct Curl_easy *data) sigpipe_restore(&pipe_st); } +#if defined(CONFIG_NRF_CURL_INTEGRATION) +void curl_easy_nrf_set_kill_signal(struct Curl_easy *data, + struct k_poll_signal *kill_signal) +{ + if (!data) + return; + + data->kill_signal = kill_signal; +} +#endif + /* * curl_easy_getinfo() is an external interface that allows an app to retrieve * information from a performed transfer and similar. diff --git a/ext/curl/lib/multihandle.h b/ext/curl/lib/multihandle.h index c70a1ce09ada..9193b4d4b819 100644 --- a/ext/curl/lib/multihandle.h +++ b/ext/curl/lib/multihandle.h @@ -151,6 +151,10 @@ struct Curl_multi { bool recheckstate; /* see Curl_multi_connchanged */ bool in_callback; /* true while executing a callback */ bool ipv6_works; + +#if defined(CONFIG_NRF_CURL_INTEGRATION) +struct k_poll_signal *kill_signal; +#endif }; #endif /* HEADER_CURL_MULTIHANDLE_H */ diff --git a/ext/curl/lib/urldata.h b/ext/curl/lib/urldata.h index 6b7ae41a2463..9533f9093069 100644 --- a/ext/curl/lib/urldata.h +++ b/ext/curl/lib/urldata.h @@ -1920,6 +1920,9 @@ struct Curl_easy { iconv_t utf8_cd; /* for translating to UTF8 */ #endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */ unsigned int magic; /* set to a CURLEASY_MAGIC_NUMBER */ +#if defined(CONFIG_NRF_CURL_INTEGRATION) +struct k_poll_signal *kill_signal; +#endif }; #define LIBCURL_NAME "libcurl" diff --git a/ext/curl/tool/tool_cfgable.h b/ext/curl/tool/tool_cfgable.h index a422113fd297..d63051fc2d7e 100644 --- a/ext/curl/tool/tool_cfgable.h +++ b/ext/curl/tool/tool_cfgable.h @@ -319,6 +319,7 @@ struct GlobalConfig { char *help_category; /* The help category, if set */ #if defined(CONFIG_NRF_CURL_INTEGRATION) bool curr_mdm_traces; + struct k_poll_signal *kill_signal; #endif struct OperationConfig *first; struct OperationConfig *current; diff --git a/ext/curl/tool/tool_main.c b/ext/curl/tool/tool_main.c index 1a764ac69e08..704a09bf9644 100644 --- a/ext/curl/tool/tool_main.c +++ b/ext/curl/tool/tool_main.c @@ -301,7 +301,7 @@ static void restore_terminal(void) int wmain(int argc, wchar_t *argv[]) #else #if defined(CONFIG_NRF_CURL_INTEGRATION) -int curl_tool_main(int argc, char *argv[]) +int curl_tool_main(int argc, char *argv[], struct k_poll_signal *kill_signal) #endif #endif { @@ -345,6 +345,10 @@ int curl_tool_main(int argc, char *argv[]) this point */ result = main_init(&global); if(!result) { +#if defined(CONFIG_NRF_CURL_INTEGRATION) + global.kill_signal = kill_signal; +#endif + /* Start our curl operation */ result = operate(&global, argc, argv); diff --git a/ext/curl/tool/tool_operate.c b/ext/curl/tool/tool_operate.c index 83cc9eb63a7d..51f4e55f5e42 100644 --- a/ext/curl/tool/tool_operate.c +++ b/ext/curl/tool/tool_operate.c @@ -343,6 +343,11 @@ static CURLcode pre_transfer(struct GlobalConfig *global, } per->input.fd = per->infd; } + +#if defined(CONFIG_NRF_CURL_INTEGRATION) + curl_easy_nrf_set_kill_signal(per->curl, global->kill_signal); +#endif + return result; } diff --git a/include/bl_storage.h b/include/bl_storage.h index 15602e059598..0d7f51dc202f 100644 --- a/include/bl_storage.h +++ b/include/bl_storage.h @@ -102,7 +102,7 @@ uint16_t get_monotonic_counter(void); * @retval -EINVAL @p new_counter is invalid (must be larger than current * counter, and cannot be 0xFFFF). * @retval -ENOMEM There are no more free counter slots (see - * @option{CONFIG_SB_NUM_VER_COUNTER_SLOTS}). + * @kconfig{CONFIG_SB_NUM_VER_COUNTER_SLOTS}). */ int set_monotonic_counter(uint16_t new_counter); diff --git a/include/bl_validation.h b/include/bl_validation.h index 699ff295720b..84b5092b3c3f 100644 --- a/include/bl_validation.h +++ b/include/bl_validation.h @@ -40,7 +40,7 @@ bool (*bl_validate_firmware_t)(uint32_t fw_dst_address, uint32_t fw_src_address) /** Whether bl_validate_firmware() is available. * * @details This is only relevant when - * @option{CONFIG_BL_VALIDATE_FW_EXT_API_OPTIONAL} is set. + * @kconfig{CONFIG_BL_VALIDATE_FW_EXT_API_OPTIONAL} is set. * * @retval true bl_validate_firmware() can be called and should work correctly. * @retval false bl_validate_firmware() is unavailable and will always return diff --git a/include/bluetooth/mesh/gen_prop_srv.h b/include/bluetooth/mesh/gen_prop_srv.h index 549c1bb465d1..9b5c03eaad14 100644 --- a/include/bluetooth/mesh/gen_prop_srv.h +++ b/include/bluetooth/mesh/gen_prop_srv.h @@ -30,7 +30,7 @@ struct bt_mesh_prop_srv; * @param[in] _properties Array of properties supported by the server. * @param[in] _property_count Number of properties supported by the server. * Cannot be larger than - * @option{CONFIG_BT_MESH_PROP_MAXCOUNT}. + * @kconfig{CONFIG_BT_MESH_PROP_MAXCOUNT}. * @param[in] _get Getter handler for property values. @sa * bt_mesh_prop_srv::get. * @param[in] _set Setter handler for property values. @sa diff --git a/include/bluetooth/mesh/light_ctrl.h b/include/bluetooth/mesh/light_ctrl.h index 2f603fd846d0..9203453061c7 100644 --- a/include/bluetooth/mesh/light_ctrl.h +++ b/include/bluetooth/mesh/light_ctrl.h @@ -202,6 +202,19 @@ enum bt_mesh_light_ctrl_coeff { #define BT_MESH_LIGHT_CTRL_OP_PROP_SET_UNACK BT_MESH_MODEL_OP_1(0x63) #define BT_MESH_LIGHT_CTRL_OP_PROP_STATUS BT_MESH_MODEL_OP_1(0x64) +#define BT_MESH_LIGHT_CTRL_MSG_LEN_MODE_GET 0 +#define BT_MESH_LIGHT_CTRL_MSG_LEN_MODE_SET 1 +#define BT_MESH_LIGHT_CTRL_MSG_LEN_MODE_STATUS 1 +#define BT_MESH_LIGHT_CTRL_MSG_LEN_OM_GET 0 +#define BT_MESH_LIGHT_CTRL_MSG_LEN_OM_SET 1 +#define BT_MESH_LIGHT_CTRL_MSG_LEN_OM_STATUS 1 +#define BT_MESH_LIGHT_CTRL_MSG_LEN_LIGHT_ONOFF_GET 0 +#define BT_MESH_LIGHT_CTRL_MSG_MINLEN_LIGHT_ONOFF_SET 2 +#define BT_MESH_LIGHT_CTRL_MSG_MINLEN_LIGHT_ONOFF_STATUS 1 +#define BT_MESH_LIGHT_CTRL_MSG_LEN_PROP_GET 2 +#define BT_MESH_LIGHT_CTRL_MSG_MINLEN_PROP_SET 2 +#define BT_MESH_LIGHT_CTRL_MSG_MINLEN_PROP_STATUS 2 + #if CONFIG_BT_MESH_LIGHT_CTRL_SRV_REG #define BT_MESH_LIGHT_CTRL_SRV_REG_CFG_INIT \ { \ diff --git a/include/bluetooth/mesh/light_ctrl_srv.h b/include/bluetooth/mesh/light_ctrl_srv.h index 651d198065c9..6da9527a2930 100644 --- a/include/bluetooth/mesh/light_ctrl_srv.h +++ b/include/bluetooth/mesh/light_ctrl_srv.h @@ -208,7 +208,7 @@ int bt_mesh_light_ctrl_srv_on(struct bt_mesh_light_ctrl_srv *srv); * state). Calling this function temporarily disables occupancy sensor * triggering (referred to as "manual mode" in the documentation). The server * will remain in manual mode until the manual mode timer expires, see - * @option{CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_MANUAL}. + * @kconfig{CONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_MANUAL}. * * @param[in] srv Light Lightness Control Server instance. * diff --git a/include/bluetooth/mesh/light_hsl_srv.h b/include/bluetooth/mesh/light_hsl_srv.h index 5b7dfc62e197..561779d53821 100644 --- a/include/bluetooth/mesh/light_hsl_srv.h +++ b/include/bluetooth/mesh/light_hsl_srv.h @@ -30,16 +30,15 @@ struct bt_mesh_light_hsl_srv; * * @brief Initialization parameters for a @ref bt_mesh_light_hsl_srv instance. * + * @param[in] _lightness_srv Pointer to the Lightness Server instance. * @param[in] _hue_handlers Hue Server model handlers. * @param[in] _sat_handlers Saturation Server model handlers. - * @param[in] _light_handlers Lightness Server model handlers. */ -#define BT_MESH_LIGHT_HSL_SRV_INIT(_hue_handlers, _sat_handlers, \ - _light_handlers) \ - { \ - .hue = BT_MESH_LIGHT_HUE_SRV_INIT(_hue_handlers), \ - .sat = BT_MESH_LIGHT_SAT_SRV_INIT(_sat_handlers), \ - .lightness = BT_MESH_LIGHTNESS_SRV_INIT(_light_handlers), \ +#define BT_MESH_LIGHT_HSL_SRV_INIT(_lightness_srv, _hue_handlers, _sat_handlers) \ + { \ + .lightness = _lightness_srv, \ + .hue = BT_MESH_LIGHT_HUE_SRV_INIT(_hue_handlers), \ + .sat = BT_MESH_LIGHT_SAT_SRV_INIT(_sat_handlers), \ } /** @def BT_MESH_MODEL_LIGHT_HSL_SRV @@ -49,7 +48,6 @@ struct bt_mesh_light_hsl_srv; * @param[in] _srv Pointer to a @ref bt_mesh_light_hsl_srv instance. */ #define BT_MESH_MODEL_LIGHT_HSL_SRV(_srv) \ - BT_MESH_MODEL_LIGHTNESS_SRV(&(_srv)->lightness), \ BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_LIGHT_HSL_SRV, \ _bt_mesh_light_hsl_srv_op, &(_srv)->pub, \ BT_MESH_MODEL_USER_DATA(struct bt_mesh_light_hsl_srv, \ @@ -69,8 +67,8 @@ struct bt_mesh_light_hsl_srv { struct bt_mesh_light_hue_srv hue; /** Light Saturation Server instance. */ struct bt_mesh_light_sat_srv sat; - /** Lightness Server instance. */ - struct bt_mesh_lightness_srv lightness; + /** Pointer to Lightness Server instance. */ + struct bt_mesh_lightness_srv *lightness; /** Model entry. */ struct bt_mesh_model *model; diff --git a/include/bluetooth/mesh/light_xyl_srv.h b/include/bluetooth/mesh/light_xyl_srv.h index 00c79fef456f..156a7a33fef7 100644 --- a/include/bluetooth/mesh/light_xyl_srv.h +++ b/include/bluetooth/mesh/light_xyl_srv.h @@ -28,14 +28,13 @@ struct bt_mesh_light_xyl_srv; * * @brief initialization parameters for a @ref bt_mesh_light_xyl_srv instance. * - * @param[in] _lightness_handlers Lightness server callbacks. + * @param[in] _lightness_srv Pointer to Lightness server instance. * @param[in] _light_xyl_handlers Light xyL server callbacks. */ -#define BT_MESH_LIGHT_XYL_SRV_INIT(_lightness_handlers, _light_xyl_handlers) \ +#define BT_MESH_LIGHT_XYL_SRV_INIT(_lightness_srv, _light_xyl_handlers) \ { \ .handlers = _light_xyl_handlers, \ - .lightness_srv = \ - BT_MESH_LIGHTNESS_SRV_INIT(_lightness_handlers), \ + .lightness_srv = _lightness_srv, \ .range = { \ .min = { .x = 0, .y = 0 }, \ .max = { .x = UINT16_MAX, .y = UINT16_MAX } \ @@ -49,7 +48,6 @@ struct bt_mesh_light_xyl_srv; * @param[in] _srv Pointer to a @ref bt_mesh_light_xyl_srv instance. */ #define BT_MESH_MODEL_LIGHT_XYL_SRV(_srv) \ - BT_MESH_MODEL_LIGHTNESS_SRV(&(_srv)->lightness_srv), \ BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_LIGHT_XYL_SRV, \ _bt_mesh_light_xyl_srv_op, &(_srv)->pub, \ BT_MESH_MODEL_USER_DATA( \ @@ -145,8 +143,8 @@ struct bt_mesh_light_xyl_srv_handlers { struct bt_mesh_light_xyl_srv { /** Model entry. */ struct bt_mesh_model *model; - /** Lightness Server instance. */ - struct bt_mesh_lightness_srv lightness_srv; + /** Pointer to Lightness Server instance. */ + struct bt_mesh_lightness_srv *lightness_srv; /** Publish parameters. */ struct bt_mesh_model_pub pub; /* Publication buffer */ diff --git a/include/bluetooth/mesh/models.rst b/include/bluetooth/mesh/models.rst deleted file mode 100644 index 288cc8f3516a..000000000000 --- a/include/bluetooth/mesh/models.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. _bt_mesh_models: - -Bluetooth mesh models -##################### - -Nordic Semiconductor provides a variety of model implementations from the `Bluetooth mesh model specification`_ and their API documentation, as well as vendor-specific models. - -For more information about these and other models, see also `Bluetooth mesh model overview`_. - -.. toctree:: - :maxdepth: 1 - :caption: Subpages: - :glob: - - ../../../include/bluetooth/mesh/gen_onoff.rst - ../../../include/bluetooth/mesh/gen_lvl.rst - ../../../include/bluetooth/mesh/gen_dtt.rst - ../../../include/bluetooth/mesh/gen_ponoff.rst - ../../../include/bluetooth/mesh/gen_plvl.rst - ../../../include/bluetooth/mesh/gen_battery.rst - ../../../include/bluetooth/mesh/gen_loc.rst - ../../../include/bluetooth/mesh/gen_prop.rst - ../../../include/bluetooth/mesh/lightness.rst - ../../../include/bluetooth/mesh/light_ctrl.rst - ../../../include/bluetooth/mesh/light_ctl.rst - ../../../include/bluetooth/mesh/light_xyl.rst - ../../../include/bluetooth/mesh/light_hsl.rst - ../../../include/bluetooth/mesh/sensor_models.rst - ../../../include/bluetooth/mesh/time.rst - ../../../include/bluetooth/mesh/scene.rst - ../../../include/bluetooth/mesh/scheduler.rst - ../../../include/bluetooth/mesh/vnd/silvair_enocean_srv.rst diff --git a/include/bluetooth/mesh/sensor.h b/include/bluetooth/mesh/sensor.h index e420e55a557c..65c9d68f25e9 100644 --- a/include/bluetooth/mesh/sensor.h +++ b/include/bluetooth/mesh/sensor.h @@ -419,7 +419,7 @@ bool bt_mesh_sensor_delta_threshold(const struct bt_mesh_sensor *sensor, * * Only known sensor types from @ref bt_mesh_sensor_types will be available. * Sensor types can be made known to the sensor module by enabling - * @option{CONFIG_BT_MESH_SENSOR_ALL_TYPES} or by referencing them in the + * @kconfig{CONFIG_BT_MESH_SENSOR_ALL_TYPES} or by referencing them in the * application. * * @param[in] id A Device Property ID. diff --git a/include/bluetooth/mesh/sensor_srv.h b/include/bluetooth/mesh/sensor_srv.h index e4cf0525ad72..50dc230f6baa 100644 --- a/include/bluetooth/mesh/sensor_srv.h +++ b/include/bluetooth/mesh/sensor_srv.h @@ -30,7 +30,7 @@ struct bt_mesh_sensor_srv; * * @param[in] _sensors Array of pointers to sensors owned by this server. * @param[in] _count Number of sensors in the array. Can at most be - * @option{CONFIG_BT_MESH_SENSOR_SRV_SENSORS_MAX}. + * @kconfig{CONFIG_BT_MESH_SENSOR_SRV_SENSORS_MAX}. */ #define BT_MESH_SENSOR_SRV_INIT(_sensors, _count) \ { \ diff --git a/include/bluetooth/services/gadgets_profile.h b/include/bluetooth/services/gadgets_profile.h index 404636ea7eeb..8fec5dbf793a 100644 --- a/include/bluetooth/services/gadgets_profile.h +++ b/include/bluetooth/services/gadgets_profile.h @@ -202,7 +202,7 @@ void bt_gadgets_profile_mtu_exchanged(struct bt_conn *conn); * with a single string as the payload. * The string must be valid JSON for the cloud side to accept it. * The namespace for this custom event is given by - * @option{CONFIG_BT_ALEXA_GADGETS_CAPABILITY_CUSTOM_NAMESPACE}. + * @kconfig{CONFIG_BT_ALEXA_GADGETS_CAPABILITY_CUSTOM_NAMESPACE}. * * @param[in] name Null-terminated event name string. * @param[in] json Null-terminated JSON string. diff --git a/include/bluetooth/services/hids.h b/include/bluetooth/services/hids.h index a0276f81d776..d67a785909c3 100644 --- a/include/bluetooth/services/hids.h +++ b/include/bluetooth/services/hids.h @@ -65,8 +65,9 @@ extern "C" { * the link context size for HIDS instance. */ #define _BT_HIDS_CONN_CTX_SIZE_CALC(...) \ - (FOR_EACH(GET_ARG1, (+), __VA_ARGS__) + \ + (FOR_EACH(_BT_HIDS_GET_ARG1, (+), __VA_ARGS__) + \ sizeof(struct bt_hids_conn_data)) +#define _BT_HIDS_GET_ARG1(...) GET_ARG_N(1, __VA_ARGS__) /** @brief Possible values for the Protocol Mode Characteristic value. */ diff --git a/include/drivers/gps.h b/include/drivers/gps.h index 424c3cc1ca88..6513009ad6fd 100644 --- a/include/drivers/gps.h +++ b/include/drivers/gps.h @@ -27,7 +27,6 @@ extern "C" { #define GPS_NMEA_SENTENCE_MAX_LENGTH 83 #define GPS_PVT_MAX_SV_COUNT 12 -#define GPS_SOCKET_NOT_PROVIDED 0 struct gps_nmea { char buf[GPS_NMEA_SENTENCE_MAX_LENGTH]; @@ -453,30 +452,6 @@ static inline int gps_deinit(const struct device *dev) return api->deinit(dev); } -/** - * @brief Function to send a request for A-GPS data to the configured A-GPS - * data source. See the A-GPS Library Kconfig documentation for alternatives. - * - * @param request Assistance data to request from A-GPS service. - * @param socket GPS socket to which assistance data will be written - * when it's received from the selected A-GPS service. - * If zero the GPS driver will be used to write the data instead - * of directly to the provided socket. - * - * @return Zero on success or (negative) error code otherwise. - */ -int gps_agps_request_send(struct gps_agps_request request, int socket); - -/** - * @brief Processes A-GPS data. - * - * @param buf Pointer to A-GPS data. - * @param len Buffer size of data to be processed. - * - * @return Zero on success or (negative) error code otherwise. - */ -int gps_process_agps_data(const uint8_t *buf, size_t len); - /** @} */ #ifdef __cplusplus diff --git a/include/esb.h b/include/esb.h index 789672f38bac..565165e23442 100644 --- a/include/esb.h +++ b/include/esb.h @@ -386,7 +386,7 @@ int esb_set_base_address_1(const uint8_t *addr); * * @param[in] prefixes Prefixes for each pipe. * @param[in] num_pipes Number of pipes. Must be less than or equal to - * @option{CONFIG_ESB_PIPE_COUNT}. + * @kconfig{CONFIG_ESB_PIPE_COUNT}. * * @retval 0 If successful. * Otherwise, a (negative) error code is returned. @@ -397,7 +397,7 @@ int esb_set_prefixes(const uint8_t *prefixes, uint8_t num_pipes); * * The @p enable_mask parameter must contain the same number of pipes as has * been configured with @ref esb_set_prefixes. This number may not be - * greater than the number defined by @option{CONFIG_ESB_PIPE_COUNT} + * greater than the number defined by @kconfig{CONFIG_ESB_PIPE_COUNT} * * @param enable_mask Bitfield mask to enable or disable pipes. * Setting a bit to 0 disables the pipe. diff --git a/include/fw_info.h b/include/fw_info.h index 0b8a8c83fdf3..939288240291 100644 --- a/include/fw_info.h +++ b/include/fw_info.h @@ -383,7 +383,7 @@ typedef bool (*fw_info_ext_api_provide_t)(const struct fw_info *fwinfo, * * @details Invalidation happens by setting the @c valid value to INVALID_VAL. * - * @note This function needs to have @option{CONFIG_NRFX_NVMC} enabled. + * @note This function needs to have @kconfig{CONFIG_NRFX_NVMC} enabled. * * @param[in] fw_info The info structure to invalidate. * This memory will be modified directly in flash. diff --git a/include/modem/agps.h b/include/modem/agps.h new file mode 100644 index 000000000000..a0a02a0248c1 --- /dev/null +++ b/include/modem/agps.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/** + * @file agps.h + * @brief Public APIs for the A-GPS library. + * @defgroup agps A-GPS library + * @{ + */ + +#ifndef AGPS_H_ +#define AGPS_H_ + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define AGPS_SOCKET_NOT_PROVIDED 0 + +/** + * @brief Function to send a request for A-GPS data to the configured A-GPS data source. See the + * A-GPS library Kconfig documentation for alternatives. + * + * @param request Assistance data to request from the A-GPS service. + * @param socket GNSS socket to which assistance data will be written when it's received from the + * selected A-GPS service. If socket argument is set to AGPS_SOCKET_NOT_PROVIDED, + * the data will be written using the GPS driver or GNSS API. + * + * @return Zero on success or (negative) error code otherwise. + */ +int agps_request_send(struct nrf_modem_gnss_agps_data_frame request, int socket); + +/** + * @brief Processes A-GPS data from the cloud. + * + * @param buf Pointer to A-GPS data from the cloud. + * @param len Buffer size of data to be processed. + * + * @return Zero on success or (negative) error code otherwise. + */ +int agps_cloud_data_process(const uint8_t *buf, size_t len); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AGPS_H_ */ diff --git a/include/mpsl/mpsl_cx_config_thread.h b/include/mpsl/mpsl_cx_config_thread.h new file mode 100644 index 000000000000..297debd98d3f --- /dev/null +++ b/include/mpsl/mpsl_cx_config_thread.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/** + * @file mpsl_cx_config_thread.h + * + * @defgroup mpsl_cx_thread MPSL Coexistence configuration according to Thread Radio Coexistence + * @ingroup mpsl_cx + * + * @{ + */ + +#ifndef MPSL_CX_CONFIG_THREAD_H__ +#define MPSL_CX_CONFIG_THREAD_H__ + +#include +#include + +/** @brief Configuration parameters for the Thread Radio Coexistence variant. */ +struct mpsl_cx_thread_interface_config { + /** GPIO pin number of REQUEST pin. */ + uint8_t request_pin; + /** GPIO pin number of PRIORITY pin. */ + uint8_t priority_pin; + /** GPIO pin number of GRANTED pin. */ + uint8_t granted_pin; +}; + +/** @brief Configures the Thread Radio Coexistence interface. + * + * This function sets device interface parameters for the Coexistence module. + * The module is used to control PTA interface through the given pins and resources. + * + * @param[in] config Pointer to the interface parameters. + * + * @retval 0 Coexistence interface successfully configured. + * @retval -NRF_EPERM Coexistence interface is not available. + * + */ +int32_t mpsl_cx_thread_interface_config_set( + struct mpsl_cx_thread_interface_config const * const config); + +#endif // MPSL_CX_CONFIG_THREAD_H__ + +/**@} */ diff --git a/include/net/aws_iot.h b/include/net/aws_iot.h index cb0f09940384..5f40c693b73b 100644 --- a/include/net/aws_iot.h +++ b/include/net/aws_iot.h @@ -163,7 +163,7 @@ struct aws_iot_config { /** Socket for AWS IoT broker connection */ int socket; /** Client id for AWS IoT broker connection, used when - * @option{CONFIG_AWS_IOT_CLIENT_ID_APP} is set. If not set an internal + * @kconfig{CONFIG_AWS_IOT_CLIENT_ID_APP} is set. If not set an internal * configurable static client id is used. */ char *client_id; diff --git a/include/net/azure_iot_hub.h b/include/net/azure_iot_hub.h index 146a361a5945..a33dc4bce608 100644 --- a/include/net/azure_iot_hub.h +++ b/include/net/azure_iot_hub.h @@ -230,7 +230,7 @@ struct azure_iot_hub_config { * successfully for subsequent calls to this library to succeed. * * @param[in] config Pointer to struct containing connection parameters. Can be - * NULL if @option{CONFIG_AZURE_IOT_HUB_DEVICE_ID} is set. + * NULL if @kconfig{CONFIG_AZURE_IOT_HUB_DEVICE_ID} is set. * @param[in] event_handler Pointer to event handler function. * * @retval 0 If successful. Otherwise, a (negative) error code is returned. diff --git a/include/net/download_client.h b/include/net/download_client.h index 841272ed1f35..2f99a0f8b9c4 100644 --- a/include/net/download_client.h +++ b/include/net/download_client.h @@ -207,8 +207,8 @@ int download_client_connect(struct download_client *client, const char *host, * @brief Download a file. * * The download is carried out in fragments of up to - * @option{CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE} bytes for HTTP, or - * @option{CONFIG_DOWNLOAD_CLIENT_COAP_BLOCK_SIZE} bytes for CoAP, + * @kconfig{CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE} bytes for HTTP, or + * @kconfig{CONFIG_DOWNLOAD_CLIENT_COAP_BLOCK_SIZE} bytes for CoAP, * which are delivered to the application * via @ref DOWNLOAD_CLIENT_EVT_FRAGMENT events. * diff --git a/include/net/fota_download.h b/include/net/fota_download.h index 77ae227e6f8c..d4f2ee9e8e57 100644 --- a/include/net/fota_download.h +++ b/include/net/fota_download.h @@ -101,7 +101,7 @@ int fota_download_init(fota_download_callback_t client_callback); * @param sec_tag Security tag you want to use with HTTPS set to -1 to Disable. * @param apn Access Point Name to use or NULL to use the default APN. * @param fragment_size Fragment size to be used for the download. - * If 0, @option{CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE} is used. + * If 0, @kconfig{CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE} is used. * * @retval 0 If download has started successfully. * @retval -EALREADY If download is already ongoing. @@ -122,7 +122,7 @@ int fota_download_start(const char *host, const char *file, int sec_tag, * @param sec_tag Security tag you want to use with HTTPS set to -1 to Disable. * @param apn Access Point Name to use or NULL to use the default APN. * @param fragment_size Fragment size to be used for the download. - * If 0, @option{CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE} is used. + * If 0, @kconfig{CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE} is used. * @param expected_type Type of firmware file to be downloaded and installed. * * @retval 0 If download has started successfully. diff --git a/include/nfc/ndef/uri_msg.h b/include/nfc/ndef/uri_msg.h index 31eb1f1fbfbd..67e1cef8da11 100644 --- a/include/nfc/ndef/uri_msg.h +++ b/include/nfc/ndef/uri_msg.h @@ -47,7 +47,7 @@ extern "C" { */ int nfc_ndef_uri_msg_encode(enum nfc_ndef_uri_rec_id uri_id_code, uint8_t const *const uri_data, - uint8_t uri_data_len, + uint16_t uri_data_len, uint8_t *buf, uint32_t *len); diff --git a/include/nfc/ndef/uri_rec.h b/include/nfc/ndef/uri_rec.h index 0b565444c982..a3d39cbb38e8 100644 --- a/include/nfc/ndef/uri_rec.h +++ b/include/nfc/ndef/uri_rec.h @@ -80,7 +80,7 @@ struct nfc_ndef_uri_rec_payload { /** Pointer to a URI string. */ uint8_t const *uri_data; /** Length of the URI string. */ - uint8_t uri_data_len; + uint16_t uri_data_len; }; /** diff --git a/lib/agps/Kconfig b/lib/agps/Kconfig index 10a8162caca6..bdd5e9a769b3 100644 --- a/lib/agps/Kconfig +++ b/lib/agps/Kconfig @@ -6,6 +6,7 @@ config AGPS bool "A-GPS library" + depends on NRF_MODEM_LIB help A library to simplify switching between A-GPS data sources. @@ -28,7 +29,6 @@ config AGPS_SRC_NRF_CLOUD config AGPS_SRC_SUPL bool "Use SUPL as data source" - depends on NRF_MODEM_LIB imply SUPL_CLIENT_LIB help Note that a request for A-GPS data using SUPL service will block until diff --git a/lib/agps/agps.c b/lib/agps/agps.c index 84f11d712b45..abf31992bf60 100644 --- a/lib/agps/agps.c +++ b/lib/agps/agps.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -22,62 +23,63 @@ LOG_MODULE_REGISTER(agps, CONFIG_AGPS_LOG_LEVEL); #if defined(CONFIG_AGPS_SRC_SUPL) -/* Number of DNS lookup attempts */ -#define DNS_ATTEMPT_COUNT 3 - static const struct device *gps_dev; -static int gnss_fd; -static int supl_fd; +static int gnss_fd = -1; +static int supl_fd = -1; #endif /* CONFIG_AGPS_SRC_SUPL */ -static enum gps_agps_type type_lookup_socket2gps[] = { - [NRF_GNSS_AGPS_UTC_PARAMETERS] = GPS_AGPS_UTC_PARAMETERS, - [NRF_GNSS_AGPS_EPHEMERIDES] = GPS_AGPS_EPHEMERIDES, - [NRF_GNSS_AGPS_ALMANAC] = GPS_AGPS_ALMANAC, - [NRF_GNSS_AGPS_KLOBUCHAR_IONOSPHERIC_CORRECTION] - = GPS_AGPS_KLOBUCHAR_CORRECTION, - [NRF_GNSS_AGPS_NEQUICK_IONOSPHERIC_CORRECTION] - = GPS_AGPS_NEQUICK_CORRECTION, - [NRF_GNSS_AGPS_GPS_SYSTEM_CLOCK_AND_TOWS] - = GPS_AGPS_GPS_SYSTEM_CLOCK_AND_TOWS, - [NRF_GNSS_AGPS_LOCATION] = GPS_AGPS_LOCATION, - [NRF_GNSS_AGPS_INTEGRITY] = GPS_AGPS_INTEGRITY, +static enum gps_agps_type type_lookup_api2driver[] = { + [NRF_MODEM_GNSS_AGPS_UTC_PARAMETERS] = + GPS_AGPS_UTC_PARAMETERS, + [NRF_MODEM_GNSS_AGPS_EPHEMERIDES] = + GPS_AGPS_EPHEMERIDES, + [NRF_MODEM_GNSS_AGPS_ALMANAC] = + GPS_AGPS_ALMANAC, + [NRF_MODEM_GNSS_AGPS_KLOBUCHAR_IONOSPHERIC_CORRECTION] = + GPS_AGPS_KLOBUCHAR_CORRECTION, + [NRF_MODEM_GNSS_AGPS_NEQUICK_IONOSPHERIC_CORRECTION] = + GPS_AGPS_NEQUICK_CORRECTION, + [NRF_MODEM_GNSS_AGPS_GPS_SYSTEM_CLOCK_AND_TOWS] = + GPS_AGPS_GPS_SYSTEM_CLOCK_AND_TOWS, + [NRF_MODEM_GNSS_AGPS_LOCATION] = + GPS_AGPS_LOCATION, + [NRF_MODEM_GNSS_AGPS_INTEGRITY] = + GPS_AGPS_INTEGRITY }; -/* Convert nrf_socket A-GPS type to GPS API type. */ -static inline enum gps_agps_type type_socket2gps(nrf_gnss_agps_data_type_t type) +/* Convert GNSS API A-GPS type to GPS driver type. */ +static inline enum gps_agps_type type_api2driver(uint16_t type) { - return type_lookup_socket2gps[type]; + return type_lookup_api2driver[type]; } #if defined(CONFIG_AGPS_SRC_SUPL) -static int send_to_modem(void *data, size_t data_len, - nrf_gnss_agps_data_type_t type) +static int send_to_modem(void *data, size_t data_len, uint16_t type) { int err; - /* At this point, GPS driver or app-provided socket is assumed. */ if (gps_dev) { - return gps_agps_write(gps_dev, type_socket2gps(type), data, - data_len); - } - - err = nrf_sendto(gnss_fd, data, data_len, 0, &type, sizeof(type)); - if (err < 0) { - LOG_ERR("Failed to send AGPS data to modem, errno: %d", errno); - err = -errno; + /* GPS driver */ + err = gps_agps_write(gps_dev, type_api2driver(type), data, data_len); + } else if (gnss_fd != -1) { + /* GNSS socket */ + err = nrf_sendto(gnss_fd, data, data_len, 0, &type, sizeof(type)); + if (err < 0) { + err = -errno; + } else { + err = 0; + } } else { - err = 0; + /* GNSS API */ + err = nrf_modem_gnss_agps_write(data, data_len, type); } - LOG_DBG("A-GPS data sent to modem"); - return err; } static int inject_agps_type(void *agps, size_t agps_size, - nrf_gnss_agps_data_type_t type, + uint16_t type, void *user_data) { ARG_UNUSED(user_data); @@ -85,12 +87,12 @@ static int inject_agps_type(void *agps, err = send_to_modem(agps, agps_size, type); if (err) { - LOG_ERR("Failed to send AGNSS data, type: %d (err: %d)", + LOG_ERR("Failed to send A-GPS data, type: %d (err: %d)", type, err); return err; } - LOG_DBG("Injected AGPS data, type: %d, size: %d", type, agps_size); + LOG_DBG("Injected A-GPS data, type: %d, size: %d", type, agps_size); return 0; } @@ -98,85 +100,68 @@ static int inject_agps_type(void *agps, static int open_supl_socket(void) { int err; - int proto; - uint16_t port; - struct addrinfo *addr; struct addrinfo *info; - proto = IPPROTO_TCP; - port = htons(CONFIG_AGPS_SUPL_PORT); - struct addrinfo hints = { - .ai_family = AF_INET, - .ai_socktype = SOCK_STREAM, - .ai_protocol = proto, - /* Either a valid, - * NULL-terminated access point name or NULL. - */ - .ai_canonname = NULL, + .ai_family = AF_UNSPEC, /* Both IPv4 and IPv6 addresses accepted. */ + .ai_socktype = SOCK_STREAM }; - err = getaddrinfo(CONFIG_AGPS_SUPL_HOST_NAME, NULL, &hints, - &info); - + err = getaddrinfo(CONFIG_AGPS_SUPL_HOST_NAME, NULL, &hints, &info); if (err) { - LOG_ERR("Failed to resolve IPv4 hostname %s, errno: %d", + LOG_ERR("Failed to resolve hostname %s, error: %d", CONFIG_AGPS_SUPL_HOST_NAME, err); - return -ECHILD; - } - - /* Create socket */ - supl_fd = socket(AF_INET, SOCK_STREAM, proto); - if (supl_fd < 0) { - LOG_ERR("Failed to create socket, errno %d", errno); - err = -errno; - goto cleanup; - } - struct timeval timeout = { - .tv_sec = 1, - .tv_usec = 0, - }; - - err = setsockopt(supl_fd, - SOL_SOCKET, - SO_RCVTIMEO, - &timeout, - sizeof(timeout)); - if (err) { - LOG_ERR("Failed to setup socket timeout, errno %d", errno); - err = -errno; - goto cleanup; + return -1; } /* Not connected */ err = -1; - for (addr = info; addr != NULL; addr = addr->ai_next) { + for (struct addrinfo *addr = info; addr != NULL; addr = addr->ai_next) { + char ip[INET6_ADDRSTRLEN] = { 0 }; struct sockaddr *const sa = addr->ai_addr; switch (sa->sa_family) { case AF_INET6: - continue; + ((struct sockaddr_in6 *)sa)->sin6_port = htons(CONFIG_AGPS_SUPL_PORT); + break; case AF_INET: - ((struct sockaddr_in *)sa)->sin_port = port; - char ip[INET_ADDRSTRLEN]; + ((struct sockaddr_in *)sa)->sin_port = htons(CONFIG_AGPS_SUPL_PORT); + break; + } - inet_ntop(AF_INET, - &((struct sockaddr_in *)sa)->sin_addr, ip, - sizeof(ip)); + supl_fd = socket(sa->sa_family, SOCK_STREAM, IPPROTO_TCP); + if (supl_fd < 0) { + LOG_ERR("Failed to create socket, errno %d", errno); + goto cleanup; + } - LOG_DBG("ip %s (%x) port %d", log_strdup(ip), - ((struct sockaddr_in *)sa)->sin_addr.s_addr, - ntohs(port)); - break; + /* The SUPL library expects a 1 second timeout for the read function. */ + struct timeval timeout = { + .tv_sec = 1, + .tv_usec = 0, + }; + + err = setsockopt(supl_fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); + if (err) { + LOG_ERR("Failed to set socket timeout, errno %d", errno); + goto cleanup; } + inet_ntop(sa->sa_family, + (void *)&((struct sockaddr_in *)sa)->sin_addr, + ip, + INET6_ADDRSTRLEN); + LOG_DBG("Connecting to %s port %d", ip, CONFIG_AGPS_SUPL_PORT); + err = connect(supl_fd, sa, addr->ai_addrlen); if (err) { - /* Try next address */ - LOG_ERR("Unable to connect, errno %d", errno); - err = -errno; + close(supl_fd); + supl_fd = -1; + + /* Try the next address */ + LOG_WRN("Connecting to server failed, errno %d", errno); } else { /* Connected */ break; @@ -188,11 +173,15 @@ static int open_supl_socket(void) if (err) { /* Unable to connect, close socket */ - close(supl_fd); - supl_fd = -1; + LOG_ERR("Could not connect to SUPL server"); + if (supl_fd > -1) { + close(supl_fd); + supl_fd = -1; + } + return -1; } - return err; + return 0; } static void close_supl_socket(void) @@ -266,16 +255,14 @@ static int init_supl(int socket) if (socket) { LOG_DBG("Using user-provided socket, fd %d", socket); - gps_dev = NULL; gnss_fd = socket; } else { gps_dev = device_get_binding("NRF9160_GPS"); - if (gps_dev == NULL) { - LOG_ERR("Could not get binding to nRF9160 GPS"); - return -ENODEV; + if (gps_dev != NULL) { + LOG_DBG("Using GPS driver to input assistance data"); + } else { + LOG_DBG("Using GNSS API to input assistance data"); } - - LOG_DBG("Using GPS driver to input assistance data"); } LOG_INF("SUPL is initialized"); @@ -283,26 +270,9 @@ static int init_supl(int socket) return 0; } -static int supl_start(const struct gps_agps_request request) +static int supl_start(const struct nrf_modem_gnss_agps_data_frame request) { int err; - struct nrf_modem_gnss_agps_data_frame req = { - .sv_mask_ephe = request.sv_mask_ephe, - .sv_mask_alm = request.sv_mask_alm, - .data_flags = - (request.utc ? - BIT(NRF_GNSS_AGPS_GPS_UTC_REQUEST) : 0) | - (request.klobuchar ? - BIT(NRF_GNSS_AGPS_KLOBUCHAR_REQUEST) : 0) | - (request.nequick ? - BIT(NRF_GNSS_AGPS_NEQUICK_REQUEST) : 0) | - (request.system_time_tow ? - BIT(NRF_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST) : 0) | - (request.position ? - BIT(NRF_GNSS_AGPS_POSITION_REQUEST) : 0) | - (request.integrity ? - BIT(NRF_GNSS_AGPS_INTEGRITY_REQUEST) : 0), - }; err = open_supl_socket(); if (err) { @@ -312,7 +282,7 @@ static int supl_start(const struct gps_agps_request request) LOG_INF("Starting SUPL session"); - err = supl_session(&req); + err = supl_session(&request); if (err) { LOG_ERR("SUPL session failed, error: %d", err); goto cleanup; @@ -328,7 +298,7 @@ static int supl_start(const struct gps_agps_request request) #endif /* CONFIG_AGPS_SRC_SUPL */ -int gps_agps_request_send(struct gps_agps_request request, int socket) +int agps_request_send(struct nrf_modem_gnss_agps_data_frame request, int socket) { int err; @@ -352,7 +322,25 @@ int gps_agps_request_send(struct gps_agps_request request, int socket) } #elif defined(CONFIG_AGPS_SRC_NRF_CLOUD) - err = nrf_cloud_agps_request(request); + /* Convert GNSS API A-GPS request to GPS driver A-GPS request. */ + struct gps_agps_request agps_request; + + agps_request.sv_mask_ephe = request.sv_mask_ephe; + agps_request.sv_mask_alm = request.sv_mask_alm; + agps_request.utc = + request.data_flags & NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST ? 1 : 0; + agps_request.klobuchar = + request.data_flags & NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST ? 1 : 0; + agps_request.nequick = + request.data_flags & NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST ? 1 : 0; + agps_request.system_time_tow = + request.data_flags & NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST ? 1 : 0; + agps_request.position = + request.data_flags & NRF_MODEM_GNSS_AGPS_POSITION_REQUEST ? 1 : 0; + agps_request.integrity = + request.data_flags & NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST ? 1 : 0; + + err = nrf_cloud_agps_request(agps_request); if (err) { LOG_ERR("nRF Cloud A-GPS request failed, error: %d", err); return err; @@ -362,15 +350,14 @@ int gps_agps_request_send(struct gps_agps_request request, int socket) return 0; } -int gps_process_agps_data(const uint8_t *buf, size_t len) +int agps_cloud_data_process(const uint8_t *buf, size_t len) { int err = 0; #if defined(CONFIG_AGPS_SRC_NRF_CLOUD) && defined(CONFIG_NRF_CLOUD_AGPS) - err = nrf_cloud_agps_process(buf, len, NULL); if (err) { - LOG_ERR("A-GPS failed, error: %d", err); + LOG_ERR("Processing A-GPS data failed, error: %d", err); } else { LOG_INF("A-GPS data successfully processed"); } diff --git a/lib/date_time/date_time.c b/lib/date_time/date_time.c index 028ffa7fdc7e..b93e78aa8eab 100644 --- a/lib/date_time/date_time.c +++ b/lib/date_time/date_time.c @@ -13,6 +13,9 @@ #if defined(CONFIG_DATE_TIME_MODEM) #include #endif +#if defined(CONFIG_LTE_LINK_CONTROL) +#include +#endif #include #include #include @@ -193,10 +196,41 @@ static int sntp_time_request(struct ntp_servers *server, uint32_t timeout, return err; } +#if defined(CONFIG_LTE_LINK_CONTROL) +static bool is_connected_to_lte(void) +{ + int err; + enum lte_lc_nw_reg_status reg_status; + + err = lte_lc_nw_reg_status_get(®_status); + if (err) { + LOG_WRN("Failed getting LTE network registration status, error: %d", err); + return false; + } + + if (reg_status == LTE_LC_NW_REG_REGISTERED_EMERGENCY || + reg_status == LTE_LC_NW_REG_REGISTERED_HOME || + reg_status == LTE_LC_NW_REG_REGISTERED_ROAMING) { + return true; + } + + return false; +} +#endif /* defined(CONFIG_LTE_LINK_CONTROL) */ + static int time_NTP_server_get(void) { int err; +#if defined(CONFIG_LTE_LINK_CONTROL) + if (!is_connected_to_lte()) { + LOG_DBG("Not connected to LTE, skipping NTP UTC time update"); + return -ENODATA; + } + + LOG_DBG("Connected to LTE, performing NTP UTC time update"); +#endif + for (int i = 0; i < ARRAY_SIZE(servers); i++) { err = sntp_time_request(&servers[i], MSEC_PER_SEC * CONFIG_DATE_TIME_NTP_QUERY_TIME_SECONDS, diff --git a/lib/lte_link_control/lte_lc.c b/lib/lte_link_control/lte_lc.c index bf1fffefdb0c..61d51d3e8e08 100644 --- a/lib/lte_link_control/lte_lc.c +++ b/lib/lte_link_control/lte_lc.c @@ -152,13 +152,13 @@ static const char system_mode_preference[] = { }; #if !defined(CONFIG_NRF_MODEM_LIB_SYS_INIT) && \ - defined(CONFIG_BOARD_THINGY91_NRF9160NS) + defined(CONFIG_BOARD_THINGY91_NRF9160_NS) static const char thingy91_magpio[] = { "AT%XMAGPIO=1,1,1,7,1,746,803,2,698,748," "2,1710,2200,3,824,894,4,880,960,5,791,849," "7,1565,1586" }; -#endif /* !CONFIG_NRF_MODEM_LIB_SYS_INIT && CONFIG_BOARD_THINGY91_NRF9160NS */ +#endif /* !CONFIG_NRF_MODEM_LIB_SYS_INIT && CONFIG_BOARD_THINGY91_NRF9160_NS */ static struct k_sem link; @@ -572,7 +572,7 @@ static int init_and_config(void) } #if !defined(CONFIG_NRF_MODEM_LIB_SYS_INIT) && \ - defined(CONFIG_BOARD_THINGY91_NRF9160NS) + defined(CONFIG_BOARD_THINGY91_NRF9160_NS) /* Configuring MAGPIO, so that the correct antenna * matching network is used for each LTE band and GPS. */ diff --git a/modules/Kconfig b/modules/Kconfig index 79b6ebd9984d..bc3470ced166 100644 --- a/modules/Kconfig +++ b/modules/Kconfig @@ -5,6 +5,7 @@ # rsource "Kconfig.mcuboot" -rsource "tfm/zephyr/Kconfig" rsource "cddl-gen/Kconfig" +rsource "mbedtls/Kconfig" rsource "memfault/Kconfig" +rsource "tfm/zephyr/Kconfig" diff --git a/modules/mbedtls/Kconfig b/modules/mbedtls/Kconfig new file mode 100644 index 000000000000..6383b9e4ce34 --- /dev/null +++ b/modules/mbedtls/Kconfig @@ -0,0 +1,9 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Increase the heap size of mbedtls when building with TF-M. +config MBEDTLS_HEAP_SIZE + default 8320 if BUILD_WITH_TFM diff --git a/modules/mcuboot/CMakeLists.txt b/modules/mcuboot/CMakeLists.txt index 6743dd426125..a70e6762bd99 100644 --- a/modules/mcuboot/CMakeLists.txt +++ b/modules/mcuboot/CMakeLists.txt @@ -126,8 +126,8 @@ if(CONFIG_BOOTLOADER_MCUBOOT) $) if (NOT DEFINED CONFIG_BOOT_SIGNATURE_KEY_FILE) - include(${CMAKE_BINARY_DIR}/mcuboot/shared_vars.cmake) - set(CONFIG_BOOT_SIGNATURE_KEY_FILE ${mcuboot_SIGNATURE_KEY_FILE}) + get_shared(mcuboot_sign_key IMAGE mcuboot PROPERTY SIGNATURE_KEY_FILE) + set(CONFIG_BOOT_SIGNATURE_KEY_FILE ${mcuboot_sign_key}) endif () foreach (filepath ${mcuboot_CONF_FILE}) @@ -235,23 +235,33 @@ if(CONFIG_BOOTLOADER_MCUBOOT) "version_MCUBOOT=${CONFIG_MCUBOOT_IMAGE_VERSION}" ) + get_shared(cpunet_signed_app_hex IMAGE CPUNET PROPERTY PM_SIGNED_APP_HEX) + if (CONFIG_NRF53_UPGRADE_NETWORK_CORE - AND CONFIG_HCI_RPMSG_BUILD_STRATEGY_FROM_SOURCE) + AND DEFINED cpunet_signed_app_hex) # Network core application updates are enabled. # We know this since MCUBoot is enabled on the application core, and # a network core child image is included in the build. # These updates are verified by the application core MCUBoot. # Create a signed variant of the network core application. - # Load the shared vars to get the path to the hex file to sign. - include(${CMAKE_BINARY_DIR}/hci_rpmsg/shared_vars.cmake) + get_shared(cpunet_images IMAGE CPUNET PROPERTY PM_DOMAIN_IMAGES) + foreach(image ${cpunet_images}) + if(${image} MATCHES "CPUNET:(.*)") + set(image_name ${CMAKE_MATCH_1}) + if(TARGET ${image_name}_subimage) + get_shared(${image_name}_byproducts IMAGE ${image_name} PROPERTY BUILD_BYPRODUCTS) + list(APPEND sign_depends ${image_name}_subimage ${${image_name}_byproducts}) + endif() + endif() + endforeach() sign( - SIGNED_BIN_FILE_IN ${CPUNET_PM_SIGNED_APP_HEX} + SIGNED_BIN_FILE_IN ${cpunet_signed_app_hex} SIGNED_HEX_FILE_NAME_PREFIX ${PROJECT_BINARY_DIR}/net_core_app START_ADDRESS_OFFSET $ SIGNED_HEX_FILE_OUT net_core_app_signed_hex - DEPENDS hci_rpmsg_subimage ${hci_rpmsg_BUILD_BYPRODUCTS} + DEPENDS ${sign_depends} ) add_custom_target( diff --git a/modules/memfault/Kconfig b/modules/memfault/Kconfig index 033d0bba17e5..deaa8590410f 100644 --- a/modules/memfault/Kconfig +++ b/modules/memfault/Kconfig @@ -13,7 +13,7 @@ config MEMFAULT_NCS_PROJECT_KEY choice prompt "Memfault device ID generation method" - default MEMFAULT_NCS_DEVICE_ID_IMEI if (BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS) + default MEMFAULT_NCS_DEVICE_ID_IMEI if (BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS) default MEMFAULT_NCS_DEVICE_ID_STATIC config MEMFAULT_NCS_DEVICE_ID_IMEI @@ -50,14 +50,14 @@ config MEMFAULT_NCS_DEVICE_ID_MAX_LEN config MEMFAULT_NCS_HW_VERSION string "Hardware version" - default "nrf9160dk" if BOARD_NRF9160DK_NRF9160NS - default "thingy91" if BOARD_THINGY91_NRF9160NS + default "nrf9160dk" if BOARD_NRF9160DK_NRF9160_NS + default "thingy91" if BOARD_THINGY91_NRF9160_NS help Device hardware version config MEMFAULT_NCS_FW_TYPE string "Firmware type" - default "nrf91ns-fw" if BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS + default "nrf91ns-fw" if BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS help Firmware type running on the board diff --git a/modules/tfm/tfm/boards/board/RTE_Device.h b/modules/tfm/tfm/boards/board/RTE_Device.h index 813cd41a034b..07eaa588641f 100644 --- a/modules/tfm/tfm/boards/board/RTE_Device.h +++ b/modules/tfm/tfm/boards/board/RTE_Device.h @@ -42,7 +42,7 @@ // Configuration settings for Driver_USART1 in component ::Drivers:USART #define RTE_USART1 1 // Pin Selection (0xFFFFFFFF means Disconnected) -#if defined(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPPNS) +#if defined(CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP_NS) // TXD #define RTE_USART1_TXD_PIN 25 // TODO: Add to devicetree // RXD diff --git a/modules/tfm/zephyr/CMakeLists.txt b/modules/tfm/zephyr/CMakeLists.txt index 58810ce5df3e..67b2ce1a172a 100644 --- a/modules/tfm/zephyr/CMakeLists.txt +++ b/modules/tfm/zephyr/CMakeLists.txt @@ -38,6 +38,10 @@ set_property(TARGET zephyr_property_target APPEND PROPERTY TFM_CMAKE_OPTIONS -DNRF_DIR=${ZEPHYR_NRF_MODULE_DIR} ) +set_property(TARGET zephyr_property_target + APPEND PROPERTY TFM_CMAKE_OPTIONS -DZEPHYR_BASE=${ZEPHYR_BASE} + ) + if (CONFIG_TFM_MINIMAL) set_property(TARGET zephyr_property_target APPEND PROPERTY TFM_CMAKE_OPTIONS diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index ac7f85bb3e85..e1f92e5fd8c8 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -76,7 +76,7 @@ if (CONFIG_BUILD_WITH_TFM AND CONFIG_UART_1_NRF_UARTE) Non-secure applications built with TF-M cannot use UART1, because this instance is used by the TF-M secure application. Disable the uart1 node in devicetree. See the following file: - nrf/samples/tfm/tfm_hello_world/boards/nrf9160dk_nrf9160ns.overlay + nrf/samples/tfm/tfm_hello_world/boards/nrf9160dk_nrf9160_ns.overlay for an example how to do it.") endif() diff --git a/samples/bluetooth/alexa_gadget/README.rst b/samples/bluetooth/alexa_gadget/README.rst index df6111220b8b..f92233c08450 100644 --- a/samples/bluetooth/alexa_gadget/README.rst +++ b/samples/bluetooth/alexa_gadget/README.rst @@ -7,7 +7,7 @@ Bluetooth: Peripheral Alexa Gadgets :local: :depth: 2 -The Peripheral Alexa Gadgets sample demonstrates how a Bluetooth LE device can connect to an Amazon Echo device using the Alexa Gadgets Bluetooth Service and Profile. +The Peripheral Alexa Gadgets sample demonstrates how a Bluetooth® LE device can connect to an Amazon Echo device using the Alexa Gadgets Bluetooth Service and Profile. Documentation for the Gadgets Service and Profile can be found at `Alexa Gadgets Bluetooth LE`_. @@ -18,7 +18,7 @@ Overview ******** When connected, the sample performs the handshake procedure and informs the peer of its supported capabilities. -Directives sent by the connected peer are printed as log messages when :option:`CONFIG_LOG` is set. +Directives sent by the connected peer are printed as log messages when :kconfig:`CONFIG_LOG` is set. Additionally, when the "wake word" State Update directive is received, LED 3 on the development kit is turned on. Gadget capabilities diff --git a/samples/bluetooth/central_bas/README.rst b/samples/bluetooth/central_bas/README.rst index 36b69296a95e..d03de34befb7 100644 --- a/samples/bluetooth/central_bas/README.rst +++ b/samples/bluetooth/central_bas/README.rst @@ -28,7 +28,7 @@ The sample supports the following development kits: :header: heading :rows: nrf5340dk_nrf5340_cpuapp_and_cpuappns , nrf52840dk_nrf52840, nrf52840dk_nrf52811, nrf52833dk_nrf52833, nrf52833dk_nrf52820, nrf52dk_nrf52832, nrf52dk_nrf52810 -The sample also requires a device running a BAS Server to connect with (for example, another development kit running the :ref:`peripheral_hids_mouse` or :ref:`peripheral_hids_keyboard` sample, or a Bluetooth Low Energy dongle and nRF Connect for Desktop) +The sample also requires a device running a BAS Server to connect with (for example, another development kit running the :ref:`peripheral_hids_mouse` or :ref:`peripheral_hids_keyboard` sample, or a Bluetooth® Low Energy dongle and nRF Connect for Desktop) User interface diff --git a/samples/bluetooth/central_bas/sample.yaml b/samples/bluetooth/central_bas/sample.yaml index 1e8a66fd677f..78d3d178b311 100644 --- a/samples/bluetooth/central_bas/sample.yaml +++ b/samples/bluetooth/central_bas/sample.yaml @@ -13,11 +13,11 @@ tests: samples.bluetooth.central_bas.build: build_only: true platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/central_hids/README.rst b/samples/bluetooth/central_hids/README.rst index 8ac4f7e2f956..f7b0df92b6dc 100644 --- a/samples/bluetooth/central_hids/README.rst +++ b/samples/bluetooth/central_hids/README.rst @@ -32,7 +32,7 @@ The sample supports the following development kits: :header: heading :rows: nrf5340dk_nrf5340_cpuapp_and_cpuappns , nrf52840dk_nrf52840, nrf52833dk_nrf52833, nrf52833dk_nrf52820, nrf52dk_nrf52832 -The sample also requires a HIDS device to connect with (for example, another development kit running the :ref:`peripheral_hids_mouse` or :ref:`peripheral_hids_keyboard` sample, or a Bluetooth Low Energy dongle and nRF Connect for Desktop). +The sample also requires a HIDS device to connect with (for example, another development kit running the :ref:`peripheral_hids_mouse` or :ref:`peripheral_hids_keyboard` sample, or a Bluetooth® Low Energy dongle and nRF Connect for Desktop). User interface ************** diff --git a/samples/bluetooth/central_hids/sample.yaml b/samples/bluetooth/central_hids/sample.yaml index a55fe2cc0c30..2dd643024c3d 100644 --- a/samples/bluetooth/central_hids/sample.yaml +++ b/samples/bluetooth/central_hids/sample.yaml @@ -13,11 +13,11 @@ tests: samples.bluetooth.central_hids.build: build_only: true platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/central_hids/src/main.c b/samples/bluetooth/central_hids/src/main.c index 1e393fbf5f94..fe2933d67c55 100644 --- a/samples/bluetooth/central_hids/src/main.c +++ b/samples/bluetooth/central_hids/src/main.c @@ -421,14 +421,10 @@ static void button_bootmode(void) } int err; enum bt_hids_pm pm = bt_hogp_pm_get(&hogp); + enum bt_hids_pm new_pm = ((pm == BT_HIDS_PM_BOOT) ? BT_HIDS_PM_REPORT : BT_HIDS_PM_BOOT); - printk("Setting protocol mode: %s\n", - (pm == BT_HIDS_PM_BOOT) ? - "BOOT" : "REPORT"); - err = bt_hogp_pm_write(&hogp, - (pm == BT_HIDS_PM_BOOT) ? - BT_HIDS_PM_REPORT : - BT_HIDS_PM_BOOT); + printk("Setting protocol mode: %s\n", (new_pm == BT_HIDS_PM_BOOT) ? "BOOT" : "REPORT"); + err = bt_hogp_pm_write(&hogp, new_pm); if (err) { printk("Cannot change protocol mode (err %d)\n", err); } diff --git a/samples/bluetooth/central_hr_coded/README.rst b/samples/bluetooth/central_hr_coded/README.rst index d8cc8eb24382..67f79616e12f 100644 --- a/samples/bluetooth/central_hr_coded/README.rst +++ b/samples/bluetooth/central_hr_coded/README.rst @@ -13,7 +13,7 @@ However, this sample specifically looks for heart rate monitors using LE Coded P Overview ******** -The sample demonstrates a Bluetooth LE Central role functionality by scanning for other Bluetooth LE devices that run a Heart Rate Server with LE Coded PHY support which not available in Zephyr Bluetooth LE Controller (See :ref:`ug_ble_controller` for more information). +The sample demonstrates a Bluetooth® LE Central role functionality by scanning for other Bluetooth LE devices that run a Heart Rate Server with LE Coded PHY support, which is not available in Zephyr Bluetooth LE Controller (See :ref:`ug_ble_controller` for more information). It then establishes a connection to the first Peripheral device in range. It can be used together with the :ref:`peripheral_hr_coded` sample. diff --git a/samples/bluetooth/central_nfc_pairing/README.rst b/samples/bluetooth/central_nfc_pairing/README.rst index 716bc2265844..bea7d7f7c221 100644 --- a/samples/bluetooth/central_nfc_pairing/README.rst +++ b/samples/bluetooth/central_nfc_pairing/README.rst @@ -7,7 +7,7 @@ Bluetooth: Central NFC pairing :local: :depth: 2 -The Central NFC pairing sample demonstrates Bluetooth LE out-of-band pairing using an :ref:`st25r3911b_nfc_readme` and the NFC TNEP protocol. +The Central NFC pairing sample demonstrates Bluetooth® LE out-of-band pairing using an :ref:`st25r3911b_nfc_readme` and the NFC TNEP protocol. You can use it to test the touch-to-pair feature between Nordic Semiconductor's devices with :ref:`st25r3911b_nfc_readme` and an NFC Tag device with Bluetooth LE support. The sample shows the usage of NFC NDEF :ref:`nfc_ch` and :ref:`tnep_poller_readme` with the :ref:`Connection Handover service`. @@ -38,7 +38,7 @@ Static Handover =============== A tag in the Static Handover mode, contains a Handover Select Message with carrier information NDEF records or a single Carrier Configuration Record. -.. figure:: /images/nfc_static_connection_handover.svg +.. figure:: images/nfc_static_connection_handover.svg :alt: Static Handover Negotiated Handover @@ -49,7 +49,7 @@ In case of the OOB data for Bluetooth LE the NFC Devices can exchange OOB data 2 Handover messages are exchanged using the TNEP Single response communication mode. The NFC Poler Device can be the Handover Requester or Handover Selector Device, the role is taken based on the NFC Tag first NDEF message. -.. figure:: /images/nfc_negotiated_connection_handover.svg +.. figure:: images/nfc_negotiated_connection_handover.svg :alt: Negotiated Handover Requirements diff --git a/samples/bluetooth/central_nfc_pairing/images/nfc_negotiated_connection_handover.svg b/samples/bluetooth/central_nfc_pairing/images/nfc_negotiated_connection_handover.svg new file mode 100644 index 000000000000..7ca6275a48d2 --- /dev/null +++ b/samples/bluetooth/central_nfc_pairing/images/nfc_negotiated_connection_handover.svg @@ -0,0 +1,591 @@ + + + + + + + + Page-1 + + Sheet.134 + + id3 + + Sheet.4 + + + + Sheet.5 + + + + Sheet.6 + + + + + id4 + + Sheet.8 + + + + Sheet.9 + + + + Sheet.10 + + + + + id5 + + Sheet.12 + + + + Sheet.13 + NFC Forum Tag + + NFC Forum Tag + + + id6 + + Sheet.15 + + + + Sheet.16 + + + + + Sheet.17 + + + + + id7 + + Sheet.19 + + + + Sheet.20 + + + + Sheet.21 + + + + + id8 + + Sheet.23 + + + + Sheet.24 + NFC Poller Device + + NFC Poller Device + + + id9 + + Sheet.26 + + + + Sheet.27 + + + + Sheet.28 + + + + Sheet.29 + Alternative Carrier (Bluetooth LE) + + Alternative Carrier (Bluetooth LE) + + + id10 + + Sheet.31 + + + + Sheet.32 + + + + Sheet.33 + + + + Sheet.34 + Alternative Carrier (Bluetooth LE) + + Alternative Carrier (Bluetooth LE) + + + id11 + + Sheet.36 + + + + Sheet.37 + + + + + Sheet.38 + + + + + Sheet.39 + + + + + Sheet.40 + + + + + Sheet.41 + + + + + Sheet.42 + + + + + Sheet.43 + + + + + Sheet.44 + + + + + Sheet.45 + + + + + Sheet.46 + + + + + Sheet.47 + + + + + Sheet.48 + + + + + Sheet.49 + + + + + Sheet.50 + + + + + Sheet.51 + + + + + Sheet.52 + + + + + Sheet.53 + + + + + Sheet.54 + + + + + Sheet.55 + + + + + Sheet.56 + + + + + Sheet.57 + + + + + Sheet.58 + + + + + Sheet.59 + + + + + Sheet.60 + + + + + Sheet.61 + + + + + Sheet.62 + + + + + Sheet.63 + + + + + Sheet.64 + + + + + Sheet.65 + + + + + Sheet.66 + + + + + Sheet.67 + + + + + Sheet.68 + + + + + Sheet.69 + + + + + Sheet.70 + + + + + Sheet.71 + + + + + Sheet.72 + + + + + Sheet.73 + + + + + Sheet.74 + + + + + Sheet.75 + + + + + Sheet.76 + + + + + Sheet.77 + + + + + Sheet.78 + + + + + Sheet.79 + + + + + Sheet.80 + + + + + Sheet.81 + + + + + Sheet.82 + + + + + Sheet.83 + + + + + Sheet.84 + + + + + Sheet.85 + + + + + Sheet.86 + + + + + Sheet.87 + + + + + Sheet.88 + + + + + Sheet.89 + + + + + Sheet.90 + + + + + Sheet.91 + + + + + Sheet.92 + + + + + Sheet.93 + + + + + Sheet.94 + + + + + Sheet.95 + + + + + Sheet.96 + + + + + Sheet.97 + + + + + Sheet.98 + + + + + Sheet.99 + + + + Sheet.100 + + + + + id12 + + Sheet.102 + + + + Sheet.103 + Handover Select (Bluetooth LE, OOB data) + + Handover Select (Bluetooth LE, OOB data) + + + id13 + + Sheet.105 + + + + Sheet.106 + Data exchange over Bluetooth LE + + Data exchange over Bluetooth LE + + + id14 + + Sheet.108 + + + + Sheet.109 + + + + Sheet.110 + + + + + id15 + + Sheet.112 + + + + Sheet.113 + TNEP + + TNEP + + + id16 + + Sheet.115 + + + + Sheet.116 + + + + Sheet.117 + + + + + id17 + + Sheet.119 + + + + Sheet.120 + TNEP + + TNEP + + + id18 + + Sheet.122 + + + + Sheet.123 + + + + + Sheet.124 + + + + + id19 + + Sheet.126 + + + + Sheet.127 + Handover Request (Bluetooth LE, OOB data) + + Handover Request (Bluetooth LE, OOB data) + + + + diff --git a/samples/bluetooth/central_nfc_pairing/images/nfc_negotiated_connection_handover.vsdx b/samples/bluetooth/central_nfc_pairing/images/nfc_negotiated_connection_handover.vsdx new file mode 100644 index 000000000000..7c349a189d2c Binary files /dev/null and b/samples/bluetooth/central_nfc_pairing/images/nfc_negotiated_connection_handover.vsdx differ diff --git a/samples/bluetooth/central_nfc_pairing/images/nfc_static_connection_handover.svg b/samples/bluetooth/central_nfc_pairing/images/nfc_static_connection_handover.svg new file mode 100644 index 000000000000..ecae89f2170c --- /dev/null +++ b/samples/bluetooth/central_nfc_pairing/images/nfc_static_connection_handover.svg @@ -0,0 +1,508 @@ + + + + + + + + Page-1 + + Sheet.116 + + id3 + + Sheet.4 + + + + Sheet.5 + + + + Sheet.6 + + + + + id4 + + Sheet.8 + + + + Sheet.9 + + + + Sheet.10 + + + + + id5 + + Sheet.12 + + + + Sheet.13 + NFC Forum Tag + + NFC Forum Tag + + + id6 + + Sheet.15 + + + + Sheet.16 + + + + + Sheet.17 + + + + + id7 + + Sheet.19 + + + + Sheet.20 + + + + Sheet.21 + + + + + id8 + + Sheet.23 + + + + Sheet.24 + NFC Poller Device + + NFC Poller Device + + + id9 + + Sheet.26 + + + + Sheet.27 + + + + Sheet.28 + + + + Sheet.29 + Alternative Carrier (Bluetooth LE) + + Alternative Carrier (Bluetooth LE) + + + id11 + + Sheet.36 + + + + Sheet.37 + + + + + Sheet.38 + + + + + Sheet.39 + + + + + Sheet.40 + + + + + Sheet.41 + + + + + Sheet.42 + + + + + Sheet.43 + + + + + Sheet.44 + + + + + Sheet.45 + + + + + Sheet.46 + + + + + Sheet.47 + + + + + Sheet.48 + + + + + Sheet.49 + + + + + Sheet.50 + + + + + Sheet.51 + + + + + Sheet.52 + + + + + Sheet.53 + + + + + Sheet.54 + + + + + Sheet.55 + + + + + Sheet.56 + + + + + Sheet.57 + + + + + Sheet.58 + + + + + Sheet.59 + + + + + Sheet.60 + + + + + Sheet.61 + + + + + Sheet.62 + + + + + Sheet.63 + + + + + Sheet.64 + + + + + Sheet.65 + + + + + Sheet.66 + + + + + Sheet.67 + + + + + Sheet.68 + + + + + Sheet.69 + + + + + Sheet.70 + + + + + Sheet.71 + + + + + Sheet.72 + + + + + Sheet.73 + + + + + Sheet.74 + + + + + Sheet.75 + + + + + Sheet.76 + + + + + Sheet.77 + + + + + Sheet.78 + + + + + Sheet.79 + + + + + Sheet.80 + + + + + Sheet.81 + + + + + Sheet.82 + + + + + Sheet.83 + + + + + Sheet.84 + + + + + Sheet.85 + + + + + Sheet.86 + + + + + Sheet.87 + + + + + Sheet.88 + + + + + Sheet.89 + + + + + Sheet.90 + + + + + Sheet.91 + + + + + Sheet.92 + + + + + Sheet.93 + + + + + Sheet.94 + + + + + Sheet.95 + + + + + Sheet.96 + + + + + Sheet.97 + + + + + Sheet.98 + + + + + Sheet.99 + + + + Sheet.100 + + + + + id12 + + Sheet.102 + + + + Sheet.103 + Handover Select (Bluetooth LE, OOB data) + + Handover Select (Bluetooth LE, OOB data) + + + id13 + + Sheet.105 + + + + Sheet.106 + Data exchange over Bluetooth LE + + Data exchange over Bluetooth LE + + + id9.109 + + Sheet.110 + + + + Sheet.111 + + + + Sheet.112 + + + + Sheet.113 + Alternative Carrier (Bluetooth LE) + + Alternative Carrier (Bluetooth LE) + + + + diff --git a/samples/bluetooth/central_nfc_pairing/images/nfc_static_connection_handover.vsdx b/samples/bluetooth/central_nfc_pairing/images/nfc_static_connection_handover.vsdx new file mode 100644 index 000000000000..ec103c41da34 Binary files /dev/null and b/samples/bluetooth/central_nfc_pairing/images/nfc_static_connection_handover.vsdx differ diff --git a/samples/bluetooth/central_smp_client/README.rst b/samples/bluetooth/central_smp_client/README.rst index 27271617dd1f..1355084ca973 100644 --- a/samples/bluetooth/central_smp_client/README.rst +++ b/samples/bluetooth/central_smp_client/README.rst @@ -30,9 +30,9 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuapp_and_cpuappns , nrf52840dk_nrf52840, nrf52833dk_nrf52833, nrf52833dk_nrf52820, nrf52dk_nrf52832 + :rows: nrf5340dk_nrf5340_cpuapp_and_cpuappns, nrf52840dk_nrf52840, nrf52833dk_nrf52833, nrf52833dk_nrf52820, nrf52dk_nrf52832 -The sample also requires a device running `mcumgr`_ with transport protocol over Bluetooth Low Energy, for example, another development kit running the :ref:`smp_svr_sample`. +The sample also requires a device running `mcumgr`_ with transport protocol over Bluetooth® Low Energy, for example, another development kit running the :ref:`smp_svr_sample`. User interface ************** diff --git a/samples/bluetooth/central_smp_client/sample.yaml b/samples/bluetooth/central_smp_client/sample.yaml index 9b9c817d2885..0c1bb274f07a 100644 --- a/samples/bluetooth/central_smp_client/sample.yaml +++ b/samples/bluetooth/central_smp_client/sample.yaml @@ -13,11 +13,11 @@ tests: samples.bluetooth.central_dfu_smp.build: build_only: true platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/central_uart/README.rst b/samples/bluetooth/central_uart/README.rst index 90a27ca69106..857fab56982c 100644 --- a/samples/bluetooth/central_uart/README.rst +++ b/samples/bluetooth/central_uart/README.rst @@ -8,7 +8,7 @@ Bluetooth: Central UART :depth: 2 The Central UART sample demonstrates how to use the :ref:`nus_client_readme`. -It uses the NUS Client to send data back and forth between a UART connection and a Bluetooth LE connection, emulating a serial port over Bluetooth LE. +It uses the NUS Client to send data back and forth between a UART connection and a Bluetooth® LE connection, emulating a serial port over Bluetooth LE. Overview diff --git a/samples/bluetooth/central_uart/sample.yaml b/samples/bluetooth/central_uart/sample.yaml index 3e3647c3f0ff..ad1413ac867c 100644 --- a/samples/bluetooth/central_uart/sample.yaml +++ b/samples/bluetooth/central_uart/sample.yaml @@ -4,12 +4,12 @@ sample: tests: samples.bluetooth.central_uart: build_only: true - platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf52dk_nrf52810 + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/direct_test_mode/CMakeLists.txt b/samples/bluetooth/direct_test_mode/CMakeLists.txt index 62b3bf81f0b3..c111f5ae28e4 100644 --- a/samples/bluetooth/direct_test_mode/CMakeLists.txt +++ b/samples/bluetooth/direct_test_mode/CMakeLists.txt @@ -5,19 +5,6 @@ # cmake_minimum_required(VERSION 3.8) -option(NRF21540EK_FEM "Enable support for the nRF21540-EK FEM." OFF) - -if(NRF21540EK_FEM) - set(DTC_OVERLAY_FILE - "${CMAKE_CURRENT_SOURCE_DIR}/configuration/dts-nrf21540-fem.overlay" - CACHE STRING "" FORCE) - - if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay") - set(DTC_OVERLAY_FILE "${DTC_OVERLAY_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay" - CACHE STRING "" FORCE) - endif() -endif() - find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(NONE) diff --git a/samples/bluetooth/direct_test_mode/README.rst b/samples/bluetooth/direct_test_mode/README.rst index d1ea84a99a13..8a7207a7d82f 100644 --- a/samples/bluetooth/direct_test_mode/README.rst +++ b/samples/bluetooth/direct_test_mode/README.rst @@ -7,7 +7,7 @@ Bluetooth: Direct Test Mode :local: :depth: 2 -This sample enables the Direct Test Mode functions described in `Bluetooth Core Specification`_: Version 5.2, Vol. 6, Part F. +This sample enables the Direct Test Mode functions described in `Bluetooth® Core Specification `_: Version 5.2, Vol. 6, Part F. Overview ******** @@ -20,7 +20,7 @@ The sample uses Direct Test Mode (DTM) to test the operation of the following fe * Packet error rate * Intermodulation performance -Test procedures are defined in the document `Bluetooth Low Energy RF PHY Test Specification`_: Document number RF-PHY.TS.p15 +Test procedures are defined in the document `Bluetooth® Low Energy RF PHY Test Specification `_: Document number RF-PHY.TS.p15 You can carry out conformance tests using dedicated test equipment, such as the Anritsu MT8852 or similar, with an nRF5 running the DTM sample set as device under test (DUT). @@ -122,8 +122,6 @@ In other words, for the first antenna, antenna pin 1 is active, for the second a nRF21540 front-end module ========================= -.. |fem_file_path| replace:: :file:`samples/bluetooth/direct_test_mode/configuration` - .. include:: /includes/sample_dtm_radio_test_fem.txt You can configure the transmitted power gain and activation delay in nRF21540 using vendor-specific commands, see `Vendor-specific packet payload`_. @@ -211,7 +209,7 @@ Building and running However, you must still program the application core to boot up the network core. You can use any sample for this, for example, the :ref:`nrf5340_empty_app_core`. The :ref:`nrf5340_empty_app_core` is built and programmed automatically by default. - If you want to program another sample for the application core, unset the :option:'CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE' option. + If you want to program another sample for the application core, unset the :kconfig:'CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE' option. .. _dtm_testing: diff --git a/samples/bluetooth/direct_test_mode/src/fem/nrf21540.c b/samples/bluetooth/direct_test_mode/src/fem/nrf21540.c index 7262d2ad5f99..432b73a96bc3 100644 --- a/samples/bluetooth/direct_test_mode/src/fem/nrf21540.c +++ b/samples/bluetooth/direct_test_mode/src/fem/nrf21540.c @@ -706,8 +706,7 @@ int nrf21540_tx_gain_set(uint8_t gain) } if (uart_ready) { - err = pm_device_state_set(uart, PM_DEVICE_STATE_OFF, - NULL, NULL); + err = pm_device_state_set(uart, PM_DEVICE_STATE_OFF); if (err) { goto error; } @@ -728,8 +727,7 @@ int nrf21540_tx_gain_set(uint8_t gain) uarte_configuration_restore(uarte_inst, &uarte_cfg); if (uart_ready) { - err = pm_device_state_set(uart, PM_DEVICE_STATE_ACTIVE, - NULL, NULL); + err = pm_device_state_set(uart, PM_DEVICE_STATE_ACTIVE); } if (uart_irq) { diff --git a/samples/bluetooth/direction_finding_connectionless_rx/README.rst b/samples/bluetooth/direction_finding_connectionless_rx/README.rst index 6c67fa2fda44..e51ff17a2634 100644 --- a/samples/bluetooth/direction_finding_connectionless_rx/README.rst +++ b/samples/bluetooth/direction_finding_connectionless_rx/README.rst @@ -7,7 +7,7 @@ Bluetooth: Direction finding connectionless locator :local: :depth: 2 -The direction finding connectionless locator sample application demonstrates Bluetooth LE direction finding reception. +The direction finding connectionless locator sample application demonstrates Bluetooth® LE direction finding reception. Requirements ************ @@ -16,7 +16,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf52833dk_nrf52833 + :rows: nrf52833dk_nrf52833, nrf5340dk_nrf5340_cpuapp_and_cpuappns The sample also requires an antenna matrix when operating in angle of arrival mode. It can be a Nordic Semiconductor design 12 patch antenna matrix, or any other antenna matrix. @@ -38,6 +38,15 @@ Configuration |config| +This sample configuration is split into the following two files: + +* generic configuration is available in :file:`prj.conf` file +* board specific configuration is available in :file:`boards/.conf` file + +Board specific configuration involves configuring the Bluetooth LE controller. +For :ref:`nRF5340 DK `, the Bluetooth LE controller is part of a ``child image`` aimed to run on the network core. +Configuration for the child image is stored in :file:`child_image/` subdirectory. + Angle of departure mode ======================= @@ -46,6 +55,8 @@ To build this sample with angle of departure mode only, set ``OVERLAY_CONFIG`` t See :ref:`cmake_options` for instructions on how to add this option. For more information about using configuration overlay files, see :ref:`zephyr:important-build-vars` in the Zephyr documentation. +To build this sample for :ref:`nRF5340 DK `, with angle of arrival mode only, add content of :file:`overlay-aod.conf` file to :file:`child_image/hci_rpmsg.conf` file. + Antenna matrix configuration for angle of arrival mode ====================================================== diff --git a/samples/bluetooth/direction_finding_connectionless_rx/boards/nrf52833dk_nrf52833.conf b/samples/bluetooth/direction_finding_connectionless_rx/boards/nrf52833dk_nrf52833.conf new file mode 100644 index 000000000000..96498c082021 --- /dev/null +++ b/samples/bluetooth/direction_finding_connectionless_rx/boards/nrf52833dk_nrf52833.conf @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_BT_CTLR=y +CONFIG_BT_LL_SW_SPLIT=y + +CONFIG_BT_CTLR_ADV_EXT=y +CONFIG_BT_CTLR_SYNC_PERIODIC=y + +# Enable Direction Finding Feature including AoA and AoD +CONFIG_BT_CTLR_DF=y + +# Disable Direction Finding TX mode +CONFIG_BT_CTLR_DF_ANT_SWITCH_TX=n +CONFIG_BT_CTLR_DF_ADV_CTE_TX=n diff --git a/samples/bluetooth/direction_finding_connectionless_rx/boards/nrf52833dk_nrf52833.overlay b/samples/bluetooth/direction_finding_connectionless_rx/boards/nrf52833dk_nrf52833.overlay index ef18c982c91f..f3e46ad35d2b 100644 --- a/samples/bluetooth/direction_finding_connectionless_rx/boards/nrf52833dk_nrf52833.overlay +++ b/samples/bluetooth/direction_finding_connectionless_rx/boards/nrf52833dk_nrf52833.overlay @@ -9,7 +9,7 @@ /* This is a number of antennas that are available on antenna matrix * designed by Nordic. For more information see README.rst. */ - dfe-antenna-num = < 12 >; + dfe-antenna-num = <12>; /* This is a setting that enables antenna 12 (in antenna matrix designed * by Nordic) for Rx PDU. For more information see README.rst. */ diff --git a/samples/bluetooth/direction_finding_connectionless_rx/child_image/hci_rpmsg.conf b/samples/bluetooth/direction_finding_connectionless_rx/child_image/hci_rpmsg.conf new file mode 100644 index 000000000000..2f293097c11a --- /dev/null +++ b/samples/bluetooth/direction_finding_connectionless_rx/child_image/hci_rpmsg.conf @@ -0,0 +1,25 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Required to enable BT_BUF_CMD_TX_SIZE for LE Set Extended Advertising Data command +CONFIG_BT_EXT_ADV=y + +# Required to enable BT_PER_ADV_SYNC_MAX +CONFIG_BT_PER_ADV_SYNC=y +CONFIG_BT_OBSERVER=y + +CONFIG_BT_CTLR=y +CONFIG_BT_LL_SW_SPLIT=y + +CONFIG_BT_CTLR_ADV_EXT=y +CONFIG_BT_CTLR_SYNC_PERIODIC=y + +# Enable Direction Finding Feature including AoA and AoD +CONFIG_BT_CTLR_DF=y +CONFIG_BT_CTLR_DF_ANT_SWITCH_TX=n + +# Disable Direction Finding TX mode +CONFIG_BT_CTLR_DF_ADV_CTE_TX=n diff --git a/samples/bluetooth/direction_finding_connectionless_rx/child_image/hci_rpmsg/nrf5340dk_nrf5340_cpunet.overlay b/samples/bluetooth/direction_finding_connectionless_rx/child_image/hci_rpmsg/nrf5340dk_nrf5340_cpunet.overlay new file mode 100644 index 000000000000..d83035bf0f8b --- /dev/null +++ b/samples/bluetooth/direction_finding_connectionless_rx/child_image/hci_rpmsg/nrf5340dk_nrf5340_cpunet.overlay @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&radio { + status = "okay"; + /* This is a number of antennas that are available on antenna matrix + * designed by Nordic. For more information see README.rst. + */ + dfe-antenna-num = <12>; + /* This is a setting that enables antenna 12 (in antenna matrix designed + * by Nordic) for Rx PDU. For more information see README.rst. + */ + dfe-pdu-antenna = <0x0>; + + /* These are GPIO pin numbers that are provided to + * Radio peripheral. The pins will be acquired by Radio to + * drive antenna switching when AoA is enabled. + * Pin numbers are selected to drive switches on antenna matrix + * desinged by Nordic. For more information see README.rst. + */ + dfegpio0-gpios = <&gpio0 4 0>; + dfegpio1-gpios = <&gpio0 5 0>; + dfegpio2-gpios = <&gpio0 6 0>; + dfegpio3-gpios = <&gpio0 7 0>; +}; diff --git a/samples/bluetooth/direction_finding_connectionless_rx/prj.conf b/samples/bluetooth/direction_finding_connectionless_rx/prj.conf index ac6f129f1026..8e19efa38729 100644 --- a/samples/bluetooth/direction_finding_connectionless_rx/prj.conf +++ b/samples/bluetooth/direction_finding_connectionless_rx/prj.conf @@ -5,8 +5,6 @@ # CONFIG_BT=y -CONFIG_BT_CTLR=y -CONFIG_BT_LL_SW_SPLIT=y CONFIG_BT_DEVICE_NAME="DF Connectionless Locator App" CONFIG_BT_EXT_ADV=y @@ -16,12 +14,3 @@ CONFIG_BT_OBSERVER=y # Enable Direction Finding Feature including AoA and AoD CONFIG_BT_DF=y CONFIG_BT_DF_CONNECTIONLESS_CTE_RX=y - -CONFIG_BT_CTLR_ADV_EXT=y -CONFIG_BT_CTLR_SYNC_PERIODIC=y -# Enable Direction Finding Feature including AoA and AoD -CONFIG_BT_CTLR_DF=y -CONFIG_BT_CTLR_DF_ANT_SWITCH_TX=n - -# Disable Direction Finding Tx mode -CONFIG_BT_CTLR_DF_ADV_CTE_TX=n diff --git a/samples/bluetooth/direction_finding_connectionless_tx/README.rst b/samples/bluetooth/direction_finding_connectionless_tx/README.rst index a148f2977e8c..8f3249cb9bfc 100644 --- a/samples/bluetooth/direction_finding_connectionless_tx/README.rst +++ b/samples/bluetooth/direction_finding_connectionless_tx/README.rst @@ -7,7 +7,7 @@ Bluetooth: Direction finding connectionless beacon :local: :depth: 2 -The direction finding connectionless beacon sample demonstrates Bluetooth LE direction finding transmission. +The direction finding connectionless beacon sample demonstrates Bluetooth® LE direction finding transmission. Requirements ************ diff --git a/samples/bluetooth/enocean/README.rst b/samples/bluetooth/enocean/README.rst index baa93219e7e1..189b0cc64dc5 100644 --- a/samples/bluetooth/enocean/README.rst +++ b/samples/bluetooth/enocean/README.rst @@ -7,7 +7,7 @@ Bluetooth: EnOcean :local: :depth: 2 -The Bluetooth EnOcean sample demonstrates the basic usage of the :ref:`bt_enocean_readme` library. +The Bluetooth® EnOcean sample demonstrates the basic usage of the :ref:`bt_enocean_readme` library. Overview ******** diff --git a/samples/bluetooth/hci_lpuart/README.rst b/samples/bluetooth/hci_lpuart/README.rst index 98dd31c2177a..d494ab8dcd22 100644 --- a/samples/bluetooth/hci_lpuart/README.rst +++ b/samples/bluetooth/hci_lpuart/README.rst @@ -21,7 +21,7 @@ The sample supports the following development kit: Overview ******** -The sample implements the Bluetooth HCI controller using the :ref:`uart_nrf_sw_lpuart` for UART communication. +The sample implements the Bluetooth® HCI controller using the :ref:`uart_nrf_sw_lpuart` for UART communication. Building and running ******************** diff --git a/samples/bluetooth/llpm/README.rst b/samples/bluetooth/llpm/README.rst index f6189703f8f2..ef4127e38dca 100644 --- a/samples/bluetooth/llpm/README.rst +++ b/samples/bluetooth/llpm/README.rst @@ -7,7 +7,7 @@ Bluetooth: LLPM :local: :depth: 2 -The Bluetooth Low Latency Packet Mode (LLPM) sample uses the :ref:`latency_readme` and the :ref:`latency_client_readme` to showcase the LLPM proprietary Bluetooth extension from Nordic Semiconductor. +The Bluetooth® Low Latency Packet Mode (LLPM) sample uses the :ref:`latency_readme` and the :ref:`latency_client_readme` to showcase the LLPM proprietary Bluetooth extension from Nordic Semiconductor. You can use it to determine the transmission latency of LLPM-enabled connections, or to compare with different connection parameters and check their influence on the results. @@ -25,7 +25,7 @@ LLPM connection interval (1 ms) The lowest supported connection interval is 1 ms for one link. Physical layer (PHY) - Starting with Bluetooth 5, the over-the-air data rate in Bluetooth Low Energy supports 2 Ms/s (mega symbol per second), which allows for faster transmission. + Starting with Bluetooth® 5, the over-the-air data rate in Bluetooth Low Energy supports 2 Ms/s (mega symbol per second), which allows for faster transmission. The LLPM connection interval is only supported on *LE 2M PHY*. Otherwise, the SoftDevice Controller will deny the request command. diff --git a/samples/bluetooth/mesh/chat/README.rst b/samples/bluetooth/mesh/chat/README.rst index c4ea68fe26c5..7bd04d82cb99 100644 --- a/samples/bluetooth/mesh/chat/README.rst +++ b/samples/bluetooth/mesh/chat/README.rst @@ -7,7 +7,7 @@ Bluetooth: Mesh chat :local: :depth: 2 -The Bluetooth mesh chat sample demonstrates how the mesh network can be used to facilitate communication between nodes by text, using the :ref:`bt_mesh_chat_client_model`. +The Bluetooth® mesh chat sample demonstrates how the mesh network can be used to facilitate communication between nodes by text, using the :ref:`bt_mesh_chat_client_model`. .. toctree:: :maxdepth: 1 diff --git a/samples/bluetooth/mesh/chat/chat_cli.rst b/samples/bluetooth/mesh/chat/chat_cli.rst index 834d97fc6f2a..0b5cf00cd21e 100644 --- a/samples/bluetooth/mesh/chat/chat_cli.rst +++ b/samples/bluetooth/mesh/chat/chat_cli.rst @@ -100,4 +100,4 @@ None. Persistent storage ****************** -If :option:`CONFIG_BT_SETTINGS` is enabled, the Chat Client stores its presence state. +If :kconfig:`CONFIG_BT_SETTINGS` is enabled, the Chat Client stores its presence state. diff --git a/samples/bluetooth/mesh/chat/src/chat_cli.c b/samples/bluetooth/mesh/chat/src/chat_cli.c index 61fad2525f97..6d3c2fef3607 100644 --- a/samples/bluetooth/mesh/chat/src/chat_cli.c +++ b/samples/bluetooth/mesh/chat/src/chat_cli.c @@ -35,9 +35,8 @@ static const uint8_t *extract_msg(struct net_buf_simple *buf) return net_buf_simple_pull_mem(buf, buf->len); } -static void handle_message(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_message(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_chat_cli *chat = model->user_data; const uint8_t *msg; @@ -47,6 +46,8 @@ static void handle_message(struct bt_mesh_model *model, if (chat->handlers->message) { chat->handlers->message(chat, ctx, msg); } + + return 0; } /* .. include_startingpoint_chat_cli_rst_1 */ @@ -60,7 +61,7 @@ static void send_message_reply(struct bt_mesh_chat_cli *chat, (void)bt_mesh_model_send(chat->model, ctx, &msg, NULL, NULL); } -static void handle_private_message(struct bt_mesh_model *model, +static int handle_private_message(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { @@ -74,23 +75,24 @@ static void handle_private_message(struct bt_mesh_model *model, } send_message_reply(chat, ctx); + return 0; } /* .. include_endpoint_chat_cli_rst_1 */ -static void handle_message_reply(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_message_reply(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_chat_cli *chat = model->user_data; if (chat->handlers->message_reply) { chat->handlers->message_reply(chat, ctx); } + + return 0; } -static void handle_presence(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_presence(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_chat_cli *chat = model->user_data; enum bt_mesh_chat_cli_presence presence; @@ -100,11 +102,12 @@ static void handle_presence(struct bt_mesh_model *model, if (chat->handlers->presence) { chat->handlers->presence(chat, ctx, presence); } + + return 0; } -static void handle_presence_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_presence_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_chat_cli *chat = model->user_data; @@ -114,33 +117,35 @@ static void handle_presence_get(struct bt_mesh_model *model, encode_presence(&msg, chat->presence); (void) bt_mesh_model_send(chat->model, ctx, &msg, NULL, NULL); + + return 0; } /* .. include_startingpoint_chat_cli_rst_2 */ const struct bt_mesh_model_op _bt_mesh_chat_cli_op[] = { { BT_MESH_CHAT_CLI_OP_MESSAGE, - BT_MESH_CHAT_CLI_MSG_MINLEN_MESSAGE, + BT_MESH_LEN_MIN(BT_MESH_CHAT_CLI_MSG_MINLEN_MESSAGE), handle_message }, { BT_MESH_CHAT_CLI_OP_PRIVATE_MESSAGE, - BT_MESH_CHAT_CLI_MSG_MINLEN_MESSAGE, + BT_MESH_LEN_MIN(BT_MESH_CHAT_CLI_MSG_MINLEN_MESSAGE), handle_private_message }, { BT_MESH_CHAT_CLI_OP_MESSAGE_REPLY, - BT_MESH_CHAT_CLI_MSG_LEN_MESSAGE_REPLY, + BT_MESH_LEN_EXACT(BT_MESH_CHAT_CLI_MSG_LEN_MESSAGE_REPLY), handle_message_reply }, { BT_MESH_CHAT_CLI_OP_PRESENCE, - BT_MESH_CHAT_CLI_MSG_LEN_PRESENCE, + BT_MESH_LEN_EXACT(BT_MESH_CHAT_CLI_MSG_LEN_PRESENCE), handle_presence }, { BT_MESH_CHAT_CLI_OP_PRESENCE_GET, - BT_MESH_CHAT_CLI_MSG_LEN_PRESENCE_GET, + BT_MESH_LEN_EXACT(BT_MESH_CHAT_CLI_MSG_LEN_PRESENCE_GET), handle_presence_get }, BT_MESH_MODEL_OP_END, diff --git a/samples/bluetooth/mesh/light/README.rst b/samples/bluetooth/mesh/light/README.rst index 5b5af712f369..74b89807daa2 100644 --- a/samples/bluetooth/mesh/light/README.rst +++ b/samples/bluetooth/mesh/light/README.rst @@ -7,7 +7,7 @@ Bluetooth: Mesh light :local: :depth: 2 -The Bluetooth mesh light sample demonstrates how to set up a mesh server model application, and control LEDs with Bluetooth mesh using the :ref:`bt_mesh_onoff_readme`. +The Bluetooth® mesh light sample demonstrates how to set up a mesh server model application, and control LEDs with Bluetooth mesh using the :ref:`bt_mesh_onoff_readme`. .. note:: This sample is self-contained, and can be tested on its own. diff --git a/samples/bluetooth/mesh/light/boards/thingy53_nrf5340_cpuapp.conf b/samples/bluetooth/mesh/light/boards/thingy53_nrf5340_cpuapp.conf index ce39b5c95bd9..ebac1268e439 100644 --- a/samples/bluetooth/mesh/light/boards/thingy53_nrf5340_cpuapp.conf +++ b/samples/bluetooth/mesh/light/boards/thingy53_nrf5340_cpuapp.conf @@ -54,7 +54,7 @@ CONFIG_PM_EXTERNAL_FLASH_SIZE=0x800000 CONFIG_USB=y CONFIG_USB_DEVICE_STACK=y -CONFIG_USB_DEVICE_PRODUCT="Application Thingy:53" +CONFIG_USB_DEVICE_PRODUCT="Thingy:53 Application" CONFIG_USB_DEVICE_VID=0x1915 CONFIG_USB_DEVICE_PID=0x530C CONFIG_USB_CDC_ACM=y diff --git a/samples/bluetooth/mesh/light/sample.yaml b/samples/bluetooth/mesh/light/sample.yaml index c733d2a99f69..41160554b96c 100644 --- a/samples/bluetooth/mesh/light/sample.yaml +++ b/samples/bluetooth/mesh/light/sample.yaml @@ -5,12 +5,12 @@ tests: samples.bluetooth.mesh.light: build_only: true platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns thingy53_nrf5340_cpuapp + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns thingy53_nrf5340_cpuapp tags: bluetooth ci_build integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf51dk_nrf51422 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - thingy53_nrf5340_cpuapp diff --git a/samples/bluetooth/mesh/light_ctrl/README.rst b/samples/bluetooth/mesh/light_ctrl/README.rst index 46c440d62047..ceca369155ab 100644 --- a/samples/bluetooth/mesh/light_ctrl/README.rst +++ b/samples/bluetooth/mesh/light_ctrl/README.rst @@ -7,7 +7,7 @@ Bluetooth: Mesh light fixture :local: :depth: 2 -The Bluetooth mesh light fixture sample demonstrates how to set up a light control mesh server model application, and control a dimmable LED with Bluetooth mesh using the :ref:`bt_mesh_onoff_readme`. +The Bluetooth® mesh light fixture sample demonstrates how to set up a light control mesh server model application, and control a dimmable LED with Bluetooth mesh using the :ref:`bt_mesh_onoff_readme`. Requirements ************ @@ -158,13 +158,13 @@ You should now see the following actions: 1. The LED fades from 0% to 100% over 500ms :guilabel:`Standby -> On`. #. The LED stays at 100% for three seconds :guilabel:`On`. -#. The LED fades from 100% to :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` over five seconds :guilabel:`On -> Prolong`. -#. The LED stays at :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` for three seconds :guilabel:`Prolong`. -#. The LED fades from :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` to 0% over five seconds :guilabel:`Prolong -> Standby`. +#. The LED fades from 100% to :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` over five seconds :guilabel:`On -> Prolong`. +#. The LED stays at :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` for three seconds :guilabel:`Prolong`. +#. The LED fades from :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` to 0% over five seconds :guilabel:`Prolong -> Standby`. -The default value of :option:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` is 10000 (~15%). +The default value of :kconfig:`CONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG` is 10000 (~15%). -.. figure:: /images/bt_mesh_light_ctrl_levels.svg +.. figure:: images/bt_mesh_light_ctrl_levels.svg :alt: Light level transitions over time Light level transitions over time diff --git a/samples/bluetooth/mesh/light_ctrl/images/bt_mesh_light_ctrl_levels.svg b/samples/bluetooth/mesh/light_ctrl/images/bt_mesh_light_ctrl_levels.svg new file mode 100644 index 000000000000..385eb439bc33 --- /dev/null +++ b/samples/bluetooth/mesh/light_ctrl/images/bt_mesh_light_ctrl_levels.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Page-1 + + + + Dynamic connector.79 + + + + Dynamic connector.80 + + + + Dynamic connector.81 + + + + Dynamic connector.82 + + + + Dynamic connector.83 + + + + Dynamic connector.84 + + + + Dynamic connector + + + + Dynamic connector.70 + + + + Dynamic connector.71 + + + + Multi-Line + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sheet.66 + On level + + + + On level + + Sheet.67 + Standby level + + + + Standby level + + Sheet.68 + Prolong level + + + + Prolong level + + Nordic Sky + Standby + + + + Standby + + Nordic Sky.87 + On + + + + On + + Nordic Sky.88 + Prolong + + + + Prolong + + Nordic Sky.89 + Standby + + + + Standby + + Signal + Fade on + + + + + Fade on + + Signal.91 + On + + + + + On + + Signal.92 + Fade Prolong + + + + + Fade Prolong + + Signal.93 + Fade Standby + + + + + Fade Standby + + Signal.94 + Prolong + + + + + Prolong + + diff --git a/samples/bluetooth/mesh/light_ctrl/images/bt_mesh_light_ctrl_levels.vsdx b/samples/bluetooth/mesh/light_ctrl/images/bt_mesh_light_ctrl_levels.vsdx new file mode 100644 index 000000000000..4b01de202fd1 Binary files /dev/null and b/samples/bluetooth/mesh/light_ctrl/images/bt_mesh_light_ctrl_levels.vsdx differ diff --git a/samples/bluetooth/mesh/light_switch/README.rst b/samples/bluetooth/mesh/light_switch/README.rst index 0a53d8e42d25..ac4e6b5443ce 100644 --- a/samples/bluetooth/mesh/light_switch/README.rst +++ b/samples/bluetooth/mesh/light_switch/README.rst @@ -8,7 +8,7 @@ Bluetooth: Mesh light switch :depth: 2 The :ref:`ug_bt_mesh` light switch sample can be used to change the state of light sources on other devices within the same mesh network. -It also demonstrates how to use Bluetooth mesh models by using the Generic OnOff Client model in an application. +It also demonstrates how to use Bluetooth® mesh models by using the Generic OnOff Client model in an application. Use the light switch sample with the :ref:`bluetooth_mesh_light` sample to demonstrate its function in a Bluetooth mesh network. diff --git a/samples/bluetooth/mesh/light_switch/boards/thingy53_nrf5340_cpuapp.conf b/samples/bluetooth/mesh/light_switch/boards/thingy53_nrf5340_cpuapp.conf index c02b6f41df48..43ebf1b4f37a 100644 --- a/samples/bluetooth/mesh/light_switch/boards/thingy53_nrf5340_cpuapp.conf +++ b/samples/bluetooth/mesh/light_switch/boards/thingy53_nrf5340_cpuapp.conf @@ -55,7 +55,7 @@ CONFIG_PM_EXTERNAL_FLASH_SIZE=0x800000 CONFIG_USB=y CONFIG_USB_DEVICE_STACK=y -CONFIG_USB_DEVICE_PRODUCT="Application Thingy:53" +CONFIG_USB_DEVICE_PRODUCT="Thingy:53 Application" CONFIG_USB_DEVICE_VID=0x1915 CONFIG_USB_DEVICE_PID=0x530C CONFIG_USB_CDC_ACM=y diff --git a/samples/bluetooth/mesh/light_switch/sample.yaml b/samples/bluetooth/mesh/light_switch/sample.yaml index c716f20d7e5b..0eb589165d44 100644 --- a/samples/bluetooth/mesh/light_switch/sample.yaml +++ b/samples/bluetooth/mesh/light_switch/sample.yaml @@ -5,12 +5,12 @@ tests: samples.bluetooth.mesh.light_switch: build_only: true platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns thingy53_nrf5340_cpuapp + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns thingy53_nrf5340_cpuapp tags: bluetooth ci_build integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf51dk_nrf51422 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - thingy53_nrf5340_cpuapp diff --git a/samples/bluetooth/mesh/sensor_client/README.rst b/samples/bluetooth/mesh/sensor_client/README.rst index de6d6012a629..e746c435220a 100644 --- a/samples/bluetooth/mesh/sensor_client/README.rst +++ b/samples/bluetooth/mesh/sensor_client/README.rst @@ -7,7 +7,7 @@ Bluetooth: Mesh sensor observer :local: :depth: 2 -The Bluetooth mesh sensor observer sample demonstrates how to set up a basic Bluetooth mesh :ref:`bt_mesh_sensor_cli_readme` model application that gets sensor data from one :ref:`bt_mesh_sensor_srv_readme` model. +The Bluetooth® mesh sensor observer sample demonstrates how to set up a basic Bluetooth mesh :ref:`bt_mesh_sensor_cli_readme` model application that gets sensor data from one :ref:`bt_mesh_sensor_srv_readme` model. Four different sensor types are used to showcase different ways for the server to publish data. In addition, the samples demonstrate usage of both :ref:`single-channel sensor types and sensor series types `. diff --git a/samples/bluetooth/mesh/sensor_server/README.rst b/samples/bluetooth/mesh/sensor_server/README.rst index 228b3ed73461..8171576ecb7b 100644 --- a/samples/bluetooth/mesh/sensor_server/README.rst +++ b/samples/bluetooth/mesh/sensor_server/README.rst @@ -7,7 +7,7 @@ Bluetooth: Mesh sensor :local: :depth: 2 -The Bluetooth mesh sensor sample demonstrates how to set up a basic mesh Sensor Server model application that provides sensor data to one :ref:`bt_mesh_sensor_cli_readme` model. +The Bluetooth® mesh sensor sample demonstrates how to set up a basic mesh Sensor Server model application that provides sensor data to one :ref:`bt_mesh_sensor_cli_readme` model. Four different sensor types are used to showcase different ways for the server to publish data. In addition, the sample demonstrates usage of both :ref:`single-channel sensor types and sensor series types `. diff --git a/samples/bluetooth/mesh/silvair_enocean/README.rst b/samples/bluetooth/mesh/silvair_enocean/README.rst index 62f9f8be7fbf..10ff0d211256 100644 --- a/samples/bluetooth/mesh/silvair_enocean/README.rst +++ b/samples/bluetooth/mesh/silvair_enocean/README.rst @@ -8,7 +8,7 @@ Bluetooth: Mesh Silvair EnOcean :depth: 2 The :ref:`ug_bt_mesh` Silvair EnOcean sample can be used to change the state of light sources on other devices within the same mesh network. -It also demonstrates how to use Bluetooth mesh models by using the Silvair EnOcean Proxy Server model in an application. +It also demonstrates how to use Bluetooth® mesh models by using the Silvair EnOcean Proxy Server model in an application. Use the Silvair EnOcean sample with the :ref:`bluetooth_mesh_light_lc` sample to demonstrate its function in a Bluetooth mesh network. diff --git a/samples/bluetooth/mesh/silvair_enocean/sample.yaml b/samples/bluetooth/mesh/silvair_enocean/sample.yaml index db483330d304..400e9d717599 100644 --- a/samples/bluetooth/mesh/silvair_enocean/sample.yaml +++ b/samples/bluetooth/mesh/silvair_enocean/sample.yaml @@ -6,10 +6,10 @@ tests: build_only: true build_on_all: false platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build integration_platforms: - rf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns diff --git a/samples/bluetooth/peripheral_ancs_client/README.rst b/samples/bluetooth/peripheral_ancs_client/README.rst index d18549cc494c..f0f2a5689310 100644 --- a/samples/bluetooth/peripheral_ancs_client/README.rst +++ b/samples/bluetooth/peripheral_ancs_client/README.rst @@ -32,7 +32,7 @@ The sample supports the following development kits: :header: heading :rows: nrf5340dk_nrf5340_cpuapp_and_cpuappns, nrf52840dk_nrf52840, nrf52833dk_nrf52833, nrf52dk_nrf52832 -The sample also requires a device running an ANCS Server to connect with (for example, an iPhone which runs iOS, or a Bluetooth Low Energy dongle and nRF Connect for Desktop). +The sample also requires a device running an ANCS Server to connect with (for example, an iPhone which runs iOS, or a Bluetooth® Low Energy dongle and nRF Connect for Desktop). User interface ************** diff --git a/samples/bluetooth/peripheral_ancs_client/sample.yaml b/samples/bluetooth/peripheral_ancs_client/sample.yaml index 1947af176589..003635251eca 100644 --- a/samples/bluetooth/peripheral_ancs_client/sample.yaml +++ b/samples/bluetooth/peripheral_ancs_client/sample.yaml @@ -4,10 +4,10 @@ sample: tests: samples.bluetooth.peripheral_ancs_client.build: build_only: true - platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/peripheral_bms/README.rst b/samples/bluetooth/peripheral_bms/README.rst index 6e935f461e9b..f770b4fea8c8 100644 --- a/samples/bluetooth/peripheral_bms/README.rst +++ b/samples/bluetooth/peripheral_bms/README.rst @@ -25,7 +25,7 @@ The sample supports the following development kits: :header: heading :rows: nrf5340dk_nrf5340_cpuapp_and_cpuappns, nrf52840dk_nrf52840, nrf52dk_nrf52832, nrf52dk_nrf52810 -The sample also requires a Bluetooth Low Energy dongle and nRF Connect for Desktop. +The sample also requires a Bluetooth® Low Energy dongle and nRF Connect for Desktop. User interface ************** diff --git a/samples/bluetooth/peripheral_cts_client/README.rst b/samples/bluetooth/peripheral_cts_client/README.rst index 8199bc412731..9f054273bd06 100644 --- a/samples/bluetooth/peripheral_cts_client/README.rst +++ b/samples/bluetooth/peripheral_cts_client/README.rst @@ -23,7 +23,7 @@ The sample supports the following development kits: :header: heading :rows: nrf5340dk_nrf5340_cpuapp_and_cpuappns, nrf52840dk_nrf52840, nrf52833dk_nrf52833, nrf52dk_nrf52832 -The sample also requires a device running a CTS Server to connect with (for example, a Bluetooth Low Energy dongle and nRF Connect for Desktop) +The sample also requires a device running a CTS Server to connect with (for example, a Bluetooth® Low Energy dongle and nRF Connect for Desktop). User interface ************** diff --git a/samples/bluetooth/peripheral_cts_client/sample.yaml b/samples/bluetooth/peripheral_cts_client/sample.yaml index 50909f393cac..4d3838aebeae 100644 --- a/samples/bluetooth/peripheral_cts_client/sample.yaml +++ b/samples/bluetooth/peripheral_cts_client/sample.yaml @@ -4,10 +4,10 @@ sample: tests: samples.bluetooth.peripheral_cts_client.build: build_only: true - platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/peripheral_gatt_dm/sample.yaml b/samples/bluetooth/peripheral_gatt_dm/sample.yaml index 64085e8f62f2..169f83e7221d 100644 --- a/samples/bluetooth/peripheral_gatt_dm/sample.yaml +++ b/samples/bluetooth/peripheral_gatt_dm/sample.yaml @@ -5,11 +5,11 @@ tests: samples.bluetooth.peripheral_gatt_dm: build_only: true platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/peripheral_hids_keyboard/README.rst b/samples/bluetooth/peripheral_hids_keyboard/README.rst index f6cc55e331b7..0969dbcfe452 100644 --- a/samples/bluetooth/peripheral_hids_keyboard/README.rst +++ b/samples/bluetooth/peripheral_hids_keyboard/README.rst @@ -95,7 +95,7 @@ After programming the sample to your development kit, you can test it either by Testing with a Microsoft Windows computer ----------------------------------------- -To test with a Microsoft Windows computer that has a Bluetooth radio, complete the following steps: +To test with a Microsoft Windows computer that has a Bluetooth® radio, complete the following steps: 1. Power on your development kit. #. Press **Button 4** on the kit if the device is not advertising. diff --git a/samples/bluetooth/peripheral_hids_keyboard/sample.yaml b/samples/bluetooth/peripheral_hids_keyboard/sample.yaml index 060773337426..2162bf32791d 100644 --- a/samples/bluetooth/peripheral_hids_keyboard/sample.yaml +++ b/samples/bluetooth/peripheral_hids_keyboard/sample.yaml @@ -12,10 +12,10 @@ tests: samples.bluetooth.peripheral_hids_keyboard.build: build_only: true platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/peripheral_hids_mouse/README.rst b/samples/bluetooth/peripheral_hids_mouse/README.rst index a701fc585c20..988448c5f986 100644 --- a/samples/bluetooth/peripheral_hids_mouse/README.rst +++ b/samples/bluetooth/peripheral_hids_mouse/README.rst @@ -21,7 +21,7 @@ This sample exposes the HID GATT Service. It uses a report map for a generic mouse. You can also disable directed advertising feature by clearing the BT_DIRECTED_ADVERTISING flag in the application configuration. -This feature is enabled by default and it changes the way in which advertising works in comparison to the other Bluetooth LE samples. +This feature is enabled by default and it changes the way in which advertising works in comparison to the other Bluetooth® Low Energy samples. When the device wants to advertise, it starts with high duty cycle directed advertising provided that it has bonding information. If the timeout occurs, then the device starts directed advertising to the next bonded peer. If all bonding information is used and there is still no connection, then the regular advertising starts. diff --git a/samples/bluetooth/peripheral_hids_mouse/sample.yaml b/samples/bluetooth/peripheral_hids_mouse/sample.yaml index a73b7a50054f..f64969757284 100644 --- a/samples/bluetooth/peripheral_hids_mouse/sample.yaml +++ b/samples/bluetooth/peripheral_hids_mouse/sample.yaml @@ -13,11 +13,11 @@ tests: samples.bluetooth.peripheral_hids_mouse.build: build_only: true platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/peripheral_hr_coded/README.rst b/samples/bluetooth/peripheral_hr_coded/README.rst index 9acec3bd75ad..087e1f04eb89 100644 --- a/samples/bluetooth/peripheral_hr_coded/README.rst +++ b/samples/bluetooth/peripheral_hr_coded/README.rst @@ -13,7 +13,7 @@ However, this sample supports LE Coded PHY. Overview ******** -The sample demonstrates a basic Bluetooth LE Peripheral role functionality that exposes the Heart Rate GATT Service with LE Coded PHY support which not available in Zephyr Bluetooth LE Controller (See :ref:`ug_ble_controller` for more information). +The sample demonstrates a basic Bluetooth® Low Energy Peripheral role functionality that exposes the Heart Rate GATT Service with LE Coded PHY support, which is not available in Zephyr Bluetooth LE Controller (See :ref:`ug_ble_controller` for more information). Once it connects to a Central device, it generates dummy heart rate values. It can be used together with the :ref:`bluetooth_central_hr_coded` sample. diff --git a/samples/bluetooth/peripheral_lbs/README.rst b/samples/bluetooth/peripheral_lbs/README.rst index ccae5000d605..81045d1c6a5e 100644 --- a/samples/bluetooth/peripheral_lbs/README.rst +++ b/samples/bluetooth/peripheral_lbs/README.rst @@ -27,7 +27,7 @@ The sample supports the following development kits: :rows: nrf5340dk_nrf5340_cpuapp_and_cpuappns, nrf52840dk_nrf52840, nrf52840dk_nrf52811, nrf52833dk_nrf52833, nrf52833dk_nrf52820, nrf52dk_nrf52832, nrf52dk_nrf52810, nrf52840dongle_nrf52840, thingy53_nrf5340_cpuapp .. note:: - When used with :ref:`zephyr:thingy53_nrf5340`, the sample supports the MCUboot bootloader with serial recovery and SMP DFU over Bluetooth. + When used with :ref:`zephyr:thingy53_nrf5340`, the sample supports the MCUboot bootloader with serial recovery and SMP DFU over Bluetooth®. Debug logs are provided over the USB CDC ACM class serial port. The sample also requires a smartphone or tablet running a compatible application. diff --git a/samples/bluetooth/peripheral_lbs/boards/thingy53_nrf5340_cpuapp.conf b/samples/bluetooth/peripheral_lbs/boards/thingy53_nrf5340_cpuapp.conf index 996de735be47..67f6f28815e7 100644 --- a/samples/bluetooth/peripheral_lbs/boards/thingy53_nrf5340_cpuapp.conf +++ b/samples/bluetooth/peripheral_lbs/boards/thingy53_nrf5340_cpuapp.conf @@ -54,7 +54,7 @@ CONFIG_PM_EXTERNAL_FLASH_SIZE=0x800000 CONFIG_USB=y CONFIG_USB_DEVICE_STACK=y -CONFIG_USB_DEVICE_PRODUCT="Application Thingy:53" +CONFIG_USB_DEVICE_PRODUCT="Thingy:53 Application" CONFIG_USB_DEVICE_VID=0x1915 CONFIG_USB_DEVICE_PID=0x530C CONFIG_USB_CDC_ACM=y diff --git a/samples/bluetooth/peripheral_lbs/sample.yaml b/samples/bluetooth/peripheral_lbs/sample.yaml index 916def56855b..abca8f434e66 100644 --- a/samples/bluetooth/peripheral_lbs/sample.yaml +++ b/samples/bluetooth/peripheral_lbs/sample.yaml @@ -4,16 +4,16 @@ sample: tests: samples.bluetooth.peripheral_lbs: build_only: true - platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns thingy53_nrf5340_cpuapp integration_platforms: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - thingy53_nrf5340_cpuapp tags: bluetooth ci_build + platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf52dk_nrf52810 + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns thingy53_nrf5340_cpuapp samples.bluetooth.peripheral_lbs_minimal: extra_args: OVERLAY_CONFIG=prj_minimal.conf build_only: true diff --git a/samples/bluetooth/peripheral_nfc_pairing/README.rst b/samples/bluetooth/peripheral_nfc_pairing/README.rst index b2256024a06a..eecb6d0de453 100644 --- a/samples/bluetooth/peripheral_nfc_pairing/README.rst +++ b/samples/bluetooth/peripheral_nfc_pairing/README.rst @@ -7,7 +7,7 @@ Bluetooth: NFC pairing :local: :depth: 2 -The NFC pairing sample demonstrates Bluetooth LE out-of-band pairing using an NFC tag and the NFC TNEP protocol. +The NFC pairing sample demonstrates Bluetooth® LE out-of-band pairing using an NFC tag and the NFC TNEP protocol. You can use it to test the touch-to-pair feature between Nordic Semiconductor's devices and an NFC polling device with Bluetooth LE support, for example, a mobile phone. The sample shows the usage of NFC NDEF :ref:`nfc_ch` and :ref:`tnep_tag_readme` with the :ref:`Connection Handover service`. @@ -43,7 +43,7 @@ Static Handover A tag in the Static Handover mode, contains a Handover Select Message with carrier information NDEF records or a single Carrier Configuration Record. -.. figure:: /images/nfc_static_connection_handover.svg +.. figure:: images/nfc_static_connection_handover.svg :alt: Static Handover Negotiated Handover @@ -59,7 +59,7 @@ This sample can be configured to take the Connection Handover Selector role or t The Connection Handover Selector role is default for this sample. You can change the default role by choosing ``CONFIG_NFC_TAG_CH_SELECTOR`` or ``CONFIG_NFC_TAG_CH_REQUESTER``. -.. figure:: /images/nfc_negotiated_connection_handover.svg +.. figure:: images/nfc_negotiated_connection_handover.svg :alt: Negotiated Handover diff --git a/samples/bluetooth/peripheral_nfc_pairing/images/nfc_negotiated_connection_handover.svg b/samples/bluetooth/peripheral_nfc_pairing/images/nfc_negotiated_connection_handover.svg new file mode 100644 index 000000000000..7ca6275a48d2 --- /dev/null +++ b/samples/bluetooth/peripheral_nfc_pairing/images/nfc_negotiated_connection_handover.svg @@ -0,0 +1,591 @@ + + + + + + + + Page-1 + + Sheet.134 + + id3 + + Sheet.4 + + + + Sheet.5 + + + + Sheet.6 + + + + + id4 + + Sheet.8 + + + + Sheet.9 + + + + Sheet.10 + + + + + id5 + + Sheet.12 + + + + Sheet.13 + NFC Forum Tag + + NFC Forum Tag + + + id6 + + Sheet.15 + + + + Sheet.16 + + + + + Sheet.17 + + + + + id7 + + Sheet.19 + + + + Sheet.20 + + + + Sheet.21 + + + + + id8 + + Sheet.23 + + + + Sheet.24 + NFC Poller Device + + NFC Poller Device + + + id9 + + Sheet.26 + + + + Sheet.27 + + + + Sheet.28 + + + + Sheet.29 + Alternative Carrier (Bluetooth LE) + + Alternative Carrier (Bluetooth LE) + + + id10 + + Sheet.31 + + + + Sheet.32 + + + + Sheet.33 + + + + Sheet.34 + Alternative Carrier (Bluetooth LE) + + Alternative Carrier (Bluetooth LE) + + + id11 + + Sheet.36 + + + + Sheet.37 + + + + + Sheet.38 + + + + + Sheet.39 + + + + + Sheet.40 + + + + + Sheet.41 + + + + + Sheet.42 + + + + + Sheet.43 + + + + + Sheet.44 + + + + + Sheet.45 + + + + + Sheet.46 + + + + + Sheet.47 + + + + + Sheet.48 + + + + + Sheet.49 + + + + + Sheet.50 + + + + + Sheet.51 + + + + + Sheet.52 + + + + + Sheet.53 + + + + + Sheet.54 + + + + + Sheet.55 + + + + + Sheet.56 + + + + + Sheet.57 + + + + + Sheet.58 + + + + + Sheet.59 + + + + + Sheet.60 + + + + + Sheet.61 + + + + + Sheet.62 + + + + + Sheet.63 + + + + + Sheet.64 + + + + + Sheet.65 + + + + + Sheet.66 + + + + + Sheet.67 + + + + + Sheet.68 + + + + + Sheet.69 + + + + + Sheet.70 + + + + + Sheet.71 + + + + + Sheet.72 + + + + + Sheet.73 + + + + + Sheet.74 + + + + + Sheet.75 + + + + + Sheet.76 + + + + + Sheet.77 + + + + + Sheet.78 + + + + + Sheet.79 + + + + + Sheet.80 + + + + + Sheet.81 + + + + + Sheet.82 + + + + + Sheet.83 + + + + + Sheet.84 + + + + + Sheet.85 + + + + + Sheet.86 + + + + + Sheet.87 + + + + + Sheet.88 + + + + + Sheet.89 + + + + + Sheet.90 + + + + + Sheet.91 + + + + + Sheet.92 + + + + + Sheet.93 + + + + + Sheet.94 + + + + + Sheet.95 + + + + + Sheet.96 + + + + + Sheet.97 + + + + + Sheet.98 + + + + + Sheet.99 + + + + Sheet.100 + + + + + id12 + + Sheet.102 + + + + Sheet.103 + Handover Select (Bluetooth LE, OOB data) + + Handover Select (Bluetooth LE, OOB data) + + + id13 + + Sheet.105 + + + + Sheet.106 + Data exchange over Bluetooth LE + + Data exchange over Bluetooth LE + + + id14 + + Sheet.108 + + + + Sheet.109 + + + + Sheet.110 + + + + + id15 + + Sheet.112 + + + + Sheet.113 + TNEP + + TNEP + + + id16 + + Sheet.115 + + + + Sheet.116 + + + + Sheet.117 + + + + + id17 + + Sheet.119 + + + + Sheet.120 + TNEP + + TNEP + + + id18 + + Sheet.122 + + + + Sheet.123 + + + + + Sheet.124 + + + + + id19 + + Sheet.126 + + + + Sheet.127 + Handover Request (Bluetooth LE, OOB data) + + Handover Request (Bluetooth LE, OOB data) + + + + diff --git a/samples/bluetooth/peripheral_nfc_pairing/images/nfc_negotiated_connection_handover.vsdx b/samples/bluetooth/peripheral_nfc_pairing/images/nfc_negotiated_connection_handover.vsdx new file mode 100644 index 000000000000..7c349a189d2c Binary files /dev/null and b/samples/bluetooth/peripheral_nfc_pairing/images/nfc_negotiated_connection_handover.vsdx differ diff --git a/samples/bluetooth/peripheral_nfc_pairing/images/nfc_static_connection_handover.svg b/samples/bluetooth/peripheral_nfc_pairing/images/nfc_static_connection_handover.svg new file mode 100644 index 000000000000..ecae89f2170c --- /dev/null +++ b/samples/bluetooth/peripheral_nfc_pairing/images/nfc_static_connection_handover.svg @@ -0,0 +1,508 @@ + + + + + + + + Page-1 + + Sheet.116 + + id3 + + Sheet.4 + + + + Sheet.5 + + + + Sheet.6 + + + + + id4 + + Sheet.8 + + + + Sheet.9 + + + + Sheet.10 + + + + + id5 + + Sheet.12 + + + + Sheet.13 + NFC Forum Tag + + NFC Forum Tag + + + id6 + + Sheet.15 + + + + Sheet.16 + + + + + Sheet.17 + + + + + id7 + + Sheet.19 + + + + Sheet.20 + + + + Sheet.21 + + + + + id8 + + Sheet.23 + + + + Sheet.24 + NFC Poller Device + + NFC Poller Device + + + id9 + + Sheet.26 + + + + Sheet.27 + + + + Sheet.28 + + + + Sheet.29 + Alternative Carrier (Bluetooth LE) + + Alternative Carrier (Bluetooth LE) + + + id11 + + Sheet.36 + + + + Sheet.37 + + + + + Sheet.38 + + + + + Sheet.39 + + + + + Sheet.40 + + + + + Sheet.41 + + + + + Sheet.42 + + + + + Sheet.43 + + + + + Sheet.44 + + + + + Sheet.45 + + + + + Sheet.46 + + + + + Sheet.47 + + + + + Sheet.48 + + + + + Sheet.49 + + + + + Sheet.50 + + + + + Sheet.51 + + + + + Sheet.52 + + + + + Sheet.53 + + + + + Sheet.54 + + + + + Sheet.55 + + + + + Sheet.56 + + + + + Sheet.57 + + + + + Sheet.58 + + + + + Sheet.59 + + + + + Sheet.60 + + + + + Sheet.61 + + + + + Sheet.62 + + + + + Sheet.63 + + + + + Sheet.64 + + + + + Sheet.65 + + + + + Sheet.66 + + + + + Sheet.67 + + + + + Sheet.68 + + + + + Sheet.69 + + + + + Sheet.70 + + + + + Sheet.71 + + + + + Sheet.72 + + + + + Sheet.73 + + + + + Sheet.74 + + + + + Sheet.75 + + + + + Sheet.76 + + + + + Sheet.77 + + + + + Sheet.78 + + + + + Sheet.79 + + + + + Sheet.80 + + + + + Sheet.81 + + + + + Sheet.82 + + + + + Sheet.83 + + + + + Sheet.84 + + + + + Sheet.85 + + + + + Sheet.86 + + + + + Sheet.87 + + + + + Sheet.88 + + + + + Sheet.89 + + + + + Sheet.90 + + + + + Sheet.91 + + + + + Sheet.92 + + + + + Sheet.93 + + + + + Sheet.94 + + + + + Sheet.95 + + + + + Sheet.96 + + + + + Sheet.97 + + + + + Sheet.98 + + + + + Sheet.99 + + + + Sheet.100 + + + + + id12 + + Sheet.102 + + + + Sheet.103 + Handover Select (Bluetooth LE, OOB data) + + Handover Select (Bluetooth LE, OOB data) + + + id13 + + Sheet.105 + + + + Sheet.106 + Data exchange over Bluetooth LE + + Data exchange over Bluetooth LE + + + id9.109 + + Sheet.110 + + + + Sheet.111 + + + + Sheet.112 + + + + Sheet.113 + Alternative Carrier (Bluetooth LE) + + Alternative Carrier (Bluetooth LE) + + + + diff --git a/samples/bluetooth/peripheral_nfc_pairing/images/nfc_static_connection_handover.vsdx b/samples/bluetooth/peripheral_nfc_pairing/images/nfc_static_connection_handover.vsdx new file mode 100644 index 000000000000..ec103c41da34 Binary files /dev/null and b/samples/bluetooth/peripheral_nfc_pairing/images/nfc_static_connection_handover.vsdx differ diff --git a/samples/bluetooth/peripheral_nfc_pairing/sample.yaml b/samples/bluetooth/peripheral_nfc_pairing/sample.yaml index 5d1422be1983..a35fa765e178 100644 --- a/samples/bluetooth/peripheral_nfc_pairing/sample.yaml +++ b/samples/bluetooth/peripheral_nfc_pairing/sample.yaml @@ -4,10 +4,10 @@ sample: tests: samples.bluetooth.peripheral_nfc_pairing: build_only: true - platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf52840dk_nrf52840 - nrf52dk_nrf52832 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/peripheral_uart/README.rst b/samples/bluetooth/peripheral_uart/README.rst index 84a08234d0d0..efac416771f0 100644 --- a/samples/bluetooth/peripheral_uart/README.rst +++ b/samples/bluetooth/peripheral_uart/README.rst @@ -8,7 +8,7 @@ Bluetooth: Peripheral UART :depth: 2 The Peripheral UART sample demonstrates how to use the :ref:`nus_service_readme`. -It uses the NUS service to send data back and forth between a UART connection and a Bluetooth LE connection, emulating a serial port over Bluetooth LE. +It uses the NUS service to send data back and forth between a UART connection and a Bluetooth® LE connection, emulating a serial port over Bluetooth LE. Overview ******** @@ -117,7 +117,7 @@ After programming the sample to your development kit, test it by performing the #. |connect_terminal| #. Optionally, you can display debug messages. See :ref:`peripheral_uart_debug` for details. #. Reset the kit. -#. Observe that **LED 1** is blinking and that the device is advertising with the device name that is configured in :option:`CONFIG_BT_DEVICE_NAME`. +#. Observe that **LED 1** is blinking and that the device is advertising with the device name that is configured in :kconfig:`CONFIG_BT_DEVICE_NAME`. #. Observe that the text "Starting Nordic UART service example" is printed on the COM listener running on the computer. #. Connect to the device using nRF Connect for Mobile. Observe that **LED 2** is on. diff --git a/samples/bluetooth/peripheral_uart/boards/thingy53_nrf5340_cpuapp.conf b/samples/bluetooth/peripheral_uart/boards/thingy53_nrf5340_cpuapp.conf index 522baf021532..a11ce849cdf5 100644 --- a/samples/bluetooth/peripheral_uart/boards/thingy53_nrf5340_cpuapp.conf +++ b/samples/bluetooth/peripheral_uart/boards/thingy53_nrf5340_cpuapp.conf @@ -45,9 +45,9 @@ CONFIG_PM_EXTERNAL_FLASH_SIZE=0x800000 CONFIG_USB=y CONFIG_USB_DEVICE_STACK=y -CONFIG_USB_DEVICE_PRODUCT="Application Thingy:53" +CONFIG_USB_DEVICE_PRODUCT="Thingy:53 Nordic UART Service sample" CONFIG_USB_DEVICE_VID=0x1915 -CONFIG_USB_DEVICE_PID=0x530C +CONFIG_USB_DEVICE_PID=0x530E CONFIG_USB_CDC_ACM=y # Use CDC_ACM0 for logs, CDC_ACM1 has application-specific usage diff --git a/samples/bluetooth/peripheral_uart/sample.yaml b/samples/bluetooth/peripheral_uart/sample.yaml index ec5b068d8767..4b8e0afa0eb9 100644 --- a/samples/bluetooth/peripheral_uart/sample.yaml +++ b/samples/bluetooth/peripheral_uart/sample.yaml @@ -5,13 +5,13 @@ tests: samples.bluetooth.peripheral_uart: build_only: true platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns thingy53_nrf5340_cpuapp + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns thingy53_nrf5340_cpuapp integration_platforms: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - thingy53_nrf5340_cpuapp tags: bluetooth ci_build samples.bluetooth.peripheral_uart_minimal: diff --git a/samples/bluetooth/rpc_host/README.rst b/samples/bluetooth/rpc_host/README.rst index 6f758a0912c4..b032ac79b446 100644 --- a/samples/bluetooth/rpc_host/README.rst +++ b/samples/bluetooth/rpc_host/README.rst @@ -3,7 +3,7 @@ Bluetooth: Host for nRF RPC Bluetooth Low Energy ################################################ -The nRF RPC Host sample demonstrates the Bluetooth Low Energy (LE) stack with the :ref:`nrfxlib:nrf_rpc` library, which exposes the stack's interface to another device or CPU using `Remote Procedure Calls (RPC)`_. +The nRF RPC Host sample demonstrates the Bluetooth® Low Energy (LE) stack with the :ref:`nrfxlib:nrf_rpc` library, which exposes the stack's interface to another device or CPU using `Remote Procedure Calls (RPC)`_. On an nRF53 device, this sample is supposed to run on the network core and it provides the Bluetooth LE functionality for the application core. Overview @@ -55,11 +55,11 @@ Example build ============= The recommended way of building the nRF RPC Host sample is to use the multi-image feature of the build system, building the sample with the same Bluetooth configuration as the application core sample. -In this way, the sample is built automatically as a child image when :option:`CONFIG_BT_RPC` is enabled. +In this way, the sample is built automatically as a child image when :kconfig:`CONFIG_BT_RPC` is enabled. See :ref:`configure_application` for information about how to configure a sample. -For example, building the :ref:`zephyr:bluetooth-beacon-sample` sample for the nRF5340 application core with the :option:`CONFIG_BT_RPC` configuration option will include the nRF RPC Host sample in the build. +For example, building the :ref:`zephyr:bluetooth-beacon-sample` sample for the nRF5340 application core with the :kconfig:`CONFIG_BT_RPC` configuration option will include the nRF RPC Host sample in the build. To do so on the command line, run the following command in the beacon sample directory: diff --git a/samples/bluetooth/shell_bt_nus/README.rst b/samples/bluetooth/shell_bt_nus/README.rst index ba813f04e93f..42ff771c864f 100644 --- a/samples/bluetooth/shell_bt_nus/README.rst +++ b/samples/bluetooth/shell_bt_nus/README.rst @@ -7,7 +7,7 @@ Bluetooth: NUS shell transport :local: :depth: 2 -The Nordic UART Service (NUS) shell transport sample demonstrates how to use the :ref:`shell_bt_nus_readme` to receive shell commands from a remote device. +The Nordic UART Service (NUS) shell transport sample demonstrates how to use the :ref:`shell_bt_nus_readme` to receive shell commands from a remote device over Bluetooth®. Overview ******** @@ -46,7 +46,7 @@ The |NCS| provides two alternatives for testing the sample: Testing using shell_bt_nus ========================== -.. include:: ../../../include/shell/shell_bt_nus.rst +.. include:: ../../../doc/nrf/libraries/shell/shell_bt_nus.rst :start-after: testing_bt_nus_shell_intro_start :end-before: testing_bt_nus_shell_intro_end diff --git a/samples/bluetooth/shell_bt_nus/sample.yaml b/samples/bluetooth/shell_bt_nus/sample.yaml index 78bc6d12a245..072cbde71704 100644 --- a/samples/bluetooth/shell_bt_nus/sample.yaml +++ b/samples/bluetooth/shell_bt_nus/sample.yaml @@ -5,11 +5,11 @@ tests: samples.bluetooth.shell_bt_nus: build_only: true platform_allow: nrf51dk_nrf51422 nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bluetooth/throughput/README.rst b/samples/bluetooth/throughput/README.rst index 9fbe665baaa1..aeeaf08d94ae 100644 --- a/samples/bluetooth/throughput/README.rst +++ b/samples/bluetooth/throughput/README.rst @@ -10,7 +10,7 @@ Bluetooth: Throughput .. note:: The implementation and usage of this sample has changed considerably with |NCS| v1.5.0. -The Bluetooth Throughput sample uses the :ref:`throughput_readme` to measure *Bluetooth* Low Energy throughput performance. +The Bluetooth® Throughput sample uses the :ref:`throughput_readme` to measure Bluetooth® Low Energy throughput performance. You can use it to determine the maximum throughput, or to experiment with different connection parameters and check their influence on the throughput. Overview @@ -39,7 +39,7 @@ Connection interval When increasing this value, more packets may be sent in one interval, but if a packet is lost, the wait until the retransmission is longer. Physical layer (PHY) data rate - Starting with Bluetooth 5, the over-the-air data rate in Bluetooth Low Energy can exceed 1 Ms/s (mega symbol per second), which allows for faster transmission. + Starting with Bluetooth® 5, the over-the-air data rate in Bluetooth Low Energy can exceed 1 Ms/s (mega symbol per second), which allows for faster transmission. In addition, it is possible to use coded PHY (available on the nRF52840 SoC only) for long-range transmission. By default, the following connection parameter values are used: diff --git a/samples/bluetooth/throughput/sample.yaml b/samples/bluetooth/throughput/sample.yaml index 52d6a0b06272..c2d28924f210 100644 --- a/samples/bluetooth/throughput/sample.yaml +++ b/samples/bluetooth/throughput/sample.yaml @@ -5,10 +5,10 @@ tests: samples.bluetooth.throughput: build_only: true platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns tags: bluetooth ci_build diff --git a/samples/bootloader/README.rst b/samples/bootloader/README.rst index 8c0cea4bc9cd..b53187953572 100644 --- a/samples/bootloader/README.rst +++ b/samples/bootloader/README.rst @@ -16,7 +16,7 @@ See :ref:`ug_bootloader` for more information about the full bootloader chain. .. note:: Currently, this immutable bootloader does not support firmware updates over the SMP transport for either an upgradable bootloader or an application. - If the application using this bootloader requires SMP-based firmware updates, such as Bluetooth LE DFU, :ref:`include MCUboot as a second-stage bootloader `. + If the application using this bootloader requires SMP-based firmware updates, such as Bluetooth® LE DFU, :ref:`include MCUboot as a second-stage bootloader `. .. _bootloader_rot: @@ -156,7 +156,7 @@ This would result, for example, in a flash memory layout like the following, whe Pre-signed variants ------------------- -When the application uses a second-stage upgradable bootloader, *S1* can be programmed with the same image as *S0* when compiled with the :option:`CONFIG_BUILD_S1_VARIANT` option. +When the application uses a second-stage upgradable bootloader, *S1* can be programmed with the same image as *S0* when compiled with the :kconfig:`CONFIG_BUILD_S1_VARIANT` option. This ensures that the upgradable bootloader can be executed from either slot chosen by the |NSIB|. When the upgradable bootloader is upgraded, the new image is placed into the slot not in use by the current version of the bootloader. @@ -201,16 +201,16 @@ Monotonic Counter Firmware versions using the |NSIB| are kept in the form of a *monotonic counter*, a hardware-based version that prevents booting an image with a lower counter value. Counter values are kept as slots in the flash memory, with each new counter value occupying a new slot. -See :option:`CONFIG_SB_MONOTONIC_COUNTER` for more details. +See :kconfig:`CONFIG_SB_MONOTONIC_COUNTER` for more details. -An application's counter value can be set by building using the :option:`CONFIG_FW_INFO_FIRMWARE_VERSION` option: +An application's counter value can be set by building using the :kconfig:`CONFIG_FW_INFO_FIRMWARE_VERSION` option: .. code-block:: CONFIG_FW_INFO_FIRMWARE_VERSION= The number of slots available for counter values depends on the type of nRF devices being used. -For default values and ranges, see :option:`CONFIG_SB_NUM_VER_COUNTER_SLOTS`. +For default values and ranges, see :kconfig:`CONFIG_SB_NUM_VER_COUNTER_SLOTS`. .. bootloader_monotonic_counter_end @@ -221,7 +221,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns, nrf5340dk_nrf5340_cpuapp_and_cpuappns, nrf52840dk_nrf52840, nrf52dk_nrf52832 + :rows: nrf9160dk_nrf9160_ns, nrf5340dk_nrf5340_cpuapp_and_cpuappns, nrf52840dk_nrf52840, nrf52dk_nrf52832 .. _bootloader_build_and_run: @@ -249,15 +249,15 @@ To add the bootloader sample as a child image to your application: #. Enable the |NSIB| by running ``menuconfig`` on your application: a. Select :guilabel:`Project` > :guilabel:`Configure nRF Connect SDK project`. - #. Go to :guilabel:`Modules` > :guilabel:`Nordic nRF Connect` > :guilabel:`Bootloader` and set :guilabel:`Use Secure Bootloader` to enable :option:`CONFIG_SECURE_BOOT`. - #. Under :guilabel:`Private key PEM file` (:option:`CONFIG_SB_SIGNING_KEY_FILE`), enter the path to the private key that you created. + #. Go to :guilabel:`Modules` > :guilabel:`Nordic nRF Connect` > :guilabel:`Bootloader` and set :guilabel:`Use Secure Bootloader` to enable :kconfig:`CONFIG_SECURE_BOOT`. + #. Under :guilabel:`Private key PEM file` (:kconfig:`CONFIG_SB_SIGNING_KEY_FILE`), enter the path to the private key that you created. If you choose to run the sample with default debug keys, you can skip this step. There are additional configuration options that you can modify, but it is not recommended to do so. The default settings are suitable for most use cases. .. note:: - If you need more flexibility with signing, or if you do not want the build system to handle your private key, choose :option:`CONFIG_SB_SIGNING_CUSTOM`, and also specify :option:`CONFIG_SB_SIGNING_COMMAND` and :option:`CONFIG_SB_SIGNING_PUBLIC_KEY`. + If you need more flexibility with signing, or if you do not want the build system to handle your private key, choose :kconfig:`CONFIG_SB_SIGNING_CUSTOM`, and also specify :kconfig:`CONFIG_SB_SIGNING_COMMAND` and :kconfig:`CONFIG_SB_SIGNING_PUBLIC_KEY`. These options allow you to define the signing command. #. Click :guilabel:`Configure`. diff --git a/samples/crypto/aes_cbc/README.rst b/samples/crypto/aes_cbc/README.rst index 31b843d3860c..d19b14ef602b 100644 --- a/samples/crypto/aes_cbc/README.rst +++ b/samples/crypto/aes_cbc/README.rst @@ -36,7 +36,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/aes_cbc/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/aes_cbc/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/aes_cbc/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/aes_cbc/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/aes_cbc/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/aes_cbc/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/aes_cbc/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/aes_cbc/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/aes_cbc/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/aes_cbc/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/aes_cbc/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/aes_cbc/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/aes_cbc/sample.yaml b/samples/crypto/aes_cbc/sample.yaml index 607df87c2572..cc1900659403 100644 --- a/samples/crypto/aes_cbc/sample.yaml +++ b/samples/crypto/aes_cbc/sample.yaml @@ -5,15 +5,15 @@ sample: tests: sample.aes_cbc: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/aes_ccm/README.rst b/samples/crypto/aes_ccm/README.rst index 00aaf2078c20..4476b233f279 100644 --- a/samples/crypto/aes_ccm/README.rst +++ b/samples/crypto/aes_ccm/README.rst @@ -37,7 +37,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/aes_ccm/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/aes_ccm/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/aes_ccm/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/aes_ccm/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/aes_ccm/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/aes_ccm/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/aes_ccm/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/aes_ccm/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/aes_ccm/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/aes_ccm/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/aes_ccm/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/aes_ccm/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/aes_ccm/sample.yaml b/samples/crypto/aes_ccm/sample.yaml index 71ee8c291e90..0dfb0bc66cf1 100644 --- a/samples/crypto/aes_ccm/sample.yaml +++ b/samples/crypto/aes_ccm/sample.yaml @@ -5,15 +5,15 @@ sample: tests: sample.aes_ccm: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/aes_ctr/README.rst b/samples/crypto/aes_ctr/README.rst index 7d592fad80e9..bac771021909 100644 --- a/samples/crypto/aes_ctr/README.rst +++ b/samples/crypto/aes_ctr/README.rst @@ -36,7 +36,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/aes_ctr/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/aes_ctr/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/aes_ctr/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/aes_ctr/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/aes_ctr/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/aes_ctr/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/aes_ctr/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/aes_ctr/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/aes_ctr/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/aes_ctr/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/aes_ctr/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/aes_ctr/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/aes_ctr/sample.yaml b/samples/crypto/aes_ctr/sample.yaml index dc65058b5f10..a919678aaec8 100644 --- a/samples/crypto/aes_ctr/sample.yaml +++ b/samples/crypto/aes_ctr/sample.yaml @@ -5,15 +5,15 @@ sample: tests: sample.aes_cbc: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/aes_gcm/README.rst b/samples/crypto/aes_gcm/README.rst index 309c8ffb1cb8..15aba0ac24e3 100644 --- a/samples/crypto/aes_gcm/README.rst +++ b/samples/crypto/aes_gcm/README.rst @@ -36,7 +36,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/aes_gcm/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/aes_gcm/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/aes_gcm/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/aes_gcm/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/aes_gcm/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/aes_gcm/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/aes_gcm/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/aes_gcm/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/aes_gcm/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/aes_gcm/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/aes_gcm/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/aes_gcm/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/aes_gcm/sample.yaml b/samples/crypto/aes_gcm/sample.yaml index fb1a98c3b25a..c1065f4b7efb 100644 --- a/samples/crypto/aes_gcm/sample.yaml +++ b/samples/crypto/aes_gcm/sample.yaml @@ -5,15 +5,15 @@ sample: tests: sample.aes_gcm: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/chachapoly/README.rst b/samples/crypto/chachapoly/README.rst index e113925cd7ec..fdfdcb22cab0 100644 --- a/samples/crypto/chachapoly/README.rst +++ b/samples/crypto/chachapoly/README.rst @@ -37,7 +37,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/chachapoly/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/chachapoly/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/chachapoly/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/chachapoly/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/chachapoly/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/chachapoly/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/chachapoly/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/chachapoly/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/chachapoly/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/chachapoly/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/chachapoly/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/chachapoly/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/chachapoly/sample.yaml b/samples/crypto/chachapoly/sample.yaml index e5049c3304a5..8fc34f071132 100644 --- a/samples/crypto/chachapoly/sample.yaml +++ b/samples/crypto/chachapoly/sample.yaml @@ -5,15 +5,15 @@ sample: tests: sample.chacha_poly: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/ecdh/README.rst b/samples/crypto/ecdh/README.rst index 4c6a0d4dd445..b6f97369d42b 100644 --- a/samples/crypto/ecdh/README.rst +++ b/samples/crypto/ecdh/README.rst @@ -32,7 +32,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/ecdh/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/ecdh/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/ecdh/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/ecdh/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/ecdh/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/ecdh/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/ecdh/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/ecdh/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/ecdh/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/ecdh/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/ecdh/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/ecdh/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/ecdh/sample.yaml b/samples/crypto/ecdh/sample.yaml index b9602c3a324f..6c0bb22c612d 100644 --- a/samples/crypto/ecdh/sample.yaml +++ b/samples/crypto/ecdh/sample.yaml @@ -6,15 +6,15 @@ sample: tests: sample.ecdh: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/ecdsa/README.rst b/samples/crypto/ecdsa/README.rst index 9439500b36a2..b4015cbdec6a 100644 --- a/samples/crypto/ecdsa/README.rst +++ b/samples/crypto/ecdsa/README.rst @@ -36,7 +36,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/ecdsa/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/ecdsa/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/ecdsa/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/ecdsa/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/ecdsa/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/ecdsa/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/ecdsa/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/ecdsa/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/ecdsa/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/ecdsa/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/ecdsa/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/ecdsa/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/ecdsa/sample.yaml b/samples/crypto/ecdsa/sample.yaml index 39aac77fd672..4ab32484fccf 100644 --- a/samples/crypto/ecdsa/sample.yaml +++ b/samples/crypto/ecdsa/sample.yaml @@ -5,15 +5,15 @@ sample: tests: sample.ecdsa: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/hkdf/README.rst b/samples/crypto/hkdf/README.rst index 66b78407ff65..a890d3834479 100644 --- a/samples/crypto/hkdf/README.rst +++ b/samples/crypto/hkdf/README.rst @@ -32,7 +32,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/hkdf/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/hkdf/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/hkdf/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/hkdf/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/hkdf/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/hkdf/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/hkdf/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/hkdf/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/hkdf/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/hkdf/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/hkdf/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/hkdf/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/hkdf/sample.yaml b/samples/crypto/hkdf/sample.yaml index 5ee267594ee3..b352ba2f98e9 100644 --- a/samples/crypto/hkdf/sample.yaml +++ b/samples/crypto/hkdf/sample.yaml @@ -4,15 +4,15 @@ sample: tests: sample.hkdf: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/hmac/README.rst b/samples/crypto/hmac/README.rst index 6084e9abf183..0e042624f68c 100644 --- a/samples/crypto/hmac/README.rst +++ b/samples/crypto/hmac/README.rst @@ -34,7 +34,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/hmac/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/hmac/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/hmac/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/hmac/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/hmac/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/hmac/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/hmac/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/hmac/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/hmac/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/hmac/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/hmac/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/hmac/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/hmac/sample.yaml b/samples/crypto/hmac/sample.yaml index ed92ceed93fb..59e0026cd6af 100644 --- a/samples/crypto/hmac/sample.yaml +++ b/samples/crypto/hmac/sample.yaml @@ -6,15 +6,15 @@ sample: tests: sample.hmac: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/persistent_key_usage/README.rst b/samples/crypto/persistent_key_usage/README.rst index 07f855030d21..edb36e879dd3 100644 --- a/samples/crypto/persistent_key_usage/README.rst +++ b/samples/crypto/persistent_key_usage/README.rst @@ -37,7 +37,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/persistent_key_usage/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/persistent_key_usage/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/persistent_key_usage/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/persistent_key_usage/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/persistent_key_usage/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/persistent_key_usage/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/persistent_key_usage/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/persistent_key_usage/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/persistent_key_usage/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/persistent_key_usage/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/persistent_key_usage/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/persistent_key_usage/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/persistent_key_usage/sample.yaml b/samples/crypto/persistent_key_usage/sample.yaml index 70d57038766e..550a7f7580b1 100644 --- a/samples/crypto/persistent_key_usage/sample.yaml +++ b/samples/crypto/persistent_key_usage/sample.yaml @@ -6,15 +6,15 @@ sample: tests: sample.aes_cbc: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/psa_tls/README.rst b/samples/crypto/psa_tls/README.rst index 5b397a325f9d..e0dcc1533d28 100644 --- a/samples/crypto/psa_tls/README.rst +++ b/samples/crypto/psa_tls/README.rst @@ -113,7 +113,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf9160dk_nrf9160ns + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf9160dk_nrf9160_ns The sample requires a `TAP adapter`_ to perform the TLS handshake. This functionality is currently only supported in Linux. diff --git a/samples/crypto/psa_tls/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/psa_tls/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/psa_tls/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/psa_tls/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/psa_tls/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/psa_tls/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/psa_tls/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/psa_tls/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/psa_tls/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/psa_tls/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/psa_tls/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/psa_tls/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/psa_tls/prj.conf b/samples/crypto/psa_tls/prj.conf index f09b73330ad0..3069de749549 100644 --- a/samples/crypto/psa_tls/prj.conf +++ b/samples/crypto/psa_tls/prj.conf @@ -50,7 +50,7 @@ CONFIG_MBEDTLS_PK_C=y CONFIG_MBEDTLS_RSA_C=y CONFIG_MBEDTLS_PKCS1_V15=y CONFIG_MBEDTLS_ENABLE_HEAP=y -CONFIG_MBEDTLS_HEAP_SIZE=65536 +CONFIG_MBEDTLS_HEAP_SIZE=56000 CONFIG_MBEDTLS_TLS_LIBRARY=y CONFIG_MBEDTLS_X509_LIBRARY=y CONFIG_NRF_SECURITY_ADVANCED=y diff --git a/samples/crypto/psa_tls/sample.yaml b/samples/crypto/psa_tls/sample.yaml index 0b21b076f07f..bf28024184dc 100644 --- a/samples/crypto/psa_tls/sample.yaml +++ b/samples/crypto/psa_tls/sample.yaml @@ -5,5 +5,5 @@ sample: tests: samples.psa_tls: build_only: true - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 tags: ci_build diff --git a/samples/crypto/rng/README.rst b/samples/crypto/rng/README.rst index d8b7c91d23f1..f4f08aa094e8 100644 --- a/samples/crypto/rng/README.rst +++ b/samples/crypto/rng/README.rst @@ -25,7 +25,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/rng/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/rng/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/rng/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/rng/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/rng/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/rng/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/rng/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/rng/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/rng/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/rng/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/rng/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/rng/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/rng/sample.yaml b/samples/crypto/rng/sample.yaml index 53a59c588e70..468cd87bd6a9 100644 --- a/samples/crypto/rng/sample.yaml +++ b/samples/crypto/rng/sample.yaml @@ -4,15 +4,15 @@ sample: tests: sample.rng: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/rsa/README.rst b/samples/crypto/rsa/README.rst index f0407054e097..4eb77d8df30f 100644 --- a/samples/crypto/rsa/README.rst +++ b/samples/crypto/rsa/README.rst @@ -36,7 +36,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/rsa/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/rsa/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/rsa/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/rsa/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/rsa/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/rsa/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/rsa/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/rsa/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/rsa/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/rsa/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/rsa/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/rsa/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/rsa/sample.yaml b/samples/crypto/rsa/sample.yaml index 6c49f1533c38..af3744473c01 100644 --- a/samples/crypto/rsa/sample.yaml +++ b/samples/crypto/rsa/sample.yaml @@ -6,15 +6,15 @@ tests: sample.rsa: skip: true tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/crypto/sha256/README.rst b/samples/crypto/sha256/README.rst index 0dfb97afc030..8174b90d222e 100644 --- a/samples/crypto/sha256/README.rst +++ b/samples/crypto/sha256/README.rst @@ -28,7 +28,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf5340dk_nrf5340_cpuapp, nrf9160dk_nrf9160_ns, nrf9160dk_nrf9160, nrf52840dk_nrf52840 .. include:: /includes/tfm.txt diff --git a/samples/crypto/sha256/boards/nrf5340dk_nrf5340_cpuappns.conf b/samples/crypto/sha256/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from samples/crypto/sha256/boards/nrf5340dk_nrf5340_cpuappns.conf rename to samples/crypto/sha256/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/samples/crypto/sha256/boards/nrf9160dk_nrf9160ns.conf b/samples/crypto/sha256/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/crypto/sha256/boards/nrf9160dk_nrf9160ns.conf rename to samples/crypto/sha256/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/crypto/sha256/boards/nrf9160dk_nrf9160ns.overlay b/samples/crypto/sha256/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/crypto/sha256/boards/nrf9160dk_nrf9160ns.overlay rename to samples/crypto/sha256/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/crypto/sha256/sample.yaml b/samples/crypto/sha256/sample.yaml index 3de49af6e995..b94912752834 100644 --- a/samples/crypto/sha256/sample.yaml +++ b/samples/crypto/sha256/sample.yaml @@ -4,15 +4,15 @@ sample: tests: sample.sha256: tags: introduction - platform_allow: nrf5340dk_nrf5340_cpuappns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf5340dk_nrf5340_cpuapp nrf9160dk_nrf9160_ns nrf9160dk_nrf9160 nrf52840dk_nrf52840 harness: console harness_config: type: multi_line regex: - ".*Example finished successfully!.*" integration_platforms: - - nrf5340dk_nrf5340_cpuappns + - nrf5340dk_nrf5340_cpuapp_ns - nrf5340dk_nrf5340_cpuapp - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns - nrf9160dk_nrf9160 - nrf52840dk_nrf52840 diff --git a/samples/debug/ppi_trace/Kconfig b/samples/debug/ppi_trace/Kconfig index 56f8b1aaaa95..e6ec1f0ae051 100644 --- a/samples/debug/ppi_trace/Kconfig +++ b/samples/debug/ppi_trace/Kconfig @@ -11,7 +11,7 @@ menu "PPI trace pins configuration" config PPI_TRACE_PIN_RTC_COMPARE_EVT int "Trace pin for RTC Compare event" - default 10 if BOARD_NRF9160DK_NRF9160 || BOARD_NRF9160DK_NRF9160NS + default 10 if BOARD_NRF9160DK_NRF9160 || BOARD_NRF9160DK_NRF9160_NS default 1 if BOARD_NRF51DK_NRF51422 default 3 help @@ -19,7 +19,7 @@ config PPI_TRACE_PIN_RTC_COMPARE_EVT config PPI_TRACE_PIN_RTC_TICK_EVT int "Trace pin for RTC Tick event" - default 11 if BOARD_NRF9160DK_NRF9160 || BOARD_NRF9160DK_NRF9160NS + default 11 if BOARD_NRF9160DK_NRF9160 || BOARD_NRF9160DK_NRF9160_NS default 2 if BOARD_NRF51DK_NRF51422 default 4 help @@ -27,7 +27,7 @@ config PPI_TRACE_PIN_RTC_TICK_EVT config PPI_TRACE_PIN_LFCLOCK_STARTED_EVT int "Trace pin for LFCLOCK Started event" - default 12 if BOARD_NRF9160DK_NRF9160 || BOARD_NRF9160DK_NRF9160NS + default 12 if BOARD_NRF9160DK_NRF9160 || BOARD_NRF9160DK_NRF9160_NS default 3 if BOARD_NRF51DK_NRF51422 default 28 help diff --git a/samples/debug/ppi_trace/README.rst b/samples/debug/ppi_trace/README.rst index dfd6a4353071..422c4c7a1bd5 100644 --- a/samples/debug/ppi_trace/README.rst +++ b/samples/debug/ppi_trace/README.rst @@ -18,7 +18,7 @@ The sample initializes trace pins to observe the following hardware events: * RTC Compare event (:c:enumerator:`NRF_RTC_EVENT_COMPARE_0`) * RTC Tick event (:c:enumerator:`NRF_RTC_EVENT_TICK`) * Low frequency clock (LFCLK) Started event (:c:enumerator:`NRF_CLOCK_EVENT_LFCLKSTARTED`) -* Radio activity during *Bluetooth* advertising (available only for Bluetooth capable devices) +* Radio activity during Bluetooth® advertising (available only for Bluetooth capable devices) The sample sets up a :ref:`zephyr:counter_api` to generate an :c:enumerator:`NRF_RTC_EVENT_COMPARE_0` event every 50 ms. Initially, RTC runs on RC low frequency (lower precision) as clock source. diff --git a/samples/edge_impulse/data_forwarder/README.rst b/samples/edge_impulse/data_forwarder/README.rst index e58c553b288d..dae2903218ac 100644 --- a/samples/edge_impulse/data_forwarder/README.rst +++ b/samples/edge_impulse/data_forwarder/README.rst @@ -17,7 +17,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns, nrf52dk_nrf52832, nrf52840dk_nrf52840 + :rows: nrf9160dk_nrf9160_ns, nrf52dk_nrf52832, nrf52840dk_nrf52840 Overview ******** diff --git a/samples/edge_impulse/data_forwarder/sample.yaml b/samples/edge_impulse/data_forwarder/sample.yaml index be954e19cafd..1076f4355516 100644 --- a/samples/edge_impulse/data_forwarder/sample.yaml +++ b/samples/edge_impulse/data_forwarder/sample.yaml @@ -7,5 +7,5 @@ tests: integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/edge_impulse/wrapper/README.rst b/samples/edge_impulse/wrapper/README.rst index 28b3665a516f..cc0e1c434eaa 100644 --- a/samples/edge_impulse/wrapper/README.rst +++ b/samples/edge_impulse/wrapper/README.rst @@ -17,7 +17,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns, nrf52840dk_nrf52840, nrf52dk_nrf52832 + :rows: nrf9160dk_nrf9160_ns, nrf52840dk_nrf52840, nrf52dk_nrf52832 Overview ******** @@ -44,7 +44,7 @@ To run the sample using a custom machine learning model, you must complete the f 1. Configure the Edge Impulse wrapper by completing the following steps: a. Prepare your own machine learning model using `Edge Impulse studio`_. - #. Set the :option:`CONFIG_EDGE_IMPULSE_URI` to URI of your machine learning model. + #. Set the :kconfig:`CONFIG_EDGE_IMPULSE_URI` to URI of your machine learning model. See the :ref:`ei_wrapper` page for detailed configuration steps. #. Define the input data for the machine learning model in :file:`samples/edge_impulse/wrapper/src/include/input_data.h`. diff --git a/samples/edge_impulse/wrapper/sample.yaml b/samples/edge_impulse/wrapper/sample.yaml index 77ed19f39bc5..255e8eae1227 100644 --- a/samples/edge_impulse/wrapper/sample.yaml +++ b/samples/edge_impulse/wrapper/sample.yaml @@ -4,9 +4,9 @@ sample: tests: samples.edge_impulse.wrapper: build_only: true - platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf9160dk_nrf9160ns + platform_allow: nrf52dk_nrf52832 nrf52840dk_nrf52840 nrf9160dk_nrf9160_ns integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/event_manager/README.rst b/samples/event_manager/README.rst index 106a78e9466d..1188291db264 100644 --- a/samples/event_manager/README.rst +++ b/samples/event_manager/README.rst @@ -38,7 +38,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns, nrf52dk_nrf52832, nrf52840dk_nrf52840 + :rows: nrf9160dk_nrf9160_ns, nrf52dk_nrf52832, nrf52840dk_nrf52840 Building and running diff --git a/samples/event_manager/sample.yaml b/samples/event_manager/sample.yaml index dfbdd0ba8293..befba1cd21ac 100644 --- a/samples/event_manager/sample.yaml +++ b/samples/event_manager/sample.yaml @@ -7,5 +7,5 @@ tests: integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/matter/common/src/dfu_over_smp.cpp b/samples/matter/common/src/dfu_over_smp.cpp new file mode 100644 index 000000000000..361aac95400f --- /dev/null +++ b/samples/matter/common/src/dfu_over_smp.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include "dfu_over_smp.h" + +#if !defined(CONFIG_MCUMGR_SMP_BT) || !defined(CONFIG_MCUMGR_CMD_IMG_MGMT) || !defined(CONFIG_MCUMGR_CMD_OS_MGMT) +#error "DFUOverSMP requires MCUMGR module configs enabled" +#endif + +#include +#include +#include +#include + +#include + +#include + +DFUOverSMP DFUOverSMP::sDFUOverSMP; + +void DFUOverSMP::Init(DFUOverSMPRestartAdvertisingHandler startAdvertisingCb) +{ + os_mgmt_register_group(); + img_mgmt_register_group(); + img_mgmt_set_upload_cb(UploadConfirmHandler, NULL); + + memset(&mBleConnCallbacks, 0, sizeof(mBleConnCallbacks)); + mBleConnCallbacks.disconnected = OnBleDisconnect; + + bt_conn_cb_register(&mBleConnCallbacks); + + restartAdvertisingCallback = startAdvertisingCb; +} + +void DFUOverSMP::ConfirmNewImage() +{ + /* Check if the image is run in the REVERT mode and eventually + * confirm it to prevent reverting on the next boot. */ + if (mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT) { + if (boot_write_img_confirmed()) { + ChipLogError(DeviceLayer, + "Confirming firmware image failed, it will be reverted on the next boot."); + } else { + ChipLogProgress(DeviceLayer, "New firmware image confirmed."); + } + } +} + +int DFUOverSMP::UploadConfirmHandler(uint32_t offset, uint32_t size, void *arg) +{ + /* For now just print update progress and confirm data chunk without any additional checks. */ + ChipLogProgress(DeviceLayer, "Software update progress %d B / %d B", offset, size); + + return 0; +} + +void DFUOverSMP::StartServer() +{ + if (!mIsEnabled) { + mIsEnabled = true; + smp_bt_register(); + + ChipLogProgress(DeviceLayer, "Enabled software update"); + + /* Start SMP advertising only in case CHIPoBLE advertising is not working. */ + if (!chip::DeviceLayer::ConnectivityMgr().IsBLEAdvertisingEnabled()) + StartBLEAdvertising(); + } else { + ChipLogProgress(DeviceLayer, "Software update is already enabled"); + } +} + +void DFUOverSMP::StartBLEAdvertising() +{ + if (!mIsEnabled) + return; + + const char *deviceName = bt_get_name(); + const uint8_t advFlags = BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR; + + bt_data ad[] = { BT_DATA(BT_DATA_FLAGS, &advFlags, sizeof(advFlags)), + BT_DATA(BT_DATA_NAME_COMPLETE, deviceName, static_cast(strlen(deviceName))) }; + + int rc; + bt_le_adv_param advParams = BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME, + BT_GAP_ADV_FAST_INT_MIN_2, BT_GAP_ADV_FAST_INT_MAX_2, nullptr); + + rc = bt_le_adv_stop(); + if (rc) { + ChipLogError(DeviceLayer, "SMP advertising stop failed (rc %d)", rc); + } + + rc = bt_le_adv_start(&advParams, ad, ARRAY_SIZE(ad), NULL, 0); + if (rc) { + ChipLogError(DeviceLayer, "SMP advertising start failed (rc %d)", rc); + } else { + ChipLogProgress(DeviceLayer, "Started SMP service BLE advertising"); + } +} + +void DFUOverSMP::OnBleDisconnect(struct bt_conn *conId, uint8_t reason) +{ + chip::DeviceLayer::PlatformMgr().LockChipStack(); + + /* After BLE disconnect SMP advertising needs to be restarted. Before making it ensure that BLE disconnect was + * not triggered by closing CHIPoBLE service connection (in that case CHIPoBLE advertising needs to be + * restarted). */ + if (!chip::DeviceLayer::ConnectivityMgr().IsBLEAdvertisingEnabled() && + chip::DeviceLayer::ConnectivityMgr().NumBLEConnections() == 0) { + sDFUOverSMP.restartAdvertisingCallback(); + } + + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); +} diff --git a/samples/matter/common/src/dfu_over_smp.h b/samples/matter/common/src/dfu_over_smp.h new file mode 100644 index 000000000000..a44a74f6e424 --- /dev/null +++ b/samples/matter/common/src/dfu_over_smp.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#pragma once + +#include + +#include + +typedef void (*DFUOverSMPRestartAdvertisingHandler)(void); + +class DFUOverSMP { +public: + void Init(DFUOverSMPRestartAdvertisingHandler startAdvertisingCb); + void ConfirmNewImage(); + void StartServer(); + void StartBLEAdvertising(); + bool IsEnabled() { return mIsEnabled; } + +private: + friend DFUOverSMP &GetDFUOverSMP(void); + + static int UploadConfirmHandler(uint32_t offset, uint32_t size, void *arg); + static void OnBleDisconnect(bt_conn *conn, uint8_t reason); + + bool mIsEnabled; + bt_conn_cb mBleConnCallbacks; + DFUOverSMPRestartAdvertisingHandler restartAdvertisingCallback; + + static DFUOverSMP sDFUOverSMP; +}; + +inline DFUOverSMP &GetDFUOverSMP(void) +{ + return DFUOverSMP::sDFUOverSMP; +} diff --git a/samples/matter/light_bulb/CMakeLists.txt b/samples/matter/light_bulb/CMakeLists.txt index 789f1244e590..9f84207d96fc 100644 --- a/samples/matter/light_bulb/CMakeLists.txt +++ b/samples/matter/light_bulb/CMakeLists.txt @@ -9,7 +9,11 @@ cmake_minimum_required(VERSION 3.13.1) option(BUILD_WITH_DFU "Build target with Device Firmware Upgrade support" OFF) if(BUILD_WITH_DFU) list(INSERT OVERLAY_CONFIG 0 ${CMAKE_CURRENT_SOURCE_DIR}/../common/config/overlay-dfu_support.conf) - set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml) + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml") + set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml) + else() + message(FATAL_ERROR "The ${BOARD} target does not support DFU") + endif() if(${BOARD} STREQUAL "nrf5340dk_nrf5340_cpuapp") list(INSERT OVERLAY_CONFIG 0 ${CMAKE_CURRENT_SOURCE_DIR}/../common/config/overlay-dfu_nrf53_extension.conf) endif() @@ -72,3 +76,7 @@ target_sources(app PRIVATE ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/server/Server.cpp ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/server/StorablePeerConnection.cpp) # NORDIC SDK APP END + +if(BUILD_WITH_DFU) + target_sources(app PRIVATE ${COMMON_ROOT}/src/dfu_over_smp.cpp) +endif() diff --git a/samples/matter/light_bulb/README.rst b/samples/matter/light_bulb/README.rst index 3a4dd598476c..8e4a4d5cd069 100644 --- a/samples/matter/light_bulb/README.rst +++ b/samples/matter/light_bulb/README.rst @@ -23,7 +23,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf52840dk_nrf52840, nrf5340dk_nrf5340_cpuapp + :rows: nrf52840dk_nrf52840, nrf5340dk_nrf5340_cpuapp, nrf21540dk_nrf52840 For remote testing scenarios, you also need the following: @@ -78,6 +78,11 @@ Device Firmware Upgrade support :start-after: matter_door_lock_sample_build_with_dfu_start :end-before: matter_door_lock_sample_build_with_dfu_end +FEM support +=========== + +.. include:: /includes/sample_fem_support.txt + User interface ************** @@ -106,7 +111,7 @@ Button 3: If for some reason the light switch device is not able to receive messages during this predefined period of time, you can restart publishing service by pressing this button again. Button 4: - Starts the the NFC tag emulation, enables Bluetooth LE advertising for the predefined period of time, and makes the device discoverable over Bluetooth LE. + Starts the NFC tag emulation, enables Bluetooth® LE advertising for the predefined period of time (15 minutes by default), and makes the device discoverable over Bluetooth LE. This button is used during the :ref:`commissioning procedure `. .. include:: ../lock/README.rst @@ -189,9 +194,8 @@ Commissioning the device :start-after: matter_door_lock_sample_commissioning_start :end-before: matter_door_lock_sample_commissioning_end -Before starting the commissioning procedure, you must make the device discoverable over Bluetooth LE. -To enable Bluetooth LE for a predefined period of time (15 minutes by default), press **Button 4**. -If the Bluetooth LE advertising times out, you can re-enable using the same button. +Before starting the commissioning procedure, the device must be made discoverable over Bluetooth LE, which starts automatically upon the device startup, but only for a predefined period of time (15 minutes by default). +If the Bluetooth LE advertising times out, you can re-enable it by pressing **Button 4**. When you start the commissioning procedure, the controller must get the commissioning information from the Matter accessory device. The data payload, which includes the device discriminator and setup PIN code, is encoded within a QR code, printed to the UART console, and can be shared using an NFC tag. diff --git a/samples/matter/light_bulb/boards/nrf21540dk_nrf52840.conf b/samples/matter/light_bulb/boards/nrf21540dk_nrf52840.conf new file mode 100644 index 000000000000..4cbd0e90c3af --- /dev/null +++ b/samples/matter/light_bulb/boards/nrf21540dk_nrf52840.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Enable Thread 1.2 features +CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y +CONFIG_OPENTHREAD_DUA=y +CONFIG_OPENTHREAD_MLR=y diff --git a/samples/matter/light_bulb/boards/nrf21540dk_nrf52840.overlay b/samples/matter/light_bulb/boards/nrf21540dk_nrf52840.overlay new file mode 100644 index 000000000000..a5f34bdd2657 --- /dev/null +++ b/samples/matter/light_bulb/boards/nrf21540dk_nrf52840.overlay @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + /* + * In some default configurations within the nRF Connect SDK, + * e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell. + * This devicetree overlay ensures that default is overridden wherever it + * is set, as this application uses the RNG node for entropy exclusively. + */ + + chosen { + zephyr,entropy = &rng; + }; + + /* + * By default, PWM module is only configured for led0 (LED1 on the board). + * The lighting-app, however, uses LED2 to show the state of the lighting, + * including its brightness level. + */ + aliases { + pwm-led1 = &pwm_led1; + }; + + pwmleds { + pwm_led1: pwm_led_1 { + pwms = < &pwm0 0xe >; + }; + }; + +}; + +&pwm0 { + /delete-property/ ch0-pin; + /delete-property/ ch0-inverted; + ch1-pin = < 0xe >; + ch1-inverted; +}; diff --git a/samples/matter/light_bulb/boards/nrf52840dk_nrf52840.conf b/samples/matter/light_bulb/boards/nrf52840dk_nrf52840.conf index 4cbd0e90c3af..bc0d51b58efc 100644 --- a/samples/matter/light_bulb/boards/nrf52840dk_nrf52840.conf +++ b/samples/matter/light_bulb/boards/nrf52840dk_nrf52840.conf @@ -8,3 +8,6 @@ CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y CONFIG_OPENTHREAD_DUA=y CONFIG_OPENTHREAD_MLR=y + +# TODO: remove increasing connection interval after fixing MPSL driver blocking issues +CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 diff --git a/samples/matter/light_bulb/child_image/multiprotocol_rpmsg.conf b/samples/matter/light_bulb/child_image/multiprotocol_rpmsg.conf new file mode 100644 index 000000000000..8b53fef45668 --- /dev/null +++ b/samples/matter/light_bulb/child_image/multiprotocol_rpmsg.conf @@ -0,0 +1,8 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# TODO: remove increasing connection interval after fixing MPSL driver blocking issues +CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 diff --git a/samples/matter/light_bulb/prj.conf b/samples/matter/light_bulb/prj.conf index 27e6f356b7f6..1c6ca4e85d7d 100644 --- a/samples/matter/light_bulb/prj.conf +++ b/samples/matter/light_bulb/prj.conf @@ -9,6 +9,9 @@ CONFIG_CHIP=y CONFIG_CHIP_PROJECT_CONFIG="src/chip_project_config.h" CONFIG_STD_CPP14=y +# Enable CHIP pairing automatically on application start. +CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y + # General networking settings CONFIG_NETWORKING=y CONFIG_NET_IPV6_NBR_CACHE=n @@ -34,6 +37,7 @@ CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" # Enable Bluetooth Low Energy CONFIG_BT=y CONFIG_BT_PERIPHERAL=y +CONFIG_BT_GATT_DYNAMIC_DB=y CONFIG_BT_DEVICE_APPEARANCE=0 CONFIG_BT_DEVICE_NAME_DYNAMIC=y CONFIG_BT_DEVICE_NAME_MAX=15 @@ -47,7 +51,6 @@ CONFIG_BT_MAX_PAIRED=0 CONFIG_BT_BONDABLE=n CONFIG_BT_TINYCRYPT_ECC=n CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY=y -CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 # Use NFC to share commissioning information CONFIG_CHIP_NFC_COMMISSIONING=y diff --git a/samples/matter/light_bulb/sample.yaml b/samples/matter/light_bulb/sample.yaml index da12306c0ead..2de6c5a4b230 100644 --- a/samples/matter/light_bulb/sample.yaml +++ b/samples/matter/light_bulb/sample.yaml @@ -4,8 +4,9 @@ sample: tests: matter.light_bulb: build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp + platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp nrf21540dk_nrf52840 integration_platforms: - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp + - nrf21540dk_nrf52840 tags: ci_build diff --git a/samples/matter/light_bulb/src/app_event.h b/samples/matter/light_bulb/src/app_event.h index b1cba9a3c81f..1fbc613e27a3 100644 --- a/samples/matter/light_bulb/src/app_event.h +++ b/samples/matter/light_bulb/src/app_event.h @@ -13,7 +13,14 @@ struct AppEvent { enum FunctionEventType : uint8_t { FunctionPress = Level + 1, FunctionRelease, FunctionTimer }; - enum OtherEventType : uint8_t { StartThread = FunctionTimer + 1, StartBleAdvertising, PublishLightBulbService }; + enum OtherEventType : uint8_t { + StartThread = FunctionTimer + 1, + StartBleAdvertising, + PublishLightBulbService, +#ifdef CONFIG_MCUMGR_SMP_BT + StartSMPAdvertising +#endif + }; AppEvent() = default; diff --git a/samples/matter/light_bulb/src/app_task.cpp b/samples/matter/light_bulb/src/app_task.cpp index 5c9a31ddd715..9dd4a7db6d44 100644 --- a/samples/matter/light_bulb/src/app_task.cpp +++ b/samples/matter/light_bulb/src/app_task.cpp @@ -20,20 +20,6 @@ #include #include -/* MCUMgr BT FOTA includes */ -#ifdef CONFIG_MCUMGR_CMD_OS_MGMT -#include "os_mgmt/os_mgmt.h" -#endif -#ifdef CONFIG_MCUMGR_CMD_IMG_MGMT -#include "img_mgmt/img_mgmt.h" -#endif -#ifdef CONFIG_MCUMGR_SMP_BT -#include -#endif -#ifdef CONFIG_BOOTLOADER_MCUBOOT -#include -#endif - #include #include #include @@ -87,16 +73,9 @@ int AppTask::Init() return ret; } -#ifdef CONFIG_BOOTLOADER_MCUBOOT - /* Check if the image is run in the REVERT mode and eventually - confirm it to prevent reverting on the next boot. */ - if (mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT) { - if (boot_write_img_confirmed()) { - LOG_ERR("Confirming firmware image failed, it will be reverted on the next boot."); - } else { - LOG_INF("New firmware image confirmed."); - } - } +#ifdef CONFIG_MCUMGR_SMP_BT + GetDFUOverSMP().Init(RequestSMPAdvertisingStart); + GetDFUOverSMP().ConfirmNewImage(); #endif /* Initialize function timer */ @@ -116,7 +95,7 @@ int AppTask::Init() ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); -#ifdef CONFIG_CHIP_NFC_COMMISSIONING +#if defined(CONFIG_CHIP_NFC_COMMISSIONING) || defined(CONFIG_MCUMGR_SMP_BT) PlatformMgr().AddEventHandler(AppTask::ChipEventHandler, 0); #endif @@ -214,13 +193,12 @@ void AppTask::UpdateClusterState() } } -int AppTask::SoftwareUpdateConfirmationHandler(uint32_t offset, uint32_t size, void *arg) +#ifdef CONFIG_MCUMGR_SMP_BT +void AppTask::RequestSMPAdvertisingStart(void) { - /* For now just print update progress and confirm data chunk without any additional checks. */ - LOG_INF("Software update progress %d B / %d B", offset, size); - - return 0; + sAppTask.PostEvent(AppEvent{ AppEvent::StartSMPAdvertising }); } +#endif void AppTask::DispatchEvent(const AppEvent &aEvent) { @@ -257,6 +235,11 @@ void AppTask::DispatchEvent(const AppEvent &aEvent) case AppEvent::StartBleAdvertising: StartBLEAdvertisingHandler(); break; +#ifdef CONFIG_MCUMGR_SMP_BT + case AppEvent::StartSMPAdvertising: + GetDFUOverSMP().StartBLEAdvertising(); + break; +#endif case AppEvent::PublishLightBulbService: sLightBulbPublishService.Publish(); break; @@ -304,19 +287,8 @@ void AppTask::FunctionReleaseHandler() sAppTask.CancelFunctionTimer(); sAppTask.mFunction = TimerFunction::NoneSelected; -#if defined(CONFIG_MCUMGR_SMP_BT) && defined(CONFIG_MCUMGR_CMD_IMG_MGMT) && defined(CONFIG_MCUMGR_CMD_OS_MGMT) - if (!sAppTask.mSoftwareUpdateEnabled) { - sAppTask.mSoftwareUpdateEnabled = true; - os_mgmt_register_group(); - img_mgmt_register_group(); - img_mgmt_set_upload_cb(SoftwareUpdateConfirmationHandler, NULL); - smp_bt_register(); - - LOG_INF("Enabled software update"); - } else { - LOG_INF("Software update is already enabled"); - } - +#ifdef CONFIG_MCUMGR_SMP_BT + GetDFUOverSMP().StartServer(); #else LOG_INF("Software update is disabled"); #endif @@ -372,8 +344,9 @@ void AppTask::StartThreadHandler() void AppTask::StartBLEAdvertisingHandler() { - if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() && !sAppTask.mSoftwareUpdateEnabled) { - LOG_INF("NFC Tag emulation and BLE advertisement not started - device is commissioned to a Thread network."); + /* Don't allow on starting Matter service BLE advertising after Thread provisioning. */ + if (ConnectivityMgr().IsThreadProvisioned()) { + LOG_INF("NFC Tag emulation and Matter service BLE advertisement not started - device is commissioned to a Thread network."); return; } @@ -389,23 +362,34 @@ void AppTask::StartBLEAdvertisingHandler() } } -#ifdef CONFIG_CHIP_NFC_COMMISSIONING void AppTask::ChipEventHandler(const ChipDeviceEvent *event, intptr_t /* arg */) { - if (event->Type == DeviceEventType::kCHIPoBLEAdvertisingChange) { - if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Started) { - if (NFCMgr().IsTagEmulationStarted()) { - LOG_INF("NFC Tag emulation is already started"); - } else { - ShareQRCodeOverNFC( - chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); - } - } else if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped) { - NFCMgr().StopTagEmulation(); + if (event->Type != DeviceEventType::kCHIPoBLEAdvertisingChange) + return; + + if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped) { +#ifdef CONFIG_CHIP_NFC_COMMISSIONING + NFCMgr().StopTagEmulation(); +#endif +#ifdef CONFIG_MCUMGR_SMP_BT + /* After CHIPoBLE advertising stop, start advertising SMP in case Thread is enabled or there are no + * active CHIPoBLE connections (exclude the case when CHIPoBLE advertising is stopped on the connection + * time) */ + if (GetDFUOverSMP().IsEnabled() && + (ConnectivityMgr().IsThreadProvisioned() || ConnectivityMgr().NumBLEConnections() == 0)) + sAppTask.RequestSMPAdvertisingStart(); +#endif + } +#ifdef CONFIG_CHIP_NFC_COMMISSIONING + else if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Started) { + if (NFCMgr().IsTagEmulationStarted()) { + LOG_INF("NFC Tag emulation is already started"); + } else { + ShareQRCodeOverNFC(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); } } -} #endif +} void AppTask::ButtonEventHandler(uint32_t buttonState, uint32_t hasChanged) { diff --git a/samples/matter/light_bulb/src/app_task.h b/samples/matter/light_bulb/src/app_task.h index 3fff5159b0e5..b2716e8dd09c 100644 --- a/samples/matter/light_bulb/src/app_task.h +++ b/samples/matter/light_bulb/src/app_task.h @@ -11,6 +11,10 @@ #include +#ifdef CONFIG_MCUMGR_SMP_BT +#include "dfu_over_smp.h" +#endif + struct k_timer; class AppTask { @@ -40,7 +44,9 @@ class AppTask { static void ButtonEventHandler(uint32_t buttonState, uint32_t hasChanged); static void TimerEventHandler(k_timer *timer); static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent *event, intptr_t arg); - static int SoftwareUpdateConfirmationHandler(uint32_t offset, uint32_t size, void *arg); +#ifdef CONFIG_MCUMGR_SMP_BT + static void RequestSMPAdvertisingStart(void); +#endif friend AppTask &GetAppTask(); @@ -49,7 +55,6 @@ class AppTask { TimerFunction mFunction = TimerFunction::NoneSelected; static AppTask sAppTask; - bool mSoftwareUpdateEnabled = false; }; inline AppTask &GetAppTask() diff --git a/samples/matter/light_switch/README.rst b/samples/matter/light_switch/README.rst index 5e33bf1ed53e..93bd37fa6b11 100644 --- a/samples/matter/light_switch/README.rst +++ b/samples/matter/light_switch/README.rst @@ -19,7 +19,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf52840dk_nrf52840, nrf5340dk_nrf5340_cpuapp + :rows: nrf52840dk_nrf52840, nrf5340dk_nrf5340_cpuapp, nrf21540dk_nrf52840 For this sample to work, you also need the :ref:`Matter light bulb ` sample programmed to another supported development kit. @@ -36,7 +36,7 @@ The light switch must be put into the test mode and paired with a light bulb dev Test mode ========= -Unlike other samples, such as :ref:`Matter door lock `, the light switch sample does not support Matter commissioning over Bluetooth LE. +Unlike other samples, such as :ref:`Matter door lock `, the light switch sample does not support Matter commissioning over Bluetooth® LE. To make the light switch and the light bulb devices able to communicate with each other, they must be initialized with the same static Thread network parameters and static Matter cryptographic keys. Pressing **Button 3** activates the test mode before enabling the pairing phase on the device. @@ -50,6 +50,16 @@ After the test mode is activated and both devices are initialized with the same During this phase, the light bulb device periodically sends multicast messages with static content. Once such a message is intercepted by the light switch device, the light switch is made aware of the IP address of the nearby light bulb device and the pairing is done. +Configuration +************* + +|config| + +FEM support +=========== + +.. include:: /includes/sample_fem_support.txt + User interface ************** diff --git a/samples/matter/light_switch/boards/nrf21540dk_nrf52840.conf b/samples/matter/light_switch/boards/nrf21540dk_nrf52840.conf new file mode 100644 index 000000000000..4cbd0e90c3af --- /dev/null +++ b/samples/matter/light_switch/boards/nrf21540dk_nrf52840.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Enable Thread 1.2 features +CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y +CONFIG_OPENTHREAD_DUA=y +CONFIG_OPENTHREAD_MLR=y diff --git a/samples/matter/light_switch/boards/nrf21540dk_nrf52840.overlay b/samples/matter/light_switch/boards/nrf21540dk_nrf52840.overlay new file mode 100644 index 000000000000..6dcf38dbaf8f --- /dev/null +++ b/samples/matter/light_switch/boards/nrf21540dk_nrf52840.overlay @@ -0,0 +1,16 @@ +/* Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + /* + * In some default configurations within the nRF Connect SDK, + * e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell. + * This devicetree overlay ensures that default is overridden wherever it + * is set, as this application uses the RNG node for entropy exclusively. + */ + chosen { + zephyr,entropy = &rng; + }; +}; diff --git a/samples/matter/light_switch/sample.yaml b/samples/matter/light_switch/sample.yaml index 81c18bdf6f7f..32186a410dfa 100644 --- a/samples/matter/light_switch/sample.yaml +++ b/samples/matter/light_switch/sample.yaml @@ -4,8 +4,9 @@ sample: tests: matter.light_switch: build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp + platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp nrf21540dk_nrf52840 integration_platforms: - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp + - nrf21540dk_nrf52840 tags: ci_build diff --git a/samples/matter/lock/CMakeLists.txt b/samples/matter/lock/CMakeLists.txt index d2be93dbca49..ecb925e6d922 100644 --- a/samples/matter/lock/CMakeLists.txt +++ b/samples/matter/lock/CMakeLists.txt @@ -9,7 +9,11 @@ cmake_minimum_required(VERSION 3.13.1) option(BUILD_WITH_DFU "Build target with Device Firmware Upgrade support" OFF) if(BUILD_WITH_DFU) list(INSERT OVERLAY_CONFIG 0 ${CMAKE_CURRENT_SOURCE_DIR}/../common/config/overlay-dfu_support.conf) - set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml) + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml") + set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml) + else() + message(FATAL_ERROR "The ${BOARD} target does not support DFU") + endif() if(${BOARD} STREQUAL "nrf5340dk_nrf5340_cpuapp") list(INSERT OVERLAY_CONFIG 0 ${CMAKE_CURRENT_SOURCE_DIR}/../common/config/overlay-dfu_nrf53_extension.conf) endif() @@ -70,3 +74,7 @@ target_sources(app PRIVATE ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/server/Server.cpp ${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/server/StorablePeerConnection.cpp) # NORDIC SDK APP END + +if(BUILD_WITH_DFU) + target_sources(app PRIVATE ${COMMON_ROOT}/src/dfu_over_smp.cpp) +endif() diff --git a/samples/matter/lock/README.rst b/samples/matter/lock/README.rst index 6db02ac0df4f..565b043989ab 100644 --- a/samples/matter/lock/README.rst +++ b/samples/matter/lock/README.rst @@ -19,7 +19,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf52840dk_nrf52840, nrf5340dk_nrf5340_cpuapp + :rows: nrf52840dk_nrf52840, nrf5340dk_nrf5340_cpuapp, nrf21540dk_nrf52840 For remote testing scenarios, if you want to commission the lock device and :ref:`control it remotely ` through a Thread network, you also need a Matter controller device :ref:`configured on PC or smartphone ` (which requires additional hardware depending on which setup you choose). @@ -46,7 +46,7 @@ Remote testing in a network .. matter_door_lock_sample_remote_testing_start By default, the Matter accessory device has Thread disabled. -You must pair it with the Matter controller over Bluetooth LE to get configuration from the controller if you want to use the device within a Thread network. +You must pair it with the Matter controller over Bluetooth® LE to get configuration from the controller if you want to use the device within a Thread network. To do this, the device must be made discoverable manually (for security reasons) and the controller must get the commissioning information from the Matter accessory device and provision the device into the network. For details, see the `Commissioning the device`_ section. @@ -77,7 +77,10 @@ Device Firmware Upgrade support .. matter_door_lock_sample_build_with_dfu_start -You can configure the sample to use the secure bootloader for performing over-the-air Device Firmware Upgrade using Bluetooth LE, using the following build flags during the build process: +.. note:: + Over-the-air Device Firmware Upgrade can be enabled only on hardware platforms containing external flash memory. + +You can configure the sample to use the secure bootloader for performing over-the-air Device Firmware Upgrade using Bluetooth® LE, using the following build flags during the build process: * ``-DOVERLAY_CONFIG=../common/config/overlay-dfu_support.conf`` * ``-DPM_STATIC_YML_FILE="configuration/build-target/pm_static.yml`` @@ -93,6 +96,11 @@ For example, when building on the command line, run the following command with * .. matter_door_lock_sample_build_with_dfu_end +FEM support +=========== + +.. include:: /includes/sample_fem_support.txt + User interface ************** @@ -136,7 +144,7 @@ Button 3: Starts the Thread networking in the :ref:`test mode ` using the default configuration. Button 4: - Starts the the NFC tag emulation, enables Bluetooth LE advertising for the predefined period of time, and makes the device discoverable over Bluetooth LE. + Starts the the NFC tag emulation, enables Bluetooth LE advertising for the predefined period of time (15 minutes by default), and makes the device discoverable over Bluetooth LE. This button is used during the :ref:`commissioning procedure `. .. matter_door_lock_sample_jlink_start diff --git a/samples/matter/lock/boards/nrf21540dk_nrf52840.conf b/samples/matter/lock/boards/nrf21540dk_nrf52840.conf new file mode 100644 index 000000000000..4cbd0e90c3af --- /dev/null +++ b/samples/matter/lock/boards/nrf21540dk_nrf52840.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Enable Thread 1.2 features +CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y +CONFIG_OPENTHREAD_DUA=y +CONFIG_OPENTHREAD_MLR=y diff --git a/samples/matter/lock/boards/nrf21540dk_nrf52840.overlay b/samples/matter/lock/boards/nrf21540dk_nrf52840.overlay new file mode 100644 index 000000000000..6dcf38dbaf8f --- /dev/null +++ b/samples/matter/lock/boards/nrf21540dk_nrf52840.overlay @@ -0,0 +1,16 @@ +/* Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + /* + * In some default configurations within the nRF Connect SDK, + * e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell. + * This devicetree overlay ensures that default is overridden wherever it + * is set, as this application uses the RNG node for entropy exclusively. + */ + chosen { + zephyr,entropy = &rng; + }; +}; diff --git a/samples/matter/lock/boards/nrf52840dk_nrf52840.conf b/samples/matter/lock/boards/nrf52840dk_nrf52840.conf index 4cbd0e90c3af..bc0d51b58efc 100644 --- a/samples/matter/lock/boards/nrf52840dk_nrf52840.conf +++ b/samples/matter/lock/boards/nrf52840dk_nrf52840.conf @@ -8,3 +8,6 @@ CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y CONFIG_OPENTHREAD_DUA=y CONFIG_OPENTHREAD_MLR=y + +# TODO: remove increasing connection interval after fixing MPSL driver blocking issues +CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 diff --git a/samples/matter/lock/child_image/multiprotocol_rpmsg.conf b/samples/matter/lock/child_image/multiprotocol_rpmsg.conf new file mode 100644 index 000000000000..8b53fef45668 --- /dev/null +++ b/samples/matter/lock/child_image/multiprotocol_rpmsg.conf @@ -0,0 +1,8 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# TODO: remove increasing connection interval after fixing MPSL driver blocking issues +CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 diff --git a/samples/matter/lock/prj.conf b/samples/matter/lock/prj.conf index c14dc25e577e..4302abafbc50 100644 --- a/samples/matter/lock/prj.conf +++ b/samples/matter/lock/prj.conf @@ -34,6 +34,7 @@ CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" # Enable Bluetooth Low Energy CONFIG_BT=y CONFIG_BT_PERIPHERAL=y +CONFIG_BT_GATT_DYNAMIC_DB=y CONFIG_BT_DEVICE_APPEARANCE=0 CONFIG_BT_DEVICE_NAME_DYNAMIC=y CONFIG_BT_DEVICE_NAME_MAX=15 @@ -47,7 +48,6 @@ CONFIG_BT_MAX_PAIRED=0 CONFIG_BT_BONDABLE=n CONFIG_BT_TINYCRYPT_ECC=n CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY=y -CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000 # Use NFC to share commissioning information CONFIG_CHIP_NFC_COMMISSIONING=y diff --git a/samples/matter/lock/sample.yaml b/samples/matter/lock/sample.yaml index a81e3f9a5392..be1ad3e69cc3 100644 --- a/samples/matter/lock/sample.yaml +++ b/samples/matter/lock/sample.yaml @@ -4,8 +4,9 @@ sample: tests: matter.lock: build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp + platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp nrf21540dk_nrf52840 integration_platforms: - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp + - nrf21540dk_nrf52840 tags: ci_build diff --git a/samples/matter/lock/src/app_event.h b/samples/matter/lock/src/app_event.h index e8c96de5fe6e..87e2d81d2ce3 100644 --- a/samples/matter/lock/src/app_event.h +++ b/samples/matter/lock/src/app_event.h @@ -13,7 +13,13 @@ struct AppEvent { enum FunctionEventType : uint8_t { FunctionPress = CompleteLockAction + 1, FunctionRelease, FunctionTimer }; - enum OtherEventType : uint8_t { StartThread = FunctionTimer + 1, StartBleAdvertising }; + enum OtherEventType : uint8_t { + StartThread = FunctionTimer + 1, + StartBleAdvertising, +#ifdef CONFIG_MCUMGR_SMP_BT + StartSMPAdvertising +#endif + }; AppEvent() = default; AppEvent(LockEventType type, bool chipInitiated) : Type(type), LockEvent{ chipInitiated } {} @@ -23,8 +29,7 @@ struct AppEvent { uint8_t Type; union { - struct { - /* was the event triggered by CHIP Data Model layer */ + struct { /* was the event triggered by CHIP Data Model layer */ bool ChipInitiated; } LockEvent; }; diff --git a/samples/matter/lock/src/app_task.cpp b/samples/matter/lock/src/app_task.cpp index 702cf679ea3f..f92a9dd86718 100644 --- a/samples/matter/lock/src/app_task.cpp +++ b/samples/matter/lock/src/app_task.cpp @@ -19,20 +19,6 @@ #include #include -/* MCUMgr BT FOTA includes */ -#ifdef CONFIG_MCUMGR_CMD_OS_MGMT -#include "os_mgmt/os_mgmt.h" -#endif -#ifdef CONFIG_MCUMGR_CMD_IMG_MGMT -#include "img_mgmt/img_mgmt.h" -#endif -#ifdef CONFIG_MCUMGR_SMP_BT -#include -#endif -#ifdef CONFIG_BOOTLOADER_MCUBOOT -#include -#endif - #include #include #include @@ -83,16 +69,9 @@ int AppTask::Init() return ret; } -#ifdef CONFIG_BOOTLOADER_MCUBOOT - /* Check if the image is run in the REVERT mode and eventually - confirm it to prevent reverting on the next boot. */ - if (mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT) { - if (boot_write_img_confirmed()) { - LOG_ERR("Confirming firmware image failed, it will be reverted on the next boot."); - } else { - LOG_INF("New firmware image confirmed."); - } - } +#ifdef CONFIG_MCUMGR_SMP_BT + GetDFUOverSMP().Init(RequestSMPAdvertisingStart); + GetDFUOverSMP().ConfirmNewImage(); #endif /* Initialize function timer */ @@ -107,7 +86,7 @@ int AppTask::Init() ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); -#ifdef CONFIG_CHIP_NFC_COMMISSIONING +#if defined(CONFIG_CHIP_NFC_COMMISSIONING) || defined(CONFIG_MCUMGR_SMP_BT) PlatformMgr().AddEventHandler(AppTask::ChipEventHandler, 0); #endif @@ -196,13 +175,12 @@ void AppTask::UpdateClusterState() } } -int AppTask::SoftwareUpdateConfirmationHandler(uint32_t offset, uint32_t size, void *arg) +#ifdef CONFIG_MCUMGR_SMP_BT +void AppTask::RequestSMPAdvertisingStart(void) { - /* For now just print update progress and confirm data chunk without any additional checks. */ - LOG_INF("Software update progress %d B / %d B", offset, size); - - return 0; + sAppTask.PostEvent(AppEvent{ AppEvent::StartSMPAdvertising }); } +#endif void AppTask::DispatchEvent(const AppEvent &event) { @@ -236,6 +214,11 @@ void AppTask::DispatchEvent(const AppEvent &event) case AppEvent::StartBleAdvertising: StartBLEAdvertisingHandler(); break; +#ifdef CONFIG_MCUMGR_SMP_BT + case AppEvent::StartSMPAdvertising: + GetDFUOverSMP().StartBLEAdvertising(); + break; +#endif default: LOG_INF("Unknown event received"); break; @@ -277,19 +260,8 @@ void AppTask::FunctionReleaseHandler() sAppTask.CancelFunctionTimer(); sAppTask.mFunction = TimerFunction::NoneSelected; -#if defined(CONFIG_MCUMGR_SMP_BT) && defined(CONFIG_MCUMGR_CMD_IMG_MGMT) && defined(CONFIG_MCUMGR_CMD_OS_MGMT) - if (!sAppTask.mSoftwareUpdateEnabled) { - sAppTask.mSoftwareUpdateEnabled = true; - os_mgmt_register_group(); - img_mgmt_register_group(); - img_mgmt_set_upload_cb(SoftwareUpdateConfirmationHandler, NULL); - smp_bt_register(); - - LOG_INF("Enabled software update"); - } else { - LOG_INF("Software update is already enabled"); - } - +#ifdef CONFIG_MCUMGR_SMP_BT + GetDFUOverSMP().StartServer(); #else LOG_INF("Software update is disabled"); #endif @@ -348,8 +320,9 @@ void AppTask::StartThreadHandler() void AppTask::StartBLEAdvertisingHandler() { - if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() && !sAppTask.mSoftwareUpdateEnabled) { - LOG_INF("NFC Tag emulation and BLE advertisement not started - device is commissioned to a Thread network."); + /* Don't allow on starting Matter service BLE advertising after Thread provisioning. */ + if (ConnectivityMgr().IsThreadProvisioned()) { + LOG_INF("NFC Tag emulation and Matter service BLE advertisement not started - device is commissioned to a Thread network."); return; } @@ -365,23 +338,34 @@ void AppTask::StartBLEAdvertisingHandler() } } -#ifdef CONFIG_CHIP_NFC_COMMISSIONING void AppTask::ChipEventHandler(const ChipDeviceEvent *event, intptr_t /* arg */) { - if (event->Type == DeviceEventType::kCHIPoBLEAdvertisingChange) { - if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Started) { - if (NFCMgr().IsTagEmulationStarted()) { - LOG_INF("NFC Tag emulation is already started"); - } else { - ShareQRCodeOverNFC( - chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); - } - } else if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped) { - NFCMgr().StopTagEmulation(); + if (event->Type != DeviceEventType::kCHIPoBLEAdvertisingChange) + return; + + if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped) { +#ifdef CONFIG_CHIP_NFC_COMMISSIONING + NFCMgr().StopTagEmulation(); +#endif +#ifdef CONFIG_MCUMGR_SMP_BT + /* After CHIPoBLE advertising stop, start advertising SMP in case Thread is enabled or there are no + * active CHIPoBLE connections (exclude the case when CHIPoBLE advertising is stopped on the connection + * time) */ + if (GetDFUOverSMP().IsEnabled() && + (ConnectivityMgr().IsThreadProvisioned() || ConnectivityMgr().NumBLEConnections() == 0)) + sAppTask.RequestSMPAdvertisingStart(); +#endif + } +#ifdef CONFIG_CHIP_NFC_COMMISSIONING + else if (event->CHIPoBLEAdvertisingChange.Result == kActivity_Started) { + if (NFCMgr().IsTagEmulationStarted()) { + LOG_INF("NFC Tag emulation is already started"); + } else { + ShareQRCodeOverNFC(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); } } -} #endif +} void AppTask::ButtonEventHandler(uint32_t buttonState, uint32_t hasChanged) { diff --git a/samples/matter/lock/src/app_task.h b/samples/matter/lock/src/app_task.h index f33a6415075a..3794fdf057e9 100644 --- a/samples/matter/lock/src/app_task.h +++ b/samples/matter/lock/src/app_task.h @@ -11,6 +11,10 @@ #include +#ifdef CONFIG_MCUMGR_SMP_BT +#include "dfu_over_smp.h" +#endif + struct k_timer; class AppTask { @@ -38,7 +42,9 @@ class AppTask { static void ButtonEventHandler(uint32_t buttonState, uint32_t hasChanged); static void TimerEventHandler(k_timer *timer); static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent *event, intptr_t arg); - static int SoftwareUpdateConfirmationHandler(uint32_t offset, uint32_t size, void *arg); +#ifdef CONFIG_MCUMGR_SMP_BT + static void RequestSMPAdvertisingStart(void); +#endif friend AppTask &GetAppTask(); @@ -48,7 +54,6 @@ class AppTask { static AppTask sAppTask; bool mFunctionTimerActive = false; - bool mSoftwareUpdateEnabled = false; }; inline AppTask &GetAppTask() diff --git a/samples/matter/template/README.rst b/samples/matter/template/README.rst index 42a76be9b659..7a02261c66cf 100644 --- a/samples/matter/template/README.rst +++ b/samples/matter/template/README.rst @@ -20,7 +20,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf52840dk_nrf52840, nrf5340dk_nrf5340_cpuapp + :rows: nrf52840dk_nrf52840, nrf5340dk_nrf5340_cpuapp, nrf21540dk_nrf52840 For testing purposes, that is to commission the device and :ref:`control it remotely ` through a Thread network, you also need a Matter controller device :ref:`configured on PC or smartphone ` (which requires additional hardware depending on which setup you choose). @@ -30,7 +30,7 @@ For testing purposes, that is to commission the device and :ref:`control it remo Overview ******** -The sample starts the Bluetooth LE advertising automatically and prepares the Matter device for commissioning into a Matter-enabled Thread network. +The sample starts the Bluetooth® LE advertising automatically and prepares the Matter device for commissioning into a Matter-enabled Thread network. The sample uses an LED to show the state of the connection. You can press a button to start the factory reset when needed. @@ -58,6 +58,16 @@ As a result, the device can join the Thread network and communicate with other T To start the commissioning procedure, the controller must get the commissioning information from the Matter accessory device. The data payload, which includes the device discriminator and setup PIN code, is encoded within a QR code, printed to the UART console. +Configuration +************* + +|config| + +FEM support +=========== + +.. include:: /includes/sample_fem_support.txt + User interface ************** diff --git a/samples/matter/template/boards/nrf21540dk_nrf52840.conf b/samples/matter/template/boards/nrf21540dk_nrf52840.conf new file mode 100644 index 000000000000..4cbd0e90c3af --- /dev/null +++ b/samples/matter/template/boards/nrf21540dk_nrf52840.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Enable Thread 1.2 features +CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y +CONFIG_OPENTHREAD_DUA=y +CONFIG_OPENTHREAD_MLR=y diff --git a/samples/matter/template/boards/nrf21540dk_nrf52840.overlay b/samples/matter/template/boards/nrf21540dk_nrf52840.overlay new file mode 100644 index 000000000000..6dcf38dbaf8f --- /dev/null +++ b/samples/matter/template/boards/nrf21540dk_nrf52840.overlay @@ -0,0 +1,16 @@ +/* Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + /* + * In some default configurations within the nRF Connect SDK, + * e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell. + * This devicetree overlay ensures that default is overridden wherever it + * is set, as this application uses the RNG node for entropy exclusively. + */ + chosen { + zephyr,entropy = &rng; + }; +}; diff --git a/samples/matter/template/prj.conf b/samples/matter/template/prj.conf index d676d1ca4c63..a03862677437 100644 --- a/samples/matter/template/prj.conf +++ b/samples/matter/template/prj.conf @@ -35,6 +35,7 @@ CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" # Enable Bluetooth Low Energy CONFIG_BT=y CONFIG_BT_PERIPHERAL=y +CONFIG_BT_GATT_DYNAMIC_DB=y CONFIG_BT_DEVICE_APPEARANCE=0 CONFIG_BT_DEVICE_NAME_DYNAMIC=y CONFIG_BT_DEVICE_NAME_MAX=15 diff --git a/samples/matter/template/sample.yaml b/samples/matter/template/sample.yaml index ab3a253c5a28..36c9214d16dd 100644 --- a/samples/matter/template/sample.yaml +++ b/samples/matter/template/sample.yaml @@ -4,8 +4,9 @@ sample: tests: matter.template: build_only: true - platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp + platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp nrf21540dk_nrf52840 integration_platforms: - nrf52840dk_nrf52840 - nrf5340dk_nrf5340_cpuapp + - nrf21540dk_nrf52840 tags: ci_build diff --git a/samples/matter/weather_station/README.rst b/samples/matter/weather_station/README.rst deleted file mode 100644 index ef4ed54ebd40..000000000000 --- a/samples/matter/weather_station/README.rst +++ /dev/null @@ -1,191 +0,0 @@ -.. _matter_weather_station_sample: - -Matter: Weather station -####################### - -.. contents:: - :local: - :depth: 2 - -This weather station sample demonstrates the usage of the :ref:`Matter ` (formerly Project Connected Home over IP, Project CHIP) application layer to build a weather station device that lets you remotely gather different kinds of data, such as temperature, air pressure, and relative humidity, using the device sensors. -This device works as a Matter accessory device, meaning it can be paired and controlled remotely over a Matter network built on top of a low-power, 802.15.4 Thread network. -You can use this sample as a reference for creating your own application. - -.. note:: - |weather_station_wip_note| - -Requirements -************ - -The sample supports the following development kits: - -.. table-from-rows:: /includes/sample_board_rows.txt - :header: heading - :rows: thingy53_nrf5340_cpuapp - -To program and gather logs from the Thingy:53 device, you need the external J-Link programmer. -If you own an nRF5340 DK that has an onboard J-Link programmer, you can also use it for this purpose. - -To commission the weather station device and :ref:`control it remotely ` through a Thread network, you also need the following: - -* A Matter controller device :ref:`configured on PC or smartphone ` (which requires additional hardware depending on which setup you choose). - -.. note:: - |matter_gn_required_note| - -Overview -******** - -The sample uses a single button for controlling the device state. -The weather station device is periodically performing temperature, air pressure, and relative humidity measurements. -The measurement results are stored in the device memory and can be read using the Matter controller. -The controller communicates with the weather station device over the Matter protocol using Zigbee Cluster Library (ZCL). -The library describes data measurements within the proper clusters that correspond to the measurement type. - -The sample can be tested remotely over the Thread protocol, which requires an additional Matter controller device that can be configured either on PC or mobile (for remote testing in a network). -You can start testing after :ref:`building and running the sample `. - -.. _matter_weather_station_network_mode: - -Remote testing in a network -=========================== - -By default, the Matter accessory device has Thread disabled, and it must be paired with the Matter controller over Bluetooth LE to get configuration from it if you want to use the device within a Thread network. -To do this, the device must be made discoverable over Bluetooth LE that starts automatically upon the device startup but only for a predefined period of time (15 minutes by default). -If the Bluetooth LE advertising times out, you can re-enable it manually using **Button 1**. -Additionally, the controller must get the commissioning information from the Matter accessory device and provision the device into the network. -For details, see the `Commissioning the device`_ section. - -Configuration -************* - -|config| - -.. _matter_weather_station_sample_selecting_build_configuration: - -Selecting build configuration -============================= - -This sample supports the following build types: - -* Debug - This build type enables additional features for verifying the application behavior, such as logs or command-line shell. -* Release - This build type enables only the necessary application functionalities to optimize its performance. - -You can find configuration options for both build types in the corresponding :file:`prj_debug.conf` and :file:`prj_release.conf` files. -By default, the sample selects the release configuration. - -If you want to build the target with the debug configuration, you can set the following flag when building the sample: - -* ``-DCMAKE_BUILD_TYPE=debug`` - -See :ref:`cmake_options` for instructions on how to add these options to your build. -For example, when building on the command line, you can build the target with the debug configuration running the following command: - -.. parsed-literal:: - :class: highlight - - west build -b thingy53_nrf5340_cpuapp -- -DCMAKE_BUILD_TYPE=debug - -Device Firmware Upgrade support -=============================== - -This sample by default uses MCUboot for performing over-the-air Device Firmware Upgrade using Bluetooth LE. -To build the sample with both the secure bootloader and the DFU support disabled, you can use the ``-DBUILD_WITH_DFU=0`` flag in your build. - -See :ref:`cmake_options` for instructions on how to add this option to your build. -For example, when building on the command line, you can run the following command: - -.. parsed-literal:: - :class: highlight - - west build -b thingy53_nrf5340_cpuapp -- -DBUILD_WITH_DFU=0 - -User interface -************** - -LED 1: - Shows the overall state of the device and its connectivity. - The following states are possible: - - * Green color short flash on (50 ms on/950 ms off) - The device is in the unprovisioned (unpaired) state and is not advertising over Bluetooth LE. - * Blue color short flash on (50 ms on/950 ms off) - The device is in the unprovisioned (unpaired) state and is advertising over Bluetooth LE. - * Blue color rapid even flashing (100 ms on/100 ms off) - The device is in the unprovisioned state and a commissioning application is connected through Bluetooth LE. - * Purple color short flash on (50 ms on/950 ms off) - The device is fully provisioned and has Thread enabled. - -Button 1: - This button is used during the :ref:`commissioning procedure `. - Depending on how long you press the button: - - * If pressed for 6 seconds, it initiates the factory reset of the device. - Releasing the button within the 6-second window cancels the factory reset procedure. - * If pressed for less than 3 seconds, it starts the NFC tag emulation, enables Bluetooth LE advertising for the predefined period of time, and makes the device discoverable over Bluetooth LE. - -Serial Wire Debug port: - Used for getting logs from the device or communicating with it through the command-line interface. - It is enabled only for the debug configuration of a sample. - See the :ref:`build configuration ` to learn how to select debug configuration. - -NFC port with antenna attached: - Used for obtaining the commissioning information from the Matter accessory device to start the :ref:`commissioning procedure `. - -Building and running -******************** - -.. |sample path| replace:: :file:`samples/matter/weather_station` - -.. include:: /includes/build_and_run.txt - -Testing -======= - -.. note:: - |weather_station_wip_note| - -.. _matter_weather_station_sample_remote_control: - -Enabling remote control -======================= - -Remote control allows you to control the Matter weather station device from a Thread network. -The weather station sample supports `Commissioning the device`_, which allows you to set up a testing environment and remotely control the sample over a Matter-enabled Thread network. - -.. _matter_weather_station_sample_remote_control_commissioning: - -Commissioning the device ------------------------- - -.. include:: ../lock/README.rst - :start-after: matter_door_lock_sample_commissioning_start - :end-before: matter_door_lock_sample_commissioning_end - -Before starting the commissioning procedure, the device must be made discoverable over Bluetooth LE that starts automatically upon the device startup but only for a predefined period of time (15 minutes by default). -If the Bluetooth LE advertising times out, you can re-enable it manually using **Button 1**. - -To start commissioning, the controller must get the commissioning information from the Matter accessory device. -The data payload, which includes the device discriminator and setup PIN code, is encoded and shared using an NFC tag. -When using the debug configuration, you can also get this type of information from the RTT interface logs. - -Upgrading the device firmware -============================= - -To upgrade the device firmware, complete the steps listed for the selected method in the `Performing Device Firmware Upgrade in Matter device`_ tutorial. - -Dependencies -************ - -This sample uses the Matter library, which includes the |NCS| platform integration layer: - -* `Matter`_ - -In addition, the sample uses the following |NCS| components: - -* :ref:`dk_buttons_and_leds_readme` -* :ref:`nfc_uri` -* :ref:`lib_nfc_t2t` - -The sample depends on the following Zephyr libraries: - -* :ref:`zephyr:logging_api` -* :ref:`zephyr:kernel_api` - -.. |weather_station_wip_note| replace:: This sample is still in development and offers no testing scenarios at the moment. diff --git a/samples/nfc/record_text/sample.yaml b/samples/nfc/record_text/sample.yaml index 7a882fd08452..c087c96b5233 100644 --- a/samples/nfc/record_text/sample.yaml +++ b/samples/nfc/record_text/sample.yaml @@ -4,5 +4,5 @@ sample: tests: samples.nfc.record_text: build_only: true - platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: ci_build diff --git a/samples/nfc/system_off/sample.yaml b/samples/nfc/system_off/sample.yaml index 85f8b907ac3c..c96f477cc1f4 100644 --- a/samples/nfc/system_off/sample.yaml +++ b/samples/nfc/system_off/sample.yaml @@ -4,5 +4,5 @@ sample: tests: samples.nfc.system_off: build_only: true - platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: ci_build diff --git a/samples/nfc/tnep_tag/sample.yaml b/samples/nfc/tnep_tag/sample.yaml index b434980e3df8..f81387b8cb91 100644 --- a/samples/nfc/tnep_tag/sample.yaml +++ b/samples/nfc/tnep_tag/sample.yaml @@ -4,5 +4,5 @@ sample: tests: samples.nfc.tnep_tag: build_only: true - platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: ci_build diff --git a/samples/nfc/writable_ndef_msg/sample.yaml b/samples/nfc/writable_ndef_msg/sample.yaml index 3dc1d5e4753e..c993aec8e749 100644 --- a/samples/nfc/writable_ndef_msg/sample.yaml +++ b/samples/nfc/writable_ndef_msg/sample.yaml @@ -4,5 +4,5 @@ sample: tests: samples.nfc.writable_ndef_msg: build_only: true - platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: ci_build diff --git a/samples/nrf5340/multiprotocol_rpmsg/README.rst b/samples/nrf5340/multiprotocol_rpmsg/README.rst index 87c6b05043aa..958f6d74f57b 100644 --- a/samples/nrf5340/multiprotocol_rpmsg/README.rst +++ b/samples/nrf5340/multiprotocol_rpmsg/README.rst @@ -12,16 +12,16 @@ This sample exposes the :ref:`softdevice_controller` and the IEEE 802.15.4 radio Overview ******** -The sample is compatible with the HCI RPMsg driver provided by the |NCS| Bluetooth :ref:`bt_hci_drivers` core and with the nRF 802.15.4 Serialization Host module. +The sample is compatible with the HCI RPMsg driver provided by the |NCS| Bluetooth® :ref:`bt_hci_drivers` core and with the nRF 802.15.4 Serialization Host module. See the following configuration options for more information: -* :option:`CONFIG_BT_RPMSG` -* :option:`CONFIG_NRF_802154_SER_HOST` -* :option:`CONFIG_BT_RPMSG_NRF53` +* :kconfig:`CONFIG_BT_RPMSG` +* :kconfig:`CONFIG_NRF_802154_SER_HOST` +* :kconfig:`CONFIG_BT_RPMSG_NRF53` You might need to adjust the Kconfig configuration of this sample to make it compatible with the peer application. -For example, :option:`CONFIG_BT_MAX_CONN` must be equal to the maximum number of connections supported by the peer application. +For example, :kconfig:`CONFIG_BT_MAX_CONN` must be equal to the maximum number of connections supported by the peer application. The following components have been disabled to make this sample energy-efficient: @@ -47,7 +47,7 @@ Building and Running You must program this sample to the nRF5340 network core. The recommended way of building the sample is to use the multi-image feature of the build system. -In this way, the sample is built automatically as a child image when both :option:`CONFIG_BT_RPMSG_NRF53` and :option:`CONFIG_NRF_802154_SER_HOST` are enabled. +In this way, the sample is built automatically as a child image when both :kconfig:`CONFIG_BT_RPMSG_NRF53` and :kconfig:`CONFIG_NRF_802154_SER_HOST` are enabled. See :ref:`configure_application` for information about how to configure the sample. diff --git a/samples/nrf5340/netboot/README.rst b/samples/nrf5340/netboot/README.rst index d843e8aa5c6a..1bee827b4ad4 100644 --- a/samples/nrf5340/netboot/README.rst +++ b/samples/nrf5340/netboot/README.rst @@ -15,7 +15,7 @@ Overview The network core bootloader sample protects the flash memory areas allocated to both itself and the application running on the network core. You must use this sample as a child image of a :ref:`multi-image ` build, where MCUboot is enabled and there is a network core application. -MCUboot verifies and shares with the network core bootloader any new network core application image received through a device firmware update (DFU) transport layer, like a serial or a Bluetooth LE connection. +MCUboot verifies and shares with the network core bootloader any new network core application image received through a device firmware update (DFU) transport layer, like a serial or a Bluetooth® LE connection. For this reason, without MCUboot, this sample does nothing other than launching directly the application. During the boot process, the network core bootloader sample and MCUboot interact as follows: @@ -55,9 +55,9 @@ This sample can be found under :file:`samples/nrf5340/netboot/` in the |NCS| fol Follow the steps below to include the sample as a child image in a :ref:`multi-image ` build that contains a network core application: -#. Add MCUboot to the build by enabling the :option:`CONFIG_BOOTLOADER_MCUBOOT` option in the application that runs on the application core. - When doing so, the build system includes the sample in the build by automatically enabling the :option:`CONFIG_SECURE_BOOT` option for the application that runs on the network core. -#. Enable the :ref:`subsys_pcd` library for MCUboot by setting the :option:`CONFIG_PCD` option when building its image. +#. Add MCUboot to the build by enabling the :kconfig:`CONFIG_BOOTLOADER_MCUBOOT` option in the application that runs on the application core. + When doing so, the build system includes the sample in the build by automatically enabling the :kconfig:`CONFIG_SECURE_BOOT` option for the application that runs on the network core. +#. Enable the :ref:`subsys_pcd` library for MCUboot by setting the :kconfig:`CONFIG_PCD` option when building its image. The build system generates a new set of firmware update files. These files match the ones described in :ref:`mcuboot:mcuboot_ncs`, except that they contain the network core application firmware and are prefixed with ``net_core_``. diff --git a/samples/nrf9160/agps/README.rst b/samples/nrf9160/agps/README.rst index 60e5bc46d459..ea7f4c6ddb65 100644 --- a/samples/nrf9160/agps/README.rst +++ b/samples/nrf9160/agps/README.rst @@ -8,7 +8,7 @@ nRF9160: A-GPS :depth: 2 The A-GPS sample demonstrates how the `nRF Connect for Cloud`_ Assisted GPS (`A-GPS`_) feature or an external :ref:`SUPL client ` can be used to implement A-GPS in your application. -The sample uses the generic A-GPS library, which allows the selection of different A-GPS sources via the :option:`CONFIG_AGPS_SRC_SUPL` configurable option. +The sample uses the generic A-GPS library, which allows the selection of different A-GPS sources via the :kconfig:`CONFIG_AGPS_SRC_SUPL` configurable option. By default, `nRF Connect for Cloud`_ is used for A-GPS and cloud communication. Requirements @@ -18,7 +18,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns, nrf9160dk_nrf9160ns + :rows: thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns The sample also requires an nRF Connect for Cloud account. @@ -59,7 +59,7 @@ In RRC idle mode, the GPS is usually able to operate. It is recommended to use LTE Power Saving Mode (PSM) and extended Discontinuous Reception (eDRX) mode to increase the allowed time of operation for GPS. During the defined intervals of PSM and eDRX, LTE communication does not occur, and the GPS has full access to the radio resources. In this sample, both PSM and eDRX are enabled by default. -You can enable or disable these features by using the :option:`CONFIG_LTE_POWER_SAVING_MODE` and :option:`CONFIG_LTE_EDRX_REQ` configuration options. +You can enable or disable these features by using the :kconfig:`CONFIG_LTE_POWER_SAVING_MODE` and :kconfig:`CONFIG_LTE_EDRX_REQ` configuration options. .. include:: /applications/asset_tracker/README.rst :start-after: external_antenna_note_start @@ -69,7 +69,7 @@ User interface ************** You can send a predefined message to nRF Connect for Cloud by pressing button 1. -The message can be changed by setting the :option:`CONFIG_CLOUD_MESSAGE` to a new message. +The message can be changed by setting the :kconfig:`CONFIG_CLOUD_MESSAGE` to a new message. To ease outdoors and remote testing of A-GPS feature, two methods for resetting the kit are provided, if the default A-GPS source is used. Both are equivalent to pressing the reset button on the nRF9160 DK, or power-cycling the nRF9160 DK or Thingy:91. @@ -99,7 +99,7 @@ Additional configuration Check and configure the following library options that are used by the sample: -* :option:`CONFIG_LTE_EDRX_REQ` +* :kconfig:`CONFIG_LTE_EDRX_REQ` Building and running @@ -140,7 +140,7 @@ Testing This is to achieve sufficient satellite coverage to get a position fix. #. Optionally, connect the nRF9160-based device to a PC with a USB cable. The kit is assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager. #. Optionally, connect to the kit with a terminal emulator (for example, PuTTY) to see log output. See How to connect with PuTTY for the required settings. - You can also use the Bluetooth LE service of Thingy:91 to see log output on a mobile device. + You can also use the Bluetooth® LE service of Thingy:91 to see log output on a mobile device. #. Log into your nRF Connect for Cloud account and select your device. #. Power on the nRF9160-based device. diff --git a/samples/nrf9160/agps/sample.yaml b/samples/nrf9160/agps/sample.yaml index 857995fc3c4c..55feef7d440a 100644 --- a/samples/nrf9160/agps/sample.yaml +++ b/samples/nrf9160/agps/sample.yaml @@ -3,8 +3,8 @@ sample: tests: samples.nrf9160.agps: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns - - thingy91_nrf9160ns + - nrf9160dk_nrf9160_ns + - thingy91_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/agps/src/main.c b/samples/nrf9160/agps/src/main.c index 2395f631ae81..4488540e24b9 100644 --- a/samples/nrf9160/agps/src/main.c +++ b/samples/nrf9160/agps/src/main.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #if defined(CONFIG_NRF_CLOUD_PGPS) #include @@ -143,10 +144,44 @@ static void gps_start_work_fn(struct k_work *work) gps_cfg.interval, gps_cfg.timeout); } +#if defined(CONFIG_AGPS) +/* Converts the A-GPS data request from GPS driver to GNSS API format. */ +static void agps_request_convert( + struct nrf_modem_gnss_agps_data_frame *dest, + const struct gps_agps_request *src) +{ + dest->sv_mask_ephe = src->sv_mask_ephe; + dest->sv_mask_alm = src->sv_mask_alm; + dest->data_flags = 0; + if (src->utc) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_GPS_UTC_REQUEST; + } + if (src->klobuchar) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_KLOBUCHAR_REQUEST; + } + if (src->nequick) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_NEQUICK_REQUEST; + } + if (src->system_time_tow) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST; + } + if (src->position) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_POSITION_REQUEST; + } + if (src->integrity) { + dest->data_flags |= NRF_MODEM_GNSS_AGPS_INTEGRITY_REQUEST; + } +} +#endif + static void on_agps_needed(struct gps_agps_request request) { #if defined(CONFIG_AGPS) - int err = gps_agps_request_send(request, GPS_SOCKET_NOT_PROVIDED); + struct nrf_modem_gnss_agps_data_frame agps_request; + + agps_request_convert(&agps_request, &request); + + int err = agps_request_send(agps_request, AGPS_SOCKET_NOT_PROVIDED); if (err) { LOG_ERR("Failed to request A-GPS data, error: %d", err); @@ -237,7 +272,7 @@ static void cloud_event_handler(const struct cloud_backend *const backend, } #if defined(CONFIG_AGPS) - err = gps_process_agps_data(evt->data.msg.buf, evt->data.msg.len); + err = agps_cloud_data_process(evt->data.msg.buf, evt->data.msg.len); if (!err) { LOG_INF("A-GPS data processed"); #if defined(CONFIG_NRF_CLOUD_PGPS) diff --git a/samples/nrf9160/at_client/README.rst b/samples/nrf9160/at_client/README.rst index 41d8618e6a2d..fb5a02d5899c 100644 --- a/samples/nrf9160/at_client/README.rst +++ b/samples/nrf9160/at_client/README.rst @@ -28,7 +28,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt diff --git a/samples/nrf9160/at_client/sample.yaml b/samples/nrf9160/at_client/sample.yaml index 3e495ecba9e4..6a48fddecb70 100644 --- a/samples/nrf9160/at_client/sample.yaml +++ b/samples/nrf9160/at_client/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.at_client: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/at_monitor/README.rst b/samples/nrf9160/at_monitor/README.rst index 1e0dc3c93c8f..9b4cca1e1922 100644 --- a/samples/nrf9160/at_monitor/README.rst +++ b/samples/nrf9160/at_monitor/README.rst @@ -16,7 +16,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt diff --git a/samples/nrf9160/at_monitor/sample.yaml b/samples/nrf9160/at_monitor/sample.yaml index 6014b5cdc1c8..be6611003857 100644 --- a/samples/nrf9160/at_monitor/sample.yaml +++ b/samples/nrf9160/at_monitor/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.at_monitor: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/aws_fota/README.rst b/samples/nrf9160/aws_fota/README.rst index 0ce6eea96573..2ea95ad3fe1f 100644 --- a/samples/nrf9160/aws_fota/README.rst +++ b/samples/nrf9160/aws_fota/README.rst @@ -93,7 +93,7 @@ Use LTE Link Monitor to write the certificates to the kit: #. Paste the three certificates into the respective fields. #. Choose a security tag. #. Click :guilabel:`Update certificates`. - #. Before programming the sample, make sure to configure the :option:`security tag ` to the one that you chose. + #. Before programming the sample, make sure to configure the :kconfig:`security tag ` to the one that you chose. .. include:: /includes/aws_s3_bucket.txt diff --git a/samples/nrf9160/aws_fota/sample.yaml b/samples/nrf9160/aws_fota/sample.yaml index b6a72d798386..b4313320e298 100644 --- a/samples/nrf9160/aws_fota/sample.yaml +++ b/samples/nrf9160/aws_fota/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.aws_fota: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/aws_iot/README.rst b/samples/nrf9160/aws_iot/README.rst index 28167b053dac..160200e99dd1 100644 --- a/samples/nrf9160/aws_iot/README.rst +++ b/samples/nrf9160/aws_iot/README.rst @@ -33,7 +33,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns, nrf9160dk_nrf9160ns + :rows: thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -68,10 +68,10 @@ Configures the time interval between each publishing of the message. .. note:: - The sample sets the option :option:`CONFIG_MQTT_KEEPALIVE` to the maximum allowed value, 1200 seconds (20 minutes) as specified by AWS IoT Core. + The sample sets the option :kconfig:`CONFIG_MQTT_KEEPALIVE` to the maximum allowed value, 1200 seconds (20 minutes) as specified by AWS IoT Core. This is to limit the IP traffic between the device and the AWS IoT message broker for supporting a low power sample. However, note that in certain LTE networks, the NAT timeout can be considerably lower than 1200 seconds. - So as a recommendation, and to prevent the likelihood of getting disconnected unexpectedly, the option :option:`CONFIG_MQTT_KEEPALIVE` must be set to the lowest of the aforementioned timeout limits (Maximum allowed MQTT keepalive and NAT timeout). + So as a recommendation, and to prevent the likelihood of getting disconnected unexpectedly, the option :kconfig:`CONFIG_MQTT_KEEPALIVE` must be set to the lowest of the aforementioned timeout limits (Maximum allowed MQTT keepalive and NAT timeout). Building and running ******************** @@ -86,12 +86,12 @@ Testing 1. Make sure that you have completed the steps in :ref:`setup_awsiot`. This retrieves the AWS IoT broker hostname, security tag and client-id. -#. Set the :option:`CONFIG_AWS_IOT_BROKER_HOST_NAME`, :option:`CONFIG_AWS_IOT_SEC_TAG`, and :option:`CONFIG_AWS_IOT_CLIENT_ID_STATIC` options to reflect the values retrieved during step 1. +#. Set the :kconfig:`CONFIG_AWS_IOT_BROKER_HOST_NAME`, :kconfig:`CONFIG_AWS_IOT_SEC_TAG`, and :kconfig:`CONFIG_AWS_IOT_CLIENT_ID_STATIC` options to reflect the values retrieved during step 1. #. Program the sample to hardware. .. note:: - The sample might require increasing the values of :option:`CONFIG_AWS_IOT_MQTT_RX_TX_BUFFER_LEN` and :option:`CONFIG_AWS_IOT_MQTT_PAYLOAD_BUFFER_LEN` options. + The sample might require increasing the values of :kconfig:`CONFIG_AWS_IOT_MQTT_RX_TX_BUFFER_LEN` and :kconfig:`CONFIG_AWS_IOT_MQTT_PAYLOAD_BUFFER_LEN` options. Sample Output ============= diff --git a/samples/nrf9160/aws_iot/sample.yaml b/samples/nrf9160/aws_iot/sample.yaml index 3efa31a9c011..887db5cfb0d8 100644 --- a/samples/nrf9160/aws_iot/sample.yaml +++ b/samples/nrf9160/aws_iot/sample.yaml @@ -3,8 +3,8 @@ sample: tests: samples.nrf9160.aws_iot: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns - - thingy91_nrf9160ns + - nrf9160dk_nrf9160_ns + - thingy91_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/azure_fota/README.rst b/samples/nrf9160/azure_fota/README.rst index 26684473f356..517c344c6b54 100644 --- a/samples/nrf9160/azure_fota/README.rst +++ b/samples/nrf9160/azure_fota/README.rst @@ -16,7 +16,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns, nrf9160dk_nrf9160ns + :rows: thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns The sample also requires an Azure IoT Hub instance, and optionally an `Azure IoT Hub Device Provisioning Service (DPS)`_ instance, if the device is not already registered with the IoT hub. @@ -56,16 +56,16 @@ Additional configuration Check and configure the following library options that are used by the sample: -* :option:`CONFIG_AZURE_FOTA_APP_VERSION` - Defines the application version string. Indicates the current firmware version on the development kit. -* :option:`CONFIG_AZURE_FOTA_APP_VERSION_AUTO` - Automatically generates the application version. If enabled, :option:`CONFIG_AZURE_FOTA_APP_VERSION` is ignored. -* :option:`CONFIG_AZURE_FOTA_TLS` - Enables HTTPS for downloads. By default, TLS is enabled and currently, the transport protocol must be configured at compile time. -* :option:`CONFIG_AZURE_FOTA_SEC_TAG` - Sets the security tag for TLS credentials when using HTTPS as the transport layer. See :ref:`certificates` for more details. -* :option:`CONFIG_AZURE_IOT_HUB_HOSTNAME` - Sets the Azure IoT Hub host name. If DPS is used, the sample assumes that the IoT hub host name is unknown, and the configuration is ignored. -* :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` - Specifies the device ID, which is used when connecting to Azure IoT Hub or when DPS is enabled. +* :kconfig:`CONFIG_AZURE_FOTA_APP_VERSION` - Defines the application version string. Indicates the current firmware version on the development kit. +* :kconfig:`CONFIG_AZURE_FOTA_APP_VERSION_AUTO` - Automatically generates the application version. If enabled, :kconfig:`CONFIG_AZURE_FOTA_APP_VERSION` is ignored. +* :kconfig:`CONFIG_AZURE_FOTA_TLS` - Enables HTTPS for downloads. By default, TLS is enabled and currently, the transport protocol must be configured at compile time. +* :kconfig:`CONFIG_AZURE_FOTA_SEC_TAG` - Sets the security tag for TLS credentials when using HTTPS as the transport layer. See :ref:`certificates` for more details. +* :kconfig:`CONFIG_AZURE_IOT_HUB_HOSTNAME` - Sets the Azure IoT Hub host name. If DPS is used, the sample assumes that the IoT hub host name is unknown, and the configuration is ignored. +* :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` - Specifies the device ID, which is used when connecting to Azure IoT Hub or when DPS is enabled. .. note:: - If the :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` option is disabled, the device ID must be set in :file:`prj.conf`. - If the :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` option is enabled, the device ID must be provided using the :c:struct:`azure_iot_hub_config` configuration struct in a call to the :c:func:`azure_iot_hub_init` function. + If the :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` option is disabled, the device ID must be set in :file:`prj.conf`. + If the :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` option is enabled, the device ID must be provided using the :c:struct:`azure_iot_hub_config` configuration struct in a call to the :c:func:`azure_iot_hub_init` function. Building and running ******************** diff --git a/samples/nrf9160/azure_fota/sample.yaml b/samples/nrf9160/azure_fota/sample.yaml index 1f3ff3d91254..b1174628ab9c 100644 --- a/samples/nrf9160/azure_fota/sample.yaml +++ b/samples/nrf9160/azure_fota/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.azure_fota: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/azure_iot_hub/README.rst b/samples/nrf9160/azure_iot_hub/README.rst index ad84eefebd2f..124c3604110c 100644 --- a/samples/nrf9160/azure_iot_hub/README.rst +++ b/samples/nrf9160/azure_iot_hub/README.rst @@ -18,7 +18,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns, nrf9160dk_nrf9160ns + :rows: thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -64,17 +64,17 @@ Additional Configuration Check and configure the following library options that are used by the sample: -* :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` - Sets the Azure IoT Hub device ID. Alternatively, enable :option:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` option and set the device ID at run time in :c:struct:`azure_iot_hub_config` passed to the :c:func:`azure_iot_hub_init` function. -* :option:`CONFIG_AZURE_IOT_HUB_HOSTNAME` - Sets the Azure IoT Hub host name. If DPS is used, the sample assumes that the IoT hub host name is unknown, and the configuration is ignored. -* :option:`CONFIG_AZURE_IOT_HUB_DPS` - Enables Azure IoT Hub DPS. -* :option:`CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE` - Sets the Azure IoT Hub DPS ID scope. +* :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID` - Sets the Azure IoT Hub device ID. Alternatively, enable :kconfig:`CONFIG_AZURE_IOT_HUB_DEVICE_ID_APP` option and set the device ID at run time in :c:struct:`azure_iot_hub_config` passed to the :c:func:`azure_iot_hub_init` function. +* :kconfig:`CONFIG_AZURE_IOT_HUB_HOSTNAME` - Sets the Azure IoT Hub host name. If DPS is used, the sample assumes that the IoT hub host name is unknown, and the configuration is ignored. +* :kconfig:`CONFIG_AZURE_IOT_HUB_DPS` - Enables Azure IoT Hub DPS. +* :kconfig:`CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE` - Sets the Azure IoT Hub DPS ID scope. .. note:: - The sample sets the option :option:`CONFIG_MQTT_KEEPALIVE` to the maximum allowed value, 1767 seconds (29.45 minutes) as specified by Azure IoT Hub. + The sample sets the option :kconfig:`CONFIG_MQTT_KEEPALIVE` to the maximum allowed value, 1767 seconds (29.45 minutes) as specified by Azure IoT Hub. This is to limit the IP traffic between the device and the Azure IoT Hub message broker for supporting a low power sample. However, note that in certain LTE networks, the NAT timeout can be considerably lower than 1767 seconds. - So as a recommendation, and to prevent the likelihood of getting disconnected unexpectedly, the option :option:`CONFIG_MQTT_KEEPALIVE` must be set to the lowest of the aforementioned timeout limits (Maximum allowed MQTT keepalive and NAT timeout). + So as a recommendation, and to prevent the likelihood of getting disconnected unexpectedly, the option :kconfig:`CONFIG_MQTT_KEEPALIVE` must be set to the lowest of the aforementioned timeout limits (Maximum allowed MQTT keepalive and NAT timeout). Building and running ******************** diff --git a/samples/nrf9160/azure_iot_hub/sample.yaml b/samples/nrf9160/azure_iot_hub/sample.yaml index ab7fc48cdc90..fe709286eda3 100644 --- a/samples/nrf9160/azure_iot_hub/sample.yaml +++ b/samples/nrf9160/azure_iot_hub/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.azure_iot_hub: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/cloud_client/README.rst b/samples/nrf9160/cloud_client/README.rst index c67c1f230a68..e2f2bfa6c5f6 100644 --- a/samples/nrf9160/cloud_client/README.rst +++ b/samples/nrf9160/cloud_client/README.rst @@ -20,7 +20,7 @@ The current version of the sample supports the following libraries as cloud back * :ref:`lib_aws_iot` * :ref:`lib_azure_iot_hub` -To swap between the supported libraries, change the option :option:`CONFIG_CLOUD_BACKEND` to match the configuration string of a compatible cloud backend. +To swap between the supported libraries, change the option :kconfig:`CONFIG_CLOUD_BACKEND` to match the configuration string of a compatible cloud backend. The identification strings for the different cloud backends are listed in the following table: .. list-table:: @@ -71,10 +71,10 @@ The configurations used in the sample are listed below. They can be added to ``c To output data in the terminal window located in the `nRF Connect for Cloud`_ web interface, the data format must be in JSON format. .. note:: - The sample sets the option :option:`CONFIG_MQTT_KEEPALIVE` to the maximum allowed value that is specified by the configured cloud backend. + The sample sets the option :kconfig:`CONFIG_MQTT_KEEPALIVE` to the maximum allowed value that is specified by the configured cloud backend. This is to limit the IP traffic between the device and the message broker of the cloud provider for supporting a low power sample. However, note that in certain LTE networks, the NAT timeout can be considerably lower than the maximum allowed MQTT keepalive. - So as a recommendation, and to prevent the likelihood of getting disconnected unexpectedly, the option :option:`CONFIG_MQTT_KEEPALIVE` must be set to the lowest of the aforementioned timeout limits (Maximum allowed MQTT keepalive and NAT timeout). + So as a recommendation, and to prevent the likelihood of getting disconnected unexpectedly, the option :kconfig:`CONFIG_MQTT_KEEPALIVE` must be set to the lowest of the aforementioned timeout limits (Maximum allowed MQTT keepalive and NAT timeout). Functionality and Supported Technologies **************************************** diff --git a/samples/nrf9160/cloud_client/sample.yaml b/samples/nrf9160/cloud_client/sample.yaml index 4fadbc8e7032..eb771ab23f55 100644 --- a/samples/nrf9160/cloud_client/sample.yaml +++ b/samples/nrf9160/cloud_client/sample.yaml @@ -3,8 +3,8 @@ sample: tests: samples.nrf9160.cloud_client: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns - - thingy91_nrf9160ns + - nrf9160dk_nrf9160_ns + - thingy91_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/coap_client/README.rst b/samples/nrf9160/coap_client/README.rst index 17792dcb9e91..2c7a32507bb0 100644 --- a/samples/nrf9160/coap_client/README.rst +++ b/samples/nrf9160/coap_client/README.rst @@ -34,7 +34,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns The sample also requires a public CoAP server IP address or URL available on the internet. diff --git a/samples/nrf9160/coap_client/sample.yaml b/samples/nrf9160/coap_client/sample.yaml index 8ec327dcbfe4..3f76c3b99595 100644 --- a/samples/nrf9160/coap_client/sample.yaml +++ b/samples/nrf9160/coap_client/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.coap_client: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/download/README.rst b/samples/nrf9160/download/README.rst index 490befa884a6..e2cb20c7e822 100644 --- a/samples/nrf9160/download/README.rst +++ b/samples/nrf9160/download/README.rst @@ -17,7 +17,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -26,9 +26,9 @@ Overview ******** The sample first initializes the :ref:`nrfxlib:nrf_modem` and AT communications. -Next, it provisions a certificate to the modem using the :ref:`modem_key_mgmt` library if the :option:`CONFIG_SAMPLE_SECURE_SOCKET` option is set. +Next, it provisions a certificate to the modem using the :ref:`modem_key_mgmt` library if the :kconfig:`CONFIG_SAMPLE_SECURE_SOCKET` option is set. The provisioning of the certificates must be done before connecting to the LTE network since the certificates can only be provisioned when the device is not connected. -The certificate file name and security tag can be configured via the :option:`CONFIG_SAMPLE_SEC_TAG` and the :option:`CONFIG_SAMPLE_CERT_FILE` options, respectively. +The certificate file name and security tag can be configured via the :kconfig:`CONFIG_SAMPLE_SEC_TAG` and the :kconfig:`CONFIG_SAMPLE_CERT_FILE` options, respectively. The sample then performs the following actions: @@ -40,13 +40,13 @@ The sample then performs the following actions: Downloading from a CoAP server ============================== -To enable CoAP block-wise transfer, it is necessary to enable :ref:`Zephyr's CoAP stack ` via the :option:`CONFIG_COAP` option. +To enable CoAP block-wise transfer, it is necessary to enable :ref:`Zephyr's CoAP stack ` via the :kconfig:`CONFIG_COAP` option. Using TLS and DTLS ================== -When the :option:`CONFIG_SAMPLE_SECURE_SOCKET` option is set, the sample provisions the certificate found in the :file:`samples/nrf9160/download/cert` folder. -The certificate file name is indicated by the :option:`CONFIG_SAMPLE_CERT_FILE` option. +When the :kconfig:`CONFIG_SAMPLE_SECURE_SOCKET` option is set, the sample provisions the certificate found in the :file:`samples/nrf9160/download/cert` folder. +The certificate file name is indicated by the :kconfig:`CONFIG_SAMPLE_CERT_FILE` option. This certificate will work for the default test files. If you are using a custom download test file, you have to provision the correct certificate for the servers from which the certificates will be downloaded. @@ -80,11 +80,11 @@ If enabled, this option computes the SHA256 hash of the downloaded file. .. option:: CONFIG_SAMPLE_COMPARE_HASH - Hash compare configuration -If enabled, this option compares the hash against the SHA256 hash set by :option:`CONFIG_SAMPLE_SHA256_HASH` for a match. +If enabled, this option compares the hash against the SHA256 hash set by :kconfig:`CONFIG_SAMPLE_SHA256_HASH` for a match. .. option:: CONFIG_SAMPLE_SHA256_HASH - Hash configuration -This option sets the SHA256 hash to be compared with :option:`CONFIG_SAMPLE_COMPUTE_HASH`. +This option sets the SHA256 hash to be compared with :kconfig:`CONFIG_SAMPLE_COMPUTE_HASH`. Building and running diff --git a/samples/nrf9160/download/boards/nrf9160dk_nrf9160ns.overlay b/samples/nrf9160/download/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/nrf9160/download/boards/nrf9160dk_nrf9160ns.overlay rename to samples/nrf9160/download/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/nrf9160/download/sample.yaml b/samples/nrf9160/download/sample.yaml index c2a00821e8aa..0b419c506e2e 100644 --- a/samples/nrf9160/download/sample.yaml +++ b/samples/nrf9160/download/sample.yaml @@ -3,9 +3,9 @@ sample: tests: samples.nrf9160.download_client: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build extra_configs: - CONFIG_SHELL=y @@ -13,8 +13,8 @@ tests: - CONFIG_DOWNLOAD_CLIENT_SHELL=y samples.nrf9160.download.tfm: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build extra_args: OVERLAY_CONFIG="overlay-tfm.conf" diff --git a/samples/nrf9160/fmfu_smp_svr/README.rst b/samples/nrf9160/fmfu_smp_svr/README.rst index 89df9b36ace2..b1904bb5a7ed 100644 --- a/samples/nrf9160/fmfu_smp_svr/README.rst +++ b/samples/nrf9160/fmfu_smp_svr/README.rst @@ -18,7 +18,7 @@ This sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -48,7 +48,7 @@ For example, when building on the command line, add the UART overlay for nRF9160 .. code-block:: console - west build -b nrf9160dk_nrf9160ns -- -DDTC_OVERLAY_FILE=uart.overlay + west build -b nrf9160dk_nrf9160_ns -- -DDTC_OVERLAY_FILE=uart.overlay Testing ======= diff --git a/samples/nrf9160/fmfu_smp_svr/sample.yaml b/samples/nrf9160/fmfu_smp_svr/sample.yaml index 6c1dacc3b48e..9695852503de 100644 --- a/samples/nrf9160/fmfu_smp_svr/sample.yaml +++ b/samples/nrf9160/fmfu_smp_svr/sample.yaml @@ -4,7 +4,7 @@ sample: tests: samples.nrf9160.fmfu_smp_svr: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/gps/Kconfig b/samples/nrf9160/gps/Kconfig index 9955e6e9eafe..3035e54d02f9 100644 --- a/samples/nrf9160/gps/Kconfig +++ b/samples/nrf9160/gps/Kconfig @@ -25,16 +25,16 @@ endchoice config GPS_SAMPLE_AT_MAGPIO string "AT%XMAGPIO command" - default "AT\%XMAGPIO=1,0,0,1,1,1574,1577" if BOARD_NRF9160DK_NRF9160NS - default "AT\%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586" if BOARD_THINGY91_NRF9160NS + default "AT\%XMAGPIO=1,0,0,1,1,1574,1577" if BOARD_NRF9160DK_NRF9160_NS + default "AT\%XMAGPIO=1,1,1,7,1,746,803,2,698,748,2,1710,2200,3,824,894,4,880,960,5,791,849,7,1565,1586" if BOARD_THINGY91_NRF9160_NS help Defines what is the AT%XMAGPIO command to be sent to GPS module. Leave empty if this command should not be sent. config GPS_SAMPLE_AT_COEX0 string "AT%XCOEX0 command" - default "AT\%XCOEX0=1,1,1565,1586" if (BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS) && GPS_SAMPLE_ANTENNA_ONBOARD - default "AT\%XCOEX0" if (BOARD_NRF9160DK_NRF9160NS || BOARD_THINGY91_NRF9160NS) && GPS_SAMPLE_ANTENNA_EXTERNAL + default "AT\%XCOEX0=1,1,1565,1586" if (BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS) && GPS_SAMPLE_ANTENNA_ONBOARD + default "AT\%XCOEX0" if (BOARD_NRF9160DK_NRF9160_NS || BOARD_THINGY91_NRF9160_NS) && GPS_SAMPLE_ANTENNA_EXTERNAL help Defines what is the AT%XCOEX0 command to be sent to GPS module. Leave empty if this command should not be sent. diff --git a/samples/nrf9160/gps/README.rst b/samples/nrf9160/gps/README.rst index 8430d95b3016..2dc1821e3468 100644 --- a/samples/nrf9160/gps/README.rst +++ b/samples/nrf9160/gps/README.rst @@ -43,7 +43,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns The sample can be optionally used with the SUPL Client library (for details on download, see :ref:`supl_client`). diff --git a/samples/nrf9160/gps/sample.yaml b/samples/nrf9160/gps/sample.yaml index a161322f2bae..548a219a3921 100644 --- a/samples/nrf9160/gps/sample.yaml +++ b/samples/nrf9160/gps/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.gps: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/gps/src/main.c b/samples/nrf9160/gps/src/main.c index 1bd3c0b6701b..b9a2b49e47e6 100644 --- a/samples/nrf9160/gps/src/main.c +++ b/samples/nrf9160/gps/src/main.c @@ -229,6 +229,28 @@ static int init_app(void) } lte_lc_register_handler(lte_handler); + + static struct supl_api supl_api = { + .read = supl_read, + .write = supl_write, + .handler = inject_agps_type, + .logger = supl_logger, + .counter_ms = k_uptime_get + }; + + k_work_queue_start( + &agps_work_q, + agps_workq_stack_area, + K_THREAD_STACK_SIZEOF(agps_workq_stack_area), + AGPS_WORKQ_THREAD_PRIORITY, + NULL); + + k_work_init(&get_agps_data_work, get_agps_data); + + if (supl_init(&supl_api) != 0) { + printk("Failed to initialize SUPL library\n"); + return -1; + } #endif /* CONFIG_SUPL_CLIENT_LIB */ if (setup_modem() != 0) { @@ -271,30 +293,6 @@ static int init_app(void) return -1; } -#ifdef CONFIG_SUPL_CLIENT_LIB - static struct supl_api supl_api = { - .read = supl_read, - .write = supl_write, - .handler = inject_agps_type, - .logger = supl_logger, - .counter_ms = k_uptime_get - }; - - k_work_queue_start( - &agps_work_q, - agps_workq_stack_area, - K_THREAD_STACK_SIZEOF(agps_workq_stack_area), - AGPS_WORKQ_THREAD_PRIORITY, - NULL); - - k_work_init(&get_agps_data_work, get_agps_data); - - if (supl_init(&supl_api) != 0) { - printk("Failed to initialize SUPL library\n"); - return -1; - } -#endif - return 0; } diff --git a/samples/nrf9160/http_update/application_update/README.rst b/samples/nrf9160/http_update/application_update/README.rst index f1343afc3f9c..fdf57984ac9d 100644 --- a/samples/nrf9160/http_update/application_update/README.rst +++ b/samples/nrf9160/http_update/application_update/README.rst @@ -27,7 +27,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns The sample also requires a signed firmware image that is available for download from an HTTP server. This image is automatically generated when building the application. @@ -41,7 +41,7 @@ Building and running .. include:: /includes/build_and_run.txt -The sample is built as a non-secure firmware image for the nrf9160dk_nrf9160ns build target. +The sample is built as a non-secure firmware image for the nrf9160dk_nrf9160_ns build target. Because of this, it automatically includes the :ref:`secure_partition_manager`. The sample also uses MCUboot, which is automatically built and merged into the final HEX file when building the sample. diff --git a/samples/nrf9160/http_update/full_modem_update/README.rst b/samples/nrf9160/http_update/full_modem_update/README.rst index cf0c00bed58b..08b7c864eacb 100644 --- a/samples/nrf9160/http_update/full_modem_update/README.rst +++ b/samples/nrf9160/http_update/full_modem_update/README.rst @@ -33,7 +33,7 @@ The sample supports the following development kit, version 0.14.0 or higher: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -44,7 +44,7 @@ Building and running .. include:: /includes/build_and_run.txt -The sample is built as a non-secure firmware image for the ``nrf9160dk_nrf9160ns`` build target. +The sample is built as a non-secure firmware image for the ``nrf9160dk_nrf9160_ns`` build target. Because of this, it automatically includes the :ref:`secure_partition_manager`. You can customize the firmware files downloaded by the sample through the following Kconfig options in the :file:`prj.conf` file: diff --git a/samples/nrf9160/http_update/full_modem_update/boards/nrf9160dk_nrf9160ns.conf b/samples/nrf9160/http_update/full_modem_update/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/nrf9160/http_update/full_modem_update/boards/nrf9160dk_nrf9160ns.conf rename to samples/nrf9160/http_update/full_modem_update/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/nrf9160/http_update/full_modem_update/boards/nrf9160dk_nrf9160ns.overlay b/samples/nrf9160/http_update/full_modem_update/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/nrf9160/http_update/full_modem_update/boards/nrf9160dk_nrf9160ns.overlay rename to samples/nrf9160/http_update/full_modem_update/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/nrf9160/http_update/modem_delta_update/README.rst b/samples/nrf9160/http_update/modem_delta_update/README.rst index 2bdf5c8dcec7..21d91f7438aa 100644 --- a/samples/nrf9160/http_update/modem_delta_update/README.rst +++ b/samples/nrf9160/http_update/modem_delta_update/README.rst @@ -26,7 +26,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -38,7 +38,7 @@ Building and running .. include:: /includes/build_and_run.txt -The sample is built as a non-secure firmware image for the ``nrf9160dk_nrf9160ns`` build target. +The sample is built as a non-secure firmware image for the ``nrf9160dk_nrf9160_ns`` build target. Because of this, it automatically includes the :ref:`secure_partition_manager`. Testing diff --git a/samples/nrf9160/https_client/README.rst b/samples/nrf9160/https_client/README.rst index 151558d4650b..b1d072f7fdc1 100644 --- a/samples/nrf9160/https_client/README.rst +++ b/samples/nrf9160/https_client/README.rst @@ -17,7 +17,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt diff --git a/samples/nrf9160/https_client/sample.yaml b/samples/nrf9160/https_client/sample.yaml index 284831423eef..3fcae542d155 100644 --- a/samples/nrf9160/https_client/sample.yaml +++ b/samples/nrf9160/https_client/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.https_client: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/lte_ble_gateway/README.rst b/samples/nrf9160/lte_ble_gateway/README.rst index 99e268d98b73..83597b228985 100644 --- a/samples/nrf9160/lte_ble_gateway/README.rst +++ b/samples/nrf9160/lte_ble_gateway/README.rst @@ -9,7 +9,7 @@ nRF9160: LTE Sensor Gateway The LTE Sensor Gateway sample demonstrates how to transmit sensor data from an nRF9160 development kit to the `nRF Connect for Cloud`_. -The sensor data is collected via Bluetooth LE, unlike the :ref:`asset_tracker` sample. +The sensor data is collected via Bluetooth® Low Energy, unlike the :ref:`asset_tracker` sample. Therefore, this sample acts as a gateway between the Bluetooth LE and the LTE connections to nRF Connect for Cloud. Overview @@ -31,7 +31,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns The sample also requires a `Nordic Thingy:52`_. @@ -77,7 +77,7 @@ After programming the board controller, you must program the main controller wit You can program the main controller as follows: 1. Set the **SW5** switch, marked as *debug/prog*, in the **NRF91** position. -#. Build the LTE Sensor Gateway sample (this sample) for the nrf9160dk_nrf9160ns build target and program the main controller with it. +#. Build the LTE Sensor Gateway sample (this sample) for the nrf9160dk_nrf9160_ns build target and program the main controller with it. #. Verify that the program was successful. To do so, use a terminal emulator, like PuTTY, to connect to the first serial port and check the output. See :ref:`putty` for the required settings. diff --git a/samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160ns.conf b/samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160ns.conf rename to samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160_ns.conf diff --git a/samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160ns.overlay b/samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160ns.overlay rename to samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160ns_0_14_0.overlay b/samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay similarity index 100% rename from samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160ns_0_14_0.overlay rename to samples/nrf9160/lte_ble_gateway/boards/nrf9160dk_nrf9160_ns_0_14_0.overlay diff --git a/samples/nrf9160/lte_ble_gateway/sample.yaml b/samples/nrf9160/lte_ble_gateway/sample.yaml index 9b18b6d8f779..a7dc16092b72 100644 --- a/samples/nrf9160/lte_ble_gateway/sample.yaml +++ b/samples/nrf9160/lte_ble_gateway/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.lte_ble_gateway: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/lwm2m_carrier/README.rst b/samples/nrf9160/lwm2m_carrier/README.rst index df5645db00ab..64482f796d74 100644 --- a/samples/nrf9160/lwm2m_carrier/README.rst +++ b/samples/nrf9160/lwm2m_carrier/README.rst @@ -16,7 +16,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -58,7 +58,7 @@ This sample uses the following |NCS| libraries: * |NCS| modules abstracted via the LwM2M carrier OS abstraction layer (:file:`lwm2m_os.h`) - .. include:: /lib/bin/lwm2m_carrier/doc/app_integration.rst + .. include:: /libraries/bin/lwm2m_carrier/app_integration.rst :start-after: lwm2m_osal_mod_list_start :end-before: lwm2m_osal_mod_list_end diff --git a/samples/nrf9160/lwm2m_carrier/sample.yaml b/samples/nrf9160/lwm2m_carrier/sample.yaml index e8ede0b3754d..246b2111bf07 100644 --- a/samples/nrf9160/lwm2m_carrier/sample.yaml +++ b/samples/nrf9160/lwm2m_carrier/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.lwm2m_carrier: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/lwm2m_client/Kconfig b/samples/nrf9160/lwm2m_client/Kconfig index 5a05aeb070cd..9e536e212aab 100644 --- a/samples/nrf9160/lwm2m_client/Kconfig +++ b/samples/nrf9160/lwm2m_client/Kconfig @@ -134,8 +134,8 @@ config ACCEL_TRIGGER config FLIP_INPUT int "Button or switch number to simulate flip" - range 1 4 if BOARD_NRF9160DK_NRF9160NS - default 3 if BOARD_NRF9160DK_NRF9160NS + range 1 4 if BOARD_NRF9160DK_NRF9160_NS + default 3 if BOARD_NRF9160DK_NRF9160_NS default 0 help Button or switch number to use for simulating @@ -195,8 +195,8 @@ config ACCEL_CALIBRATION_ITERATIONS config CALIBRATION_INPUT int "Button to trigger accelerometer calibration" - range 1 2 if BOARD_NRF9160DK_NRF9160NS - default 1 if BOARD_NRF9160DK_NRF9160NS + range 1 2 if BOARD_NRF9160DK_NRF9160_NS + default 1 if BOARD_NRF9160DK_NRF9160_NS help Button number to use to trigger accelerometer calibration: 1 - Button 1 diff --git a/samples/nrf9160/lwm2m_client/README.rst b/samples/nrf9160/lwm2m_client/README.rst index 0c401767367e..97818fbae180 100644 --- a/samples/nrf9160/lwm2m_client/README.rst +++ b/samples/nrf9160/lwm2m_client/README.rst @@ -17,7 +17,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns The sample also requires an LwM2M server URL address available on the internet. For this sample, the URL address mentioned on the `Leshan Demo Server`_ page is used. @@ -97,9 +97,9 @@ Additional configurations Check and configure the following library options that are used by the sample: -* :option:`CONFIG_LWM2M_CLIENT_UTILS` - Enables the utility library :ref:`lib_lwm2m_client_utils`, which initializes a predefined set of objects. +* :kconfig:`CONFIG_LWM2M_CLIENT_UTILS` - Enables the utility library :ref:`lib_lwm2m_client_utils`, which initializes a predefined set of objects. -* :option:`CONFIG_LWM2M_IPSO_SUPPORT` - Enables support for different IPSO objects. If you are disabling this option, you must disable all the individual configuration options that enables the sensor. +* :kconfig:`CONFIG_LWM2M_IPSO_SUPPORT` - Enables support for different IPSO objects. If you are disabling this option, you must disable all the individual configuration options that enables the sensor. Configuration files diff --git a/samples/nrf9160/lwm2m_client/sample.yaml b/samples/nrf9160/lwm2m_client/sample.yaml index fc64f4a17705..f4b871d2e0ee 100644 --- a/samples/nrf9160/lwm2m_client/sample.yaml +++ b/samples/nrf9160/lwm2m_client/sample.yaml @@ -4,7 +4,7 @@ tests: samples.nrf9160.lwm2m_client: build_only: true extra_args: OVERLAY_CONFIG=overlay-ci.conf - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/lwm2m_client/src/ui/Kconfig b/samples/nrf9160/lwm2m_client/src/ui/Kconfig index ac54ae4e24d8..a0a180e0281a 100644 --- a/samples/nrf9160/lwm2m_client/src/ui/Kconfig +++ b/samples/nrf9160/lwm2m_client/src/ui/Kconfig @@ -10,8 +10,8 @@ config UI_LED_USE_PWM bool "Use PWM to control LEDs" default y depends on $(dt_alias_enabled,rgb-pwm) - select PWM if BOARD_THINGY91_NRF9160NS - select PWM_0 if BOARD_THINGY91_NRF9160NS + select PWM if BOARD_THINGY91_NRF9160_NS + select PWM_0 if BOARD_THINGY91_NRF9160_NS help If enabled, LEDs will be controlled with PWM. In order to enable this option, the devicetree must have an @@ -24,8 +24,8 @@ config UI_BUZZER bool "Enable buzzer" default y depends on $(dt_alias_enabled,buzzer-pwm) - select PWM if BOARD_THINGY91_NRF9160NS - select PWM_1 if BOARD_THINGY91_NRF9160NS + select PWM if BOARD_THINGY91_NRF9160_NS + select PWM_1 if BOARD_THINGY91_NRF9160_NS help If enabled, a buzzer will be controllable with PWM. In order to enable this option, the devicetree must have @@ -48,7 +48,7 @@ endif # UI_BUZZER config UI_BUTTON bool "Enable buttons" - default y if BOARD_NRF9160DK_NRF9160NS + default y if BOARD_NRF9160DK_NRF9160_NS endmenu diff --git a/samples/nrf9160/lwm2m_client/src/ui/buzzer.c b/samples/nrf9160/lwm2m_client/src/ui/buzzer.c index 3a18d28e8cc9..2495481ba0c9 100644 --- a/samples/nrf9160/lwm2m_client/src/ui/buzzer.c +++ b/samples/nrf9160/lwm2m_client/src/ui/buzzer.c @@ -65,9 +65,7 @@ static void buzzer_disable(void) pwm_out(0, 0); #ifdef CONFIG_PM_DEVICE - int err = pm_device_state_set(pwm_dev, - PM_DEVICE_STATE_SUSPEND, - NULL, NULL); + int err = pm_device_state_set(pwm_dev, PM_DEVICE_STATE_SUSPEND); if (err) { LOG_ERR("PWM disable failed"); } @@ -81,9 +79,7 @@ static int buzzer_enable(void) atomic_set(&buzzer_enabled, 1); #ifdef CONFIG_PM_DEVICE - err = pm_device_state_set(pwm_dev, - PM_DEVICE_STATE_ACTIVE, - NULL, NULL); + err = pm_device_state_set(pwm_dev, PM_DEVICE_STATE_ACTIVE); if (err) { LOG_ERR("PWM enable failed"); return err; diff --git a/samples/nrf9160/lwm2m_client/src/ui/led_pwm.c b/samples/nrf9160/lwm2m_client/src/ui/led_pwm.c index 8131f0dafde5..682ebce3be88 100644 --- a/samples/nrf9160/lwm2m_client/src/ui/led_pwm.c +++ b/samples/nrf9160/lwm2m_client/src/ui/led_pwm.c @@ -183,8 +183,7 @@ void ui_leds_start(void) { #ifdef CONFIG_PM_DEVICE int err = pm_device_state_set(leds.pwm_dev, - PM_DEVICE_STATE_ACTIVE, - NULL, NULL); + PM_DEVICE_STATE_ACTIVE); if (err) { LOG_ERR("PWM enable failed"); } @@ -197,8 +196,7 @@ void ui_leds_stop(void) k_work_cancel_delayable_sync(&leds.work, &leds.work_sync); #ifdef CONFIG_PM_DEVICE int err = pm_device_state_set(leds.pwm_dev, - PM_DEVICE_STATE_SUSPEND, - NULL, NULL); + PM_DEVICE_STATE_SUSPEND); if (err) { LOG_ERR("PWM disable failed"); } diff --git a/samples/nrf9160/memfault/README.rst b/samples/nrf9160/memfault/README.rst index b6d598cabe78..fb9d5b777239 100644 --- a/samples/nrf9160/memfault/README.rst +++ b/samples/nrf9160/memfault/README.rst @@ -18,7 +18,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns, nrf9160dk_nrf9160ns + :rows: thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns Before using the Memfault platform, you must register an account in `Memfault`_ and a set up a project according to the instructions in `Memfault documentation `_. @@ -43,14 +43,14 @@ There are also some metrics, which are specific to |NCS| that are enabled by def * LTE metrics: - * Enabled and disabled using :option:`CONFIG_MEMFAULT_NCS_LTE_METRICS`. + * Enabled and disabled using :kconfig:`CONFIG_MEMFAULT_NCS_LTE_METRICS`. * ``Ncs_LteTimeToConnect`` - Time from the point when the device starts to search for an LTE network until the time when it gets registered with the network. * ``Ncs_LteConnectionLossCount`` - The number of times that the device has lost the LTE network connection after the initial network registration. * Stack usage metrics: * Shows how many bytes of unused space is left in a stack. - * Configurable using :option:`CONFIG_MEMFAULT_NCS_STACK_METRICS`. + * Configurable using :kconfig:`CONFIG_MEMFAULT_NCS_STACK_METRICS`. * ``Ncs_AtCmdUnusedStack`` - The :ref:`at_cmd_readme` library's stack. * ``Ncs_ConnectionPollUnusedStack``- Stack used by the cloud libraries for :ref:`lib_nrf_cloud`, :ref:`lib_aws_iot` and :ref:`lib_azure_iot_hub`. @@ -98,7 +98,7 @@ See `Memfault SDK`_ for more information. Minimal setup ============= -To send data to the Memfault cloud, a project key must be configured using :option:`CONFIG_MEMFAULT_NCS_PROJECT_KEY`. +To send data to the Memfault cloud, a project key must be configured using :kconfig:`CONFIG_MEMFAULT_NCS_PROJECT_KEY`. .. note:: The Memfault SDK requires certificates required for the HTTPS transport. @@ -116,31 +116,31 @@ There are two sources for Kconfig options when using Memfault SDK in |NCS|: Check and configure the following options in Memfault SDK that are used by the sample: -* :option:`CONFIG_MEMFAULT` -* :option:`CONFIG_MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM` -* :option:`CONFIG_MEMFAULT_SHELL` -* :option:`CONFIG_MEMFAULT_HTTP_ENABLE` -* :option:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD` -* :option:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD_INTERVAL_SECS` -* :option:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD_USE_DEDICATED_WORKQUEUE` -* :option:`CONFIG_MEMFAULT_COREDUMP_COLLECT_BSS_REGIONS` +* :kconfig:`CONFIG_MEMFAULT` +* :kconfig:`CONFIG_MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM` +* :kconfig:`CONFIG_MEMFAULT_SHELL` +* :kconfig:`CONFIG_MEMFAULT_HTTP_ENABLE` +* :kconfig:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD` +* :kconfig:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD_INTERVAL_SECS` +* :kconfig:`CONFIG_MEMFAULT_HTTP_PERIODIC_UPLOAD_USE_DEDICATED_WORKQUEUE` +* :kconfig:`CONFIG_MEMFAULT_COREDUMP_COLLECT_BSS_REGIONS` -If :option:`CONFIG_MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM` is enabled, TLS certificates used for HTTP uploads are provisioned to the nRF9160 modem when :c:func:`memfault_zephyr_port_install_root_certs` is called. +If :kconfig:`CONFIG_MEMFAULT_ROOT_CERT_STORAGE_NRF9160_MODEM` is enabled, TLS certificates used for HTTP uploads are provisioned to the nRF9160 modem when :c:func:`memfault_zephyr_port_install_root_certs` is called. Check and configure the following options for Memfault that are specific to |NCS|: -* :option:`CONFIG_MEMFAULT_NCS_PROJECT_KEY` -* :option:`CONFIG_MEMFAULT_NCS_LTE_METRICS` -* :option:`CONFIG_MEMFAULT_NCS_STACK_METRICS` -* :option:`CONFIG_MEMFAULT_NCS_INTERNAL_FLASH_BACKED_COREDUMP` +* :kconfig:`CONFIG_MEMFAULT_NCS_PROJECT_KEY` +* :kconfig:`CONFIG_MEMFAULT_NCS_LTE_METRICS` +* :kconfig:`CONFIG_MEMFAULT_NCS_STACK_METRICS` +* :kconfig:`CONFIG_MEMFAULT_NCS_INTERNAL_FLASH_BACKED_COREDUMP` -If :option:`CONFIG_MEMFAULT_NCS_INTERNAL_FLASH_BACKED_COREDUMP` is enabled, :option:`CONFIG_PM_PARTITION_SIZE_MEMFAULT_STORAGE` can be used to set the flash partition size for the flash storage. +If :kconfig:`CONFIG_MEMFAULT_NCS_INTERNAL_FLASH_BACKED_COREDUMP` is enabled, :kconfig:`CONFIG_PM_PARTITION_SIZE_MEMFAULT_STORAGE` can be used to set the flash partition size for the flash storage. Configuration files =================== -.. include:: ../../../include/memfault_ncs.rst +.. include:: ../../../doc/nrf/libraries/others/memfault_ncs.rst :start-after: memfault_config_files_start :end-before: memfault_config_files_end diff --git a/samples/nrf9160/memfault/sample.yaml b/samples/nrf9160/memfault/sample.yaml index a1b614d84a9c..8e4a1c06d5f2 100644 --- a/samples/nrf9160/memfault/sample.yaml +++ b/samples/nrf9160/memfault/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.memfault: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns tags: ci_build extra_configs: - CONFIG_MEMFAULT_NCS_PROJECT_KEY="dummy-key" diff --git a/samples/nrf9160/modem_shell/README.rst b/samples/nrf9160/modem_shell/README.rst index 4df4666e6724..dfeea8b6f247 100644 --- a/samples/nrf9160/modem_shell/README.rst +++ b/samples/nrf9160/modem_shell/README.rst @@ -346,7 +346,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns Configuration ************* @@ -379,6 +379,17 @@ Building and running .. include:: /includes/build_and_run_nrf9160.txt +DK buttons +========== + +The buttons have the following functions: + +Button 1: + Raises a kill or abort signal. A long press of the button will kill or abort all supported running commands. You can abort commands ``iperf3`` (also with ``th``), ``curl``, ``ping`` and ``sock send``. + +Button 2: + Enables or disables the UARTs for power consumption measurements. Toggles between UARTs enabled and disabled. + Testing ======= @@ -419,7 +430,7 @@ PPP support To build the MoSh sample with PPP/dial up support for Windows, use the ``-DOVERLAY_CONFIG=overlay-ppp.conf`` option. For example: -``west build -p -b nrf9160dk_nrf9160ns -d build -- -DOVERLAY_CONFIG=overlay-ppp.conf`` +``west build -p -b nrf9160dk_nrf9160_ns -d build -- -DOVERLAY_CONFIG=overlay-ppp.conf`` See :ref:`cmake_options` for more instructions on how to add this option. @@ -429,7 +440,7 @@ Application FOTA support To build the MoSh sample with application FOTA support, use the ``-DOVERLAY_CONFIG=overlay-app_fota.conf`` option. For example: -``west build -p -b nrf9160dk_nrf9160ns -d build -- -DOVERLAY_CONFIG=overlay-app_fota.conf`` +``west build -p -b nrf9160dk_nrf9160_ns -d build -- -DOVERLAY_CONFIG=overlay-app_fota.conf`` See :ref:`cmake_options` for more instructions on how to add this option. @@ -439,7 +450,7 @@ LwM2M carrier library support To build the MoSh sample with LwM2M carrier library support, use the ``-DOVERLAY_CONFIG=overlay-lwm2m_carrier.conf`` option. For example: -``west build -p -b nrf9160dk_nrf9160ns -d build -- -DOVERLAY_CONFIG=overlay-lwm2m_carrier.conf`` +``west build -p -b nrf9160dk_nrf9160_ns -d build -- -DOVERLAY_CONFIG=overlay-lwm2m_carrier.conf`` See :ref:`cmake_options` for more instructions on how to add this option. diff --git a/samples/nrf9160/modem_shell/boards/nrf9160dk_nrf9160ns.overlay b/samples/nrf9160/modem_shell/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/nrf9160/modem_shell/boards/nrf9160dk_nrf9160ns.overlay rename to samples/nrf9160/modem_shell/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/nrf9160/modem_shell/boards/thingy91_nrf9160ns.conf b/samples/nrf9160/modem_shell/boards/thingy91_nrf9160_ns.conf similarity index 100% rename from samples/nrf9160/modem_shell/boards/thingy91_nrf9160ns.conf rename to samples/nrf9160/modem_shell/boards/thingy91_nrf9160_ns.conf diff --git a/samples/nrf9160/modem_shell/sample.yaml b/samples/nrf9160/modem_shell/sample.yaml index 129209fed2f3..215b1bfb1ad8 100644 --- a/samples/nrf9160/modem_shell/sample.yaml +++ b/samples/nrf9160/modem_shell/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.modem_shell: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/modem_shell/src/gnss/gnss.h b/samples/nrf9160/modem_shell/src/gnss/gnss.h index b2dffeba4abd..fe38b2494ebc 100644 --- a/samples/nrf9160/modem_shell/src/gnss/gnss.h +++ b/samples/nrf9160/modem_shell/src/gnss/gnss.h @@ -185,14 +185,15 @@ int gnss_set_duty_cycling_policy(enum gnss_duty_cycling_policy policy); int gnss_set_elevation_threshold(uint8_t elevation); /** - * @brief Sets whether low accuracy fixes are allowed. + * @brief Sets the GNSS use case configuration. * - * @param value True if low accuracy fixes are allowed, false if not. + * @param low_accuracy_enabled True if low accuracy fixes are allowed, false if not. + * @param scheduled_downloads_disabled True if scheduled downloads are disabled, false if not. * * @retval 0 if the operation was successful. * Otherwise, a (negative) error code is returned. */ -int gnss_set_low_accuracy(bool value); +int gnss_set_use_case(bool low_accuracy_enabled, bool scheduled_downloads_disabled); /** * @brief Sets the NMEA mask. diff --git a/samples/nrf9160/modem_shell/src/gnss/gnss_common.c b/samples/nrf9160/modem_shell/src/gnss/gnss_common.c index 25fef6d16970..00e524115174 100644 --- a/samples/nrf9160/modem_shell/src/gnss/gnss_common.c +++ b/samples/nrf9160/modem_shell/src/gnss/gnss_common.c @@ -13,7 +13,7 @@ #include "gnss.h" -#ifdef CONFIG_BOARD_THINGY91_NRF9160NS +#ifdef CONFIG_BOARD_THINGY91_NRF9160_NS #define GNSS_LNA_ENABLE_XMAGPIO "AT\%XMAGPIO=1,1,1,7,1,746,803,2,698,748," \ "2,1710,2200,3,824,894,4,880,960,5,791,849," \ "7,1565,1586" diff --git a/samples/nrf9160/modem_shell/src/gnss/gnss_gps_driver.c b/samples/nrf9160/modem_shell/src/gnss/gnss_gps_driver.c index 78e74bb88a49..ee9ce5097c3f 100644 --- a/samples/nrf9160/modem_shell/src/gnss/gnss_gps_driver.c +++ b/samples/nrf9160/modem_shell/src/gnss/gnss_gps_driver.c @@ -302,7 +302,7 @@ int gnss_set_elevation_threshold(uint8_t elevation) return -EOPNOTSUPP; } -int gnss_set_low_accuracy(bool value) +int gnss_set_use_case(bool low_accuracy_enabled, bool scheduled_downloads_disabled) { shell_error(shell_global, "GNSS: Operation not supported in GPS driver mode"); diff --git a/samples/nrf9160/modem_shell/src/gnss/gnss_interface.c b/samples/nrf9160/modem_shell/src/gnss/gnss_interface.c index f6da7a269041..50847b014f34 100644 --- a/samples/nrf9160/modem_shell/src/gnss/gnss_interface.c +++ b/samples/nrf9160/modem_shell/src/gnss/gnss_interface.c @@ -933,20 +933,23 @@ int gnss_set_elevation_threshold(uint8_t elevation) return err; } -int gnss_set_low_accuracy(bool value) +int gnss_set_use_case(bool low_accuracy_enabled, bool scheduled_downloads_disabled) { int err; uint8_t use_case = NRF_MODEM_GNSS_USE_CASE_MULTIPLE_HOT_START; gnss_api_init(); - if (value) { + if (low_accuracy_enabled) { use_case |= NRF_MODEM_GNSS_USE_CASE_LOW_ACCURACY; } + if (scheduled_downloads_disabled) { + use_case |= NRF_MODEM_GNSS_USE_CASE_SCHED_DOWNLOAD_DISABLE; + } err = nrf_modem_gnss_use_case_set(use_case); if (err) { - shell_error(shell_global, "GNSS: Failed to set use case"); + shell_error(shell_global, "GNSS: Failed to set use case, check modem FW version"); } return err; diff --git a/samples/nrf9160/modem_shell/src/gnss/gnss_shell.c b/samples/nrf9160/modem_shell/src/gnss/gnss_shell.c index d092a8774b79..93fea8f47afd 100644 --- a/samples/nrf9160/modem_shell/src/gnss/gnss_shell.c +++ b/samples/nrf9160/modem_shell/src/gnss/gnss_shell.c @@ -297,29 +297,28 @@ static int cmd_gnss_config_elevation(const struct shell *shell, size_t argc, cha return gnss_set_elevation_threshold(elevation); } -static int cmd_gnss_config_accuracy(const struct shell *shell, size_t argc, char **argv) -{ - return print_help(shell, argc, argv); -} - -static int cmd_gnss_config_accuracy_normal(const struct shell *shell, size_t argc, char **argv) +static int cmd_gnss_config_use_case(const struct shell *shell, size_t argc, char **argv) { if (gnss_running) { shell_error(shell, "%s: stop GNSS to execute command", argv[0]); return -ENOEXEC; } - return gnss_set_low_accuracy(false); -} + uint8_t value; + bool low_accuracy_enabled = false; + bool scheduled_downloads_disabled = false; -static int cmd_gnss_config_accuracy_low(const struct shell *shell, size_t argc, char **argv) -{ - if (gnss_running) { - shell_error(shell, "%s: stop GNSS to execute command", argv[0]); - return -ENOEXEC; + value = atoi(argv[1]); + if (value == 1) { + low_accuracy_enabled = true; + } + + value = atoi(argv[2]); + if (value == 1) { + scheduled_downloads_disabled = true; } - return gnss_set_low_accuracy(true); + return gnss_set_use_case(low_accuracy_enabled, scheduled_downloads_disabled); } static int cmd_gnss_config_nmea(const struct shell *shell, size_t argc, char **argv) @@ -877,14 +876,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE( SHELL_SUBCMD_SET_END ); -SHELL_STATIC_SUBCMD_SET_CREATE( - sub_gnss_config_accuracy, - SHELL_CMD_ARG(normal, NULL, "Normal accuracy fixes (default).", - cmd_gnss_config_accuracy_normal, 1, 0), - SHELL_CMD_ARG(low, NULL, "Low accuracy fixes allowed.", cmd_gnss_config_accuracy_low, 1, 0), - SHELL_SUBCMD_SET_END -); - SHELL_STATIC_SUBCMD_SET_CREATE( sub_gnss_config_powersave, SHELL_CMD_ARG(off, NULL, "Power saving off (default).", @@ -930,7 +921,11 @@ SHELL_STATIC_SUBCMD_SET_CREATE( cmd_gnss_config_system, 2, 0), SHELL_CMD(elevation, NULL, "\nElevation threshold angle.", cmd_gnss_config_elevation), - SHELL_CMD(accuracy, &sub_gnss_config_accuracy, "Fix accuracy.", cmd_gnss_config_accuracy), + SHELL_CMD_ARG(use_case, NULL, + " \n" + "Use case configuration. 0 = option disabled, 1 = option enabled " + "(default all disabled).", + cmd_gnss_config_use_case, 3, 0), SHELL_CMD_ARG(nmea, NULL, " \n" "NMEA mask. 0 = disabled, 1 = enabled (default all enabled).", diff --git a/samples/nrf9160/modem_shell/src/gnss/gnss_socket.c b/samples/nrf9160/modem_shell/src/gnss/gnss_socket.c index a2fcd592defe..bf98350611e4 100644 --- a/samples/nrf9160/modem_shell/src/gnss/gnss_socket.c +++ b/samples/nrf9160/modem_shell/src/gnss/gnss_socket.c @@ -781,9 +781,16 @@ int gnss_set_elevation_threshold(uint8_t elevation) return 0; } -int gnss_set_low_accuracy(bool value) +int gnss_set_use_case(bool low_accuracy_enabled, bool scheduled_downloads_disabled) { - low_accuracy = value; + if (scheduled_downloads_disabled) { + shell_error(shell_global, + "GNSS: Disabling scheduled downloads not supported in " + "GNSS socket API mode"); + return -EOPNOTSUPP; + } + + low_accuracy = low_accuracy_enabled; return 0; } diff --git a/samples/nrf9160/modem_shell/src/main.c b/samples/nrf9160/modem_shell/src/main.c index f966b3cbdfa5..25ce978d3f6f 100644 --- a/samples/nrf9160/modem_shell/src/main.c +++ b/samples/nrf9160/modem_shell/src/main.c @@ -47,9 +47,12 @@ #if defined(CONFIG_MOSH_WORKER_THREADS) #include "th/th_ctrl.h" #endif +#include "mosh_defines.h" /* global variables */ struct modem_param_info modem_param; +struct k_poll_signal mosh_signal; + /** * @brief Global shell pointer that can be used for printing. * @@ -87,6 +90,17 @@ static void mosh_print_version_info(void) static void button_handler(uint32_t button_states, uint32_t has_changed) { + if (has_changed & button_states & DK_BTN1_MSK) { + shell_print(shell_global, "Button 1 pressed - raising a kill signal"); + k_poll_signal_raise(&mosh_signal, MOSH_SIGNAL_KILL); +#if defined(CONFIG_MOSH_WORKER_THREADS) + th_ctrl_kill_em_all(); +#endif + } else if (has_changed & ~button_states & DK_BTN1_MSK) { + shell_print(shell_global, "Button 1 released - resetting a kill signal"); + k_poll_signal_reset(&mosh_signal); + } + if (has_changed & button_states & DK_BTN2_MSK) { shell_print(shell_global, "Button 2 pressed, toggling UART power state"); uart_toggle_power_state(shell_global); @@ -182,6 +196,7 @@ void main(void) #if defined(CONFIG_BOOTLOADER_MCUBOOT) boot_write_img_confirmed(); #endif + k_poll_signal_init(&mosh_signal); /* Resize terminal width and height of the shell to have proper command editing. */ shell_execute_cmd(shell_global, "resize"); diff --git a/samples/nrf9160/modem_shell/src/mosh_defines.h b/samples/nrf9160/modem_shell/src/mosh_defines.h index 2ad394ffb9f4..5215e928d16c 100644 --- a/samples/nrf9160/modem_shell/src/mosh_defines.h +++ b/samples/nrf9160/modem_shell/src/mosh_defines.h @@ -17,4 +17,8 @@ #define MOSH_AT_CMD_RESPONSE_MAX_LEN 2700 +enum mosh_signals { + MOSH_SIGNAL_KILL, +}; + #endif /* MOSH_DEFINES_H */ diff --git a/samples/nrf9160/modem_shell/src/ping/icmp_ping.c b/samples/nrf9160/modem_shell/src/ping/icmp_ping.c index 5278590896ab..bc3fc231e370 100644 --- a/samples/nrf9160/modem_shell/src/ping/icmp_ping.c +++ b/samples/nrf9160/modem_shell/src/ping/icmp_ping.c @@ -22,6 +22,7 @@ #include "utils/net_utils.h" #include "link_api.h" +#include "mosh_defines.h" #include "icmp_ping.h" @@ -39,6 +40,8 @@ #define ICMP6_ECHO_REQ 128 #define ICMP6_ECHO_REP 129 +extern struct k_poll_signal mosh_signal; + enum ping_rai { PING_RAI_NONE, PING_RAI_ONGOING, @@ -525,6 +528,7 @@ static void icmp_ping_tasks_execute(const struct shell *shell) uint32_t count = 0; uint32_t rtt_min = 0xFFFFFFFF; uint32_t rtt_max = 0; + int set, res; enum ping_rai rai; uint32_t ping_t; @@ -540,6 +544,13 @@ static void icmp_ping_tasks_execute(const struct shell *shell) } ping_t = send_ping_wait_reply(shell, rai); + k_poll_signal_check(&mosh_signal, &set, &res); + if (set && res == MOSH_SIGNAL_KILL) { + k_poll_signal_reset(&mosh_signal); + shell_error(shell, "KILL signal received - exiting"); + break; + } + if (ping_t > 0) { count++; sum += ping_t; diff --git a/samples/nrf9160/modem_shell/src/shell.c b/samples/nrf9160/modem_shell/src/shell.c index 99f8af72f024..d4ad416b7edb 100644 --- a/samples/nrf9160/modem_shell/src/shell.c +++ b/samples/nrf9160/modem_shell/src/shell.c @@ -44,7 +44,7 @@ extern const struct shell *shell_global; extern struct k_sem nrf_modem_lib_initialized; - +extern struct k_poll_signal mosh_signal; /** * @brief Overriding modem library error handler. */ @@ -162,7 +162,7 @@ int lwm2m_carrier_event_handler(const lwm2m_carrier_event_t *event) #if defined(CONFIG_MOSH_IPERF3) static int cmd_iperf3(const struct shell *shell, size_t argc, char **argv) { - (void)iperf_main(argc, argv, NULL, 0, NULL); + (void)iperf_main(argc, argv, NULL, 0, &mosh_signal); return 0; } #endif @@ -170,7 +170,7 @@ static int cmd_iperf3(const struct shell *shell, size_t argc, char **argv) #if defined(CONFIG_MOSH_CURL) static int cmd_curl(const struct shell *shell, size_t argc, char **argv) { - (void)curl_tool_main(argc, argv); + (void)curl_tool_main(argc, argv, &mosh_signal); shell_print(shell, "\nDONE"); return 0; } diff --git a/samples/nrf9160/modem_shell/src/sock/sock.c b/samples/nrf9160/modem_shell/src/sock/sock.c index 0b603439461a..516937300fd8 100644 --- a/samples/nrf9160/modem_shell/src/sock/sock.c +++ b/samples/nrf9160/modem_shell/src/sock/sock.c @@ -28,6 +28,8 @@ #include "net_utils.h" #include "str_utils.h" +extern struct k_poll_signal mosh_signal; + /* Maximum number of sockets takes into account AT command socket */ #define MAX_SOCKETS (CONFIG_POSIX_MAX_FDS - 1) #define SOCK_SEND_BUFFER_SIZE_UDP 1200 @@ -695,6 +697,15 @@ static int sock_send( { int bytes; int dest_addr_len = 0; + int set, res; + + k_poll_signal_check(&mosh_signal, &set, &res); + if (set && res == MOSH_SIGNAL_KILL) { + k_poll_signal_reset(&mosh_signal); + shell_error(shell_global, + "KILL signal received - exiting"); + return -ECANCELED; + } if (log_data) { if (data_hex_format) { @@ -741,6 +752,7 @@ static void data_send_work_handler(struct k_work *item) struct data_transfer_info *data_send_info_ptr = CONTAINER_OF(item, struct data_transfer_info, work); struct sock_info *socket_info = data_send_info_ptr->parent; + int ret; if (!socket_info->in_use) { shell_print( @@ -751,16 +763,17 @@ static void data_send_work_handler(struct k_work *item) return; } - sock_send( + ret = sock_send( socket_info, socket_info->send_buffer, socket_info->send_buffer_size, true, data_send_info_ptr->data_format_hex); - k_work_schedule( - &socket_info->send_info.work, - K_SECONDS(socket_info->send_info.interval)); + if (ret != -ECANCELED) { + k_work_schedule(&socket_info->send_info.work, + K_SECONDS(socket_info->send_info.interval)); + } } static void sock_send_random_data_length(struct sock_info *socket_info) @@ -779,6 +792,11 @@ static void sock_send_random_data_length(struct sock_info *socket_info) bytes = sock_send(socket_info, socket_info->send_buffer, strlen(socket_info->send_buffer), false, false); + if (bytes == -ECANCELED) { + socket_info->send_poll = false; + break; + } + if (bytes < 0) { /* Wait for socket to allow sending again */ socket_info->send_poll = true; diff --git a/samples/nrf9160/modem_shell/src/th/th_ctrl.c b/samples/nrf9160/modem_shell/src/th/th_ctrl.c index b034d934752d..c3e83920a61a 100644 --- a/samples/nrf9160/modem_shell/src/th/th_ctrl.c +++ b/samples/nrf9160/modem_shell/src/th/th_ctrl.c @@ -159,6 +159,16 @@ void th_ctrl_status_print(const struct shell *shell) th_ctrl_data_status_print(shell, &th_work_data_2); } +void th_ctrl_kill_em_all(void) +{ + if (k_work_is_pending(&(th_work_data_1.work))) { + k_poll_signal_raise(&th_work_data_1.kill_signal, 1); + } + if (k_work_is_pending(&(th_work_data_2.work))) { + k_poll_signal_raise(&th_work_data_2.kill_signal, 2); + } +} + void th_ctrl_kill(const struct shell *shell, int nbr) { if (nbr == 1) { diff --git a/samples/nrf9160/modem_shell/src/th/th_ctrl.h b/samples/nrf9160/modem_shell/src/th/th_ctrl.h index 9e000b4b5102..42159650640b 100644 --- a/samples/nrf9160/modem_shell/src/th/th_ctrl.h +++ b/samples/nrf9160/modem_shell/src/th/th_ctrl.h @@ -16,5 +16,6 @@ void th_ctrl_status_print(const struct shell *shell); void th_ctrl_start(const struct shell *shell, size_t argc, char **argv, bool bg_thread); void th_ctrl_kill(const struct shell *shell, int nbr); +void th_ctrl_kill_em_all(void); #endif /* TH_CTRL_H */ diff --git a/samples/nrf9160/modem_shell/src/uart/uart.c b/samples/nrf9160/modem_shell/src/uart/uart.c index b45832ed9511..a723efe46650 100644 --- a/samples/nrf9160/modem_shell/src/uart/uart.c +++ b/samples/nrf9160/modem_shell/src/uart/uart.c @@ -16,19 +16,19 @@ void disable_uarts(void) uart_dev = device_get_binding(DT_LABEL(DT_NODELABEL(uart0))); if (uart_dev) { - pm_device_state_set(uart_dev, PM_DEVICE_STATE_LOW_POWER, NULL, NULL); + pm_device_state_set(uart_dev, PM_DEVICE_STATE_LOW_POWER); } uart_dev = device_get_binding(DT_LABEL(DT_NODELABEL(uart1))); if (uart_dev) { - pm_device_state_set(uart_dev, PM_DEVICE_STATE_LOW_POWER, NULL, NULL); + pm_device_state_set(uart_dev, PM_DEVICE_STATE_LOW_POWER); } } void enable_uarts(void) { const struct device *uart_dev; - uint32_t current_state; + enum pm_device_state current_state; uart_dev = device_get_binding(DT_LABEL(DT_NODELABEL(uart0))); @@ -45,12 +45,12 @@ void enable_uarts(void) } if (uart_dev) { - pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL); + pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE); } uart_dev = device_get_binding(DT_LABEL(DT_NODELABEL(uart1))); if (uart_dev) { - pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL); + pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE); } printk("UARTs enabled\n"); diff --git a/samples/nrf9160/modem_shell/src/uart/uart_shell.c b/samples/nrf9160/modem_shell/src/uart/uart_shell.c index ad4148b0bd4b..e713b008f652 100644 --- a/samples/nrf9160/modem_shell/src/uart/uart_shell.c +++ b/samples/nrf9160/modem_shell/src/uart/uart_shell.c @@ -79,7 +79,7 @@ void uart_toggle_power_state_at_event(const struct shell *shell, const struct lt void uart_toggle_power_state(const struct shell *shell) { const struct device *uart_dev; - uint32_t uart0_power_state; + enum pm_device_state uart0_power_state; int err; uart_dev = device_get_binding(DT_LABEL(DT_NODELABEL(uart0))); @@ -99,27 +99,21 @@ void uart_toggle_power_state(const struct shell *shell) k_sleep(K_MSEC(500)); /* set uart0 to low power state */ - err = pm_device_state_set(uart_dev, PM_DEVICE_STATE_LOW_POWER, NULL, NULL); + err = pm_device_state_set(uart_dev, PM_DEVICE_STATE_LOW_POWER); /* set uart1 to low power state */ uart_dev = device_get_binding(DT_LABEL(DT_NODELABEL(uart1))); if (uart_dev) { - pm_device_state_set(uart_dev, - PM_DEVICE_STATE_LOW_POWER, - NULL, - NULL); + pm_device_state_set(uart_dev, PM_DEVICE_STATE_LOW_POWER); } } else { /* set uart0 to active state */ - err = pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE, NULL, NULL); + err = pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE); /* set uart1 to active state */ uart_dev = device_get_binding(DT_LABEL(DT_NODELABEL(uart1))); if (uart_dev) { - pm_device_state_set(uart_dev, - PM_DEVICE_STATE_ACTIVE, - NULL, - NULL); + pm_device_state_set(uart_dev, PM_DEVICE_STATE_ACTIVE); } shell_print(shell, "Enabling UARTs"); diff --git a/samples/nrf9160/mqtt_simple/README.rst b/samples/nrf9160/mqtt_simple/README.rst index c6df99e21ea9..3e219244422f 100644 --- a/samples/nrf9160/mqtt_simple/README.rst +++ b/samples/nrf9160/mqtt_simple/README.rst @@ -16,7 +16,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns Additionally, the sample supports :ref:`qemu_x86`. @@ -100,7 +100,7 @@ For example, when building on the command line, you can build the sample with th .. code-block:: console - west build -b nrf9160dk_nrf9160ns -- -DOVERLAY_CONFIG=overlay-tls.conf + west build -b nrf9160dk_nrf9160_ns -- -DOVERLAY_CONFIG=overlay-tls.conf .. note:: The CA certificate for the default MQTT broker is included in the project and automatically provisioned after boot if the sample is built with the TLS configuration. @@ -123,10 +123,10 @@ Testing #. Observe that the sample displays the following information in the terminal:: The MQTT simple sample started -#. Observe that the development kit connects to the configured MQTT broker (:option:`CONFIG_MQTT_BROKER_HOSTNAME`) after it gets the LTE connection. - At this stage, the development kit is ready to echo the data sent to it on the configured subscribe topic (:option:`CONFIG_MQTT_SUB_TOPIC`). +#. Observe that the development kit connects to the configured MQTT broker (:kconfig:`CONFIG_MQTT_BROKER_HOSTNAME`) after it gets the LTE connection. + At this stage, the development kit is ready to echo the data sent to it on the configured subscribe topic (:kconfig:`CONFIG_MQTT_SUB_TOPIC`). #. Use an MQTT client like `Mosquitto`_ to subscribe to and publish data to the broker. - Observe that the development kit publishes all the data that you publish to :option:`CONFIG_MQTT_SUB_TOPIC` on :option:`CONFIG_MQTT_PUB_TOPIC`. + Observe that the development kit publishes all the data that you publish to :kconfig:`CONFIG_MQTT_SUB_TOPIC` on :kconfig:`CONFIG_MQTT_PUB_TOPIC`. Sample output ============= @@ -154,10 +154,10 @@ Troubleshooting =============== Public MQTT brokers might be unstable. -If you experience problems connecting to the MQTT broker, try switching to another MQTT broker by changing the value of the :option:`CONFIG_MQTT_BROKER_HOSTNAME` configuration option. +If you experience problems connecting to the MQTT broker, try switching to another MQTT broker by changing the value of the :kconfig:`CONFIG_MQTT_BROKER_HOSTNAME` configuration option. .. note:: - If the :option:`CONFIG_MQTT_BROKER_HOSTNAME` configuration option is changed and the overlay TLS configuration is used, the included CA certificate must be updated with the CA certificate for + If the :kconfig:`CONFIG_MQTT_BROKER_HOSTNAME` configuration option is changed and the overlay TLS configuration is used, the included CA certificate must be updated with the CA certificate for the newly configurated MQTT broker. diff --git a/samples/nrf9160/mqtt_simple/sample.yaml b/samples/nrf9160/mqtt_simple/sample.yaml index 5049691f2cdd..16e47631e60a 100644 --- a/samples/nrf9160/mqtt_simple/sample.yaml +++ b/samples/nrf9160/mqtt_simple/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.mqtt_simple: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/multicell_location/README.rst b/samples/nrf9160/multicell_location/README.rst index 3eb2588ecb30..08ce07408e2d 100644 --- a/samples/nrf9160/multicell_location/README.rst +++ b/samples/nrf9160/multicell_location/README.rst @@ -17,7 +17,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns, nrf9160dk_nrf9160ns + :rows: thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt @@ -109,15 +109,15 @@ Additional configuration Check and configure the following library options that are used by the sample: -* :option:`CONFIG_MULTICELL_LOCATION_SERVICE_NRF_CLOUD` -* :option:`CONFIG_MULTICELL_LOCATION_SERVICE_HERE` -* :option:`CONFIG_MULTICELL_LOCATION_SERVICE_SKYHOOK` +* :kconfig:`CONFIG_MULTICELL_LOCATION_SERVICE_NRF_CLOUD` +* :kconfig:`CONFIG_MULTICELL_LOCATION_SERVICE_HERE` +* :kconfig:`CONFIG_MULTICELL_LOCATION_SERVICE_SKYHOOK` For the location service that is used, the authorization method can be set with one of the following options: -* :option:`CONFIG_MULTICELL_LOCATION_NRF_CLOUD_API_KEY` -* :option:`CONFIG_MULTICELL_LOCATION_HERE_API_KEY` -* :option:`CONFIG_MULTICELL_LOCATION_SKYHOOK_API_KEY` +* :kconfig:`CONFIG_MULTICELL_LOCATION_NRF_CLOUD_API_KEY` +* :kconfig:`CONFIG_MULTICELL_LOCATION_HERE_API_KEY` +* :kconfig:`CONFIG_MULTICELL_LOCATION_SKYHOOK_API_KEY` See :ref:`lib_multicell_location` for more information on the various configuration options that exist for the services. diff --git a/samples/nrf9160/multicell_location/sample.yaml b/samples/nrf9160/multicell_location/sample.yaml index da6670eb9ea4..667c7237865c 100644 --- a/samples/nrf9160/multicell_location/sample.yaml +++ b/samples/nrf9160/multicell_location/sample.yaml @@ -3,10 +3,10 @@ sample: tests: samples.nrf9160.multicell_location: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns - - thingy91_nrf9160ns + - nrf9160dk_nrf9160_ns + - thingy91_nrf9160_ns tags: ci_build extra_configs: - CONFIG_MULTICELL_LOCATION_SERVICE_HERE=y diff --git a/samples/nrf9160/pdn/README.rst b/samples/nrf9160/pdn/README.rst index eb4687e51edd..aa9965febb8f 100644 --- a/samples/nrf9160/pdn/README.rst +++ b/samples/nrf9160/pdn/README.rst @@ -16,7 +16,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt diff --git a/samples/nrf9160/pdn/sample.yaml b/samples/nrf9160/pdn/sample.yaml index ce9734c26770..c2b909127908 100644 --- a/samples/nrf9160/pdn/sample.yaml +++ b/samples/nrf9160/pdn/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.pdn: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/secure_services/README.rst b/samples/nrf9160/secure_services/README.rst index d692e0f9f2f9..1edc46f0d130 100644 --- a/samples/nrf9160/secure_services/README.rst +++ b/samples/nrf9160/secure_services/README.rst @@ -23,7 +23,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns .. include:: /includes/spm.txt diff --git a/samples/nrf9160/secure_services/sample.yaml b/samples/nrf9160/secure_services/sample.yaml index d4c533f81547..a7c672402544 100644 --- a/samples/nrf9160/secure_services/sample.yaml +++ b/samples/nrf9160/secure_services/sample.yaml @@ -2,9 +2,9 @@ sample: name: secure services tests: samples.nrf9160.secure_services.default: - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build harness: console harness_config: @@ -37,9 +37,9 @@ tests: - "Secure Services example." samples.nrf9160.secure_services.bootloaders: - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns extra_args: CONFIG_BOOTLOADER_MCUBOOT=y CONFIG_SECURE_BOOT=y CONFIG_SPM_SERVICE_PREVALIDATE=y mcuboot_CONFIG_EXT_API_PROVIDE_EXT_API_ENABLED=y CONFIG_SPM_SERVICE_S0_ACTIVE=y harness: console harness_config: @@ -73,9 +73,9 @@ tests: - "Secure Services example." samples.nrf9160.secure_services.b0_mcuboot: - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns extra_args: OVERLAY_CONFIG="b0_mcuboot_overlay.conf" build_only: true tags: ci_build diff --git a/samples/nrf9160/sms/README.rst b/samples/nrf9160/sms/README.rst index fe68c0d5876f..c94e45beb547 100644 --- a/samples/nrf9160/sms/README.rst +++ b/samples/nrf9160/sms/README.rst @@ -19,7 +19,7 @@ The sample requires an LTE connection. When the sample starts, it sends SMS if a recipient phone number is set in the configuration. The sample then receives all the SMS messages and displays the information about the messages including the text that is sent. -The maximum size of the AT command response defined by :option:`CONFIG_AT_CMD_RESPONSE_MAX_LEN` might limit the size of the SMS message that can be received. +The maximum size of the AT command response defined by :kconfig:`CONFIG_AT_CMD_RESPONSE_MAX_LEN` might limit the size of the SMS message that can be received. This parameter is defined in the :ref:`at_cmd_readme` module. Values over 512 bytes will not restrict the size of the received message as the maximum data length of the SMS is 140 bytes. @@ -30,7 +30,7 @@ The sample supports the following development kit: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns + :rows: nrf9160dk_nrf9160_ns Configuration @@ -52,17 +52,17 @@ Additional Configuration Check and configure the following mandatory library options that are used by the sample: -* :option:`CONFIG_SMS` -* :option:`CONFIG_NRF_MODEM_LIB` +* :kconfig:`CONFIG_SMS` +* :kconfig:`CONFIG_NRF_MODEM_LIB` Check and configure the following optional library options that are used by the sample: -* :option:`CONFIG_SMS_SUBSCRIBERS_MAX_CNT` -* :option:`CONFIG_AT_CMD_RESPONSE_MAX_LEN` -* :option:`CONFIG_LTE_AUTO_INIT_AND_CONNECT` -* :option:`CONFIG_LOG` -* :option:`CONFIG_ASSERT` -* :option:`CONFIG_ASSERT_VERBOSE` +* :kconfig:`CONFIG_SMS_SUBSCRIBERS_MAX_CNT` +* :kconfig:`CONFIG_AT_CMD_RESPONSE_MAX_LEN` +* :kconfig:`CONFIG_LTE_AUTO_INIT_AND_CONNECT` +* :kconfig:`CONFIG_LOG` +* :kconfig:`CONFIG_ASSERT` +* :kconfig:`CONFIG_ASSERT_VERBOSE` Building and running ******************** diff --git a/samples/nrf9160/sms/sample.yaml b/samples/nrf9160/sms/sample.yaml index 9916eb7f3314..a4ecc16ae189 100644 --- a/samples/nrf9160/sms/sample.yaml +++ b/samples/nrf9160/sms/sample.yaml @@ -3,7 +3,7 @@ sample: tests: samples.nrf9160.sms: build_only: true - platform_allow: nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/nrf9160/udp/README.rst b/samples/nrf9160/udp/README.rst index da3ed93a3ca6..0107dcdf6173 100644 --- a/samples/nrf9160/udp/README.rst +++ b/samples/nrf9160/udp/README.rst @@ -17,7 +17,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns, nrf9160dk_nrf9160ns + :rows: thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns Additionally, it supports :ref:`qemu_x86`. @@ -53,13 +53,13 @@ Configuration You can configure the following options: -* :option:`CONFIG_UDP_DATA_UPLOAD_SIZE_BYTES` -* :option:`CONFIG_UDP_DATA_UPLOAD_FREQUENCY_SECONDS` -* :option:`CONFIG_UDP_SERVER_ADDRESS_STATIC` -* :option:`CONFIG_UDP_SERVER_PORT` -* :option:`CONFIG_UDP_PSM_ENABLE` -* :option:`CONFIG_UDP_EDRX_ENABLE` -* :option:`CONFIG_UDP_RAI_ENABLE` +* :kconfig:`CONFIG_UDP_DATA_UPLOAD_SIZE_BYTES` +* :kconfig:`CONFIG_UDP_DATA_UPLOAD_FREQUENCY_SECONDS` +* :kconfig:`CONFIG_UDP_SERVER_ADDRESS_STATIC` +* :kconfig:`CONFIG_UDP_SERVER_PORT` +* :kconfig:`CONFIG_UDP_PSM_ENABLE` +* :kconfig:`CONFIG_UDP_EDRX_ENABLE` +* :kconfig:`CONFIG_UDP_RAI_ENABLE` Configuration options @@ -102,11 +102,11 @@ Additional configuration Below configurations are recommended for low power behavior: - * :option:`CONFIG_LTE_PSM_REQ_RPTAU` option set to a value greater than the value of :option:`CONFIG_UDP_DATA_UPLOAD_FREQUENCY_SECONDS`. - * :option:`CONFIG_LTE_PSM_REQ_RAT` set to 0. - * :option:`CONFIG_SERIAL` disabled in ``prj.conf`` and ``spm.conf``. - * :option:`CONFIG_UDP_EDRX_ENABLE` set to false. - * :option:`CONFIG_UDP_RAI_ENABLE` set to true for NB-IoT. It is not supported for LTE-M. + * :kconfig:`CONFIG_LTE_PSM_REQ_RPTAU` option set to a value greater than the value of :kconfig:`CONFIG_UDP_DATA_UPLOAD_FREQUENCY_SECONDS`. + * :kconfig:`CONFIG_LTE_PSM_REQ_RAT` set to 0. + * :kconfig:`CONFIG_SERIAL` disabled in ``prj.conf`` and ``spm.conf``. + * :kconfig:`CONFIG_UDP_EDRX_ENABLE` set to false. + * :kconfig:`CONFIG_UDP_RAI_ENABLE` set to true for NB-IoT. It is not supported for LTE-M. PSM and eDRX timers are set with binary strings that signify a time duration in seconds. See `Power saving mode setting section in AT commands reference document`_ for a conversion chart of these timer values. @@ -146,7 +146,7 @@ After programming the sample to your device, test it by performing the following .. note:: Logging output is disabled by default in this sample in order to produce the lowest possible amount of current consumption. - To enable logging, set the :option:`CONFIG_SERIAL` option in the ``prj.conf`` and ``spm.conf`` configuration files. + To enable logging, set the :kconfig:`CONFIG_SERIAL` option in the ``prj.conf`` and ``spm.conf`` configuration files. .. _uart_output: diff --git a/samples/nrf9160/udp/sample.yaml b/samples/nrf9160/udp/sample.yaml index b8e347bec87a..88dff6892776 100644 --- a/samples/nrf9160/udp/sample.yaml +++ b/samples/nrf9160/udp/sample.yaml @@ -3,8 +3,8 @@ sample: tests: samples.nrf9160.udp: build_only: true - platform_allow: nrf9160dk_nrf9160ns thingy91_nrf9160ns + platform_allow: nrf9160dk_nrf9160_ns thingy91_nrf9160_ns integration_platforms: - - nrf9160dk_nrf9160ns - - thingy91_nrf9160ns + - nrf9160dk_nrf9160_ns + - thingy91_nrf9160_ns tags: ci_build diff --git a/samples/openthread/cli/README.rst b/samples/openthread/cli/README.rst index 146c84607d0f..427e39666c66 100644 --- a/samples/openthread/cli/README.rst +++ b/samples/openthread/cli/README.rst @@ -21,7 +21,7 @@ OpenThread CLI is integrated into the system shell accessible over serial connec To indicate a Thread command, the ``ot`` keyword needs to precede the command. The amount of commands you can test depends on the application configuration. -The CLI sample comes with the :ref:`full set of OpenThread functionalities ` enabled (:option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER`). +The CLI sample comes with the :ref:`full set of OpenThread functionalities ` enabled (:kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER`). If used alone, the sample allows you to test the network status. It is recommended to use at least two development kits running the same sample to be able to test communication. @@ -31,13 +31,13 @@ It is recommended to use at least two development kits running the same sample t Diagnostic module ================= -By default, the CLI sample comes with the :option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER` :ref:`feature set ` enabled, which allows you to use Zephyr's diagnostic module with its ``diag`` commands. +By default, the CLI sample comes with the :kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER` :ref:`feature set ` enabled, which allows you to use Zephyr's diagnostic module with its ``diag`` commands. Use these commands for manually checking hardware-related functionalities without running a Thread network. For example, when adding a new functionality or during the manufacturing process to ensure radio communication is working. See `Testing diagnostic module`_ section for an example. .. note:: - If you disable the :option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER` feature set, you can enable the diagnostic module with the :option:`CONFIG_OPENTHREAD_DIAG` Kconfig option. + If you disable the :kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER` feature set, you can enable the diagnostic module with the :kconfig:`CONFIG_OPENTHREAD_DIAG` Kconfig option. .. _ot_cli_sample_thread_v12: @@ -75,8 +75,6 @@ You can switch to USB transport by :ref:`activating the USB overlay extension ; - rx-en-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>; - pdn-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>; - ant-sel-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; - }; -}; diff --git a/samples/openthread/coprocessor/README.rst b/samples/openthread/coprocessor/README.rst index f6e4959437c2..dc481ea792ce 100644 --- a/samples/openthread/coprocessor/README.rst +++ b/samples/openthread/coprocessor/README.rst @@ -28,7 +28,7 @@ The sample demonstrates using a co-processor target on the MCU to communicate wi According to the co-processor architecture, the MCU part must cooperate with user higher layer process to establish the complete full stack application. The sample shows how to set up the connection between the co-processor and wpantund. -This sample comes with the :ref:`full set of OpenThread functionalities ` enabled (:option:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER`). +This sample comes with the :ref:`full set of OpenThread functionalities ` enabled (:kconfig:`CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER`). .. _ot_coprocessor_sample_vendor_hook_extension: @@ -48,7 +48,7 @@ Logging extension This sample by default uses :ref:`Spinel logging backend `, which allows sending log messages to the host device using the Spinel protocol. This feature is very useful, because it does not require having separate interfaces to communicate with the co-processor through the Spinel protocol and collect log messages. -Moreover, selecting the Spinel logging backend (by setting :option:`CONFIG_LOG_BACKEND_SPINEL`) does not exclude using another backend like UART or RTT at the same time. +Moreover, selecting the Spinel logging backend (by setting :kconfig:`CONFIG_LOG_BACKEND_SPINEL`) does not exclude using another backend like UART or RTT at the same time. By default, the log levels for all modules are set to critical to not engage the microprocessor in unnecessary activities. To make the solution flexible, you can change independently the log levels for your modules, for the whole Zephyr system, and for OpenThread. @@ -57,8 +57,6 @@ Use the :file:`overlay-logging.conf` overlay file as reference for this purpose. FEM support =========== -.. |fem_file_path| replace:: :file:`samples/openthread/common` - .. include:: /includes/sample_fem_support.txt Requirements @@ -82,7 +80,7 @@ User interface All the interactions with the application are handled using serial communication. You can interact with the sample through :ref:`ug_thread_tools_wpantund`, using ``wpanctl`` commands. -If you use the RCP architecture (see :option:`CONFIG_OPENTHREAD_COPROCESSOR_RCP`), you can alternatively use ``ot-daemon`` or ``ot-cli`` with commands listed in `OpenThread CLI Reference`_. +If you use the RCP architecture (see :kconfig:`CONFIG_OPENTHREAD_COPROCESSOR_RCP`), you can alternatively use ``ot-daemon`` or ``ot-cli`` with commands listed in `OpenThread CLI Reference`_. See :ref:`ug_thread_tools_ot_apps` for more information. Both NCP and RCP support communication with the kit using `Pyspinel`_ commands. @@ -100,9 +98,9 @@ Configuration Check and configure the following library options that are used by the sample: -* :option:`CONFIG_OPENTHREAD_COPROCESSOR_NCP` - Selects the NCP architecture for the sample. +* :kconfig:`CONFIG_OPENTHREAD_COPROCESSOR_NCP` - Selects the NCP architecture for the sample. This is the default. -* :option:`CONFIG_OPENTHREAD_COPROCESSOR_RCP` - Selects the RCP architecture for the sample. +* :kconfig:`CONFIG_OPENTHREAD_COPROCESSOR_RCP` - Selects the RCP architecture for the sample. .. _ot_coprocessor_sample_config_files: diff --git a/samples/peripheral/802154_phy_test/CMakeLists.txt b/samples/peripheral/802154_phy_test/CMakeLists.txt new file mode 100644 index 000000000000..d16065786db4 --- /dev/null +++ b/samples/peripheral/802154_phy_test/CMakeLists.txt @@ -0,0 +1,39 @@ +# +# Copyright (c) 2021 Nordic Semiconductor +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +cmake_minimum_required(VERSION 3.10) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(phy_tt LANGUAGES NONE) + +target_include_directories(app PRIVATE + include + include/internal + include/internal/ctrl + include/internal/rf) + +target_sources(app PRIVATE + src/main.c + src/comm_proc.c + src/uart_proc.c + src/rf_proc.c + src/ptt_conf.c + src/periph_proc.c + src/timer_proc.c + src/ctrl/ptt_ctrl.c + src/ctrl/ptt_events.c + src/ctrl/ptt_mode_manager.c + src/ctrl/ptt_parser.c + src/ctrl/ptt_proto.c + src/ctrl/ptt_rf_proc.c + src/ctrl/ptt_timers.c + src/ctrl/ptt_uart_proc.c + src/ctrl/ptt_zb_perf_cmd_mode_ota.c + src/ctrl/ptt_zb_perf_cmd_mode_response.c + src/ctrl/ptt_zb_perf_cmd_mode_uart.c + src/ctrl/ptt_zb_perf_cmd_mode.c + src/ctrl/ptt_zb_perf_dut_mode.c + src/rf/ptt_rf.c) diff --git a/samples/peripheral/802154_phy_test/Kconfig b/samples/peripheral/802154_phy_test/Kconfig new file mode 100644 index 000000000000..61a310b04abf --- /dev/null +++ b/samples/peripheral/802154_phy_test/Kconfig @@ -0,0 +1,80 @@ +# +# Copyright (c) 2021 Nordic Semiconductor +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +source "Kconfig.zephyr" + +menu "PHY Test Tool configuration" + +choice + prompt "Device Mode" + default PTT_BOTH + help + Select the device mode + +config PTT_DUT_MODE + bool "Configure device as a DUT" + help + DUT (Device Under Test) - serial communication is not initialized + +config PTT_CMD_MODE + bool "Configure device as a CMD" + help + CMD - serial communication is available with 115200 8N1 settings + +config PTT_BOTH + bool "Supports both CMD and DUT modes" + help + Device can be switched between modes using "custom changemode 0/1" command. + +endchoice + +config PTT_POWER + int "Transmit Power (dBm)" + default 0 + range -20 8 + +config PTT_CHANNEL_MASK + hex "Channel page and channel number mask" + default 0x00000800 + +config PTT_SW_VERSION + int "Software Version" + default 1 + range 0 255 + +config PTT_HW_VERSION + int "Hardware Version" + default 1 + range 0 255 + +config PTT_ANTENNA_DIVERSITY + bool "Enable Antenna Diversity (Not Yet Supported)" + default n + +if PTT_ANTENNA_DIVERSITY + +choice + prompt "Antenna Mode" + default PTT_ANT_MODE_AUTO + help + Select the antenna diversity mode + +config PTT_ANT_MODE_AUTO + bool "Automatic" + +config PTT_ANT_MODE_MANUAL + bool "Manual" + +endchoice + +config PTT_ANTENNA_NUMBER + int "Antenna Number" + range 0 2 + default 0 + +endif #PTT_ANTENNA_DIVERSITY + +endmenu diff --git a/samples/peripheral/802154_phy_test/README.rst b/samples/peripheral/802154_phy_test/README.rst new file mode 100644 index 000000000000..dbcf36fd71e7 --- /dev/null +++ b/samples/peripheral/802154_phy_test/README.rst @@ -0,0 +1,986 @@ +.. _802154_phy_test: + +IEEE 802.15.4 PHY Test Tool +########################### + +.. contents:: + :local: + :depth: 2 + +The IEEE 802.15.4 PHY Test Tool provides a solution for performing Zigbee RF Performance and PHY Certification tests, as well as a general evaluation of the integrated radio with IEEE 802.15.4 standard. + +Overview +******** + +You can perform the testing by connecting to the development kit through the serial port and sending supported commands. + +See the :ref:`802154_phy_test_ui` for the list of the available commands. + +Requirements +************ + +The sample supports the following development kits: + +.. table-from-rows:: /includes/sample_board_rows.txt + :header: heading + :rows: nrf5340dk_nrf5340_cpunet, nrf52840dk_nrf52840 + +Conducting tests using the sample also requires a testing device, like another development kit running the same sample, set into DUT mode. +For more information, see :ref:`802154_phy_test_testing`. + +.. note:: + You can perform the testing using other equipment, like spectrum analyzers, oscilloscopes, or RF power meters, but these methods are not covered by this documentation. + +.. _802154_phy_test_ui: + +Serial commands list +******************** + +This section lists the serial commands that are supported by the sample. + +changemode - Change the device mode +=================================== + +It changes the device mode if BOTH modes are available. + + .. parsed-literal:: + :class: highlight + + custom changemode ** + +The ```` argument can assume one of the following values: + +* ``0`` - DUT +* ``1`` - CMD + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom changemode *1* + +indication - LED indication +=========================== + +It makes the CMD device control the LED indicating packet reception. + + .. parsed-literal:: + :class: highlight + + custom indication ** + +The ```` argument can assume one of the following values: + +* ``0`` - none +* ``1`` - LED packet reception indication + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom indication *1* + +rping - Ping the DUT +==================== + +It makes the CMD device send a PING to the DUT device and wait for the reply. + + .. parsed-literal:: + :class: highlight + + custom rping + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom rping + +lpingtimeout - Set the ping timeout +=================================== + +It makes the CMD device set the timeout in milliseconds for receiving the *pong* responses from the DUT device. + + .. parsed-literal:: + :class: highlight + + custom lpingtimeout ** ** + +* The ```` value indicates the higher byte of the timeout. +* The ```` value indicates the lower byte of the timeout. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lpingtimeout *0* *255* + +setchannel - Set the common radio channel for the DUT and CMD +============================================================= + +It sets a common radio channel for the DUT and CMD devices, sends a PING, and waits for the response. + + .. parsed-literal:: + :class: highlight + + custom setchannel ** ** ** **. + +The four ```` arguments are four octets defining the channel page and number. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom setchannel *0* *0* *8* *0* + +lsetchannel - Set the CMD radio channel +======================================= + +It sets radio channel of the CMD device. + + .. parsed-literal:: + :class: highlight + + custom lsetchannel ** ** ** **. + +The four ```` arguments are four bytes defining the channel page and number. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lsetchannel *0* *0* *16* *0* + +rsetchannel - Set the DUT radio channel +======================================= + +It sets the radio channel of the DUT device. + + .. parsed-literal:: + :class: highlight + + custom rsetchannel ** + +The ```` argument indicates the selected channel’s number. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom rsetchannel *13* + +lgetchannel - Get the CMD radio channel +======================================= + +It gets the current configured channel of the CMD device. + + .. parsed-literal:: + :class: highlight + + custom lgetchannel + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgetchannel + +lsetpower - Set the CMD radio power +=================================== + +It sets the CMD device's TX power. + + .. parsed-literal:: + :class: highlight + + custom lsetpower ** ** ** + +* The ```` and ```` arguments are currently unsupported. + Use ``0`` for both. +* The ```` argument indicates the TX power as a signed integer in dBm. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom rsetpower *0* *0* *-17* + +lgetpower - Get the CMD radio power +=================================== + +It gets the current configured power of the CMD device. + + .. parsed-literal:: + :class: highlight + + custom lgetpower + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgetpower + +rgetpower - Get the DUT radio power +=================================== + +It gets the current configured power of the DUT device. + + .. parsed-literal:: + :class: highlight + + custom rgetpower + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom rgetpower + +rstream - DUT modulated waveform transmission +============================================= + +It commands the DUT device to start a modulated waveform transmission of a certain duration in milliseconds. + + .. parsed-literal:: + :class: highlight + + custom rstream ** ** + +* The ```` argument indicates the higher byte of the duration value. +* The ```` argument indicates the lower byte of the duration value. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom rstream *255* *255* + +rstart - Start the RX Test +========================== + +It makes the DUT device start the RX test routine, clearing previous statistics. + + .. parsed-literal:: + :class: highlight + + custom rstart + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom rstart + +rend - End the RX Test +====================== + +It makes the DUT device terminate the RX test routine. +The DUT device also sends the test results to the CMD device + + .. parsed-literal:: + :class: highlight + + custom rend + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom rend + +find - Find the DUT +=================== + +It makes the CMD device cycle all the channels (11-26) trying to PING the DUT device. +It stops upon receiving a reply. + + .. parsed-literal:: + :class: highlight + + custom find + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom find + +lgetcca - Clear Channel Assessment +================================== + +It makes the CMD device perform a Clear Channel Assessment (CCA) with the requested mode and print the result. + + .. parsed-literal:: + :class: highlight + + custom lgetcca ** + +The ```` argument indicates the IEEE 802.15.4 CCA mode (1-3). + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgetcca *1* + +lgeted - Perform Energy Detection +================================= + +It starts the energy detection and reports the result as 2 hexadecimal bytes. + + .. parsed-literal:: + :class: highlight + + custom lgeted + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgeted + +lgetlqi - Get Link Quality Indicator +==================================== + +It puts the CMD device in receive mode and makes it wait for a packet. +It then outputs the result as 2 hexadecimal bytes. + + .. parsed-literal:: + :class: highlight + + custom lgetlqi + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgetlqi + +lgetrssi - Measure RSSI +======================= + +It gets the RSSI in dBm. + + .. parsed-literal:: + :class: highlight + + custom lgetrssi + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgetrssi + +lsetshort - Set short address +============================= + +It sets the CMD device's short address. +It is used for frame filtering and acknowledgment transmission. + + .. parsed-literal:: + :class: highlight + + custom lsetshort *0x* + +The ```` argument indicates the IEEE 802.15.4 short, two-byte address. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lsetshort *0x00FF* + +lsetextended - Set extended address +=================================== + +It sets the CMD device's extended address. +It is used for frame filtering and acknowledgment transmission. + + .. parsed-literal:: + :class: highlight + + custom lsetextended *0x* + +The ```` argument indicates the IEEE 802.15.4 long, 8-byte address. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lsetextended *0x000000000000FFFF* + +lsetpanid - Set PAN id +====================== + +It sets the PAN id. +It is used for frame filtering and acknowledgment transmission. + + .. parsed-literal:: + :class: highlight + + custom lsetpanid *0x* + +The ```` argument indicates the two-bytes of the IEEE 802.15.4 PAN ID. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lsetpanid *0x000A* + +lsetpayload - Set payload for burst transmission +================================================ + +It sets an arbitrary payload of a raw IEEE 802.15.4 packet. + + .. parsed-literal:: + :class: highlight + + custom lsetpayload ** ** + +* The ```` argument indicates the length of the payload in bytes. +* The ```` argument indicates the bytes of the packet payload. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lsetpayload *5* *FFFFFFFFFF* + +ltx - Burst transmission of packets +=================================== + +It starts the transmission of packets with a random (or previously defined) payload. + + .. parsed-literal:: + :class: highlight + + custom ltx ** ** + +* The ```` argument indicates the number of packets to be sent. + Set to ``0`` for an infinite transmission. +* The ```` argument indicates the delay in milliseconds between the transmissions. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom ltx *10* *1000* + +ltxend - Stop the burst transmission of packets +=============================================== + +It makes the CMD device stop current burst transmission. + + .. parsed-literal:: + :class: highlight + + custom ltxend + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom ltxend + +lstart - Start the continuous receive mode +========================================== + +It makes the sample enter the continuous receive mode and print the received packet information over a serial connection. +The sample does not accept any other command until it receives ``custom lend``. + + .. parsed-literal:: + :class: highlight + + custom lstart + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lstart + +lend - End the continuous receive mode +====================================== + +It makes the sample leave the continuous receive mode and print statistics + + .. parsed-literal:: + :class: highlight + + custom lend + +The statistics are shown in the following format: + + .. parsed-literal:: + :class: highlight + + [total]0x%x%x%x%x [protocol]0x%x%x%x%x [totalLqi]0x%x%x%x%x [totalRssiMgnitude]0x%x%x%x%x + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lend + +lsetantenna - Set CMD antenna number +==================================== + +It sets the antenna used by the CMD device. + + .. parsed-literal:: + :class: highlight + + custom lsetantenna ** + +The ```` argument indicates the antenna number, in the range between ``0`` and ``225``. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lsetantenna *1* + +lgetantenna - Get CMD antenna number +==================================== + +It gets the antenna used by the CMD device. + + .. parsed-literal:: + :class: highlight + + custom lgetantenna + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgetantenna + +rsetantenna - Set DUT antenna number +==================================== + +It sets the antenna used by the DUT device. + + .. parsed-literal:: + :class: highlight + + custom rsetantenna ** + +The ```` argument indicates the antenna number, in the range between ``0`` and ``225``. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom rsetantenna *1* + +rgetantenna - Get DUT antenna number +==================================== + +It gets the antenna used by the DUT device. + + .. parsed-literal:: + :class: highlight + + custom rgetantenna + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom rgetantenna + +lcarrier - Unmodulated waveform (carrier) transmission +====================================================== + +It starts the transmission of the unmodulated carrier. + + .. parsed-literal:: + :class: highlight + + custom lcarrier ** ** ** + +* The ```` argument indicates the duration of the continuous signal transmission. + It ranges between ``1`` and ``32767`` milliseconds. +* The ```` argument indicates the duration of the interval between the pulses. + It ranges between ``0`` and ``32767`` milliseconds. +* The ```` argument indicates the upper limit for the command’s execution. + It ranges between ``0`` and ``32767`` milliseconds. + Set to ``0`` for infinite transmission. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lcarrier ``10`` ``200`` ``2000`` + +lstream - Modulated waveform transmission +========================================= + +It starts a modulated waveform transmission. + + .. parsed-literal:: + :class: highlight + + custom lstream ** ** ** + +* The ```` argument indicates the duration of the continuous packet transmission. + It ranges between ``1`` and ``32767`` milliseconds. +* The ```` argument indicates the duration of the interval between the pulses. + It ranges between ``0`` and ``32767`` milliseconds. +* The ```` argument indicates the upper limit for the command’s execution. + It ranges between ``0`` and ``32767`` milliseconds. + Set to ``0`` for infinite transmission. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lstream *100* *200* *20000* + +rhardwareversion - Get the DUT hardware version +=============================================== + +It gets the hardware version of the DUT device. + + .. parsed-literal:: + :class: highlight + + custom rhardwareversion + + .. parsed-literal:: + :class: highlight + + custom rhardwareversion + +rsoftwareversion - Get the DUT software version +=============================================== + +It gets the software version of the DUT device. + + .. parsed-literal:: + :class: highlight + + custom rsoftwareversion + + .. parsed-literal:: + :class: highlight + + custom rsoftwareversion + +lclk - High-frequency clock output on a selected pin +==================================================== + +It makes the CMD device disable or enable the high-frequency clock output on a selected pin. +The actual clock frequency depends on the SoC used. +It is the highest possible considering the GPIO and CLOCK modules possibilities. + + .. parsed-literal:: + :class: highlight + + custom lclk ** ** + +* The ```` argument indicates the GPIO pin number. + It ranges between ``0`` and the number of GPIO pins supported by the SoC. +* The ```` argument can assume one of the following values: + + * ``0`` - disabled + * ``1`` - enabled + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lclk *10* *1* + +lsetgpio - Set GPIO pin value +============================= + +It makes the CMD device set the value of the selected GPIO out pin. + + .. parsed-literal:: + :class: highlight + + custom lsetgpio ** ** + +* The ```` argument indicates the GPIO pin number. + It ranges between ``0`` and the number of GPIO pins supported by the SoC. +* The ```` argument can assume one of the following values: + + * ``0`` - low + * ``1`` - high + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lsetgpio *29* *0* + +lgetgpio - Get GPIO pin value +============================= + +It makes CMD reconfigure the selected GPIO pin to INPUT mode and read its value. + + .. parsed-literal:: + :class: highlight + + custom lgetgpio ** + +* The ```` argument indicates the GPIO pin number. + It ranges between ``0`` and the number of GPIO pins supported by the SoC. + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgetgpio *29* + +lsetdcdc - Set DC/DC mode +========================= + +It makes the CMD device disable or enable the DC/DC mode. +It has no effects on unsupported boards. + + .. parsed-literal:: + :class: highlight + + custom lsetdcdc ** + +* The ```` argument can assume one of the following values: + + * ``0`` - disabled + * ``1`` - enabled + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lsetdcdc *1* + +lgetdcdc - Get DC/DC mode +========================= + +It gets the DC/DC mode of the CMD device. +It is always ``0`` for unsupported boards. + + .. parsed-literal:: + :class: highlight + + custom lgetdcdc + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgetdcdc + +lseticache - Set ICACHE configuration +===================================== + +It makes the CMD device disable or enable the ICACHE + + .. parsed-literal:: + :class: highlight + + custom lseticache ** + +* The ```` argument can assume one of the following values: + + * ``0`` - disabled + * ``1`` - enabled + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lseticache *1* + +lgettemp - Read SoC temperature +=============================== + +It makes the CMD device print the SoC temperature in the format ``<.%02>``. + + .. parsed-literal:: + :class: highlight + + custom lgettemp + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lgettemp + +lsleep - Transition radio to sleep mode +======================================= + +It makes the CMD device put the radio in sleep mode. + + .. parsed-literal:: + :class: highlight + + custom lsleep + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lsleep + +lreceive - Transition radio to receive mode +=========================================== + +It makes the CMD device put the radio in receive mode. + + .. parsed-literal:: + :class: highlight + + custom lreceive + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lreceive + +lreboot - Reboots the device +============================ + +It reboots the device + + .. parsed-literal:: + :class: highlight + + custom lreboot + +See the following example: + + .. parsed-literal:: + :class: highlight + + custom lreboot + +Building and running +******************** + +.. |sample path| replace:: :file:`samples/peripheral/802154_phy_test` + +.. include:: /includes/build_and_run.txt + +.. note:: + On the |nRF5340DKnoref|, the IEEE 802.15.4 PHY Test Tool is a standalone network sample that does not require any counterpart application sample. + However, you must still program the application core to boot up the network core, and forward the UART pins to the network core of the CMD device. + The :ref:`nrf5340_empty_app_core` sample, which does both, is built and programmed automatically by default. + +.. _802154_phy_test_testing: + +Testing the sample +================== + +After programming the sample to your development kit, test it by performing the following steps: + +1. Connect the development kit to the computer using a USB cable. + Use the development kit's programmer USB port (J2). + The kits are assigned a COM port (in Windows) or a ttyACM device (in Linux), visible in the Device Manager or in the :file:`/dev` directory. +#. |connect_terminal| +#. If the sample is configured to support BOTH modes (the default setting), switch the development kit into CMD mode by sending the following command: + + .. parsed-literal:: + :class: highlight + + custom changemode *1* + +#. On the bottom side of your development kit, locate the table describing the GPIO pin assignment to the LEDs. + Read the numbers of the GPIO pins assigned to LED 1, 2, 3 or 4. + For example, on the nRF52840DK, the LEDs are controlled by the pins ranging between P0.13 and P0.16. +#. The LEDs on nRF5340DK and nRF52840DK are in the ``sink`` configuration. + To turn them on, you must set the respective pin's state to low to let the current flow through the LED, using the ``custom lsetgpio 0`` command, where ```` is the number of the pin assigned for selected LED. + See the following example for how to light up LED 1 on the nRF5340DK: + + .. parsed-literal:: + :class: highlight + + custom lsetgpio *28* 0 + +If the selected LED lights up, the sample works as expected and is ready for use. + +.. _802154_phy_test_testing_board: + +.. note:: + The serial communication does not utilize echo, and the timeout for receiving the entire command after receiving its first character is very short. + To let the device properly receive the commands, use a terminal application that supports *line mode*, or send the entire command using commands like ``echo`` or ``printf``. + +Performing radio tests without the serial interface +=================================================== + +1. Make sure that at least one of the development kits can be set into CMD mode and the other one to the DUT mode. + The DUT device will not initialize the serial interface. + The easiest way to achieve this is to flash both devices with the sample configured to support BOTH modes (default setting). +#. Connect both development kits to the computer using a USB cable. + The kits are assigned a COM port (in Windows) or a ttyACM device (in Linux), visible in the Device Manager or the :file:`/dev` directory. +#. |connect_terminal| +#. If the samples are configured to support BOTH modes (the default setting), switch one of the development kits into CMD mode by sending the following command: + + .. parsed-literal:: + :class: highlight + + custom changemode *1* + +#. Run the following command on the development kit running in CMD mode: + + .. parsed-literal:: + :class: highlight + + custom find + +#. The development kit running in CMD mode should respond with one of the following 2 responses: + + * ``channel find `` - if the CMD device successfully communicates with the DUT device. + * ``DUT NOT FOUND`` - if it could not exchange packets with the DUT device. + +Refer to the :ref:`802154_phy_test_ui` for the complete list of the available commands. diff --git a/samples/peripheral/802154_phy_test/include/comm_proc.h b/samples/peripheral/802154_phy_test/include/comm_proc.h new file mode 100644 index 000000000000..9d9ca579dc2f --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/comm_proc.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: communication interfaces */ + +#ifndef COMM_PROC_H__ +#define COMM_PROC_H__ + +#include + +#include + +/**< Maximum expected size of received packet */ +#define COMM_MAX_TEXT_DATA_SIZE (320u) + +/**< Time to wait for a mark of end of a packet (new line) */ +#define COMM_PER_COMMAND_TIMEOUT (500u) + +/**< Maximum size of transmitted packet */ +#define COMM_TX_BUFFER_SIZE (320u) + +/**< Additional symbols in the end of transmitted packet */ +#define COMM_APPENDIX "\r\n" +#define COMM_APPENDIX_SIZE sizeof(COMM_APPENDIX) + +/**< Stated of COMM packet parser */ +enum input_state { + INPUT_STATE_IDLE = 0, /**< Wait for the first symbol */ + INPUT_STATE_WAITING_FOR_NEWLINE, /**< Wait for new line symbol or timeout */ + INPUT_STATE_TEXT_PROCESSING, /**< Passes received string to the library */ +}; + +struct text_proc_s { + struct k_timer timer; + struct k_work work; + char buf[COMM_MAX_TEXT_DATA_SIZE]; + uint16_t len; + enum input_state state; +}; + +void comm_init(void); + +void comm_input_process(struct text_proc_s *text_proc, const uint8_t *buf, uint32_t len); + +void comm_text_processor_fn(struct k_work *work); + +void comm_proc(void); + +void comm_input_timeout_handler(struct k_timer *timer); + +#endif /* COMM_PROC_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_ctrl.h b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_ctrl.h new file mode 100644 index 000000000000..44a3feb693c3 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_ctrl.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: control module interface intended for internal usage on library + * level + */ + +#ifndef PTT_CTRL_H__ +#define PTT_CTRL_H__ + +#include "ptt_events.h" +#include "ptt_types.h" + +/** @brief Push a received packet from rf to ctrl module + * + * Provides the control module with a packet received over the air + * + * @param pkt - packet received over the air + * @param len - length of the packet + * @param rssi - RSSI of the packet + * @param lqi - LQI of the packet + * + * @return none + */ +void ptt_ctrl_rf_push_packet(const uint8_t *pkt, ptt_pkt_len_t len, int8_t rssi, uint8_t lqi); + +/** @brief Pass an event "Transmission started" + * + * Pass to the control module external event about starting transmission + * + * @param evt_id - id of currently processed event + */ +void ptt_ctrl_rf_tx_started(ptt_evt_id_t evt_id); + +/** @brief Pass an event "Transmission finished" + * + * Pass to the control module external event about finished transmission + * + * @param evt_id - id of currently processed event + */ +void ptt_ctrl_rf_tx_finished(ptt_evt_id_t evt_id); + +/** @brief Pass an event "Transmission failed" + * + * Pass to the control module external event about failed transmission + * + * @param evt_id - id of currently processed event + * @param tx_error - a reason of transmission fail + */ +void ptt_ctrl_rf_tx_failed(ptt_evt_id_t evt_id, ptt_rf_tx_error_t tx_error); + +/** @brief Pass an event "Reception failed" + * + * Pass to the control module information about failed reception + * + * @param rx_error - a reason of reception fail + */ +void ptt_ctrl_rf_rx_failed(ptt_rf_rx_error_t rx_error); + +/** @brief Pass an event "ED detected" and a result + * + * Pass to the control module external event about finished ED procedure and its result + * + * @param evt_id - id of currently processed event + * @param result - result of "ED detected" procedure + */ +void ptt_ctrl_rf_ed_detected(ptt_evt_id_t evt_id, ptt_ed_t result); + +/** @brief Pass an event "ED failed" + * + * Pass to the control module external event about failed ED procedure + * + * @param evt_id - id of currently processed event + */ +void ptt_ctrl_rf_ed_failed(ptt_evt_id_t evt_id); + +/** @brief Pass an event "CCA done" and a result + * + * Pass to the control module external event about finished CCA procedure and its result + * + * @param evt_id - id of currently processed event + * @param result - result of CCA procedure + */ +void ptt_ctrl_rf_cca_done(ptt_evt_id_t evt_id, bool result); + +/** @brief Pass an event "CCA failed" and a result + * + * Pass to the control module external event about finished CCA procedure and its result + * + * @param evt_id - id of currently processed event + */ +void ptt_ctrl_rf_cca_failed(ptt_evt_id_t evt_id); + +#endif /* PTT_CTRL_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_events.h b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_events.h new file mode 100644 index 000000000000..1e400358cc9a --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_events.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: events interface intended for internal usage on library level */ + +#ifndef PTT_EVENTS_H__ +#define PTT_EVENTS_H__ + +#include + +#define PTT_EVENT_UNASSIGNED (0xFFu) + +/** type definition of event id */ +typedef uint8_t ptt_evt_id_t; + +#endif /* PTT_EVENTS_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_timers.h b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_timers.h new file mode 100644 index 000000000000..af391e82437e --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_timers.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: timers interface intended for internal usage on library level */ + +#ifndef PTT_TIMERS_H__ +#define PTT_TIMERS_H__ + +#include "ptt_errors.h" +#include "ptt_events.h" +#include "ptt_types.h" + +/** type definition of function to be call when timer is expired */ +typedef void (*ptt_timer_cb)(ptt_evt_id_t evt_id); + +/** @brief Add a timer to the timer pool + * + * @param timeout - timeout for the timer in ms + * @param cb - function to be called when timeout expired + * @param evt_id - event id to identify timer also will be passed as parameter to user cb + * + * @return zero on success, or error code + */ +enum ptt_ret ptt_timer_add(ptt_time_t timeout, ptt_timer_cb cb, ptt_evt_id_t evt_id); + +/** @brief Free timer for evt_id + * + * @param evt_id - event, corresponding to removing timer + */ +void ptt_timer_remove(ptt_evt_id_t evt_id); + +#endif /* PTT_TIMERS_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_trace.h b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_trace.h new file mode 100644 index 000000000000..9c4a5823c6d3 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_trace.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: trace interface intended for internal usage on library level */ + +#ifndef PTT_TRACE_H__ +#define PTT_TRACE_H__ + +#ifdef TESTS + +#include "stdio.h" +#define PTT_TRACE printf + +#else +#include +LOG_MODULE_DECLARE(phy_tt); + +#define PTT_TRACE(...) LOG_DBG(__VA_ARGS__) + +#endif + +#define PTT_TRACE_FUNC_ENTER() PTT_TRACE("%s ->\n", __func__) +#define PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id) PTT_TRACE("%s -> evt_id: %d\n", __func__, evt_id) +#define PTT_TRACE_FUNC_EXIT() PTT_TRACE("%s -<\n", __func__) +#define PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret) PTT_TRACE("%s -< ret: %d\n", __func__, ret) + +#endif /* PTT_TRACE_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_uart.h b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_uart.h new file mode 100644 index 000000000000..111d950777e2 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/internal/ctrl/ptt_uart.h @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: uart transport interface intended for internal usage on library + * level + */ + +#ifndef PTT_UART_H__ +#define PTT_UART_H__ + +#include "ptt_errors.h" +#include "ptt_uart_api.h" + +#define PTT_VALUE_ON (1u) +#define PTT_VALUE_OFF (0u) + +/* commands text */ +#define UART_CMD_R_PING_TEXT "custom rping" +#define UART_CMD_L_PING_TIMEOUT_TEXT "custom lpingtimeout" +#define UART_CMD_SETCHANNEL_TEXT "custom setchannel" +#define UART_CMD_L_SETCHANNEL_TEXT "custom lsetchannel" +#define UART_CMD_R_SETCHANNEL_TEXT "custom rsetchannel" +#define UART_CMD_L_GET_CHANNEL_TEXT "custom lgetchannel" +#define UART_CMD_L_SET_POWER_TEXT "custom lsetpower" +#define UART_CMD_R_SET_POWER_TEXT "custom rsetpower" +#define UART_CMD_L_GET_POWER_TEXT "custom lgetpower" +#define UART_CMD_R_GET_POWER_TEXT "custom rgetpower" +#define UART_CMD_R_STREAM_TEXT "custom rstream" +#define UART_CMD_R_START_TEXT "custom rstart" +#define UART_CMD_R_END_TEXT "custom rend" +#define UART_CMD_L_REBOOT_TEXT "custom lreboot" +#define UART_CMD_FIND_TEXT "custom find" +#define UART_CMD_R_HW_VERSION_TEXT "custom rhardwareversion" +#define UART_CMD_R_SW_VERSION_TEXT "custom rsoftwareversion" +#define UART_CMD_CHANGE_MODE_TEXT "custom changemode" +#define UART_CMD_L_GET_CCA_TEXT "custom lgetcca" +#define UART_CMD_L_GET_ED_TEXT "custom lgeted" +#define UART_CMD_L_GET_LQI_TEXT "custom lgetlqi" +#define UART_CMD_L_GET_RSSI_TEXT "custom lgetrssi" +#define UART_CMD_L_SET_SHORT_TEXT "custom lsetshort" +#define UART_CMD_L_SET_EXTENDED_TEXT "custom lsetextended" +#define UART_CMD_L_SET_PAN_ID_TEXT "custom lsetpanid" +#define UART_CMD_L_SET_PAYLOAD_TEXT "custom lsetpayload" +#define UART_CMD_L_START_TEXT "custom lstart" +#define UART_CMD_L_END_TEXT "custom lend" +#define UART_CMD_L_SET_ANTENNA_TEXT "custom lsetantenna" +#define UART_CMD_L_GET_ANTENNA_TEXT "custom lgetantenna" +#define UART_CMD_R_SET_ANTENNA_TEXT "custom rsetantenna" +#define UART_CMD_R_GET_ANTENNA_TEXT "custom rgetantenna" +#define UART_CMD_L_TX_TEXT "custom ltx" +#define UART_CMD_L_CLK_TEXT "custom lclk" +#define UART_CMD_L_SET_GPIO_TEXT "custom lsetgpio" +#define UART_CMD_L_GET_GPIO_TEXT "custom lgetgpio" +#define UART_CMD_L_TX_END_TEXT "custom ltxend" +#define UART_CMD_L_CARRIER_TEXT "custom lcarrier" +#define UART_CMD_L_STREAM_TEXT "custom lstream" +#define UART_CMD_L_SET_DCDC_TEXT "custom lsetdcdc" +#define UART_CMD_L_GET_DCDC_TEXT "custom lgetdcdc" +#define UART_CMD_L_SET_ICACHE_TEXT "custom lseticache" +#define UART_CMD_L_GET_ICACHE_TEXT "custom lgeticache" +#define UART_CMD_L_GET_TEMP_TEXT "custom lgettemp" +#define UART_CMD_L_INDICATION_TEXT "custom lindication" +#define UART_CMD_L_SLEEP_TEXT "custom lsleep" +#define UART_CMD_L_RECEIVE_TEXT "custom lreceive" + +/* commands payload in space separated words */ +#define UART_CMD_R_PING_PAYLOAD_L 0 +#define UART_CMD_L_PING_TIMEOUT_PAYLOAD_L 2 +#define UART_CMD_SETCHANNEL_PAYLOAD_L 4 +#define UART_CMD_L_SETCHANNEL_PAYLOAD_L 4 +#define UART_CMD_R_SETCHANNEL_PAYLOAD_L 1 +#define UART_CMD_L_GET_CHANNEL_PAYLOAD_L 0 +#define UART_CMD_L_SET_POWER_PAYLOAD_L 3 +#define UART_CMD_R_SET_POWER_PAYLOAD_L 3 +#define UART_CMD_L_GET_POWER_PAYLOAD_L 0 +#define UART_CMD_R_GET_POWER_PAYLOAD_L 0 +#define UART_CMD_R_STREAM_PAYLOAD_L 2 +#define UART_CMD_R_START_PAYLOAD_L 0 +#define UART_CMD_R_END_PAYLOAD_L 0 +#define UART_CMD_L_REBOOT_PAYLOAD_L 0 +#define UART_CMD_FIND_PAYLOAD_L 0 +#define UART_CMD_R_HW_VERSION_PAYLOAD_L 0 +#define UART_CMD_R_SW_VERSION_PAYLOAD_L 0 +#define UART_CMD_CHANGE_MODE_PAYLOAD_L 1 +#define UART_CMD_L_GET_CCA_PAYLOAD_L 1 +#define UART_CMD_L_GET_ED_PAYLOAD_L 0 +#define UART_CMD_L_GET_LQI_PAYLOAD_L 0 +#define UART_CMD_L_GET_RSSI_PAYLOAD_L 0 +#define UART_CMD_L_SET_SHORT_PAYLOAD_L 1 +#define UART_CMD_L_SET_EXTENDED_PAYLOAD_L 1 +#define UART_CMD_L_SET_PAN_ID_PAYLOAD_L 1 +#define UART_CMD_L_SET_PAYLOAD_PAYLOAD_L 2 +#define UART_CMD_L_START_PAYLOAD_L 0 +#define UART_CMD_L_END_PAYLOAD_L 0 +#define UART_CMD_L_SET_ANTENNA_PAYLOAD_L 1 +#define UART_CMD_L_GET_ANTENNA_PAYLOAD_L 0 +#define UART_CMD_R_SET_ANTENNA_PAYLOAD_L 1 +#define UART_CMD_R_GET_ANTENNA_PAYLOAD_L 0 +#define UART_CMD_L_TX_PAYLOAD_L 2 +#define UART_CMD_L_CLK_PAYLOAD_L 2 +#define UART_CMD_L_SET_GPIO_PAYLOAD_L 2 +#define UART_CMD_L_GET_GPIO_PAYLOAD_L 1 +#define UART_CMD_L_TX_END_PAYLOAD_L 0 +#define UART_CMD_L_CARRIER_PAYLOAD_L 3 +#define UART_CMD_L_STREAM_PAYLOAD_L 3 +#define UART_CMD_L_SET_DCDC_PAYLOAD_L 1 +#define UART_CMD_L_GET_DCDC_PAYLOAD_L 0 +#define UART_CMD_L_SET_ICACHE_PAYLOAD_L 1 +#define UART_CMD_L_GET_ICACHE_PAYLOAD_L 0 +#define UART_CMD_L_GET_TEMP_PAYLOAD_L 0 +#define UART_CMD_L_INDICATION_PAYLOAD_L 1 +#define UART_CMD_L_SLEEP_PAYLOAD_L 0 +#define UART_CMD_L_RECEIVE_PAYLOAD_L 0 + +#define UART_TEXT_PAYLOAD_DELIMETERS " " + +#define UART_CMD_SET_POWER_VALUE_PLACE 2 + +#define UART_SET_PAN_ID_SYM_NUM 6 +#define UART_SET_SHORT_SYM_NUM 6 +#define UART_SET_EXTENDED_SYM_NUM 18 + +/** UART commands */ +enum ptt_uart_cmd { + PTT_UART_CMD_R_PING = 0x00, /**< send ping to DUT */ + PTT_UART_CMD_L_PING_TIMEOUT, /**< set ping timeout to CMD */ + PTT_UART_CMD_SETCHANNEL, /**< set channel to CMD and DUT */ + PTT_UART_CMD_L_SETCHANNEL, /**< set channel to CMD */ + PTT_UART_CMD_R_SETCHANNEL, /**< set channel to DUT */ + PTT_UART_CMD_L_GET_CHANNEL, /**< get channel from CMD */ + PTT_UART_CMD_L_SET_POWER, /**< set power to CMD */ + PTT_UART_CMD_R_SET_POWER, /**< set power to DUT */ + PTT_UART_CMD_L_GET_POWER, /**< get power from CMD */ + PTT_UART_CMD_R_GET_POWER, /**< get power from DUT */ + PTT_UART_CMD_R_STREAM, /**< DUT transmits a stream */ + PTT_UART_CMD_R_START, /**< DUT starts RX test */ + PTT_UART_CMD_R_END, /**< DUT ends RX test and sends a report */ + PTT_UART_CMD_L_REBOOT, /**< CMD reboot local device */ + PTT_UART_CMD_FIND, /**< CMD starts find procedure */ + PTT_UART_CMD_R_HW_VERSION, /**< get HW version from DUT */ + PTT_UART_CMD_R_SW_VERSION, /**< get SW version from DUT */ + PTT_UART_CMD_CHANGE_MODE, /**< change device mode */ + PTT_UART_CMD_L_GET_CCA, /**< CMD will perform CCA with selected mode and print result*/ + PTT_UART_CMD_L_GET_ED, /**< CMD will perform ED and print out the result */ + PTT_UART_CMD_L_GET_LQI, + /**< CMD will put the device into receive mode and wait for reception of a single packet */ + PTT_UART_CMD_L_GET_RSSI, /**< CMD will measure RSSI and print result */ + PTT_UART_CMD_L_SET_SHORT, /**< CMD will set its short address */ + PTT_UART_CMD_L_SET_EXTENDED, /**< CMD will set its extended address */ + PTT_UART_CMD_L_SET_PAN_ID, /**< CMD will set its PAN Id */ + PTT_UART_CMD_L_SET_PAYLOAD, /**< CMD will set payload for next ltx commands */ + PTT_UART_CMD_L_START, + /**< CMD will put the DUT in a continuous receive mode, where each packet received */ + /** is displayed in turn */ + PTT_UART_CMD_L_END, + /**< CMD will stop the continuous receive mode, if active. If continuous receive mode */ + /** is not active, the command is ignored. */ + PTT_UART_CMD_L_SET_ANTENNA, /**< CMD will set antenna device is sending frames with. */ + PTT_UART_CMD_L_GET_ANTENNA, /**< CMD will print out the antenna used by the device */ + PTT_UART_CMD_R_SET_ANTENNA, /**< CMD will set antenna DUT device is sending frames with. */ + PTT_UART_CMD_R_GET_ANTENNA, /**< CMD will print out the antenna used by the DUT device */ + PTT_UART_CMD_L_TX, + /**< CMD will transmit a number of raw 802.15.4 frames with */ + /** payload previously set by “custom lsetpayload” */ + PTT_UART_CMD_L_CLK, /**< CMD will output HFCLK to GPIO pin */ + PTT_UART_CMD_L_SET_GPIO, /**< CMD will set value to GPIO pin */ + PTT_UART_CMD_L_GET_GPIO, /**< CMD will get value from GPIO pin */ + PTT_UART_CMD_L_TX_END, + /**< CMD will stop ltx command processing if ltx started with infinite number of packets */ + PTT_UART_CMD_L_CARRIER, /**< CMD will emit carrier signal without modulation */ + PTT_UART_CMD_L_STREAM, + /**< CMD will emit modulated signal with payload set by “custom lsetpayload”*/ + PTT_UART_CMD_L_SET_DCDC, /**< CMD will disable/enable DC/DC mode */ + PTT_UART_CMD_L_GET_DCDC, /**< CMD will print current DC/DC mode */ + PTT_UART_CMD_L_SET_ICACHE, /**< CMD will disable/enable ICACHE */ + PTT_UART_CMD_L_GET_ICACHE, /**< CMD will print current state of ICACHE */ + PTT_UART_CMD_L_GET_TEMP, /**< CMD will print out the SoC temperature */ + PTT_UART_CMD_L_INDICATION, /**< CMD will control LED indicating received packet */ + PTT_UART_CMD_L_SLEEP, /**< CMD will put radio into sleep mode */ + PTT_UART_CMD_L_RECEIVE, /**< CMD will put radio into receive mode*/ + PTT_UART_CMD_N, /**< command count */ +}; + +/** Actions to perform with payload before sending it to command handler */ +enum ptt_uart_payload { + /**< payload will be parsed as bytes separated by @ref UART_TEXT_PAYLOAD_DELIMETERS*/ + /** will be send to command handler */ + PTT_UART_PAYLOAD_PARSED_AS_BYTES, + /**< payload will be written as raw ASCII and command handlerwill be */ + /** responsible for parsing actions types count */ + PTT_UART_PAYLOAD_RAW, + PTT_UART_PAYLOAD_N, +}; + +/** command name and additional info for text command parsing */ +struct uart_text_cmd_s { + const char *name; /**< string containing command name */ + enum ptt_uart_cmd code; /**< command code */ + uint8_t payload_len; /**< payload length in space separated words */ + enum ptt_uart_payload payload_type; + /**< action to perform with payload before sending it to command handler\ */ +}; + +/** @brief Send a packet over UART + * + * @param pkt - data to send + * @param len - length of pkt + * + * @return PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_uart_send_packet(const uint8_t *pkt, ptt_pkt_len_t len); + +/** @brief Send @ref PTT_UART_PROMPT_STR over UART + * + * @param - none + * + * @return - none + */ +void ptt_uart_print_prompt(void); + +/** @brief Notify UART module a handler is busy + * + * @param - none + * + * @return - none + */ +void ptt_handler_busy(void); + +/** @brief Notify UART module a handler is free + * + * @param - none + * + * @return - none + */ +void ptt_handler_free(void); + +#endif /* PTT_UART_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/internal/ptt_errors.h b/samples/peripheral/802154_phy_test/include/internal/ptt_errors.h new file mode 100644 index 000000000000..6208e47e7005 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/internal/ptt_errors.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: PHY Test Tool library errors declaration */ + +#ifndef PTT_ERRORS_H__ +#define PTT_ERRORS_H__ + +#include + +/** error codes */ +enum ptt_ret { + PTT_RET_SUCCESS = 0, /**< success */ + PTT_RET_NULL_PTR, /**< pointer is NULL */ + PTT_RET_INVALID_VALUE, /**< invalid input value */ + PTT_RET_INVALID_STATE, /**< invalid state */ + PTT_RET_INVALID_MODE, /**< invalid mode of device */ + PTT_RET_INVALID_COMMAND, /**< invalid command*/ + PTT_RET_NO_FREE_SLOT, /**< no free slots in a pool */ + PTT_RET_BUSY, /**< resource is busy */ +}; + +#endif /* PTT_ERRORS_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/internal/ptt_proto.h b/samples/peripheral/802154_phy_test/include/internal/ptt_proto.h new file mode 100644 index 000000000000..18758fdf9cb1 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/internal/ptt_proto.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: Protocol related definitions */ + +#ifndef PTT_PROTO_H__ +#define PTT_PROTO_H__ + +#include +#include + +#include "ptt_types.h" + +/* first byte of a packet preamble */ +#define PTT_PREAMBLE_1ST (0xDEu) +/* second byte of a packet preamble */ +#define PTT_PREAMBLE_2ND (0xDEu) +/* third byte of a packet preamble */ +#define PTT_PREAMBLE_3D (0x00u) +/* length of a packet preamble */ +#define PTT_PREAMBLE_LEN (3u) + +/* length of command id field */ +#define PTT_CMD_CODE_LEN (1u) + +/* index in a packet where command id is placed */ +#define PTT_CMD_CODE_START (PTT_PREAMBLE_LEN) +/* index in a packet where payload started */ +#define PTT_PAYLOAD_START (PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN) + +#define PTT_PAYLOAD_LEN_SET_CHANNEL 4 +#define PTT_PAYLOAD_LEN_SET_POWER 1 +#define PTT_PAYLOAD_LEN_STREAM 2 +#define PTT_PAYLOAD_LEN_GET_POWER 1 +#define PTT_PAYLOAD_LEN_REPORT 16 +#define PTT_PAYLOAD_LEN_GET_HARDWARE 1 +#define PTT_PAYLOAD_LEN_GET_SOFTWARE 1 +#define PTT_PAYLOAD_LEN_SET_ANTENNA 1 +#define PTT_PAYLOAD_LEN_GET_ANTENNA 1 + +/** OTA commands codes */ +enum ptt_cmd { + PTT_CMD_PING = 0x00, /**< ping command */ + PTT_CMD_ACK = 0x01, /**< ack command */ + PTT_CMD_SET_CHANNEL = 0x02, /**< set DUT radio channel command */ + PTT_CMD_SET_POWER = 0x05, /**< set DUT radio power command */ + PTT_CMD_GET_POWER = 0x06, /**< send get power request to DUT command */ + PTT_CMD_GET_POWER_RESPONSE = 0x07, /**< get power command response */ + PTT_CMD_STREAM = 0x09, /**< start modulated waveform stream */ + PTT_CMD_START_RX_TEST = 0x0A, /**< start statistics incrementing */ + PTT_CMD_END_RX_TEST = 0x0B, /**< send report request to DUT command */ + PTT_CMD_REPORT = 0x0C, /**< test statistic report */ + PTT_CMD_GET_HARDWARE_VERSION = 0x11, /**< send hardware version request to DUT */ + PTT_CMD_GET_HARDWARE_VERSION_RESPONSE = 0x12, /**< get hardware version response */ + PTT_CMD_GET_SOFTWARE_VERSION = 0x13, /**< send software version request to DUT */ + PTT_CMD_GET_SOFTWARE_VERSION_RESPONSE = 0x14, /**< get software version response */ + PTT_CMD_GET_ANTENNA = 0x20, /**< send antenna request to DUT command */ + PTT_CMD_GET_ANTENNA_RESPONSE = 0x21, /**< get antenna command response */ + PTT_CMD_SET_ANTENNA = 0x22, /**< set DUT antenna command */ + PTT_CMD_CHANGE_MODE = 0xF0, /**< change device mode command */ +}; + +/** @brief Check a packet for valid protocol header + * + * @param pkt - pointer to packet data + * @param len - length of packet + * + * @return true - packet header is valid + * @return false - packet header isn't valid + */ +bool ptt_proto_check_packet(const uint8_t *pkt, ptt_pkt_len_t len); + +/** @brief Fill a packet with protocol header and provided command + * + * @param pkt - pointer to packet data, must have enough space to reside the header and command + * @param cmd - command id + * @param pkt_max_size - available space in the packet + * + * @return ptt_pkt_len_t - length of header with command + */ +ptt_pkt_len_t ptt_proto_construct_header(uint8_t *pkt, enum ptt_cmd cmd, + ptt_pkt_len_t pkt_max_size); + +/* helper functions to convert between protocol big-endian format and host endianness */ +void ptt_htobe16(uint8_t *src, uint8_t *dst); +void ptt_htobe32(uint8_t *src, uint8_t *dst); +void ptt_betoh16(uint8_t *src, uint8_t *dst); +void ptt_betoh32(uint8_t *src, uint8_t *dst); + +uint16_t ptt_htobe16_val(uint8_t *src); +uint32_t ptt_htobe32_val(uint8_t *src); +uint16_t ptt_betoh16_val(uint8_t *src); +uint32_t ptt_betoh32_val(uint8_t *src); + +void ptt_htole16(uint8_t *src, uint8_t *dst); + +#endif /* PTT_PROTO_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/internal/ptt_utils.h b/samples/peripheral/802154_phy_test/include/internal/ptt_utils.h new file mode 100644 index 000000000000..5b53b39a98d8 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/internal/ptt_utils.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: miscellaneous helpful things */ + +#ifndef PTT_UTILS_H__ +#define PTT_UTILS_H__ + +#include + +#define PTT_COMPILE_TIME_ASSERT_CAT_(a, b) a##b +#define PTT_COMPILE_TIME_ASSERT_CAT(a, b) PTT_COMPILE_TIME_ASSERT_CAT_(a, b) + +#define PTT_COMPILE_TIME_ASSERT(cond) \ + typedef char PTT_COMPILE_TIME_ASSERT_CAT(assertion_failed_, __LINE__)[(cond) ? 1 : -1] + +#define PTT_UNUSED(x) ((void)(x)) + +#define PTT_CAST_TO_UINT8_P(x) ((uint8_t *)(x)) +#define PTT_CAST_TO_STR(x) ((char *)(x)) + +#endif /* PTT_UTILS_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/internal/rf/ptt_rf.h b/samples/peripheral/802154_phy_test/include/internal/rf/ptt_rf.h new file mode 100644 index 000000000000..d123c2893d4c --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/internal/rf/ptt_rf.h @@ -0,0 +1,293 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: radio module interface intended for internal usage on library + * level + */ + +#ifndef PTT_RF_H__ +#define PTT_RF_H__ + +#include + +#include "ptt_config.h" +#include "ctrl/ptt_events.h" +#include "ptt_errors.h" +#include "ptt_types.h" + +#define PTT_CHANNEL_MIN (11u) +#define PTT_CHANNEL_MAX (26u) + +#define PTT_PANID_ADDRESS_SIZE (2u) +#define PTT_SHORT_ADDRESS_SIZE (2u) +#define PTT_EXTENDED_ADDRESS_SIZE (8u) + +/* received packets statistic */ +struct ptt_rf_stat_s { + uint32_t total_pkts; /**< total received packets */ + uint32_t total_lqi; /**< sum of lqi of received packets */ + uint32_t total_rssi; /**< sum of rssi of received packets */ +}; + +/** payload for `custom ltx` command */ +struct ptt_ltx_payload_s { + uint8_t arr[PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE]; /**< raw PHY packet */ + uint8_t len; /**< length of used part of arr */ +}; + +/* information that came with the packet */ +struct ptt_rf_packet_info_s { + uint8_t lqi; + int8_t rssi; +}; + +/** @brief RF module context initialization + * + * @param none + * + * @return none + */ +void ptt_rf_init(void); + +/** @brief RF module context unitialization + * + * @param none + * + * @return none + */ +void ptt_rf_uninit(void); + +/** @brief RF module reset to default + * + * @param none + * + * @return none + */ +void ptt_rf_reset(void); + +/** @brief Send a packet to a transmitter + * + * @param evt_id - event id locking this transmission + * @param pkt - data to be transmitted + * @param len - length of the data + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_send_packet(ptt_evt_id_t evt_id, const uint8_t *pkt, ptt_pkt_len_t len); + +/** @brief Set channel mask to radio driver + * + * @param evt_id - event id locking setting mask + * @param mask - channel bit mask, if more than one bit enabled, least significant will be used + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_set_channel_mask(ptt_evt_id_t evt_id, uint32_t mask); + +/** @brief Set channel to radio driver + * + * @param evt_id - event id locking setting channel + * @param channel - channel number (11-26) + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_set_channel(ptt_evt_id_t evt_id, uint8_t channel); + +/** @brief Set short address to radio driver + * + * @param evt_id - event id locking setting address + * @param short_address Pointer to the short address (2 bytes, little-endian) + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_set_short_address(ptt_evt_id_t evt_id, const uint8_t *short_addr); + +/** @brief Set extended address to radio driver + * + * @param evt_id - event id locking setting address + * @param extended_address Pointer to the extended address (8 bytes, little-endian) + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_set_extended_address(ptt_evt_id_t evt_id, const uint8_t *extended_addr); + +/** @brief Set pan id to radio driver + * + * @param evt_id - event id locking setting PAN id + * @param pan_id Pointer to the PAN ID (2 bytes, little-endian) + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_set_pan_id(ptt_evt_id_t evt_id, const uint8_t *pan_id); + +/** @brief Returns number of current channel + * + * @param none + * + * @return uint8_t - current channel number + */ +uint8_t ptt_rf_get_channel(void); + +/** @brief Set power to radio driver + * + * @param evt_id - event id locking setting power + * @param power - power in dbm + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_set_power(ptt_evt_id_t evt_id, int8_t power); + +/** @brief Returns current power + * + * @param none + * + * @return int8_t - current power + */ +int8_t ptt_rf_get_power(void); + +/** @brief Set antenna to radio driver + * + * @param evt_id - event id locking setting antenna + * @param antenna - is value in range [0-255] + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_set_antenna(ptt_evt_id_t evt_id, uint8_t antenna); + +/** @brief Returns current antenna + * + * @param none + * + * @return uint8_t - current antenna + */ +uint8_t ptt_rf_get_antenna(void); + +/** @brief Calls radio driver to verify if the channel is clear + * + * @param evt_id - event id locking radio module + * @param mode - CCA mode + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_cca(ptt_evt_id_t evt_id, uint8_t mode); + +/** @brief Calls radio driver to detect the maximum energy for a given time + * + * @param evt_id - event id locking radio module + * @param time_us - duration of energy detection procedure. + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_ed(ptt_evt_id_t evt_id, uint32_t time_us); + +/** @brief Calls radio driver to begin the RSSI measurement + * + * @param evt_id - event id locking static module + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_rssi_measure_begin(ptt_evt_id_t evt_id); + +/** @brief Calls radio driver to get the result of the last RSSI measurement + * + * @param[IN] evt_id - event id locking static module + * @param[OUT] rssi - RSSI measurement result in dBm, unchanged if error code returned + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_rssi_last_get(ptt_evt_id_t evt_id, ptt_rssi_t *rssi); + +/** @brief Convert channel bitmask into a channel number + * + * @param mask - channel bit mask, if more than one bit enabled, least significant will be used + * + * @return uint8_t - channel number or 0, if there is no valid channels inside mask + */ +uint8_t ptt_rf_convert_channel_mask_to_num(uint32_t mask); + +/** @brief Clear statistic and enable statistic gathering in RF module + * + * @param evt_id - event id locking statistic control + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_start_statistic(ptt_evt_id_t evt_id); + +/** @brief Disable statistic gathering in RF module + * + * @param evt_id - event id locking statistic control + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_end_statistic(ptt_evt_id_t evt_id); + +/** @brief Get gathered statistic from RF module + * + * @param none + * + * @return struct ptt_rf_stat_s - structure with gathered statistic + */ +struct ptt_rf_stat_s ptt_rf_get_stat_report(void); + +/** @brief Start modulated stream transmission + * + * @param evt_id - event id locking this transmission + * @param pkt - payload to modulate carrier with + * @param len - length of payload to modulate carrier with + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_start_modulated_stream(ptt_evt_id_t evt_id, const uint8_t *pkt, + ptt_pkt_len_t len); + +/** @brief Stop modulated stream transmission + * + * @param evt_id - event id locking this transmission + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_stop_modulated_stream(ptt_evt_id_t evt_id); + +/** @brief Start continuous carrier transmission + * + * @param evt_id - event id locking this transmission + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_start_continuous_carrier(ptt_evt_id_t evt_id); + +/** @brief Stop continuous carrier transmission + * + * @param evt_id - event id locking this transmission + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_stop_continuous_carrier(ptt_evt_id_t evt_id); + +/** @brief Getter for payload of custom ltx command + * + * @param none + * + * @return struct ptt_ltx_payload_s * pointer to payload + */ +struct ptt_ltx_payload_s *ptt_rf_get_custom_ltx_payload(void); + +/** @brief Change radio state to receiving + * + * @param evt_id - event id locking this operation + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_receive(void); + +/** @brief Change radio state to sleeping + * + * @param evt_id - event id locking this operation + * + * @return enum ptt_ret - PTT_RET_SUCCESS or error + */ +enum ptt_ret ptt_rf_sleep(void); + +#endif /* PTT_RF_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/periph_proc.h b/samples/peripheral/802154_phy_test/include/periph_proc.h new file mode 100644 index 000000000000..4f859ef93ba0 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/periph_proc.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: Periphery interfaces */ + +#ifndef PERIPH_PROC_H__ +#define PERIPH_PROC_H__ + +#include + +#include "ptt.h" + +/** @brief Initialize various periphery + * + * @param none + * + * @return none + * + */ +void periph_init(void); + +#endif /* PERIPH_PROC_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/ptt.h b/samples/peripheral/802154_phy_test/include/ptt.h new file mode 100644 index 000000000000..970fc09c6e6e --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/ptt.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: PHY Test Tool library interface for external usage */ + +#ifndef PTT_H__ +#define PTT_H__ + +#include "ptt_types.h" + +/** @brief PTT library initialization + * + * @param call_me_cb - callback to be called from the library to schedule a timer + * @param max_time - maximum supported time by a current timer implementation + * + * @return none + */ +void ptt_init(ptt_call_me_cb_t call_me_cb, ptt_time_t max_time); + +/** @brief PTT library uninitialization + * + * @param none + * + * @return none + */ +void ptt_uninit(void); + +/** @brief Notify the library about expired timeout + * + * @param current_time - current time in milliseconds + * + * @return none + */ +void ptt_process(ptt_time_t current_time); + +/* external provided function to get current time */ +extern ptt_time_t ptt_get_current_time(void); +/* external provided function to get mode mask from application */ +extern bool ptt_get_mode_mask_ext(uint32_t *mode); +/* external provided function to get channel_mask from application */ +extern bool ptt_get_channel_mask_ext(uint32_t *channel_mask); +/* external provided function to get power from application */ +extern bool ptt_get_power_ext(int8_t *power); +/* external provided function to get antenna from application */ +extern bool ptt_get_antenna_ext(uint8_t *antenna); +/* external provided function to get SW version from application */ +extern bool ptt_get_sw_version_ext(uint8_t *sw_version); +/* external provided function to get HW version from application */ +extern bool ptt_get_hw_version_ext(uint8_t *hw_version); +/* external provided function to get ANT mode from application */ +extern bool ptt_get_ant_mode_ext(uint8_t *ant_mode); +/* external provided function to get ANT number from application */ +extern bool ptt_get_ant_num_ext(uint8_t *ant_num); +/* external provided function to reset board */ +extern void ptt_do_reset_ext(void); +/** @brief external provided function to get random value + * + * must be able to get at least @ref PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE bytes every + * (@ref PTT_L_STREAM_INTERVAL_MIN + @ref PTT_L_STREAM_PULSE_MIN) ms + */ +extern uint32_t ptt_random_get_ext(void); +/* external provided function to control HFLCK output */ +extern bool ptt_clk_out_ext(uint8_t pin, bool mode); +/* external provided function to set GPIO pin value */ +extern bool ptt_set_gpio_ext(uint8_t pin, uint8_t value); +/* external provided function to get GPIO pin value */ +extern bool ptt_get_gpio_ext(uint8_t pin, uint8_t *value); +/* external provided function to disable/enable DC/DC mode */ +extern void ptt_set_dcdc_ext(bool enable); +/* external provided function to get current DC/DC mode */ +extern bool ptt_get_dcdc_ext(void); +/* external provided function to disable/enable ICACHE */ +extern void ptt_set_icache_ext(bool enable); +/* external provided function to get current state of ICACHE */ +extern bool ptt_get_icache_ext(void); +/* external provided function to get SoC temperature */ +extern bool ptt_get_temp_ext(int32_t *temp); +/* external provided function to set LED indicating received packet state to ON */ +extern void ptt_ctrl_led_indication_on_ext(void); +/* external provided function to set LED indicating received packet state to OFF*/ +extern void ptt_ctrl_led_indication_off_ext(void); + +#endif /* PTT_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/ptt_config.h b/samples/peripheral/802154_phy_test/include/ptt_config.h new file mode 100644 index 000000000000..df5e5ecc7817 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/ptt_config.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: settings intended for external configuration */ + +#ifndef PTT_CONFIG_H__ +#define PTT_CONFIG_H__ + +#define PTT_EVENT_POOL_N 8u +#define PTT_EVENT_DATA_SIZE 320u /* necessary to keep aligned to 4 */ +#define PTT_EVENT_CTX_SIZE 32u /* necessary to keep aligned to 4 */ + +#define PTT_TIMER_POOL_N 8u + +/* will be rounded up to multiplication of 8 symbols (128 us) */ +#define PTT_ED_TIME_US 128u + +/* timeout for the measurement process to finish */ +#define PTT_RSSI_TIME_MS 1u + +/* if this value returned by RSSI measurement procedure, error will be printed */ +#define PTT_RSSI_ERROR_VALUE INT8_MAX + +/* time to wait for packet for `lgetlqi` command */ +#define PTT_LQI_DELAY_MS 5000u + +#define PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE 125u +#define PTT_CUSTOM_LTX_DEFAULT_REPEATS 1 +#define PTT_CUSTOM_LTX_DEFAULT_TIMEOUT_MS 0 +#define PTT_CUSTOM_LTX_TIMEOUT_MAX_VALUE INT16_MAX + +#define PTT_L_CARRIER_PULSE_MIN 1 /* must fit in int32_t */ +#define PTT_L_CARRIER_PULSE_MAX INT16_MAX /* must fit in int32_t */ +#define PTT_L_CARRIER_INTERVAL_MIN 0 /* must fit in int32_t */ +#define PTT_L_CARRIER_INTERVAL_MAX INT16_MAX /* must fit in int32_t */ +#define PTT_L_CARRIER_DURATION_MIN 0 /* must fit in int32_t */ +#define PTT_L_CARRIER_DURATION_MAX INT16_MAX /* must fit in int32_t */ + +#define PTT_L_STREAM_PULSE_MIN 1 /* must fit in int32_t */ +#define PTT_L_STREAM_PULSE_MAX INT16_MAX /* must fit in int32_t */ +#define PTT_L_STREAM_INTERVAL_MIN 0 /* must fit in int32_t */ +#define PTT_L_STREAM_INTERVAL_MAX INT16_MAX /* must fit in int32_t */ +#define PTT_L_STREAM_DURATION_MIN 0 /* must fit in int32_t */ +#define PTT_L_STREAM_DURATION_MAX INT16_MAX /* must fit in int32_t */ + +#define PTT_UART_PROMPT_STR ">" + +#define PTT_LED_INDICATION_BLINK_TIMEOUT_MS 200 + +#endif /* PTT_CONFIG_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/ptt_rf_api.h b/samples/peripheral/802154_phy_test/include/ptt_rf_api.h new file mode 100644 index 000000000000..ba91f11629df --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/ptt_rf_api.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: radio module interface intended for external usage */ + +#ifndef PTT_RF_API_H__ +#define PTT_RF_API_H__ + +#include + +#include "ptt_types.h" + +/** @brief Provides library RF module with a received packet + * + * @param pkt - pointer to a packet data + * @param len - length of a received data + * @param rssi - RSSI + * @param lqi - LQI + * + * @return none + */ +void ptt_rf_push_packet(const uint8_t *pkt, ptt_pkt_len_t len, int8_t rssi, uint8_t lqi); + +/** @brief Provides library RF module with "Transmission started" event + * + * @param none + * + * @return none + */ +void ptt_rf_tx_started(void); + +/** @brief Provides library RF module with "Transmission finished" event + * + * @param none + * + * @return none + */ +void ptt_rf_tx_finished(void); + +/** @brief Provides library RF module with "Transmission failed" event + * + * @param tx_error - reason of transmission fail + * + * @return none + */ +void ptt_rf_tx_failed(ptt_rf_tx_error_t tx_error); + +/** @brief Provides library RF module with "Reception failed" event + * + * @param rx_error - reason of reception fail + * + * @return none + */ +void ptt_rf_rx_failed(ptt_rf_rx_error_t rx_error); + +/** @brief Provides library RF module with "CCA done" and a result + * + * @param result - result of CCA procedure + * + * @return none + */ +void ptt_rf_cca_done(bool result); + +/** @brief Provides library RF module with "CCA failed" + * + * @param none + * + * @return none + */ +void ptt_rf_cca_failed(void); + +/** @brief Provides library RF module with "ED detected" and a result + * + * @param result - result of ED procedure + * + * @return none + */ +void ptt_rf_ed_detected(ptt_ed_t result); + +/** @brief Provides library RF module with "ED failed" + * + * @param none + * + * @return none + */ +void ptt_rf_ed_failed(void); + +/* external provided function to set channel on current radio */ +extern void ptt_rf_set_channel_ext(uint8_t channel); +/* external provided function to set power on current radio */ +extern void ptt_rf_set_power_ext(int8_t power); +/* external provided function to get current power from current radio */ +extern int8_t ptt_rf_get_power_ext(void); +/* external provided function to set promiscuous mode on current radio */ +extern void ptt_rf_promiscuous_set_ext(bool value); +/* external provided function to start receive on current radio */ +extern bool ptt_rf_receive_ext(void); +/* external provided function to put current radio on sleep */ +extern bool ptt_rf_sleep_ext(void); +/* external provided function to start sending continuous carrier on current radio */ +extern bool ptt_rf_continuous_carrier_ext(void); +/* external provided function to start sending modulated carrier on current radio */ +extern bool ptt_rf_modulated_stream_ext(const uint8_t *pkt, ptt_pkt_len_t len); +/* external provided function to send a packet on current radio */ +extern bool ptt_rf_send_packet_ext(const uint8_t *pkt, ptt_pkt_len_t len, bool cca); +/* external provided function to verify if the channel is clear */ +extern bool ptt_rf_cca_ext(uint8_t mode); +/* external provided function to detects the maximum energy for a given time */ +extern bool ptt_rf_ed_ext(uint32_t time_us); +/* external provided function to begin the RSSI measurement */ +extern bool ptt_rf_rssi_measure_begin_ext(void); +/* external provided function to get the result of the last RSSI measurement */ +extern ptt_rssi_t ptt_rf_rssi_last_get_ext(void); +/* external provided function to set PAN ID used by the device */ +extern void ptt_rf_set_pan_id_ext(const uint8_t *pan_id); +/* external provided function to set extended address of the device */ +extern void ptt_rf_set_extended_address_ext(const uint8_t *extended_address); +/* external provided function to set short address of the device */ +extern void ptt_rf_set_short_address_ext(const uint8_t *short_address); +/* external provided function to set antenna on current radio */ +extern void ptt_rf_set_antenna_ext(uint8_t antenna); +/* external provided function to get current antenna from current radio */ +extern uint8_t ptt_rf_get_antenna_ext(void); + +#endif /* PTT_RF_API_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/ptt_types.h b/samples/peripheral/802154_phy_test/include/ptt_types.h new file mode 100644 index 000000000000..1859df36eeee --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/ptt_types.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: PHY Test Tool types */ + +#ifndef PTT_TYPES_H__ +#define PTT_TYPES_H__ + +#include +#include + +typedef uint16_t ptt_pkt_len_t; + +typedef int32_t (*ptt_uart_send_cb)(const uint8_t *pkt, ptt_pkt_len_t len, bool add_crlf); + +typedef uint32_t ptt_time_t; +typedef void (*ptt_call_me_cb_t)(ptt_time_t timeout); + +typedef uint16_t ptt_ed_t; +typedef int8_t ptt_rssi_t; + +typedef uint8_t ptt_rf_rx_error_t; + +#define PTT_RF_RX_ERROR_NONE 0x00 /**< there is no error */ +#define PTT_RF_RX_ERROR_INVALID_FCS 0x01 /**< received a frame with an invalid checksum */ +#define PTT_RF_RX_ERROR_OPERATION_FAILED 0x02 /**< reception failed */ + +typedef uint8_t ptt_rf_tx_error_t; + +#define PTT_RF_TX_ERROR_NONE 0x00 /**< there is no error */ +#define PTT_RF_TX_ERROR_INVALID_ACK_FCS 0x01 /**< received ACK frame is valid, but has wrong FCS */ +#define PTT_RF_TX_ERROR_NO_ACK 0x02 /**< ACK was not received during the timeout period */ +#define PTT_RF_TX_ERROR_OPERATION_FAILED 0x03 /**< transmission failed */ + +#endif /* PTT_TYPES_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/ptt_uart_api.h b/samples/peripheral/802154_phy_test/include/ptt_uart_api.h new file mode 100644 index 000000000000..a3a12daea5f7 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/ptt_uart_api.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: UART interface intended for external usage */ + +#ifndef PTT_UART_API_H__ +#define PTT_UART_API_H__ + +#include "ptt_types.h" + +/** @brief Initialize library UART processing module + * + * @param send_cb - callback provided by application to send packets via UART + * + * @return none + */ +void ptt_uart_init(ptt_uart_send_cb send_cb); + +/** @brief Uninitialize library UART processing module + * + * @param none + * + * @return none + */ +void ptt_uart_uninit(void); + +/** @brief Push received packet to library for further processing + * + * @param pkt - received packet + * @param len - length of the packet + * + * @return none + */ +void ptt_uart_push_packet(const uint8_t *pkt, ptt_pkt_len_t len); + +#endif /* PTT_UART_API_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/rf_proc.h b/samples/peripheral/802154_phy_test/include/rf_proc.h new file mode 100644 index 000000000000..85e1dc89d9ee --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/rf_proc.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: RF interfaces */ + +#ifndef RF_PROC_H__ +#define RF_PROC_H__ + +#include + +#include "ptt_rf_api.h" + +/**< Size of PHY header */ +#define RF_PHR_SIZE (1u) + +/**< Size of frame check sequence */ +#define RF_FCS_SIZE (2u) + +/**< Maximum size of PSDU */ +#define RF_PSDU_MAX_SIZE (127u) + +/**< Start of PSDU payload */ +#define RF_PSDU_START (1u) + +/** @brief NRF radio driver initialization + * + * @param none + * + * @return none + */ +void rf_init(void); + +/** @brief NRF radio driver deinitialization + * + * @param none + * + * @return none + */ +void rf_uninit(void); + +/** @brief Thread function for Radio handling + * + * @param none + * + * @return none + * + */ +void rf_thread(void); + +/**< element of received packets array */ +struct rf_rx_pkt_s { + uint8_t *rf_buf; /**< pointer to buffer inside radio driver with a received packet */ + uint8_t *data; /**< pointer to payload */ + ptt_pkt_len_t length; /**< size of payload of received packet */ + int8_t rssi; /**< RSSI */ + uint8_t lqi; /**< LQI */ +}; + +#endif /* RF_PROC_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/timer_proc.h b/samples/peripheral/802154_phy_test/include/timer_proc.h new file mode 100644 index 000000000000..2ec1d411e56b --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/timer_proc.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: timer interfaces */ + +#ifndef TIMER_PROC_H__ +#define TIMER_PROC_H__ + +#include + +#include "ptt.h" + +/** @brief Callback provided by application to be called from the library + * to schedule a timer with a given timeout + * + * @param timeout - timeout in milliseconds + * + * @return none + */ +void launch_ptt_process_timer(ptt_time_t timeout); + +/** @brief Return maximum time supported by current timer implementation + * + * @param none + * + * @return ptt_time_t - maximum time in milliseconds + */ +ptt_time_t ptt_get_max_time(void); + +#endif /* TIMER_PROC_H__ */ diff --git a/samples/peripheral/802154_phy_test/include/uart_proc.h b/samples/peripheral/802154_phy_test/include/uart_proc.h new file mode 100644 index 000000000000..473ac397da67 --- /dev/null +++ b/samples/peripheral/802154_phy_test/include/uart_proc.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: uart interfaces */ + +#ifndef UART_PROC_H__ +#define UART_PROC_H__ + +#include + +#include "ptt.h" + +/**< Amount of bytes requested from driver */ +#define UART_BYTES_TO_READ (1u) + +/** @brief Initialize UARTE driver and UART module inside PTT library + * + * @param none + * + * @return none + * + */ +void uart_init(void); + +int32_t uart_send(const uint8_t *pkt, ptt_pkt_len_t len, bool add_crlf); + +#endif /* UART_PROC_H__ */ diff --git a/samples/peripheral/802154_phy_test/prj.conf b/samples/peripheral/802154_phy_test/prj.conf new file mode 100644 index 000000000000..ea3c4ecacbe6 --- /dev/null +++ b/samples/peripheral/802154_phy_test/prj.conf @@ -0,0 +1,45 @@ +# Enabling assert +CONFIG_ASSERT=y + +# Logger configuration +CONFIG_LOG=y +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_USE_SEGGER_RTT=y +CONFIG_LOG_BACKEND_RTT=y +CONFIG_LOG_BACKEND_UART=n +CONFIG_LOG_STRDUP_BUF_COUNT=10 + +# Enable UART +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_NRFX_UARTE=y +CONFIG_NRFX_UARTE0=y +CONFIG_UART_0_NRF_TX_BUFFER_SIZE=3072 + +# Enable temperature sensor +CONFIG_NRFX_TEMP=y + +# Enable DC/DC Support +CONFIG_NRFX_POWER=y + +# Enable RNG +CONFIG_NRFX_RNG=y +# Use XOROSHIRO PRNG +CONFIG_XOROSHIRO_RANDOM_GENERATOR=y + +# Enable Timer +CONFIG_NRFX_TIMER2=y + +# Enabling radio driver +CONFIG_NRF_802154_RADIO_DRIVER=y + +# Allow sharing the RTC between IEEE 802.15.4 and Zephyr +CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=2 + +# Workaround for a bug in the MPSL Glue Layer (not required for nRF52840) +CONFIG_BT=y + +# Include empty image in the APP core (not used for nRF52840) +CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE=y + +# Enable ring buffers +CONFIG_RING_BUFFER=y diff --git a/samples/peripheral/802154_phy_test/sample.yaml b/samples/peripheral/802154_phy_test/sample.yaml new file mode 100644 index 000000000000..0f0f9a87602f --- /dev/null +++ b/samples/peripheral/802154_phy_test/sample.yaml @@ -0,0 +1,11 @@ +sample: + name: IEEE 802.15.4 PHY Test Tool + description: IEEE 802.15.4 PHY Test Tool sample +tests: + samples.peripheral.802154_phy_test: + build_only: true + platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpunet + integration_platforms: + - nrf52840dk_nrf52840 + - nrf5340dk_nrf5340_cpunet + tags: ci_build diff --git a/samples/peripheral/802154_phy_test/src/comm_proc.c b/samples/peripheral/802154_phy_test/src/comm_proc.c new file mode 100644 index 000000000000..c9ada89a0339 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/comm_proc.c @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: Communication interface for library */ + +#include +#include + +#include "uart_proc.h" +#ifdef USE_USB +#include "usb_proc.h" +#endif +#include "comm_proc.h" + +#include +LOG_MODULE_REGISTER(comm); + +#include "ptt_uart_api.h" + +static int32_t comm_send_cb(const uint8_t *pkt, ptt_pkt_len_t len, bool add_crlf); + +static void comm_symbols_process(struct text_proc_s *text_proc, const uint8_t *buf, uint32_t len); +static inline void text_process(struct text_proc_s *text_proc); +static inline void input_state_reset(struct text_proc_s *text_proc); + +void comm_input_process(struct text_proc_s *text_proc, const uint8_t *buf, uint32_t len) +{ + switch (text_proc->state) { + case INPUT_STATE_IDLE: + if (text_proc->len != 0) { + LOG_WRN("text_proc->len is not 0 when input state is idle"); + text_proc->len = 0; + } + + /* start the timer after first received symbol */ + k_timer_start(&text_proc->timer, K_MSEC(COMM_PER_COMMAND_TIMEOUT), K_MSEC(0)); + + text_proc->state = INPUT_STATE_WAITING_FOR_NEWLINE; + + comm_symbols_process(text_proc, buf, len); + break; + + case INPUT_STATE_WAITING_FOR_NEWLINE: + comm_symbols_process(text_proc, buf, len); + break; + + case INPUT_STATE_TEXT_PROCESSING: + LOG_WRN("received a command when processing previous one, discarded"); + break; + + default: + LOG_ERR("incorrect input state"); + break; + } +} + +K_FIFO_DEFINE(text_processing_fifo); + +void comm_text_processor_fn(struct k_work *work) +{ + LOG_DBG("Called work queue function"); + struct text_proc_s *text_proc = CONTAINER_OF(work, struct text_proc_s, work); + + /* force string termination for further processing */ + text_proc->buf[text_proc->len] = '\0'; + LOG_DBG("received packet to lib: len %d, %s", text_proc->len, log_strdup(text_proc->buf)); + text_process(text_proc); +} + +void comm_input_timeout_handler(struct k_timer *timer) +{ + LOG_DBG("push packet to lib via timer"); + struct text_proc_s *text_proc = CONTAINER_OF(timer, struct text_proc_s, timer); + + k_work_submit(&text_proc->work); +} + +static void comm_symbols_process(struct text_proc_s *text_proc, const uint8_t *buf, uint32_t len) +{ + for (uint32_t cnt = 0; cnt < len; cnt++) { + if (('\n' != buf[cnt]) && ('\r' != buf[cnt])) { + text_proc->buf[text_proc->len] = buf[cnt]; + ++text_proc->len; + + if (text_proc->len >= COMM_MAX_TEXT_DATA_SIZE) { + LOG_ERR("cannot parse %d bytes received, freeing input buffer", + COMM_MAX_TEXT_DATA_SIZE); + + /* Stop the timeout timer */ + k_timer_stop(&text_proc->timer); + input_state_reset(text_proc); + } + } else { + LOG_DBG("push packet to lib via newline"); + /* Stop the timeout timer */ + k_timer_stop(&text_proc->timer); + k_work_submit(&text_proc->work); + + text_proc->state = INPUT_STATE_TEXT_PROCESSING; + break; + } + } +} + +static inline void input_state_reset(struct text_proc_s *text_proc) +{ + text_proc->len = 0; + text_proc->state = INPUT_STATE_IDLE; +} + +static inline void text_process(struct text_proc_s *text_proc) +{ + ptt_uart_push_packet((uint8_t *)text_proc->buf, text_proc->len); + input_state_reset(text_proc); +} + +void comm_init(void) +{ + /* won't initialize UART if the device has DUT mode only */ +#if CONFIG_PTT_DUT_MODE + LOG_INF("Device is in DUT mode only."); +#else + LOG_INF("Init"); + uart_init(); +#ifdef USE_USB + usb_init(); +#endif + ptt_uart_init(comm_send_cb); +#endif +} + +static int32_t comm_send_cb(const uint8_t *pkt, ptt_pkt_len_t len, bool add_crlf) +{ + if ((add_crlf && (len >= (COMM_TX_BUFFER_SIZE - COMM_APPENDIX_SIZE))) || + (!add_crlf && (len >= COMM_TX_BUFFER_SIZE))) { + LOG_WRN("%s: not enough of tx buffer size", __func__); + return -1; + } + + uart_send(pkt, len, add_crlf); + +#ifdef USE_USB + usb_send(pkt, len, add_crlf); +#endif + + return len; +} + +void comm_proc(void) +{ +#ifdef USE_USB + usb_task(); +#endif +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_ctrl.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_ctrl.c new file mode 100644 index 000000000000..17ee2200a943 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_ctrl.c @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: PTT interface part */ + +#include +#include + +#include "ptt.h" + +#include "ctrl/ptt_trace.h" +#include "rf/ptt_rf.h" + +#include "ptt_ctrl_internal.h" +#include "ptt_events_internal.h" +#include "ptt_modes.h" +#include "ptt_timers_internal.h" + +#ifdef TESTS +#include "test_ctrl_conf.h" +#endif /* TESTS */ + +/** default timeout for waiting for any response */ +#define PTT_DEFAULT_TIMEOUT (500u) + +static struct ptt_ctrl_s ptt_ctrl_ctx; + +void ptt_init(ptt_call_me_cb_t call_me_cb, ptt_time_t max_time) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + assert(call_me_cb != NULL); + + ptt_ctrl_handlers_reset_all(); + ptt_ctrl_ctx.call_me_cb = call_me_cb; + ptt_ctrl_ctx.rsp_timeout = PTT_DEFAULT_TIMEOUT; + ptt_ctrl_ctx.max_time = max_time; + + ptt_events_init(); + ptt_timers_init(); + ptt_rf_init(); + + ret = ptt_mode_default_init(); + + assert(ret == PTT_RET_SUCCESS); + + PTT_UNUSED(ret); +} + +void ptt_uninit(void) +{ + ptt_mode_uninit(); + ptt_events_uninit(); + ptt_timers_uninit(); + ptt_rf_uninit(); +} + +void ptt_process(ptt_time_t current_time) +{ + ptt_timers_process(current_time); +} + +struct ptt_timer_ctx_s *ptt_ctrl_get_timer_ctx(void) +{ + return &ptt_ctrl_ctx.timer_ctx; +} + +void ptt_ctrl_call_me_cb(ptt_time_t timeout) +{ + if (ptt_ctrl_ctx.call_me_cb != NULL) { + ptt_ctrl_ctx.call_me_cb(timeout); + } +} + +struct ptt_evt_ctx_s *ptt_ctrl_get_evt_ctx(void) +{ + return &ptt_ctrl_ctx.evt_ctx; +} + +ptt_time_t ptt_ctrl_get_rsp_timeout(void) +{ + return ptt_ctrl_ctx.rsp_timeout; +} + +void ptt_ctrl_set_rsp_timeout(ptt_time_t timeout) +{ + ptt_ctrl_ctx.rsp_timeout = timeout; +} + +ptt_time_t ptt_ctrl_get_max_time(void) +{ + return ptt_ctrl_ctx.max_time; +} + +enum ptt_mode_t ptt_ctrl_get_current_mode(void) +{ + return ptt_ctrl_ctx.current_mode; +} + +void ptt_ctrl_set_current_mode(enum ptt_mode_t mode) +{ + ptt_ctrl_ctx.current_mode = mode; +} + +enum ptt_mode_t ptt_ctrl_get_default_mode(void) +{ + uint32_t mode_mask; + enum ptt_mode_t mode = PTT_MODE_ZB_PERF_DUT; + + if (ptt_get_mode_mask_ext(&mode_mask)) { + for (uint8_t i = 0; i <= sizeof(mode_mask) * 8; i++) { + if (((mode_mask >> i) & 1u) == 1u) { + mode = i; + break; + } + } + } + + return mode; +} + +uint8_t ptt_ctrl_get_hw_version(void) +{ + uint8_t hw_version = 0xFF; + + ptt_get_hw_version_ext(&hw_version); + return hw_version; +} + +uint8_t ptt_ctrl_get_sw_version(void) +{ + uint8_t sw_version = 0xFF; + + ptt_get_sw_version_ext(&sw_version); + return sw_version; +} + +void ptt_ctrl_set_dcdc(bool activate) +{ + ptt_set_dcdc_ext(activate); +} + +bool ptt_ctrl_get_dcdc(void) +{ + return ptt_get_dcdc_ext(); +} + +enum ptt_ret ptt_ctrl_get_temp(int32_t *temp) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (!ptt_get_temp_ext(temp)) { + ret = PTT_RET_INVALID_VALUE; + } + + return ret; +} + +struct ptt_ext_evts_handlers_s *ptt_ctrl_get_handlers(void) +{ + return &ptt_ctrl_ctx.mode_handlers; +} + +void ptt_random_vector_generate(uint8_t *buff, uint8_t requested_size) +{ + for (int i = 0; i < requested_size; ++i) { + buff[i] = ptt_random_get_ext() % UINT8_MAX; + } +} + +void ptt_ctrl_set_icache(bool enable) +{ + ptt_set_icache_ext(enable); +} + +bool ptt_ctrl_get_icache(void) +{ + return ptt_get_icache_ext(); +} + +void ptt_ctrl_led_indication_on(void) +{ + ptt_ctrl_led_indication_on_ext(); +} + +void ptt_ctrl_led_indication_off(void) +{ + ptt_ctrl_led_indication_off_ext(); +} + +void ptt_ctrl_handlers_reset_all(void) +{ + ptt_ctrl_ctx.mode_handlers = (struct ptt_ext_evts_handlers_s){ 0 }; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_uart_pkt_received(void) +{ + return ptt_ctrl_ctx.mode_handlers.uart_pkt_received; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_tx_finished(void) +{ + return ptt_ctrl_ctx.mode_handlers.rf_tx_finished; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_tx_failed(void) +{ + return ptt_ctrl_ctx.mode_handlers.rf_tx_failed; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_rx_failed(void) +{ + return ptt_ctrl_ctx.mode_handlers.rf_rx_failed; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_tx_started(void) +{ + return ptt_ctrl_ctx.mode_handlers.rf_tx_started; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_rx_done(void) +{ + return ptt_ctrl_ctx.mode_handlers.rf_rx_done; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_ed_detected(void) +{ + return ptt_ctrl_ctx.mode_handlers.rf_ed_detected; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_ed_failed(void) +{ + return ptt_ctrl_ctx.mode_handlers.rf_ed_failed; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_cca_done(void) +{ + return ptt_ctrl_ctx.mode_handlers.rf_cca_done; +} + +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_cca_failed(void) +{ + return ptt_ctrl_ctx.mode_handlers.rf_cca_failed; +} + +#ifdef TESTS +#include "test_ctrl_wrappers.c" +#endif /* TESTS */ diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_ctrl_internal.h b/samples/peripheral/802154_phy_test/src/ctrl/ptt_ctrl_internal.h new file mode 100644 index 000000000000..747f8f781d21 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_ctrl_internal.h @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: control module interface intended for internal usage on library + * level + */ + +#ifndef PTT_CTRL_INTERNAL_H__ +#define PTT_CTRL_INTERNAL_H__ + +#include "ctrl/ptt_ctrl.h" + +#include "ptt_modes.h" +#include "ptt_events_internal.h" +#include "ptt_timers_internal.h" + +/** type definition of function to handle event */ +typedef void (*ptt_ext_evt_handler)(ptt_evt_id_t evt_id); + +/** handlers for each event + * NULL if unsupported by current mode + */ +struct ptt_ext_evts_handlers_s { + ptt_ext_evt_handler rf_tx_finished; /**< packet transmission finished */ + ptt_ext_evt_handler rf_tx_failed; /**< packet transmission failed */ + ptt_ext_evt_handler rf_tx_started; /**< packet transmission started */ + ptt_ext_evt_handler rf_rx_done; /**< packet received over radio */ + ptt_ext_evt_handler rf_rx_failed; /**< packet reception failed */ + ptt_ext_evt_handler rf_cca_done; /**< CCA procedure finished */ + ptt_ext_evt_handler rf_cca_failed; /**< CCA procedure failed */ + ptt_ext_evt_handler rf_ed_detected; /**< ED procedure finished */ + ptt_ext_evt_handler rf_ed_failed; /**< ED procedure failed */ + ptt_ext_evt_handler uart_pkt_received; /**< packet received over UART */ +}; + +/** control module context */ +struct ptt_ctrl_s { + ptt_call_me_cb_t call_me_cb; + /**< callback from application to be call when need to update nearest timeout */ + enum ptt_mode_t current_mode; /**< current device mode */ + struct ptt_ext_evts_handlers_s mode_handlers; /**< event handlers */ + struct ptt_timer_ctx_s timer_ctx; /**< timers context */ + struct ptt_evt_ctx_s evt_ctx; /**< events context */ + ptt_time_t rsp_timeout; /**< common timeout for all responses */ + ptt_time_t max_time; /**< maximum time supported by application timer */ +}; + +/* Get timer context */ +struct ptt_timer_ctx_s *ptt_ctrl_get_timer_ctx(void); + +/* Get event context */ +struct ptt_evt_ctx_s *ptt_ctrl_get_evt_ctx(void); + +/* Call call_me_cb - an application callback with given timeout */ +void ptt_ctrl_call_me_cb(ptt_time_t timeout); + +/* Get response timeout */ +ptt_time_t ptt_ctrl_get_rsp_timeout(void); + +/* Set response timeout */ +void ptt_ctrl_set_rsp_timeout(ptt_time_t timeout); + +/* Get max time */ +ptt_time_t ptt_ctrl_get_max_time(void); + +/* Get SoC temperature */ +enum ptt_ret ptt_ctrl_get_temp(int32_t *temp); + +/* Get current mode */ +enum ptt_mode_t ptt_ctrl_get_current_mode(void); + +/* Set current mode */ +void ptt_ctrl_set_current_mode(enum ptt_mode_t mode); + +/* Get default mode */ +enum ptt_mode_t ptt_ctrl_get_default_mode(void); + +/* Get HW version */ +uint8_t ptt_ctrl_get_hw_version(void); + +/* Get SW version */ +uint8_t ptt_ctrl_get_sw_version(void); + +/* Get external events handlers structure */ +struct ptt_ext_evts_handlers_s *ptt_ctrl_get_handlers(void); + +/* Disable/enable DC/DC mode */ +void ptt_ctrl_set_dcdc(bool activate); + +/* Get current DC/DC mode */ +bool ptt_ctrl_get_dcdc(void); + +/* Enable/Disable ICACHE */ +void ptt_ctrl_set_icache(bool enable); + +/* Get current state of ICACHE */ +bool ptt_ctrl_get_icache(void); + +/* Reset external events structure */ +void ptt_ctrl_handlers_reset_all(void); + +/* Get current handler for a packet received through UART */ +ptt_ext_evt_handler ptt_ctrl_get_handler_uart_pkt_received(void); + +/* Get current handler for Transmission finished event */ +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_tx_finished(void); + +/* Get current handler for Transmission failed event */ +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_tx_failed(void); + +/* Get current handler for Reception failed event */ +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_rx_failed(void); + +/* Get current handler for Transmission started event */ +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_tx_started(void); + +/* Get current handler for a packet received through RF */ +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_rx_done(void); + +/* Get current handler for CCA done procedure */ +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_cca_done(void); + +/* Get current handler for CCA failed procedure */ +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_cca_failed(void); + +/* Get current handler for ED done procedure*/ +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_ed_detected(void); + +/* Get current handler for ED failed procedure */ +ptt_ext_evt_handler ptt_ctrl_get_handler_rf_ed_failed(void); + +/** Get vector of random values + * + * @param buff - buffer to store vector, must be at least requested_size long + * @param requested_size - number of random bytes to store in buff + * + * @return - None + */ +void ptt_random_vector_generate(uint8_t *buff, uint8_t requested_size); + +/* Change state of LED indicating received packet to ON */ +void ptt_ctrl_led_indication_on(void); + +/* Change state of LED indicating received packet to OFF */ +void ptt_ctrl_led_indication_off(void); + +#endif /* PTT_CTRL_INTERNAL_H__ */ diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_events.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_events.c new file mode 100644 index 000000000000..d66b87f21d50 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_events.c @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: events implementation */ + +#include +#include +#include + +#include "ctrl/ptt_trace.h" + +#include "ptt_events_internal.h" + +#ifdef TESTS +#include "test_events_conf.h" +#else +#include "ptt_ctrl_internal.h" +#endif + +void ptt_events_init(void) +{ + PTT_TRACE("%s ->\n", __func__); + + struct ptt_evt_ctx_s *evt_ctx = ptt_ctrl_get_evt_ctx(); + + *evt_ctx = (struct ptt_evt_ctx_s){ 0 }; + + PTT_TRACE("%s -<\n", __func__); +} + +void ptt_events_uninit(void) +{ + PTT_TRACE("%s\n", __func__); +} + +void ptt_events_reset_all(void) +{ + PTT_TRACE("%s ->\n", __func__); + + ptt_events_uninit(); + ptt_events_init(); + + PTT_TRACE("%s -<\n", __func__); +} + +enum ptt_ret ptt_event_alloc(ptt_evt_id_t *evt_id) +{ + PTT_TRACE("%s -> evt %p\n", __func__, evt_id); + + uint8_t i; + struct ptt_evt_ctx_s *evt_ctx = ptt_ctrl_get_evt_ctx(); + enum ptt_ret ret = PTT_RET_SUCCESS; + + assert(evt_ctx != NULL); + + if (evt_id == NULL) { + ret = PTT_RET_NULL_PTR; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + + for (i = 0; i < PTT_EVENT_POOL_N; ++i) { + if (false == evt_ctx->evt_pool[i].use) { + *evt_id = i; + evt_ctx->evt_pool[i].use = true; + + ret = PTT_RET_SUCCESS; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + } + + ret = PTT_RET_NO_FREE_SLOT; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; +} + +enum ptt_ret ptt_event_free(ptt_evt_id_t evt_id) +{ + PTT_TRACE("%s -> evt_id %d\n", __func__, evt_id); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (evt_id >= PTT_EVENT_POOL_N) { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + + struct ptt_evt_ctx_s *evt_ctx = ptt_ctrl_get_evt_ctx(); + + assert(evt_ctx != NULL); + + if (false == evt_ctx->evt_pool[evt_id].use) { + /* evt already inactive */ + ret = PTT_RET_SUCCESS; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + + evt_ctx->evt_pool[evt_id] = (struct ptt_event_s){ 0 }; + + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; +} + +enum ptt_ret ptt_event_alloc_and_fill(ptt_evt_id_t *evt_id, const uint8_t *pkt, ptt_pkt_len_t len) +{ + PTT_TRACE("%s -> evt %p pkt %p len %d\n", __func__, evt_id, pkt, len); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (pkt == NULL) { + ret = PTT_RET_NULL_PTR; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + if (len > PTT_EVENT_DATA_SIZE) { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + if (len == 0) { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + + ret = ptt_event_alloc(evt_id); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + + struct ptt_event_s *event = ptt_get_event_by_id(*evt_id); + + assert(event != NULL); + + event->data.len = len; + memcpy(event->data.arr, pkt, event->data.len); + + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; +} + +struct ptt_event_s *ptt_get_event_by_id(ptt_evt_id_t evt_id) +{ + PTT_TRACE("%s -> evt_id %d\n", __func__, evt_id); + + if (evt_id >= PTT_EVENT_POOL_N) { + return NULL; + } + + struct ptt_evt_ctx_s *evt_ctx = ptt_ctrl_get_evt_ctx(); + + assert(evt_ctx != NULL); + + if (false == evt_ctx->evt_pool[evt_id].use) { + /* event inactive */ + return NULL; + } + + return &evt_ctx->evt_pool[evt_id]; +} + +void ptt_event_set_cmd(ptt_evt_id_t evt_id, ptt_evt_cmd_t cmd) +{ + PTT_TRACE("%s -> evt_id %d cmd %d\n", __func__, evt_id, cmd); + + struct ptt_event_s *event = ptt_get_event_by_id(evt_id); + + assert(event != NULL); + + event->cmd = cmd; + + PTT_TRACE("%s -<\n", __func__); +} + +ptt_evt_cmd_t ptt_event_get_cmd(ptt_evt_id_t evt_id) +{ + PTT_TRACE("%s -> evt_id %d\n", __func__, evt_id); + + struct ptt_event_s *event = ptt_get_event_by_id(evt_id); + + assert(event != NULL); + + PTT_TRACE("%s -< cmd %d\n", __func__, event->cmd); + return event->cmd; +} + +void ptt_event_set_state(ptt_evt_id_t evt_id, ptt_evt_state_t state) +{ + PTT_TRACE("%s -> evt_id %d state %d\n", __func__, evt_id, state); + + struct ptt_event_s *event = ptt_get_event_by_id(evt_id); + + assert(event != NULL); + + event->state = state; + + PTT_TRACE("%s -<\n", __func__); +} + +ptt_evt_state_t ptt_event_get_state(ptt_evt_id_t evt_id) +{ + PTT_TRACE("%s -> evt_id %d\n", __func__, evt_id); + + struct ptt_event_s *event = ptt_get_event_by_id(evt_id); + + assert(event != NULL); + + PTT_TRACE("%s -< state %d\n", __func__, event->state); + return event->state; +} + +void ptt_event_set_ctx_data(ptt_evt_id_t evt_id, const uint8_t *data, uint16_t len) +{ + PTT_TRACE("%s -> evt_id %d data %p len %d\n", __func__, evt_id, data, len); + + struct ptt_event_s *event = ptt_get_event_by_id(evt_id); + + assert(event != NULL); + + assert(data != NULL); + assert(len <= PTT_EVENT_CTX_SIZE); + + event->ctx.len = len; + memcpy(event->ctx.arr, data, event->ctx.len); + + PTT_TRACE("%s -<\n", __func__); +} + +struct ptt_evt_ctx_data_s *ptt_event_get_ctx_data(ptt_evt_id_t evt_id) +{ + PTT_TRACE("%s -> evt_id %d\n", __func__, evt_id); + + struct ptt_event_s *event = ptt_get_event_by_id(evt_id); + + assert(event != NULL); + + PTT_TRACE("%s -< ctx %p\n", __func__, &event->ctx); + return &event->ctx; +} + +void ptt_event_set_data(ptt_evt_id_t evt_id, const uint8_t *data, uint16_t len) +{ + PTT_TRACE("%s -> evt_id %d data %p len %d\n", __func__, evt_id, data, len); + + struct ptt_event_s *event = ptt_get_event_by_id(evt_id); + + assert(event != NULL); + + assert(data != NULL); + assert(len <= PTT_EVENT_DATA_SIZE); + + event->data.len = len; + memcpy(event->data.arr, data, event->data.len); + + PTT_TRACE("%s -<\n", __func__); +} + +struct ptt_evt_data_s *ptt_event_get_data(ptt_evt_id_t evt_id) +{ + PTT_TRACE("%s -> evt_id %d\n", __func__, evt_id); + + struct ptt_event_s *event = ptt_get_event_by_id(evt_id); + + assert(event != NULL); + + PTT_TRACE("%s -< ctx %p\n", __func__, &event->data); + return &event->data; +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_events_internal.h b/samples/peripheral/802154_phy_test/src/ctrl/ptt_events_internal.h new file mode 100644 index 000000000000..ab6ba25b702a --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_events_internal.h @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: events interface intended for usage inside control module */ + +#ifndef PTT_EVENTS_INTERNAL_H__ +#define PTT_EVENTS_INTERNAL_H__ + +#include "ctrl/ptt_events.h" + +#include "ptt_config.h" +#include "ptt_errors.h" +#include "ptt_types.h" +#include "ptt_utils.h" + +/** events command type definition */ +typedef uint32_t ptt_evt_cmd_t; + +/** events state type definition */ +typedef uint8_t ptt_evt_state_t; + +PTT_COMPILE_TIME_ASSERT((PTT_EVENT_DATA_SIZE % sizeof(int32_t)) == 0u); + +/** struct to hold packet data and length */ +struct ptt_evt_data_s { + uint8_t arr[PTT_EVENT_DATA_SIZE]; /**< packet */ + uint16_t len; /**< packet used lengths */ +}; + +PTT_COMPILE_TIME_ASSERT((PTT_EVENT_CTX_SIZE % sizeof(int32_t)) == 0u); + +/** struct to hold context data and length */ +struct ptt_evt_ctx_data_s { + uint8_t arr[PTT_EVENT_CTX_SIZE]; /**< context */ + uint16_t len; /**< context used lengths */ +}; + +/** event data */ +struct ptt_event_s { + struct ptt_evt_data_s data; /**< packet payload */ + struct ptt_evt_ctx_data_s ctx; /**< command's context */ + ptt_evt_cmd_t cmd; /**< command */ + ptt_evt_state_t state; /**< command processing state */ + bool use; /**< flag to determine is this event currently in use */ +}; + +/** events context */ +struct ptt_evt_ctx_s { + struct ptt_event_s evt_pool[PTT_EVENT_POOL_N]; /**< array of events */ +}; + +/** @brief Initialize events context + * + * @param none + * + * @return none + */ +void ptt_events_init(void); + +/** @brief Uninitialize events context and free resources + * + * @param none + * + * @return none + */ +void ptt_events_uninit(void); + +/** @brief Reset events context to default values as after initialization + * + * @param none + * + * @return none + */ +void ptt_events_reset_all(void); + +/** @brief Allocate event entry in the event pool + * + * @param[out] evt_id - pointer to event index in event pool + * + * @return PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_event_alloc(ptt_evt_id_t *evt_id); + +/** @brief Free event in the event pool + * + * If event pointed by evt_id is free already returns PTT_RET_SUCCESS + * + * @param evt_id - index of event in event pool + * + * @return PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_event_free(ptt_evt_id_t evt_id); + +/** @brief Allocate an event and fill the event content with data provided by pkt and its length + * + * Makes copy from pkt to the event content + * + * @param[out] evt_id - index of event in event pool + * @param pkt - pointer to data + * @param len - length of data + * + * @return PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_event_alloc_and_fill(ptt_evt_id_t *evt_id, const uint8_t *pkt, ptt_pkt_len_t len); + +/** @brief Return pointer to an event by its index in the event pool + * + * @param evt_id - index of event in event pool + * + * @return pointer to the event, or NULL if the event is not found + */ +struct ptt_event_s *ptt_get_event_by_id(ptt_evt_id_t evt_id); + +/** @brief Assign given command to the event + * + * @param evt_id - the event + * @param cmd - command + * + * @return none + */ +void ptt_event_set_cmd(ptt_evt_id_t evt_id, ptt_evt_cmd_t cmd); + +/** @brief Get a command assigned to the event + * + * @param evt_id - the even + * + * @return ptt_evt_cmd_t Command + */ +ptt_evt_cmd_t ptt_event_get_cmd(ptt_evt_id_t evt_id); + +/** @brief Assign given state to the event + * + * @param evt_id - the event + * @param state - state + * + * @return none + */ +void ptt_event_set_state(ptt_evt_id_t evt_id, ptt_evt_state_t state); + +/** @brief Get a state assigned to the event + * + * @param evt_id - the event + * + * @return ptt_evt_state_t State + */ +ptt_evt_state_t ptt_event_get_state(ptt_evt_id_t evt_id); + +/** @brief Copy data to event context + * + * @param evt_id - the event + * @param data - pointer to data, mustn't be NULL + * @param len - length of the data, len <= PTT_EVENT_CTX_SIZE + * + * @return none + */ +void ptt_event_set_ctx_data(ptt_evt_id_t evt_id, const uint8_t *data, uint16_t len); + +/** @brief Returns a pointer to context data of the event + * + * @param none + * + * @return none + */ +struct ptt_evt_ctx_data_s *ptt_event_get_ctx_data(ptt_evt_id_t evt_id); + +/** @brief Copy data to event data + * + * @param evt_id - the event + * @param data - pointer to data, mustn't be NULL + * @param len - length of the data, len <= PTT_EVENT_DATA_SIZE + * + * @return none + */ +void ptt_event_set_data(ptt_evt_id_t evt_id, const uint8_t *data, uint16_t len); + +/** @brief Returns a pointer to data of the event + * + * @param none + * + * @return none + */ +struct ptt_evt_data_s *ptt_event_get_data(ptt_evt_id_t evt_id); + +#endif /* PTT_EVENTS_INTERNAL_H__ */ diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_mode_manager.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_mode_manager.c new file mode 100644 index 000000000000..47447ce9c369 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_mode_manager.c @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: mode manager implementation. */ + +#include "ptt.h" + +#include "ctrl/ptt_trace.h" +#include "rf/ptt_rf.h" + +#include "ptt_ctrl_internal.h" +#include "ptt_modes.h" + +static enum ptt_ret ptt_mode_init(enum ptt_mode_t mode); + +/* caller should take care about freeing shared resources */ +enum ptt_ret ptt_mode_default_init(void) +{ + enum ptt_mode_t mode = ptt_ctrl_get_default_mode(); + + return ptt_mode_init(mode); +} + +enum ptt_ret ptt_mode_switch(enum ptt_mode_t new_mode) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + uint32_t mode_mask; + + if (new_mode >= PTT_MODE_N) { + PTT_TRACE("%s: invalid new_mode %d\n", __func__, new_mode); + ret = PTT_RET_INVALID_VALUE; + } else { + if (ptt_get_mode_mask_ext(&mode_mask)) { + /* if new_mode isn't allowed */ + if ((mode_mask & (1u << new_mode)) == 0) { + PTT_TRACE("%s: new_mode isn't allowed %d\n", __func__, new_mode); + ret = PTT_RET_INVALID_VALUE; + } + } + } + + if (ret == PTT_RET_SUCCESS) { + ret = ptt_mode_uninit(); + if (ret == PTT_RET_SUCCESS) { + ret = ptt_mode_init(new_mode); + } + } + + return ret; +} + +enum ptt_ret ptt_mode_uninit(void) +{ + enum ptt_mode_t current_mode = ptt_ctrl_get_current_mode(); + enum ptt_ret ret = PTT_RET_SUCCESS; + + switch (current_mode) { + case PTT_MODE_ZB_PERF_DUT: + ret = ptt_zb_perf_dut_mode_uninit(); + break; + + case PTT_MODE_ZB_PERF_CMD: + ret = ptt_zb_perf_cmd_mode_uninit(); + break; + + default: + PTT_TRACE("%s: invalid current_mode %d\n", __func__, current_mode); + ret = PTT_RET_INVALID_MODE; + break; + } + + if (ret == PTT_RET_SUCCESS) { + ptt_timers_reset_all(); + ptt_events_reset_all(); + ptt_ctrl_handlers_reset_all(); + ptt_rf_reset(); + ptt_ctrl_set_current_mode(PTT_MODE_N); + } + + return ret; +} + +/* caller should take care about freeing shared resources */ +static enum ptt_ret ptt_mode_init(enum ptt_mode_t mode) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + switch (mode) { + case PTT_MODE_ZB_PERF_DUT: + ret = ptt_zb_perf_dut_mode_init(); + break; + + case PTT_MODE_ZB_PERF_CMD: + ret = ptt_zb_perf_cmd_mode_init(); + break; + + default: + PTT_TRACE("%s: invalid mode %d\n", __func__, mode); + ret = PTT_RET_INVALID_MODE; + break; + } + + if (ret == PTT_RET_SUCCESS) { + ptt_ctrl_set_current_mode(mode); + } + + return ret; +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_modes.h b/samples/peripheral/802154_phy_test/src/ctrl/ptt_modes.h new file mode 100644 index 000000000000..43040e88bc62 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_modes.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: modes declaration intended for usage inside control module */ + +#ifndef PTT_MODES_H__ +#define PTT_MODES_H__ + +#include "ptt_config.h" +#include "ptt_errors.h" +#include "ptt_utils.h" + +/** device modes */ +enum ptt_mode_t { + PTT_MODE_ZB_PERF_DUT = 0, /**< device under test mode */ + PTT_MODE_ZB_PERF_CMD, /**< command mode */ + PTT_MODE_N /**< mode count */ +}; + +/** @brief Switch current mode to a given + * + * Uninitialize current mode, reset shared resources and initialize a new mode. + * If a given mode matches with current mode, current mode resets to state as after initialization. + * + * @param new_mode - a new mode to switch + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_mode_switch(enum ptt_mode_t new_mode); + +/** @brief Initialize default mode + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_mode_default_init(void); + +/** @brief Uninitialize current mode + * + * @param none + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_mode_uninit(void); + +/** @brief Initialize Zigbee RF Performance Test Plan CMD mode + * + * @param none + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_zb_perf_cmd_mode_init(void); + +/** @brief Uninitialize Zigbee RF Performance Test Plan CMD mode + * + * @param none + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_zb_perf_cmd_mode_uninit(void); + +/** @brief Initialize Zigbee RF Performance Test Plan DUT mode + * + * @param none + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_zb_perf_dut_mode_init(void); + +/** @brief Uninitialize Zigbee RF Performance Test Plan DUT mode + * + * @param none + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_zb_perf_dut_mode_uninit(void); + +#endif /* PTT_MODES_H__ */ diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_parser.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_parser.c new file mode 100644 index 000000000000..38883988f270 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_parser.c @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: converting string of ASCII codes to integers */ + +#include "ptt_parser_internal.h" + +#include +#include +#include +#include + +#define PARSER_DECIMAL_BASE 10 +#define PARSER_HEXADECIMAL_BASE 16 +#define PARSER_BASE_NOT_FOUND 0xffu + +static enum ptt_ret ptt_parser_hex_string_next_byte(const char *hex_str, uint8_t *out_num_p); + +enum ptt_ret ptt_parser_string_to_int(const char *str, int32_t *out_value_p, uint8_t base, + int32_t min, int32_t max) +{ + if (str == NULL) { + return PTT_RET_NULL_PTR; + } + + if (out_value_p == NULL) { + return PTT_RET_NULL_PTR; + } + + enum ptt_ret ret = PTT_RET_SUCCESS; + char *end_p; + long out_num = strtol(str, &end_p, base); + + /* "In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string + * is valid." <- from man strtol + */ + /* also lets discard LONG_MIN/LONG_MAX values which show strtol failed */ + if (('\0' != *end_p) || (out_num < min) || (out_num > max) || (out_num == LONG_MIN) || + (out_num == LONG_MAX)) { + ret = PTT_RET_INVALID_VALUE; + } else { + *out_value_p = out_num; + } + + return ret; +} + +inline enum ptt_ret ptt_parser_string_to_int32(const char *str, int32_t *out_value, uint8_t base) +{ + return ptt_parser_string_to_int(str, out_value, base, INT32_MIN, INT32_MAX); +} + +inline enum ptt_ret ptt_parser_string_to_byte(const char *str, uint8_t *out_value_p, uint8_t base) +{ + int32_t out_value; + enum ptt_ret ret = ptt_parser_string_to_int(str, &out_value, base, INT8_MIN, UINT8_MAX); + + if (ret == PTT_RET_SUCCESS) { + *out_value_p = out_value; + } + + return ret; +} + +inline enum ptt_ret ptt_parser_string_to_int8(const char *str, int8_t *out_value_p, uint8_t base) +{ + int32_t out_value; + enum ptt_ret ret = ptt_parser_string_to_int(str, &out_value, base, INT8_MIN, INT8_MAX); + + if (ret == PTT_RET_SUCCESS) { + *out_value_p = out_value; + } + + return ret; +} + +inline enum ptt_ret ptt_parser_string_to_uint8(const char *str, uint8_t *out_value_p, uint8_t base) +{ + int32_t out_value; + enum ptt_ret ret = ptt_parser_string_to_int(str, &out_value, base, 0, UINT8_MAX); + + if (ret == PTT_RET_SUCCESS) { + *out_value_p = out_value; + } + + return ret; +} + +inline enum ptt_ret ptt_parser_string_to_int16(const char *str, int16_t *out_value_p, uint8_t base) +{ + int32_t out_value; + enum ptt_ret ret = ptt_parser_string_to_int(str, &out_value, base, INT16_MIN, INT16_MAX); + + if (ret == PTT_RET_SUCCESS) { + *out_value_p = out_value; + } + + return ret; +} + +inline enum ptt_ret ptt_parser_string_to_uint16(const char *str, uint16_t *out_value_p, + uint8_t base) +{ + int32_t out_value; + enum ptt_ret ret = ptt_parser_string_to_int(str, &out_value, base, 0, UINT16_MAX); + + if (ret == PTT_RET_SUCCESS) { + *out_value_p = out_value; + } + + return ret; +} + +enum ptt_ret ptt_parser_hex_string_to_uint8_array(const char *hex_str, uint8_t *out_value_p, + uint8_t max_len, uint8_t *written_len) +{ + if (hex_str == NULL) { + return PTT_RET_NULL_PTR; + } + + if (out_value_p == NULL) { + return PTT_RET_NULL_PTR; + } + + if (max_len == 0) { + return PTT_RET_NO_FREE_SLOT; + } + + /* cut away prefix, if present */ + if ((hex_str[0] == '0') && ((hex_str[1] == 'X') || (hex_str[1] == 'x'))) { + hex_str += 2; + } + + /* one byte is represented by 2 ASCII symbols => we expect even number of elements */ + if ((strlen(hex_str) % 2) || (!strlen(hex_str))) { + return PTT_RET_INVALID_VALUE; + } + + enum ptt_ret ret = PTT_RET_SUCCESS; + uint8_t byte_cnt = 0; + + while ((ret == PTT_RET_SUCCESS) && strlen(hex_str)) { + if (byte_cnt < max_len) { + ret = ptt_parser_hex_string_next_byte(hex_str, &(out_value_p[byte_cnt])); + hex_str += 2; + ++byte_cnt; + } else { + ret = PTT_RET_NO_FREE_SLOT; + } + } + + if (written_len != NULL) { + *written_len = byte_cnt; + } + + return ret; +} + +static enum ptt_ret ptt_parser_hex_string_next_byte(const char *hex_str, uint8_t *out_num_p) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + char hex_byte[3] = { 0 }; + + hex_byte[0] = hex_str[0]; + hex_byte[1] = hex_str[1]; + hex_byte[2] = '\0'; + + char *end_p; + long out_num = strtol(hex_byte, &end_p, PARSER_HEXADECIMAL_BASE); + + /* "In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string + * is valid." <- from man strtol + */ + if ((*end_p != '\0') || (out_num < INT8_MIN) || (out_num > UINT8_MAX)) { + ret = PTT_RET_INVALID_VALUE; + } else { + *out_num_p = (uint8_t)out_num; + } + + return ret; +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_parser_internal.h b/samples/peripheral/802154_phy_test/src/ctrl/ptt_parser_internal.h new file mode 100644 index 000000000000..2bd621e2c7b1 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_parser_internal.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: parser interface intended for usage inside control module */ + +#ifndef PTT_PARSER_INTERNAL_H__ +#define PTT_PARSER_INTERNAL_H__ + +#include "ptt_types.h" +#include "ptt_errors.h" + +/** @brief Converts string to integer and checks upper and lower boundaries + * + * Works with decimal values and hexadecimal values with '0x' or 0X' prefix. + * Will return error if converted value fails boundary check or can not be + * stored in long type. + * + * @param[IN] str - pointer to NULL terminated string + * @param[OUT] out_value - pointer to store out value of procedure + * @param[IN] base - base used in conversion. Zero for auto selection + * @param[IN] min - lower boundary of expected integer + * @param[IN] max - higher boundary of expected integer + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_parser_string_to_int(const char *str, int32_t *out_value, uint8_t base, + int32_t min, int32_t max); + +/** @brief Converts string to uint8_t, will be successful for all value that fit in one byte + * + * This is a wrapper for @ref ptt_parser_string_to_int with min = INT8_MIN and max = UINT8_MAX. + * Used to get one byte from input regardless of it sign. + * + * @param[IN] str - pointer to NULL terminated string + * @param[OUT] out_value - pointer to store out value of procedure + * @param[IN] base - base used in conversion. Zero for auto selection + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_parser_string_to_byte(const char *str, uint8_t *out_value, uint8_t base); + +/** @brief Converts string to int32_t + * + * This is a wrapper for @ref ptt_parser_string_to_int with min = INT32_MIN and max = INT32_MAX. + * + * @param[IN] str - pointer to NULL terminated string + * @param[OUT] out_value - pointer to store out value of procedure + * @param[IN] base - base used in conversion. Zero for auto selection + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_parser_string_to_int32(const char *str, int32_t *out_value, uint8_t base); + +/** @brief Converts string to int8_t + * + * This is a wrapper for @ref ptt_parser_string_to_int with min = INT8_MIN and max = INT8_MAX. + * + * @param[IN] str - pointer to NULL terminated string + * @param[OUT] out_value - pointer to store out value of procedure + * @param[IN] base - base used in conversion. Zero for auto selection + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_parser_string_to_int8(const char *str, int8_t *out_value, uint8_t base); + +/** @brief Converts string to uint8_t + * + * This is a wrapper for @ref ptt_parser_string_to_int with min = 0 and max = UINT8_MAX. + * + * @param[IN] str - pointer to NULL terminated string + * @param[OUT] out_value - pointer to store out value of procedure + * @param[IN] base - base used in conversion. Zero for auto selection + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_parser_string_to_uint8(const char *str, uint8_t *out_value, uint8_t base); + +/** @brief Converts string to int16_t + * + * This is a wrapper for @ref ptt_parser_string_to_int with min = INT16_MIN and max = INT16_MAX. + * + * @param[IN] str - pointer to NULL terminated string + * @param[OUT] out_value - pointer to store out value of procedure + * @param[IN] base - base used in conversion. Zero for auto selection + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_parser_string_to_int16(const char *str, int16_t *out_value, uint8_t base); + +/** @brief Converts string to uint16_t + * + * This is a wrapper for @ref ptt_parser_string_to_int with min = 0 and max = UINT16_MAX. + * + * @param[IN] str - pointer to NULL terminated string + * @param[OUT] out_value - pointer to store out value of procedure + * @param[IN] base - base used in conversion. Zero for auto selection + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_parser_string_to_uint16(const char *str, uint16_t *out_value, uint8_t base); + +/** @brief Converts string of hexadecimal values to array of uint8_t + * + * Detects and cut out prefix '0x' or '0X'. Returns error if string can not be + * stored fully in provided array, has invalid symbols or is empty. + * + * @param[IN] hex_str - pointer to NULL terminated string of hexadecimal values + * @param[OUT] out_value - pointer to allocated array long enough to store max_len values + * @param[IN] max_len - maximum available space in array out_value + * @param[OUT] written_len - pointer to length of converted array, can be NULL, + * contains incorrect value on error + * + * @return enum ptt_ret returns PTT_RET_SUCCESS, or error code + */ +enum ptt_ret ptt_parser_hex_string_to_uint8_array(const char *hex_str, uint8_t *out_value, + uint8_t max_len, uint8_t *written_len); + +#endif /* PTT_PARSER_INTERNAL_H__ */ diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_proto.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_proto.c new file mode 100644 index 000000000000..7dc9c2fd688f --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_proto.c @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: Protocol processing */ + +#include +#include +#include +#include + +#include "ctrl/ptt_trace.h" + +#include "ptt_proto.h" + +#include "ptt_types.h" + +bool ptt_proto_check_packet(const uint8_t *pkt, ptt_pkt_len_t len) +{ + bool ret = false; + + if ((pkt != NULL) && (len > PTT_PREAMBLE_LEN)) { + if ((pkt[0] == PTT_PREAMBLE_1ST) && (pkt[1] == PTT_PREAMBLE_2ND) && + (pkt[2] == PTT_PREAMBLE_3D)) { + ret = true; + } + } + + return ret; +} + +ptt_pkt_len_t ptt_proto_construct_header(uint8_t *pkt, enum ptt_cmd cmd, ptt_pkt_len_t pkt_max_size) +{ + ptt_pkt_len_t len = 0; + + assert(pkt_max_size >= (PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN)); + + pkt[len] = PTT_PREAMBLE_1ST; + len++; + pkt[len] = PTT_PREAMBLE_2ND; + len++; + pkt[len] = PTT_PREAMBLE_3D; + len++; + pkt[len] = cmd; + len++; + + assert((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN) == len); + + return len; +} + +void ptt_htobe16(uint8_t *src, uint8_t *dst) +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + dst[0] = src[1]; + dst[1] = src[0]; +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + dst[0] = src[0]; + dst[1] = src[1]; +#else +#error "Unsupported endianness" +#endif +} + +void ptt_htole16(uint8_t *src, uint8_t *dst) +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + dst[0] = src[0]; + dst[1] = src[1]; +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + dst[0] = src[1]; + dst[1] = src[0]; +#else +#error "Unsupported endianness" +#endif +} + +void ptt_htobe32(uint8_t *src, uint8_t *dst) +{ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + dst[0] = src[3]; + dst[1] = src[2]; + dst[2] = src[1]; + dst[3] = src[0]; +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; +#else +#error "Unsupported endianness" +#endif +} + +void ptt_betoh16(uint8_t *src, uint8_t *dst) +{ + ptt_htobe16(src, dst); +} + +void ptt_betoh32(uint8_t *src, uint8_t *dst) +{ + ptt_htobe32(src, dst); +} + +uint16_t ptt_htobe16_val(uint8_t *src) +{ + uint16_t val = 0; + + ptt_htobe16(src, (uint8_t *)(&val)); + + return val; +} + +uint32_t ptt_htobe32_val(uint8_t *src) +{ + uint32_t val = 0; + + ptt_htobe32(src, (uint8_t *)(&val)); + + return val; +} + +uint16_t ptt_betoh16_val(uint8_t *src) +{ + uint16_t val = 0; + + ptt_betoh16(src, (uint8_t *)(&val)); + + return val; +} + +uint32_t ptt_betoh32_val(uint8_t *src) +{ + uint32_t val = 0; + + ptt_betoh32(src, (uint8_t *)(&val)); + + return val; +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_rf_proc.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_rf_proc.c new file mode 100644 index 000000000000..7d71cd99f240 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_rf_proc.c @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: processing external events from RF */ + +#include + +#include "ptt_ctrl_internal.h" +#include "ptt_events_internal.h" +#include "rf/ptt_rf.h" + +#include "ptt_proto.h" + +#include "ctrl/ptt_trace.h" + +#ifdef TESTS +#include "test_rf_proc_conf.h" +#endif /* TESTS */ + +void ptt_ctrl_rf_tx_started(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_rf_tx_started(); + + if (handler != NULL) { + handler(evt_id); + } else { + ptt_event_free(evt_id); + } + + PTT_TRACE_FUNC_EXIT(); +} + +void ptt_ctrl_rf_tx_finished(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_rf_tx_finished(); + + if (handler != NULL) { + handler(evt_id); + } else { + ptt_event_free(evt_id); + } + + PTT_TRACE_FUNC_EXIT(); +} + +void ptt_ctrl_rf_tx_failed(ptt_evt_id_t evt_id, ptt_rf_tx_error_t tx_error) +{ + PTT_TRACE("%s -> evt %d res %d\n", __func__, evt_id, tx_error); + + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_rf_tx_failed(); + + ptt_event_set_ctx_data(evt_id, PTT_CAST_TO_UINT8_P(&tx_error), sizeof(tx_error)); + + if (handler != NULL) { + handler(evt_id); + } else { + ptt_event_free(evt_id); + } + + PTT_TRACE_FUNC_EXIT(); +} + +void ptt_ctrl_rf_cca_done(ptt_evt_id_t evt_id, bool result) +{ + PTT_TRACE("%s -> evt %d res %d\n", __func__, evt_id, result); + + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_rf_cca_done(); + + ptt_event_set_ctx_data(evt_id, PTT_CAST_TO_UINT8_P(&result), sizeof(result)); + + if (handler != NULL) { + handler(evt_id); + } else { + ptt_event_free(evt_id); + } + + PTT_TRACE_FUNC_EXIT(); +} + +void ptt_ctrl_rf_cca_failed(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_rf_cca_failed(); + + if (handler != NULL) { + handler(evt_id); + } else { + ptt_event_free(evt_id); + } + + PTT_TRACE_FUNC_EXIT(); +} + +void ptt_ctrl_rf_ed_detected(ptt_evt_id_t evt_id, ptt_ed_t result) +{ + PTT_TRACE("%s -> evt %d res %d\n", __func__, evt_id, result); + + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_rf_ed_detected(); + + ptt_event_set_ctx_data(evt_id, PTT_CAST_TO_UINT8_P(&result), sizeof(result)); + + if (handler != NULL) { + handler(evt_id); + } else { + ptt_event_free(evt_id); + } + + PTT_TRACE_FUNC_EXIT(); +} + +void ptt_ctrl_rf_ed_failed(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_rf_ed_failed(); + + if (handler != NULL) { + handler(evt_id); + } else { + ptt_event_free(evt_id); + } + + PTT_TRACE_FUNC_EXIT(); +} + +void ptt_ctrl_rf_push_packet(const uint8_t *pkt, ptt_pkt_len_t len, int8_t rssi, uint8_t lqi) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret; + ptt_evt_id_t evt_id; + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_rf_rx_done(); + + ret = ptt_event_alloc_and_fill(&evt_id, pkt, len); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: ptt_event_alloc_and_fill returned error code: %d", __func__, ret); + } else { + struct ptt_rf_packet_info_s pkt_info = { .rssi = rssi, .lqi = lqi }; + + ptt_event_set_ctx_data(evt_id, (uint8_t *)(&pkt_info), sizeof(pkt_info)); + + if (handler != NULL) { + handler(evt_id); + } else { + ptt_event_free(evt_id); + } + } +} + +void ptt_ctrl_rf_rx_failed(ptt_rf_rx_error_t rx_error) +{ + PTT_TRACE("%s -> res %d\n", __func__, rx_error); + + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_rf_rx_failed(); + + if (handler != NULL) { + enum ptt_ret ret; + ptt_evt_id_t evt_id; + + ret = ptt_event_alloc(&evt_id); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: ptt_event_alloc returned error code: %d", __func__, ret); + } else { + ptt_event_set_ctx_data(evt_id, PTT_CAST_TO_UINT8_P(&rx_error), + sizeof(rx_error)); + handler(evt_id); + } + } + + PTT_TRACE_FUNC_EXIT(); +} + +#ifdef TESTS +#include "test_rf_proc_wrappers.c" +#endif /* TESTS */ diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_timers.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_timers.c new file mode 100644 index 000000000000..088058a2442e --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_timers.c @@ -0,0 +1,303 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: timers implementation */ + +#include + +#include "ptt.h" + +#include "ctrl/ptt_trace.h" + +#include "ptt_timers_internal.h" + +#ifdef TESTS +#include "test_timers_conf.h" +#else +#include "ptt_ctrl_internal.h" +#endif + +/* Main idea is to keep timeouts bounded to current time and refresh them every + * time when a new timer added or any timer is ended. The nearest timeout is + * selected from all timeouts in the pool and the application timer is called + * with this timeout. It helps to charge the application timer actually only + * when a timer which is closer than already charged one is added and allows + * to keep a pool of timers based on a single application timer. + */ + +static void charge_app_timer(void); +static ptt_time_t get_min_timeout(void); +static void update_timers(ptt_time_t current_time); + +static inline void app_timer_update(ptt_time_t timeout); +static inline ptt_time_t update_timeout(ptt_time_t timeout, ptt_time_t value); +static inline ptt_time_t time_diff(ptt_time_t prev_time, ptt_time_t new_time); + +void ptt_timers_init(void) +{ + PTT_TRACE("%s ->\n", __func__); + + struct ptt_timer_ctx_s *timer_ctx = ptt_ctrl_get_timer_ctx(); + + *timer_ctx = (struct ptt_timer_ctx_s){ 0 }; + timer_ctx->free_slots = PTT_TIMER_POOL_N; + timer_ctx->last_timeout = ptt_ctrl_get_max_time(); + timer_ctx->last_update_time = ptt_ctrl_get_max_time(); + + PTT_TRACE("%s -<\n", __func__); +} + +void ptt_timers_uninit(void) +{ + PTT_TRACE("%s\n", __func__); +} + +void ptt_timers_reset_all(void) +{ + PTT_TRACE("%s ->\n", __func__); + ptt_timers_uninit(); + ptt_timers_init(); + PTT_TRACE("%s -<\n", __func__); +} + +static inline ptt_time_t time_diff(ptt_time_t prev_time, ptt_time_t new_time) +{ + if (prev_time <= new_time) { + return (new_time - prev_time); + } else { + return ((ptt_ctrl_get_max_time() - prev_time) + new_time); + } +} + +static inline void app_timer_update(ptt_time_t timeout) +{ + PTT_TRACE("%s -> %d\n", __func__, timeout); + + struct ptt_timer_ctx_s *timer_ctx = ptt_ctrl_get_timer_ctx(); + + timer_ctx->last_timeout = timeout; + ptt_ctrl_call_me_cb(timeout); + + PTT_TRACE("%s -<\n", __func__); +} + +static inline ptt_time_t update_timeout(ptt_time_t timeout, ptt_time_t value) +{ + if (value > timeout) { + return 0; + } else { + return (timeout - value); + } +} + +void ptt_timers_process(ptt_time_t current_time) +{ + PTT_TRACE("%s -> %d\n", __func__, current_time); + + uint8_t i; + struct ptt_timer_ctx_s *timer_ctx; + + update_timers(current_time); + + timer_ctx = ptt_ctrl_get_timer_ctx(); + + for (i = 0; i < PTT_TIMER_POOL_N; ++i) { + if ((true == timer_ctx->timer_pool[i].use) && + (timer_ctx->timer_pool[i].timeout == 0)) { + if (timer_ctx->timer_pool[i].cb != NULL) { + timer_ctx->timer_pool[i].cb(timer_ctx->timer_pool[i].evt_id); + } + timer_ctx->timer_pool[i] = (struct ptt_timer_s){ 0 }; + timer_ctx->free_slots++; + } + } + + charge_app_timer(); + + PTT_TRACE("%s -<\n", __func__); +} + +enum ptt_ret ptt_timer_add(ptt_time_t timeout, ptt_timer_cb cb, ptt_evt_id_t evt_id) +{ + PTT_TRACE("%s -> tm %d cb %p evt %d\n", __func__, timeout, cb, evt_id); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_timer_s timer = { 0 }; + + if (timeout > ptt_ctrl_get_max_time()) { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + + if (cb != NULL) { + timer.cb = cb; + } else { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + + if (evt_id < PTT_EVENT_POOL_N) { + timer.evt_id = evt_id; + } else { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + + timer.timeout = timeout; + timer.use = true; + + struct ptt_timer_ctx_s *timer_ctx = ptt_ctrl_get_timer_ctx(); + + if (timer_ctx->free_slots == 0) { + ret = PTT_RET_NO_FREE_SLOT; + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; + } + + ptt_time_t current_time = ptt_get_current_time(); + + /* refresh last update time each time when the first timer is added to empty pool + * to have actual time after large delay of update_timers calls + */ + if (timer_ctx->free_slots == PTT_TIMER_POOL_N) { + timer_ctx->last_update_time = current_time; + + /* as pool is empty */ + timer_ctx->timer_pool[0] = timer; + timer_ctx->free_slots--; + + app_timer_update(timer.timeout); + } else { + /* need to bind all previously placed timers to current time to align them with + * timer of adding new timer + */ + /* legend: + * o - time of last binding timers to absolute time (last_update_time) + * c - current time (time of adding the new timer) + * a - time when the application timer will shoot + * t0, t1 - previously added timers + * t2 - new timer + * x0, x1, x2 - timeouts + */ + /* o----c-----a + * |-------------x0 t0 + * |----------x1 t1 + * .....|.......... t2(new) + */ + update_timers(current_time); + /* o----c-----a + * .....|--------x0 t0 + * .....|-----x1 t1 + * .....|.......... t2(new) + */ + + /* add timer to pool */ + for (uint8_t i = 0; i < PTT_TIMER_POOL_N; ++i) { + if (false == timer_ctx->timer_pool[i].use) { + timer_ctx->timer_pool[i] = timer; + timer_ctx->free_slots--; + break; + } + } + /* o----c-----a + * .....|--------x0 t0 + * .....|-----x1 t1 + * .....|----------x2 t2(new) + */ + + /* check is new timer closer than already charged in the application timer */ + /* note: timer.timeout = x2 - c */ + /* note: timer_ctx->last_timeout = x1 - c */ + if (timer_ctx->last_timeout > timer.timeout) { + app_timer_update(timer.timeout); + } + } + + PTT_TRACE("%s -< ret %d\n", __func__, ret); + return ret; +} + +/* if removing timer was going to expire then one of next calls from an application + * will be ptt_timers_process, where timer pool will be updated and new application + * timer will be charged if any timers are running + */ +void ptt_timer_remove(ptt_evt_id_t evt_id) +{ + PTT_TRACE("%s -> evt %d\n", __func__, evt_id); + + uint8_t i; + struct ptt_timer_ctx_s *timer_ctx = ptt_ctrl_get_timer_ctx(); + + for (i = 0; i < PTT_TIMER_POOL_N; ++i) { + if (evt_id == timer_ctx->timer_pool[i].evt_id) { + timer_ctx->timer_pool[i] = (struct ptt_timer_s){ 0 }; + timer_ctx->free_slots += 1; + } + } + + PTT_TRACE("%s -<\n", __func__); +} + +static void charge_app_timer(void) +{ + PTT_TRACE("%s ->\n", __func__); + + ptt_time_t current_time = ptt_get_current_time(); + + update_timers(current_time); + ptt_time_t nearest_timeout = get_min_timeout(); + + app_timer_update(nearest_timeout); + + PTT_TRACE("%s -<\n", __func__); +} + +static ptt_time_t get_min_timeout(void) +{ + PTT_TRACE("%s ->\n", __func__); + + /* @fixme: division by 4 is workaround to update application timer variables + * min_timeout = ptt_ctrl_get_max_time() should be after bug is fixed + */ + ptt_time_t min_timeout = ptt_ctrl_get_max_time() / 4; + struct ptt_timer_ctx_s *timer_ctx = ptt_ctrl_get_timer_ctx(); + uint8_t i; + + for (i = 0; i < PTT_TIMER_POOL_N; ++i) { + if ((true == timer_ctx->timer_pool[i].use) && + (min_timeout > timer_ctx->timer_pool[i].timeout)) { + min_timeout = timer_ctx->timer_pool[i].timeout; + } + } + + PTT_TRACE("%s -< tm %d\n", __func__, min_timeout); + return min_timeout; +} + +static void update_timers(ptt_time_t current_time) +{ + PTT_TRACE("%s -> ct %d\n", __func__, current_time); + + uint8_t i; + struct ptt_timer_ctx_s *timer_ctx = ptt_ctrl_get_timer_ctx(); + + /* calculate time difference */ + ptt_time_t diff = time_diff(timer_ctx->last_update_time, current_time); + + for (i = 0; i < PTT_TIMER_POOL_N; ++i) { + if (true == timer_ctx->timer_pool[i].use) { + timer_ctx->timer_pool[i].timeout = + update_timeout(timer_ctx->timer_pool[i].timeout, diff); + } + } + + timer_ctx->last_timeout = update_timeout(timer_ctx->last_timeout, diff); + timer_ctx->last_update_time = current_time; + + PTT_TRACE("%s -<\n", __func__); +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_timers_internal.h b/samples/peripheral/802154_phy_test/src/ctrl/ptt_timers_internal.h new file mode 100644 index 000000000000..615b3c5dd42a --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_timers_internal.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: timer interface intended for usage inside control module */ + +#ifndef PTT_TIMERS_INTERNAL_H__ +#define PTT_TIMERS_INTERNAL_H__ + +#include "ctrl/ptt_timers.h" + +#include "ptt_config.h" +#include "ptt_types.h" + +/** timer */ +struct ptt_timer_s { + ptt_time_t timeout; /**< timeout, when expires user function will be called */ + ptt_timer_cb cb; /**< function to be called when timer is expired */ + ptt_evt_id_t evt_id; /**< event id which will be passed to user function */ + bool use; /**< flag to determine that timer currently at use */ +}; + +/** context for timer */ +struct ptt_timer_ctx_s { + struct ptt_timer_s timer_pool[PTT_TIMER_POOL_N]; /**< array of timers */ + ptt_time_t last_update_time; /**< time of last update of used timers in the pool */ + ptt_time_t last_timeout; /**< timeout with which call_me_cb was called last time */ + uint8_t free_slots; /**< counter of free slots at timer_pool */ +}; + +/** @brief Initialize timers context + * + * @param none + * + * @return none + */ +void ptt_timers_init(void); + +/** @brief Uninitialize timers context + * + * @param none + * + * @return none + */ +void ptt_timers_uninit(void); + +/** @brief Reset timers context to default values as after initialization + * + * @param none + * + * @return none + */ +void ptt_timers_reset_all(void); + +/** @brief Find expired timers and calls their callbacks from `cb` field + * + * @param current_time - current time, provided by an application, should be no more than max_time + * + * @return none + */ +void ptt_timers_process(ptt_time_t current_time); + +#endif /* PTT_TIMERS_INTERNAL_H__ */ diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_uart_proc.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_uart_proc.c new file mode 100644 index 000000000000..bc0e2175d3b3 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_uart_proc.c @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + *//* Purpose: processing external UART messages */ + +/* We expects a command string looks like "custom ". + * Each whitespace-separated value fits into one byte and payload has big-endian byte order. + * For example: "custom setchannel 0x00 0x00 0x08 0x00" to set 11 channel. + */ + +#include +#include +#include +#include + +#include "ctrl/ptt_ctrl.h" +#include "ctrl/ptt_events.h" +#include "ctrl/ptt_trace.h" +#include "ctrl/ptt_uart.h" + +#include "ptt_proto.h" + +#include "ptt_ctrl_internal.h" +#include "ptt_errors.h" +#include "ptt_events_internal.h" +#include "ptt_modes.h" +#include "ptt_uart_api.h" +#include "ptt_parser_internal.h" + +#ifdef TESTS +#include "test_uart_conf.h" +#endif + +/** array to parse text command */ +static struct uart_text_cmd_s text_cmds[PTT_UART_CMD_N] = { + { UART_CMD_R_PING_TEXT, PTT_UART_CMD_R_PING, UART_CMD_R_PING_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_PING_TIMEOUT_TEXT, PTT_UART_CMD_L_PING_TIMEOUT, + UART_CMD_L_PING_TIMEOUT_PAYLOAD_L, PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_SETCHANNEL_TEXT, PTT_UART_CMD_SETCHANNEL, UART_CMD_SETCHANNEL_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_SETCHANNEL_TEXT, PTT_UART_CMD_L_SETCHANNEL, UART_CMD_L_SETCHANNEL_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_R_SETCHANNEL_TEXT, PTT_UART_CMD_R_SETCHANNEL, UART_CMD_R_SETCHANNEL_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_CHANNEL_TEXT, PTT_UART_CMD_L_GET_CHANNEL, UART_CMD_L_GET_CHANNEL_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_SET_POWER_TEXT, PTT_UART_CMD_L_SET_POWER, UART_CMD_L_SET_POWER_PAYLOAD_L, + PTT_UART_PAYLOAD_RAW }, + { UART_CMD_R_SET_POWER_TEXT, PTT_UART_CMD_R_SET_POWER, UART_CMD_R_SET_POWER_PAYLOAD_L, + PTT_UART_PAYLOAD_RAW }, + { UART_CMD_L_GET_POWER_TEXT, PTT_UART_CMD_L_GET_POWER, UART_CMD_L_GET_POWER_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_R_GET_POWER_TEXT, PTT_UART_CMD_R_GET_POWER, UART_CMD_R_GET_POWER_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_R_STREAM_TEXT, PTT_UART_CMD_R_STREAM, UART_CMD_R_STREAM_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_R_START_TEXT, PTT_UART_CMD_R_START, UART_CMD_R_START_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_R_END_TEXT, PTT_UART_CMD_R_END, UART_CMD_R_END_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_REBOOT_TEXT, PTT_UART_CMD_L_REBOOT, UART_CMD_L_REBOOT_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_FIND_TEXT, PTT_UART_CMD_FIND, UART_CMD_FIND_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_R_HW_VERSION_TEXT, PTT_UART_CMD_R_HW_VERSION, UART_CMD_R_HW_VERSION_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_R_SW_VERSION_TEXT, PTT_UART_CMD_R_SW_VERSION, UART_CMD_R_SW_VERSION_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_CHANGE_MODE_TEXT, PTT_UART_CMD_CHANGE_MODE, UART_CMD_CHANGE_MODE_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_CCA_TEXT, PTT_UART_CMD_L_GET_CCA, UART_CMD_L_GET_CCA_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_ED_TEXT, PTT_UART_CMD_L_GET_ED, UART_CMD_L_GET_ED_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_LQI_TEXT, PTT_UART_CMD_L_GET_LQI, UART_CMD_L_GET_LQI_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_RSSI_TEXT, PTT_UART_CMD_L_GET_RSSI, UART_CMD_L_GET_RSSI_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_SET_SHORT_TEXT, PTT_UART_CMD_L_SET_SHORT, UART_CMD_L_SET_SHORT_PAYLOAD_L, + PTT_UART_PAYLOAD_RAW }, + { UART_CMD_L_SET_EXTENDED_TEXT, PTT_UART_CMD_L_SET_EXTENDED, + UART_CMD_L_SET_EXTENDED_PAYLOAD_L, PTT_UART_PAYLOAD_RAW }, + { UART_CMD_L_SET_PAN_ID_TEXT, PTT_UART_CMD_L_SET_PAN_ID, UART_CMD_L_SET_PAN_ID_PAYLOAD_L, + PTT_UART_PAYLOAD_RAW }, + { UART_CMD_L_SET_PAYLOAD_TEXT, PTT_UART_CMD_L_SET_PAYLOAD, UART_CMD_L_SET_PAYLOAD_PAYLOAD_L, + PTT_UART_PAYLOAD_RAW }, + { UART_CMD_L_START_TEXT, PTT_UART_CMD_L_START, UART_CMD_L_START_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_END_TEXT, PTT_UART_CMD_L_END, UART_CMD_L_END_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_SET_ANTENNA_TEXT, PTT_UART_CMD_L_SET_ANTENNA, UART_CMD_L_SET_ANTENNA_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_ANTENNA_TEXT, PTT_UART_CMD_L_GET_ANTENNA, UART_CMD_L_GET_ANTENNA_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_R_SET_ANTENNA_TEXT, PTT_UART_CMD_R_SET_ANTENNA, UART_CMD_R_SET_ANTENNA_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_R_GET_ANTENNA_TEXT, PTT_UART_CMD_R_GET_ANTENNA, UART_CMD_R_GET_ANTENNA_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_TX_END_TEXT, PTT_UART_CMD_L_TX_END, UART_CMD_L_TX_END_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_TX_TEXT, PTT_UART_CMD_L_TX, UART_CMD_L_TX_PAYLOAD_L, PTT_UART_PAYLOAD_RAW }, + { UART_CMD_L_CLK_TEXT, PTT_UART_CMD_L_CLK, UART_CMD_L_CLK_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_SET_GPIO_TEXT, PTT_UART_CMD_L_SET_GPIO, UART_CMD_L_SET_GPIO_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_GPIO_TEXT, PTT_UART_CMD_L_GET_GPIO, UART_CMD_L_GET_GPIO_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_CARRIER_TEXT, PTT_UART_CMD_L_CARRIER, UART_CMD_L_CARRIER_PAYLOAD_L, + PTT_UART_PAYLOAD_RAW }, + { UART_CMD_L_STREAM_TEXT, PTT_UART_CMD_L_STREAM, UART_CMD_L_STREAM_PAYLOAD_L, + PTT_UART_PAYLOAD_RAW }, + { UART_CMD_L_SET_DCDC_TEXT, PTT_UART_CMD_L_SET_DCDC, UART_CMD_L_SET_DCDC_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_DCDC_TEXT, PTT_UART_CMD_L_GET_DCDC, UART_CMD_L_GET_DCDC_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_SET_ICACHE_TEXT, PTT_UART_CMD_L_SET_ICACHE, UART_CMD_L_SET_ICACHE_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_ICACHE_TEXT, PTT_UART_CMD_L_GET_ICACHE, UART_CMD_L_GET_ICACHE_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_GET_TEMP_TEXT, PTT_UART_CMD_L_GET_TEMP, UART_CMD_L_GET_TEMP_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_INDICATION_TEXT, PTT_UART_CMD_L_INDICATION, UART_CMD_L_INDICATION_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_SLEEP_TEXT, PTT_UART_CMD_L_SLEEP, UART_CMD_L_SLEEP_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, + { UART_CMD_L_RECEIVE_TEXT, PTT_UART_CMD_L_RECEIVE, UART_CMD_L_RECEIVE_PAYLOAD_L, + PTT_UART_PAYLOAD_PARSED_AS_BYTES }, +}; + +static ptt_uart_send_cb uart_send_cb; + +static bool handler_busy; + +static enum ptt_ret packet_parser(ptt_evt_id_t evt_id); +static enum ptt_ret text_cmd_parser(ptt_evt_id_t evt_id); +static enum ptt_ret payload_fill(struct ptt_evt_ctx_data_s *ctx_data, char *payload, uint8_t len); + +void ptt_uart_init(ptt_uart_send_cb send_cb) +{ + uart_send_cb = send_cb; + ptt_uart_print_prompt(); +} + +void ptt_uart_uninit(void) +{ + uart_send_cb = NULL; +} + +inline void ptt_uart_print_prompt(void) +{ + if (uart_send_cb != NULL) { + uart_send_cb(PTT_CAST_TO_UINT8_P(PTT_UART_PROMPT_STR), + sizeof(PTT_UART_PROMPT_STR) - 1, false); + } +} + +enum ptt_ret ptt_uart_send_packet(const uint8_t *pkt, ptt_pkt_len_t len) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if ((pkt == NULL) || (len == 0)) { + ret = PTT_RET_INVALID_VALUE; + } + + if (ret == PTT_RET_SUCCESS) { + if (uart_send_cb == NULL) { + ret = PTT_RET_NULL_PTR; + } else { + int32_t size = uart_send_cb(pkt, len, true); + + if (size != len) { + ret = PTT_RET_BUSY; + } + } + } + + PTT_TRACE("%s: ret %d", __func__, ret); + return ret; +} + +void ptt_uart_push_packet(const uint8_t *pkt, ptt_pkt_len_t len) +{ + ptt_evt_id_t evt_id; + enum ptt_ret ret; + + if ((pkt == NULL) || (len == 0)) { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE("%s: invalid input value", __func__); + } else { + ret = ptt_event_alloc_and_fill(&evt_id, pkt, len); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: ptt_event_alloc_and_fill return error code: %d", __func__, + ret); + } else { + ret = packet_parser(evt_id); + } + } + + /* to prevent sending prompt on invalid command + * when handler is busy processing previous command + */ + if ((ret != PTT_RET_SUCCESS) && !handler_busy) { + ptt_uart_print_prompt(); + } +} + +/* @todo: refactor to let handler return result being busy */ +void ptt_handler_busy(void) +{ + handler_busy = true; +} + +void ptt_handler_free(void) +{ + handler_busy = false; +} + +static enum ptt_ret packet_parser(ptt_evt_id_t evt_id) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + ptt_ext_evt_handler handler = ptt_ctrl_get_handler_uart_pkt_received(); + + ret = text_cmd_parser(evt_id); + + if (ret == PTT_RET_SUCCESS) { + if (ptt_event_get_cmd(evt_id) == PTT_UART_CMD_CHANGE_MODE) { + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + ret = ptt_mode_switch(ctx_data->arr[0]); + + ptt_uart_print_prompt(); + + ptt_event_free(evt_id); + } else if (handler == NULL) { + ret = PTT_RET_INVALID_MODE; + ptt_event_free(evt_id); + } else { + handler(evt_id); + } + } else { + ptt_event_free(evt_id); + } + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("packet parser ended with error code: %u", ret); + } + + return ret; +} + +/* fills evt_id with command and its parameters or return error */ +static enum ptt_ret text_cmd_parser(ptt_evt_id_t evt_id) +{ + uint8_t str; + uint8_t i; + size_t cmd_name_len; + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_data_s *data = ptt_event_get_data(evt_id); + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(data != NULL); + assert(ctx_data != NULL); + + for (i = 0; i < PTT_UART_CMD_N; ++i) { + cmd_name_len = strlen(text_cmds[i].name); + + /* compare without '\0' symbol */ + str = strncmp(PTT_CAST_TO_STR(data->arr), text_cmds[i].name, cmd_name_len); + + if (str != 0) { + ret = PTT_RET_INVALID_VALUE; + } else { + if (text_cmds[i].payload_type == PTT_UART_PAYLOAD_RAW) { + /* raw payload already written in data, just pass */ + ret = PTT_RET_SUCCESS; + } else if (text_cmds[i].payload_type == PTT_UART_PAYLOAD_PARSED_AS_BYTES) { + /* after a command should be only whitespace + * in case of payload or \0 + */ + if ((data->arr[cmd_name_len] == '\0') || + (data->arr[cmd_name_len] == ' ')) { + char *payload = PTT_CAST_TO_STR(data->arr + cmd_name_len); + + ret = payload_fill(ctx_data, payload, + text_cmds[i].payload_len); + } else { + ret = PTT_RET_INVALID_VALUE; + } + } else { + ret = PTT_RET_INVALID_VALUE; + } + + if (ret == PTT_RET_SUCCESS) { + ptt_event_set_cmd(evt_id, text_cmds[i].code); + } + + /* we found command name, time to quit */ + break; + } + } + + return ret; +} + +/* payload points to payload of text cmd */ +static enum ptt_ret payload_fill(struct ptt_evt_ctx_data_s *ctx_data, char *payload, uint8_t len) +{ + if ((payload == NULL) || (ctx_data == NULL)) { + return PTT_RET_INVALID_VALUE; + } + + enum ptt_ret ret = PTT_RET_SUCCESS; + static char *save; + char *next_word = strtok_r(payload, UART_TEXT_PAYLOAD_DELIMETERS, &save); + + for (uint8_t i = 0; i < len; ++i) { + if (next_word == NULL) { + /* expected more words in payload */ + ret = PTT_RET_INVALID_VALUE; + break; + } + + uint8_t out_num; + + /* signed values are processed in their handlers */ + ret = ptt_parser_string_to_uint8(next_word, &out_num, 0); + + if (ret != PTT_RET_SUCCESS) { + break; + } + + if (ctx_data->len >= PTT_EVENT_CTX_SIZE) { + ret = PTT_RET_INVALID_VALUE; + break; + } + + ctx_data->arr[ctx_data->len] = out_num; + ++(ctx_data->len); + + next_word = strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save); + } + + if (next_word != NULL) { + ret = PTT_RET_INVALID_VALUE; + } + + return ret; +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode.c new file mode 100644 index 000000000000..51af8106e6b3 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: implementation of Zigbee RF Performance Test Plan CMD mode */ + +#include "ctrl/ptt_trace.h" + +#include "ptt_ctrl_internal.h" +#include "ptt_modes.h" +#include "ptt_zb_perf_cmd_mode.h" + +enum ptt_ret ptt_zb_perf_cmd_mode_init(void) +{ + PTT_TRACE("%s ->\n", __func__); + + cmd_ota_cmd_init(); + cmd_uart_cmd_init(); + + struct ptt_ext_evts_handlers_s *handlers = ptt_ctrl_get_handlers(); + + handlers->rf_tx_finished = cmd_rf_tx_finished; + handlers->rf_tx_failed = cmd_rf_tx_failed; + handlers->rf_rx_done = cmd_rf_rx_done; + handlers->rf_rx_failed = cmd_rf_rx_failed; + handlers->uart_pkt_received = cmd_uart_pkt_received; + handlers->rf_cca_done = cmd_rf_cca_done; + handlers->rf_cca_failed = cmd_rf_cca_failed; + handlers->rf_ed_detected = cmd_rf_ed_detected; + handlers->rf_ed_failed = cmd_rf_ed_failed; + + PTT_TRACE("%s -<\n", __func__); + return PTT_RET_SUCCESS; +} + +enum ptt_ret ptt_zb_perf_cmd_mode_uninit(void) +{ + PTT_TRACE("%s ->\n", __func__); + + cmd_ota_cmd_uninit(); + cmd_uart_cmd_uninit(); + + PTT_TRACE("%s -<\n", __func__); + return PTT_RET_SUCCESS; +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode.h b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode.h new file mode 100644 index 000000000000..7884ce94c125 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode.h @@ -0,0 +1,358 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: implementation of Zigbee RF Performance Test Plan CMD mode */ + +#ifndef PTT_MODE_ZB_PERF_CMD_H__ +#define PTT_MODE_ZB_PERF_CMD_H__ + +#include + +#include "ctrl/ptt_ctrl.h" +#include "ctrl/ptt_events.h" +#include "ctrl/ptt_timers.h" +#include "ctrl/ptt_uart.h" + +#include "ptt_errors.h" +#include "ptt_config.h" +#include "ptt_utils.h" + +#define PTT_PING_ERROR_MES "NO ACK" +#define PTT_PING_SUCCESS_MES "ACK" +#define PTT_GET_POWER_ERROR_MES "NO POWER RESPONSE" +#define PTT_END_RX_TEST_ERROR_MES "NO REPORT" +#define PTT_GET_HARDWARE_ERROR_MES "NO HW VERSION RESPONSE" +#define PTT_GET_SOFTWARE_ERROR_MES "NO SW VERSION RESPONSE" +#define PTT_FIND_ERROR_MES "DUT NOT FOUND" +#define PTT_GET_CCA_SUCCESS_MES "CCA:" /* note: value will be added in response function */ +#define PTT_GET_CCA_ERROR_MES "CCA FAILED" +#define PTT_GET_ED_SUCCESS_MES "ED:" /* note: value will be added in response function */ +#define PTT_GET_ED_ERROR_MES "ED FAILED" +#define PTT_GET_RSSI_SUCCESS_MES "RSSI:" /* note: value will be added in response function */ +#define PTT_GET_RSSI_ERROR_MES "RSSI FAILED" +#define PTT_GET_LQI_SUCCESS_MES "LQI:" /* note: value will be added in response function */ +#define PTT_GET_LQI_ERROR_MES "LQI:ERROR" +#define PTT_GET_ANTENNA_MES "ANTENNA:" /* note: value will be added in response function */ +#define PTT_GET_ANTENNA_ERROR_MES "NO ANTENNA RESPONSE" +#define PTT_L_TX_NO_ACK_MES "NO ACK" +#define PTT_L_TX_CRC_ERROR_MES "CRC ERROR" +#define PTT_L_TX_ERROR_MES "TX ERROR" +#define PTT_L_START_CRC_ERROR_MES "CRC ERROR" +#define PTT_L_START_ERROR_MES "RX ERROR" +#define PTT_GET_DCDC_MES "DCDC:" /* note: value will be added in response function */ +#define PTT_GET_ICACHE_MES "ICACHE:" /* note: value will be added in response function */ + +/** states of OTA commands processing in CMD mode */ +enum cmd_ota_state_t { + CMD_OTA_STATE_IDLE = 0, /**< waiting for next command */ + CMD_OTA_STATE_PING_SENDING, /**< rf module send ping command */ + CMD_OTA_STATE_PING_WAITING_FOR_ACK, /**< ping sent, waiting for ack */ + CMD_OTA_STATE_SET_CHANNEL_SENDING, /**< rf module send set_channel command */ + CMD_OTA_STATE_SET_POWER_SENDING, /**< rf module send set_power command */ + CMD_OTA_STATE_STREAM_SENDING, /**< rf module send stream command */ + CMD_OTA_STATE_START_RX_TEST_SENDING, /**< cmd send start rx test command to dut */ + CMD_OTA_STATE_GET_POWER_SENDING, /**< rf module send get_power command */ + CMD_OTA_STATE_GET_POWER_WAITING_FOR_RSP, /**< get_power sent, waiting for response */ + CMD_OTA_STATE_END_RX_TEST_SENDING, /**< rf module send end_rx_test command */ + CMD_OTA_STATE_END_RX_TEST_WAITING_FOR_REPORT, /**< end_rx_test sent, waiting for report */ + CMD_OTA_STATE_GET_HARDWARE_SENDING, /**< rf module send get hardware command */ + CMD_OTA_STATE_GET_HARDWARE_WAITING_FOR_RSP, /**< get hardware sent, waiting for response*/ + CMD_OTA_STATE_GET_SOFTWARE_SENDING, /**< rf module send get software command */ + CMD_OTA_STATE_GET_SOFTWARE_WAITING_FOR_RSP, /**< get software sent, waiting for response*/ + CMD_OTA_STATE_SET_ANTENNA_SENDING, /**< rf module send set_antenna command */ + CMD_OTA_STATE_GET_ANTENNA_SENDING, /**< rf module send get_antenna command */ + CMD_OTA_STATE_GET_ANTENNA_WAITING_FOR_RSP, /**< get_antenna sent, waiting for response */ + CMD_OTA_STATE_N + /**< Total number of OTA command processing states */ +}; + +/** states of uart command processing in CMD mode */ +enum cmd_uart_state_t { + CMD_UART_STATE_IDLE = 0, + /**< waiting for next command */ + CMD_UART_STATE_SET_CHANNEL, + /**< CMD device set channel on DUT */ + CMD_UART_STATE_STREAM, + /**< CMD device processes enable stream on DUT */ + CMD_UART_STATE_WAIT_DELAY, + /**< CMD is waiting for delay */ + CMD_UART_STATE_PING, + /**< CMD device processes ping command */ + CMD_UART_STATE_WAITING_FOR_LEND, + /**< CMD device in continuous receive mode and will accepts only "custom lend" command */ + CMD_UART_STATE_WAITING_FOR_RF_PACKET, + /**< CMD device in continuous receive mode waiting for reception of any rf packet */ + CMD_UART_STATE_LTX_WAITING_FOR_ACK, + /**< CMD device in continuous receive mode waiting for reception of ACK rf packet */ + CMD_UART_STATE_LTX, + /**< CMD device processes ltx command */ + CMD_UART_STATE_L_CLK_OUT, + /**< CMD device is waiting for disabling CLK output mode */ + CMD_UART_STATE_L_CARRIER_INTERVAL, + /**< CMD device processing lcarrier command and radio is in receiving mode */ + CMD_UART_STATE_L_CARRIER_PULSE, + /**< CMD device processing lcarrier command and sending continuous carrier */ + CMD_UART_STATE_L_STREAM_INTERVAL, + /**< CMD device processing lstream command and radio is in receiving mode */ + CMD_UART_STATE_L_STREAM_PULSE, + /**< CMD device processing lstream command and sending modulated carrier */ + CMD_UART_STATE_N + /**< Total number of UART command processing states */ +}; + +/* information for "custom ltx" command */ +struct cmd_uart_ltx_info_s { + bool is_infinite; + bool is_stop_requested; + uint8_t repeats_cnt; + uint8_t max_repeats_cnt; + uint8_t ack_cnt; + uint16_t timeout; +}; + +PTT_COMPILE_TIME_ASSERT(sizeof(struct cmd_uart_ltx_info_s) <= PTT_EVENT_CTX_SIZE); + +/* information for "custom lcarrier" command */ +struct cmd_uart_waveform_timings_s { + int32_t pulse_duration; + int32_t interval; +}; + +PTT_COMPILE_TIME_ASSERT(sizeof(struct cmd_uart_waveform_timings_s) <= PTT_EVENT_CTX_SIZE); + +/** @brief Initialize OTA commands processing module in CMD mode + * + * @param none + * + * @return none + */ +void cmd_ota_cmd_init(void); + +/** @brief Uninitialize OTA commands processing module in CMD mode + * + * @param none + * + * @return none + */ +void cmd_ota_cmd_uninit(void); + +/** @brief Process new OTA command + * + * @param none + * + * @return none + */ +enum ptt_ret cmd_ota_cmd_process(ptt_evt_id_t new_ota_cmd); + +/** @brief Notify OTA modyle about "RX done" event + * + * @param new_rf_pkt_evt - event containing the received packet. + * + * @return none + */ +void cmd_ota_rf_rx_done(ptt_evt_id_t new_rf_pkt_evt); + +/** @brief Notify OTA mode about "TX finished" event. + * + * @param evt_id - expects to be the same as the event passed to ptt_rf_send_packet() + * + * @return none + */ +void cmd_ota_rf_tx_finished(ptt_evt_id_t evt_id); + +/** @brief Notify OTA mode about "TX failed" event. + * + * @param evt_id - expects to be the same as the event passed to ptt_rf_send_packet() + * + * @return none + */ +void cmd_ota_rf_tx_failed(ptt_evt_id_t evt_id); + +/** @brief Handler for "TX finished" event. + * + * @param evt_id - expects to be the same as the event passed to ptt_rf_send_packet() + * + * @return none + */ +void cmd_rf_tx_finished(ptt_evt_id_t evt_id); + +/** @brief Handler for "TX failed" event. + * + * @param evt_id - expects to be the same as the event passed to ptt_rf_send_packet() + * + * @return none + */ +void cmd_rf_tx_failed(ptt_evt_id_t evt_id); + +/** @brief Handler for new received RF packet + * + * @param new_rf_pkt_evt - new event containing the received packet. + * Handler is responsible for freeing the event. + * + * @return none + */ +void cmd_rf_rx_done(ptt_evt_id_t new_rf_pkt_evt); + +/** @brief Handler for "RX failed" event. + * + * @param evt_id - new event containing the error code of reception fail. + * Handler is responsible for freeing the event. + * + * @return none + */ +void cmd_rf_rx_failed(ptt_evt_id_t evt_id); + +/** @brief Initialize UART commands processing module in CMD mode + * + * @param none + * + * @return none + */ +void cmd_uart_cmd_init(void); + +/** @brief Uninitialize UART commands processing module in CMD mode + * + * @param none + * + * @return none + */ +void cmd_uart_cmd_uninit(void); + +/** @brief Handler for new received UART packet + * + * @param new_uart_cmd - new event containing the received UART packet. + * Handler is responsible for freeing the event. + * + * @return none + */ +void cmd_uart_pkt_received(ptt_evt_id_t new_uart_cmd); + +/** @brief Handler for "CCA done" event + * + * @evt_id - event same as used for uart module locking. + * Contains CCA result in context. + * Handler is responsible for freeing the event. + * + * @return none + */ +void cmd_rf_cca_done(ptt_evt_id_t evt_id); + +/** @brief Handler for "CCA failed" event + * + * @evt_id - event same as used for uart module locking. + * Handler is responsible for freeing the event. + * + * @return none + */ +void cmd_rf_cca_failed(ptt_evt_id_t evt_id); + +/** @brief Handler for "ED detected" event + * + * @evt_id - event same as used for uart module locking. + * Contains ED result in context. + * Handler is responsible for freeing the event. + * + * @return none + */ +void cmd_rf_ed_detected(ptt_evt_id_t evt_id); + +/** @brief Handler for "ED failed" event + * + * @evt_id - event same as used for uart module locking. + * Handler is responsible for freeing the event. + * + * @return none + */ +void cmd_rf_ed_failed(ptt_evt_id_t evt_id); + +/** @brief Handler for OTA command failed result such as timeouts and errors + * + * @param evt_id - expects to be the same as the event passed to cmd_ota_cmd_process() + * + * @return none + */ +void cmt_uart_ota_cmd_timeout_notify(ptt_evt_id_t evt_id); + +/** @brief Handler for OTA command success result with the response in the context if expected + * + * @param evt_id - expects to be the same as the event passed to cmd_ota_cmd_process() + * + * @return none + */ +void cmt_uart_ota_cmd_finish_notify(ptt_evt_id_t evt_id); + +/* Send responses through UART. Responses use passed event as memory + * for storing prepared UART packet. + * If payload is expected in context it will be extracted and processed. + * It depends on UART command. + */ +/* Sends ACK response through UART */ +void cmd_uart_send_rsack(ptt_evt_id_t evt_id); +/* Sends NO ACK response through UART */ +void cmd_uart_send_rsp_no_ack(ptt_evt_id_t evt_id); +/* Sends current CMD channel through UART */ +void cmd_uart_send_rsp_l_channel(ptt_evt_id_t evt_id); +/* Sends NO POWER RESPONSE through UART */ +void cmd_uart_send_rsp_power_error(ptt_evt_id_t evt_id); +/* Sends DUT power through UART */ +void cmd_uart_send_rsp_power(ptt_evt_id_t evt_id); +/* Sends NO REPORT through UART */ +void cmd_uart_send_rsp_rx_test_error(ptt_evt_id_t evt_id); +/* Sends RX test report through UART */ +void cmd_uart_send_rsp_rx_test(ptt_evt_id_t evt_id); +/* Sends NO HW VERSION through UART */ +void cmd_uart_send_rsp_hw_error(ptt_evt_id_t evt_id); +/* Sends HW version through UART */ +void cmd_uart_send_rsp_hw(ptt_evt_id_t evt_id); +/* Sends NO SW VERSION through UART */ +void cmd_uart_send_rsp_sw_error(ptt_evt_id_t evt_id); +/* Sends SW version through UART */ +void cmd_uart_send_rsp_sw(ptt_evt_id_t evt_id); +/* Sends found DUT channel through UART */ +void cmd_uart_send_rsp_find(ptt_evt_id_t evt_id); +/* Sends DUT NOT FOUND through UART */ +void cmd_uart_send_rsp_find_timeout(ptt_evt_id_t evt_id); +/* Sends CCA FAILED through UART */ +void cmd_uart_send_rsp_cca_failed(ptt_evt_id_t evt_id); +/* Sends CCA result through UART */ +void cmd_uart_send_rsp_cca_done(ptt_evt_id_t evt_id); +/* Sends ED FAILED through UART */ +void cmd_uart_send_rsp_ed_failed(ptt_evt_id_t evt_id); +/* Sends ED result through UART */ +void cmd_uart_send_rsp_ed_detected(ptt_evt_id_t evt_id); +/* Sends RSSI FAILED through UART */ +void cmd_uart_send_rsp_rssi_failed(ptt_evt_id_t evt_id); +/* Sends RSSI result through UART */ +void cmd_uart_send_rsp_rssi_done(ptt_evt_id_t evt_id); +/* Sends new packet report through UART */ +void cmd_uart_send_rsp_l_start_new_packet(ptt_evt_id_t new_rf_pkt_evt); +/* Sends report about received packet from previous call to lstart */ +void cmd_uart_send_rsp_l_end(ptt_evt_id_t evt_id, uint32_t proto_pkts); +/* Sends LQI FAILED through UART */ +void cmd_uart_send_rsp_lqi_failed(ptt_evt_id_t evt_id); +/* Sends LQI result through UART */ +void cmd_uart_send_rsp_lqi_done(ptt_evt_id_t evt_id); +/* Sends current antenna through UART */ +void cmd_uart_send_rsp_antenna(ptt_evt_id_t evt_id); +/* Sends NO ANTENNA RESPONSE through UART */ +void cmd_uart_send_rsp_antenna_error(ptt_evt_id_t evt_id); +/* Sends NO ACK through UART */ +void cmd_uart_send_rsp_ltx_failed(ptt_evt_id_t evt_id); +/* Sends ack packet through UART */ +void cmd_uart_send_rsp_ltx_ack(ptt_evt_id_t evt_id, uint32_t packet_n); +/* Sends new packet reception fail report through UART */ +void cmd_uart_send_rsp_l_start_rx_fail(ptt_evt_id_t new_rf_pkt_evt); +/* Sends GPIO pin value through UART */ +void cmd_uart_send_rsp_l_get_gpio(ptt_evt_id_t evt_id); +/* Sends GPIO pin reading error through UART */ +void cmd_uart_send_rsp_l_get_gpio_error(ptt_evt_id_t evt_id); +/* Sends SoC temperature through UART */ +void cmd_uart_send_rsp_get_temp(ptt_evt_id_t evt_id); +/* Sends current DCDC mode through UART */ +void cmd_uart_send_rsp_get_dcdc(ptt_evt_id_t evt_id); +/* Sends current state of ICACHE through UART */ +void cmd_uart_send_rsp_get_icache(ptt_evt_id_t evt_id); + +#endif /* PTT_MODE_ZB_PERF_CMD_H__ */ diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode_ota.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode_ota.c new file mode 100644 index 000000000000..a673ca00d5b2 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode_ota.c @@ -0,0 +1,820 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: OTA commands processing of Zigbee RF Performance Test Plan CMD mode */ + +/* The module processes an event containing OTA command from UART module and + * returns the event with result. The event locks the module as currently processed OTA command + * and the module rejects any other commands while processing the one. + */ + +#include +#include +#include + +#include "ctrl/ptt_trace.h" +#include "rf/ptt_rf.h" + +#include "ptt_proto.h" + +#include "ptt_ctrl_internal.h" +#include "ptt_events_internal.h" +#include "ptt_modes.h" +#include "ptt_zb_perf_cmd_mode.h" + +#ifdef TESTS +#include "test_cmd_ota_conf.h" +#endif + +/** currently processed OTA command */ +static ptt_evt_id_t ota_cmd_evt; + +/* current event handlers */ +static enum ptt_ret cmd_ota_cmd_proc(void); +static enum ptt_ret cmd_set_channel(void); +static enum ptt_ret cmd_set_power(void); +static enum ptt_ret cmd_ping(void); +static void cmd_ping_sent(void); +static enum ptt_ret cmd_get_power(void); +static void cmd_get_power_sent(void); +static enum ptt_ret cmd_end_rx_test(void); +static void cmd_end_rx_test_sent(void); +static enum ptt_ret cmd_get_hardware_version(void); +static void cmd_get_hardware_sent(void); +static enum ptt_ret cmd_get_software_version(void); +static void cmd_get_software_sent(void); +static enum ptt_ret cmd_stream(void); +static enum ptt_ret cmd_start_rx_test(void); +static enum ptt_ret cmd_set_antenna(void); +static enum ptt_ret cmd_get_antenna(void); +static void cmd_get_antenna_sent(void); + +/* timer handlers */ +static void cmd_ping_timeout(ptt_evt_id_t timer_evt_id); +static void cmd_get_power_timeout(ptt_evt_id_t timer_evt_id); +static void cmd_end_rx_test_timeout(ptt_evt_id_t timer_evt_id); +static void cmd_get_hardware_timeout(ptt_evt_id_t timer_evt_id); +static void cmd_get_software_timeout(ptt_evt_id_t timer_evt_id); +static void cmd_get_antenna_timeout(ptt_evt_id_t timer_evt_id); + +/* new rf packets processing */ +static void cmd_ping_ack(ptt_evt_id_t new_rf_pkt_evt); +static void cmd_get_power_response(ptt_evt_id_t new_rf_pkt_evt); +static void cmd_end_rx_test_report(ptt_evt_id_t new_rf_pkt_evt); +static void cmd_get_hardware_response(ptt_evt_id_t new_rf_pkt_evt); +static void cmd_get_software_response(ptt_evt_id_t new_rf_pkt_evt); +static void cmd_get_antenna_response(ptt_evt_id_t new_rf_pkt_evt); + +/* notifications for UART command processing */ +static void cmd_fill_ctx_end_and_reset(const uint8_t *data, ptt_pkt_len_t len); +static void cmd_send_finish_and_reset(void); +static void cmd_send_timeout_and_reset(void); + +static enum ptt_ret cmd_make_and_send_rf_packet(enum ptt_cmd cmd); + +/* OTA command lock routines */ +static inline void cmd_ota_cmd_lock(ptt_evt_id_t new_ota_cmd); +static inline void cmd_change_ota_cmd_state(ptt_evt_state_t state); +static inline ptt_evt_id_t cmd_get_ota_cmd_and_reset(void); +static inline bool cmd_is_ota_cmd_locked(void); +static inline bool cmd_is_ota_cmd_locked_by(ptt_evt_id_t evt_id); +static void cmd_ota_cmd_unlock(void); + +#ifdef TESTS +#include "test_cmd_ota_wrappers.c" +#endif + +void cmd_ota_cmd_init(void) +{ + cmd_ota_cmd_unlock(); +} + +void cmd_ota_cmd_uninit(void) +{ + cmd_ota_cmd_unlock(); +} + +enum ptt_ret cmd_ota_cmd_process(ptt_evt_id_t new_ota_cmd) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (false == cmd_is_ota_cmd_locked()) { + /* store event as currently processed OTA command */ + cmd_ota_cmd_lock(new_ota_cmd); + ret = cmd_ota_cmd_proc(); + if (ret != PTT_RET_SUCCESS) { + cmd_ota_cmd_unlock(); + } + } else { + PTT_TRACE("%s: state isn't idle cmd %d state %d\n", __func__, + ptt_event_get_cmd(ota_cmd_evt), ptt_event_get_state(ota_cmd_evt)); + ret = PTT_RET_BUSY; + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_ota_cmd_proc(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + enum ptt_cmd cmd = ptt_event_get_cmd(ota_cmd_evt); + + PTT_TRACE("%s: cmd %d\n", __func__, cmd); + + switch (ptt_event_get_cmd(ota_cmd_evt)) { + case PTT_CMD_PING: + ret = cmd_ping(); + break; + + case PTT_CMD_SET_CHANNEL: + ret = cmd_set_channel(); + break; + + case PTT_CMD_SET_POWER: + ret = cmd_set_power(); + break; + + case PTT_CMD_GET_POWER: + ret = cmd_get_power(); + break; + + case PTT_CMD_STREAM: + ret = cmd_stream(); + break; + + case PTT_CMD_START_RX_TEST: + ret = cmd_start_rx_test(); + break; + + case PTT_CMD_END_RX_TEST: + ret = cmd_end_rx_test(); + break; + + case PTT_CMD_GET_HARDWARE_VERSION: + ret = cmd_get_hardware_version(); + break; + + case PTT_CMD_GET_SOFTWARE_VERSION: + ret = cmd_get_software_version(); + break; + + case PTT_CMD_SET_ANTENNA: + ret = cmd_set_antenna(); + break; + + case PTT_CMD_GET_ANTENNA: + ret = cmd_get_antenna(); + break; + + default: + PTT_TRACE("%s: unknown command cmd %d\n", __func__, cmd); + ret = PTT_RET_INVALID_COMMAND; + break; + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +void cmd_ota_rf_tx_finished(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + assert(true == cmd_is_ota_cmd_locked_by(evt_id)); + + PTT_TRACE("%s: cmd %d state %d\n", __func__, ptt_event_get_cmd(ota_cmd_evt), + ptt_event_get_state(ota_cmd_evt)); + + switch (ptt_event_get_state(ota_cmd_evt)) { + case CMD_OTA_STATE_PING_SENDING: + cmd_ping_sent(); + break; + + case CMD_OTA_STATE_SET_CHANNEL_SENDING: + case CMD_OTA_STATE_SET_POWER_SENDING: + case CMD_OTA_STATE_STREAM_SENDING: + case CMD_OTA_STATE_START_RX_TEST_SENDING: + case CMD_OTA_STATE_SET_ANTENNA_SENDING: + cmd_send_finish_and_reset(); + break; + + case CMD_OTA_STATE_GET_POWER_SENDING: + cmd_get_power_sent(); + break; + + case CMD_OTA_STATE_END_RX_TEST_SENDING: + cmd_end_rx_test_sent(); + break; + + case CMD_OTA_STATE_GET_HARDWARE_SENDING: + cmd_get_hardware_sent(); + break; + + case CMD_OTA_STATE_GET_SOFTWARE_SENDING: + cmd_get_software_sent(); + break; + + case CMD_OTA_STATE_GET_ANTENNA_SENDING: + cmd_get_antenna_sent(); + break; + + default: + PTT_TRACE("%s: inappropriate state cmd %d state %d\n", __func__, + ptt_event_get_cmd(ota_cmd_evt), ptt_event_get_state(ota_cmd_evt)); + break; + } + + PTT_TRACE_FUNC_EXIT(); +} + +void cmd_ota_rf_tx_failed(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + assert(true == cmd_is_ota_cmd_locked_by(evt_id)); + + PTT_TRACE("%s: cmd %d state %d\n", __func__, ptt_event_get_cmd(ota_cmd_evt), + ptt_event_get_state(ota_cmd_evt)); + + switch (ptt_event_get_state(ota_cmd_evt)) { + case CMD_OTA_STATE_PING_SENDING: + case CMD_OTA_STATE_SET_CHANNEL_SENDING: + case CMD_OTA_STATE_SET_POWER_SENDING: + case CMD_OTA_STATE_GET_POWER_SENDING: + case CMD_OTA_STATE_STREAM_SENDING: + case CMD_OTA_STATE_START_RX_TEST_SENDING: + case CMD_OTA_STATE_END_RX_TEST_SENDING: + case CMD_OTA_STATE_GET_HARDWARE_SENDING: + case CMD_OTA_STATE_GET_SOFTWARE_SENDING: + case CMD_OTA_STATE_SET_ANTENNA_SENDING: + case CMD_OTA_STATE_GET_ANTENNA_SENDING: + cmd_send_timeout_and_reset(); + break; + + default: + PTT_TRACE("%s: inappropriate state cmd %d state %d\n", __func__, + ptt_event_get_cmd(ota_cmd_evt), ptt_event_get_state(ota_cmd_evt)); + break; + } + + PTT_TRACE_FUNC_EXIT(); +} + +void cmd_ota_rf_rx_done(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_rf_pkt_evt); + + if (false == cmd_is_ota_cmd_locked()) { + PTT_TRACE("%s unexpected packet for idle state ignored\n", __func__); + } else { + struct ptt_evt_data_s *evt_data = ptt_event_get_data(new_rf_pkt_evt); + + assert(evt_data != NULL); + + if (!ptt_proto_check_packet(evt_data->arr, evt_data->len)) { + PTT_TRACE("%s not protocol packet received and ignored\n", __func__); + } else { + PTT_TRACE("%s: protocol packet received. Current cmd %d state %d\n", + __func__, ptt_event_get_cmd(ota_cmd_evt), + ptt_event_get_state(ota_cmd_evt)); + + ptt_event_set_cmd(new_rf_pkt_evt, evt_data->arr[PTT_CMD_CODE_START]); + + switch (ptt_event_get_state(ota_cmd_evt)) { + case CMD_OTA_STATE_PING_WAITING_FOR_ACK: + cmd_ping_ack(new_rf_pkt_evt); + break; + + case CMD_OTA_STATE_GET_POWER_WAITING_FOR_RSP: + cmd_get_power_response(new_rf_pkt_evt); + break; + + case CMD_OTA_STATE_END_RX_TEST_WAITING_FOR_REPORT: + cmd_end_rx_test_report(new_rf_pkt_evt); + break; + + case CMD_OTA_STATE_GET_HARDWARE_WAITING_FOR_RSP: + cmd_get_hardware_response(new_rf_pkt_evt); + break; + + case CMD_OTA_STATE_GET_SOFTWARE_WAITING_FOR_RSP: + cmd_get_software_response(new_rf_pkt_evt); + break; + + case CMD_OTA_STATE_GET_ANTENNA_WAITING_FOR_RSP: + cmd_get_antenna_response(new_rf_pkt_evt); + break; + + default: + PTT_TRACE("%s: inappropriate state cmd %d state %d\n", __func__, + ptt_event_get_cmd(ota_cmd_evt), + ptt_event_get_state(ota_cmd_evt)); + break; + } + } + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_ping(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_PING_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_PING); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_ping_timeout(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(true == cmd_is_ota_cmd_locked_by(timer_evt_id)); + + cmd_send_timeout_and_reset(); + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_ping_sent(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = ptt_timer_add(ptt_ctrl_get_rsp_timeout(), cmd_ping_timeout, ota_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_ota_cmd_state(CMD_OTA_STATE_PING_WAITING_FOR_ACK); + } else { + PTT_TRACE("%s: add_timer return error code: %d\n", __func__, ret); + cmd_send_timeout_and_reset(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_ping_ack(ptt_evt_id_t new_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_evt_id); + + if (ptt_event_get_cmd(new_evt_id) == PTT_CMD_ACK) { + ptt_timer_remove(ota_cmd_evt); + + uint8_t result = 1; + + cmd_fill_ctx_end_and_reset(&result, sizeof(result)); + } else { + PTT_TRACE("%s: command is not ACK\n", __func__); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_set_channel(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_SET_CHANNEL_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_SET_CHANNEL); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_set_power(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_SET_POWER_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_SET_POWER); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_get_power(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_GET_POWER_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_GET_POWER); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_get_power_timeout(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(true == cmd_is_ota_cmd_locked_by(timer_evt_id)); + + cmd_send_timeout_and_reset(); + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_get_power_sent(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = + ptt_timer_add(ptt_ctrl_get_rsp_timeout(), cmd_get_power_timeout, ota_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_ota_cmd_state(CMD_OTA_STATE_GET_POWER_WAITING_FOR_RSP); + } else { + PTT_TRACE("%s: add_timer return error code: %d\n", __func__, ret); + cmd_send_timeout_and_reset(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_get_power_response(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_rf_pkt_evt); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(new_rf_pkt_evt); + + assert(evt_data != NULL); + + if ((ptt_event_get_cmd(new_rf_pkt_evt) == PTT_CMD_GET_POWER_RESPONSE) && + ((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN + PTT_PAYLOAD_LEN_GET_POWER) == evt_data->len)) { + ptt_timer_remove(ota_cmd_evt); + + cmd_fill_ctx_end_and_reset(&evt_data->arr[PTT_PAYLOAD_START], + PTT_PAYLOAD_LEN_GET_POWER); + } else { + PTT_TRACE("%s: invalid length %d\n", __func__, evt_data->len); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_set_antenna(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_SET_ANTENNA_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_SET_ANTENNA); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_get_antenna(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_GET_ANTENNA_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_GET_ANTENNA); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_get_antenna_timeout(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(true == cmd_is_ota_cmd_locked_by(timer_evt_id)); + + cmd_send_timeout_and_reset(); + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_get_antenna_sent(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = + ptt_timer_add(ptt_ctrl_get_rsp_timeout(), cmd_get_antenna_timeout, ota_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_ota_cmd_state(CMD_OTA_STATE_GET_ANTENNA_WAITING_FOR_RSP); + } else { + PTT_TRACE("%s: add_timer return error code: %d\n", __func__, ret); + cmd_send_timeout_and_reset(); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static void cmd_get_antenna_response(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_rf_pkt_evt); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(new_rf_pkt_evt); + + assert(evt_data != NULL); + + if ((ptt_event_get_cmd(new_rf_pkt_evt) == PTT_CMD_GET_ANTENNA_RESPONSE) && + ((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN + PTT_PAYLOAD_LEN_GET_ANTENNA) == + evt_data->len)) { + ptt_timer_remove(ota_cmd_evt); + + cmd_fill_ctx_end_and_reset(&evt_data->arr[PTT_PAYLOAD_START], + PTT_PAYLOAD_LEN_GET_ANTENNA); + } else { + PTT_TRACE("%s: invalid length %d\n", __func__, evt_data->len); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_end_rx_test(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_END_RX_TEST_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_END_RX_TEST); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_end_rx_test_timeout(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(true == cmd_is_ota_cmd_locked_by(timer_evt_id)); + + cmd_send_timeout_and_reset(); + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_end_rx_test_sent(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = + ptt_timer_add(ptt_ctrl_get_rsp_timeout(), cmd_end_rx_test_timeout, ota_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_ota_cmd_state(CMD_OTA_STATE_END_RX_TEST_WAITING_FOR_REPORT); + } else { + PTT_TRACE("%s: add_timer return error code: %d\n", __func__, ret); + cmd_send_timeout_and_reset(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_end_rx_test_report(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_EXIT_WITH_VALUE(new_rf_pkt_evt); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(new_rf_pkt_evt); + + assert(evt_data != NULL); + + if ((ptt_event_get_cmd(new_rf_pkt_evt) == PTT_CMD_REPORT) && + ((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN + PTT_PAYLOAD_LEN_REPORT) == evt_data->len)) { + ptt_timer_remove(ota_cmd_evt); + + cmd_fill_ctx_end_and_reset(&evt_data->arr[PTT_PAYLOAD_START], + PTT_PAYLOAD_LEN_REPORT); + } else { + PTT_TRACE("%s: invalid length %d\n", __func__, evt_data->len); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_get_hardware_version(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_GET_HARDWARE_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_GET_HARDWARE_VERSION); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_get_hardware_timeout(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER(); + + assert(true == cmd_is_ota_cmd_locked_by(timer_evt_id)); + + cmd_send_timeout_and_reset(); + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_get_hardware_sent(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = + ptt_timer_add(ptt_ctrl_get_rsp_timeout(), cmd_get_hardware_timeout, ota_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_ota_cmd_state(CMD_OTA_STATE_GET_HARDWARE_WAITING_FOR_RSP); + } else { + PTT_TRACE("%s: add_timer return error code: %d\n", __func__, ret); + cmd_send_timeout_and_reset(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_get_hardware_response(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_rf_pkt_evt); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(new_rf_pkt_evt); + + assert(evt_data != NULL); + + if ((ptt_event_get_cmd(new_rf_pkt_evt) == PTT_CMD_GET_HARDWARE_VERSION_RESPONSE) && + ((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN + PTT_PAYLOAD_LEN_GET_HARDWARE) == + evt_data->len)) { + ptt_timer_remove(ota_cmd_evt); + + cmd_fill_ctx_end_and_reset(&evt_data->arr[PTT_PAYLOAD_START], + PTT_PAYLOAD_LEN_GET_HARDWARE); + } else { + PTT_TRACE("%s: invalid length %d\n", __func__, evt_data->len); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_get_software_version(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_GET_SOFTWARE_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_GET_SOFTWARE_VERSION); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_get_software_timeout(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(true == cmd_is_ota_cmd_locked_by(timer_evt_id)); + + cmd_send_timeout_and_reset(); + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_get_software_sent(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = + ptt_timer_add(ptt_ctrl_get_rsp_timeout(), cmd_get_software_timeout, ota_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_ota_cmd_state(CMD_OTA_STATE_GET_SOFTWARE_WAITING_FOR_RSP); + } else { + PTT_TRACE("%s: add_timer return error code: %d\n", __func__, ret); + cmd_send_timeout_and_reset(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_get_software_response(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_rf_pkt_evt); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(new_rf_pkt_evt); + + assert(evt_data != NULL); + + if ((ptt_event_get_cmd(new_rf_pkt_evt) == PTT_CMD_GET_SOFTWARE_VERSION_RESPONSE) && + ((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN + PTT_PAYLOAD_LEN_GET_SOFTWARE) == + evt_data->len)) { + ptt_timer_remove(ota_cmd_evt); + + cmd_fill_ctx_end_and_reset(&evt_data->arr[PTT_PAYLOAD_START], + PTT_PAYLOAD_LEN_GET_SOFTWARE); + } else { + PTT_TRACE("%s: invalid length %d\n", __func__, evt_data->len); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_stream(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_STREAM_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_STREAM); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_start_rx_test(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_ota_cmd_state(CMD_OTA_STATE_START_RX_TEST_SENDING); + enum ptt_ret ret = cmd_make_and_send_rf_packet(PTT_CMD_START_RX_TEST); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static inline void cmd_ota_cmd_lock(ptt_evt_id_t new_ota_cmd) +{ + assert(ota_cmd_evt == PTT_EVENT_UNASSIGNED); + + ota_cmd_evt = new_ota_cmd; +} + +static inline void cmd_change_ota_cmd_state(ptt_evt_state_t state) +{ + PTT_TRACE("%s: %d", __func__, state); + + ptt_event_set_state(ota_cmd_evt, state); +} + +static inline ptt_evt_id_t cmd_get_ota_cmd_and_reset(void) +{ + ptt_evt_id_t evt_id = ota_cmd_evt; + + cmd_ota_cmd_unlock(); + return evt_id; +} + +static void cmd_ota_cmd_unlock(void) +{ + ota_cmd_evt = PTT_EVENT_UNASSIGNED; +} + +static inline bool cmd_is_ota_cmd_locked(void) +{ + return (ota_cmd_evt == PTT_EVENT_UNASSIGNED) ? false : true; +} + +static inline bool cmd_is_ota_cmd_locked_by(ptt_evt_id_t evt_id) +{ + return (evt_id == ota_cmd_evt) ? true : false; +} + +static void cmd_fill_ctx_end_and_reset(const uint8_t *data, ptt_pkt_len_t len) +{ + ptt_event_set_ctx_data(ota_cmd_evt, data, len); + cmd_send_finish_and_reset(); +} + +static void cmd_send_finish_and_reset(void) +{ + ptt_evt_id_t evt_id = cmd_get_ota_cmd_and_reset(); + + cmt_uart_ota_cmd_finish_notify(evt_id); +} + +static void cmd_send_timeout_and_reset(void) +{ + ptt_evt_id_t evt_id = cmd_get_ota_cmd_and_reset(); + + cmt_uart_ota_cmd_timeout_notify(evt_id); +} + +static enum ptt_ret cmd_make_and_send_rf_packet(enum ptt_cmd cmd) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_data_s *evt_data = ptt_event_get_data(ota_cmd_evt); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(ota_cmd_evt); + + assert(ctx_data != NULL); + + evt_data->len = ptt_proto_construct_header(evt_data->arr, cmd, PTT_EVENT_DATA_SIZE); + + if (evt_data->len != (PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN)) { + ret = PTT_RET_INVALID_VALUE; + } else { + memcpy(&evt_data->arr[evt_data->len], ctx_data->arr, ctx_data->len); + evt_data->len += ctx_data->len; + + ret = ptt_rf_send_packet(ota_cmd_evt, evt_data->arr, evt_data->len); + } + + return ret; +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode_response.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode_response.c new file mode 100644 index 000000000000..ca0d20dee730 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode_response.c @@ -0,0 +1,475 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: UART response constructing for Zigbee RF Performance Test Plan CMD mode */ + +#include +#include +#include +#include + +#include "ctrl/ptt_trace.h" +#include "ctrl/ptt_uart.h" +#include "rf/ptt_rf.h" + +#include "ptt_proto.h" + +#include "ptt_ctrl_internal.h" +#include "ptt_events_internal.h" +#include "ptt_zb_perf_cmd_mode.h" + +#if defined(CMD_UART_UNIT_TEST) +#include "test_cmd_uart_conf.h" +#elif defined(CMD_RESPONSE_UNIT_TEST) +#include "test_cmd_response_conf.h" +#endif + +#define CMD_UART_BUF 320 + +static void cmd_uart_send_rf_packet_with_num(ptt_evt_id_t new_rf_pkt_evt, uint32_t packet_n); + +void cmd_uart_send_rsp_get_icache(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), PTT_GET_ICACHE_MES "%d", ctx_data->arr[0]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_get_dcdc(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), PTT_GET_DCDC_MES "%d", ctx_data->arr[0]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_get_temp(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), "%d", *(int32_t *)ctx_data->arr); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_antenna_error(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_GET_ANTENNA_ERROR_MES), + sizeof(PTT_GET_ANTENNA_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_antenna(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), PTT_GET_ANTENNA_MES "%d", ctx_data->arr[0]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +static void cmd_uart_send_rf_packet_with_num(ptt_evt_id_t new_rf_pkt_evt, uint32_t packet_n) +{ + struct ptt_evt_data_s *rf_evt_data = ptt_event_get_data(new_rf_pkt_evt); + + assert(rf_evt_data != NULL); + + struct ptt_evt_ctx_data_s *rf_ctx_data = ptt_event_get_ctx_data(new_rf_pkt_evt); + + assert(rf_ctx_data != NULL); + + char out_str[CMD_UART_BUF] = { 0 }; + struct ptt_rf_packet_info_s *pkt_info = (struct ptt_rf_packet_info_s *)(rf_ctx_data->arr); + + sprintf(out_str, "C:%d L:%d Data:", packet_n, rf_evt_data->len); + + uint16_t filled_length = strlen(out_str); + + /* we have each byte coded as two ASCII symbols */ + if ((rf_evt_data->len * 2) < (CMD_UART_BUF - filled_length)) { + for (int i = 0; i < rf_evt_data->len; ++i) { + uint8_t lst = rf_evt_data->arr[i] & 0x0F; + uint8_t mst = (rf_evt_data->arr[i] >> 4) & 0x0F; + + out_str[filled_length + 2 * i] = (mst >= 0xA) ? mst - 0xA + 'A' : mst + '0'; + out_str[filled_length + 2 * i + 1] = + (lst >= 0xA) ? lst - 0xA + 'A' : lst + '0'; + } + + /* let's use rf_evt_data as temporary buffer, as we copied everything from there */ + sprintf(PTT_CAST_TO_STR(rf_evt_data->arr), " CRC:1 LQI:0x%02x RSSI:%d", + pkt_info->lqi, pkt_info->rssi); + + /* concatenate everything together */ + if ((filled_length + rf_evt_data->len * 2 + + strlen(PTT_CAST_TO_STR(rf_evt_data->arr)) + sizeof('\0')) <= CMD_UART_BUF) { + strcat(out_str, PTT_CAST_TO_STR(rf_evt_data->arr)); + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(out_str), strlen(out_str)); + } else { + PTT_TRACE("%s: response string is too long\n", __func__); + } + } else { + PTT_TRACE("%s: there is not enough space to convert the array into ASCII\n", + __func__); + } +} + +void cmd_uart_send_rsp_ltx_ack(ptt_evt_id_t evt_id, uint32_t packet_n) +{ + cmd_uart_send_rf_packet_with_num(evt_id, packet_n); +} + +void cmd_uart_send_rsp_l_start_new_packet(ptt_evt_id_t new_rf_pkt_evt) +{ + struct ptt_rf_stat_s stat = ptt_rf_get_stat_report(); + + cmd_uart_send_rf_packet_with_num(new_rf_pkt_evt, stat.total_pkts); +} + +void cmd_uart_send_rsp_l_start_rx_fail(ptt_evt_id_t new_rf_pkt_evt) +{ + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(new_rf_pkt_evt); + + assert(ctx_data != NULL); + + ptt_rf_rx_error_t rx_error = *(ptt_rf_rx_error_t *)ctx_data->arr; + + if (rx_error == PTT_RF_RX_ERROR_INVALID_FCS) { + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_L_START_CRC_ERROR_MES), + sizeof(PTT_L_START_CRC_ERROR_MES) - 1); + } else { + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_L_START_ERROR_MES), + sizeof(PTT_L_START_ERROR_MES) - 1); + } +} + +void cmd_uart_send_rsp_l_end(ptt_evt_id_t evt_id, uint32_t proto_pkts) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_rf_stat_s stat = ptt_rf_get_stat_report(); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), "0x%08x 0x%08x 0x%08x 0x%08x", stat.total_pkts, + proto_pkts, stat.total_lqi, stat.total_rssi); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_lqi_failed(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_GET_LQI_ERROR_MES), + sizeof(PTT_GET_LQI_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_lqi_done(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + struct ptt_rf_packet_info_s *pkt_info = (struct ptt_rf_packet_info_s *)(ctx_data->arr); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), PTT_GET_LQI_SUCCESS_MES "0x%04x", pkt_info->lqi); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_ltx_failed(ptt_evt_id_t evt_id) +{ + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + ptt_rf_tx_error_t tx_error = *(ptt_rf_tx_error_t *)ctx_data->arr; + + switch (tx_error) { + case PTT_RF_TX_ERROR_INVALID_ACK_FCS: + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_L_TX_CRC_ERROR_MES), + sizeof(PTT_L_TX_CRC_ERROR_MES) - 1); + break; + + case PTT_RF_TX_ERROR_NO_ACK: + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_L_TX_NO_ACK_MES), + sizeof(PTT_L_TX_NO_ACK_MES) - 1); + break; + + default: + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_L_TX_ERROR_MES), + sizeof(PTT_L_TX_ERROR_MES) - 1); + break; + } +} + +void cmd_uart_send_rsp_rssi_done(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), PTT_GET_RSSI_SUCCESS_MES "%d", + *(ptt_rssi_t *)ctx_data->arr); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_rssi_failed(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_GET_RSSI_ERROR_MES), + sizeof(PTT_GET_RSSI_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_ed_detected(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), PTT_GET_ED_SUCCESS_MES "0x%04x", + *(ptt_ed_t *)ctx_data->arr); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_ed_failed(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_GET_ED_ERROR_MES), + sizeof(PTT_GET_ED_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_cca_done(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), PTT_GET_CCA_SUCCESS_MES "%d", + *(bool *)ctx_data->arr); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_cca_failed(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_GET_CCA_ERROR_MES), + sizeof(PTT_GET_CCA_ERROR_MES) - 1); +} + +void cmd_uart_send_rsack(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_PING_SUCCESS_MES), + sizeof(PTT_PING_SUCCESS_MES) - 1); +} + +void cmd_uart_send_rsp_no_ack(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_PING_ERROR_MES), + sizeof(PTT_PING_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_l_channel(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), "%d", ctx_data->arr[0]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_power_error(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_GET_POWER_ERROR_MES), + sizeof(PTT_GET_POWER_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_power(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + /* @todo: figure out where to find mode */ + uint16_t mode = 0xffff; + + sprintf(PTT_CAST_TO_STR(evt_data->arr), "0x%04x 0x%02x", mode, ctx_data->arr[0]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_rx_test_error(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_END_RX_TEST_ERROR_MES), + sizeof(PTT_END_RX_TEST_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_rx_test(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), + "0x%02x%02x%02x%02x 0x%02x%02x%02x%02x 0x%02x%02x%02x%02x 0x%02x%02x%02x%02x", + ctx_data->arr[0], ctx_data->arr[1], ctx_data->arr[2], ctx_data->arr[3], + ctx_data->arr[4], ctx_data->arr[5], ctx_data->arr[6], ctx_data->arr[7], + ctx_data->arr[8], ctx_data->arr[9], ctx_data->arr[10], ctx_data->arr[11], + ctx_data->arr[12], ctx_data->arr[13], ctx_data->arr[14], ctx_data->arr[15]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_hw_error(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_GET_HARDWARE_ERROR_MES), + sizeof(PTT_GET_HARDWARE_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_hw(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), "0x%02x", ctx_data->arr[0]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_sw_error(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_GET_SOFTWARE_ERROR_MES), + sizeof(PTT_GET_SOFTWARE_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_sw(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), "0x%02x", ctx_data->arr[0]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_find(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + uint32_t mask = ptt_betoh32_val(ctx_data->arr); + + uint8_t channel = ptt_rf_convert_channel_mask_to_num(mask); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), "channel %d find ack", channel); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_find_timeout(ptt_evt_id_t evt_id) +{ + ptt_uart_send_packet(PTT_CAST_TO_UINT8_P(PTT_FIND_ERROR_MES), + sizeof(PTT_FIND_ERROR_MES) - 1); +} + +void cmd_uart_send_rsp_l_get_gpio(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), "PIN %d: %d", ctx_data->arr[0], ctx_data->arr[1]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} + +void cmd_uart_send_rsp_l_get_gpio_error(ptt_evt_id_t evt_id) +{ + struct ptt_evt_data_s *evt_data = ptt_event_get_data(evt_id); + + assert(evt_data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(evt_id); + + assert(ctx_data != NULL); + + sprintf(PTT_CAST_TO_STR(evt_data->arr), "PIN %d: ERROR", ctx_data->arr[0]); + + ptt_uart_send_packet(evt_data->arr, strlen(PTT_CAST_TO_STR(evt_data->arr))); +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode_uart.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode_uart.c new file mode 100644 index 000000000000..39bd9bb32621 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_cmd_mode_uart.c @@ -0,0 +1,2736 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: UART processing of Zigbee RF Performance Test Plan CMD mode */ + +/* The module processes an event containing UART command. The event locks the module as + * currently processed UART command and the module rejects any other UART commands while + * processing the one. + * The module allocates event for OTA cmd, passes it to OTA cmd processing module, + * gets it back with result and then frees the event. + */ + +#include +#include +#include + +#include "ptt.h" + +#include "ctrl/ptt_trace.h" +#include "ctrl/ptt_uart.h" +#include "rf/ptt_rf.h" + +#include "ptt_proto.h" +#include "ptt_config.h" + +#include "ptt_ctrl_internal.h" +#include "ptt_events_internal.h" +#include "ptt_parser_internal.h" +#include "ptt_zb_perf_cmd_mode.h" + +#ifdef TESTS +#include "test_cmd_uart_conf.h" +#endif + +/** currently processed UART command */ +static ptt_evt_id_t uart_cmd_evt; + +/** @brief: Event for "custom lindicate" command + * + * Used as: + * 1. Event to arm timer; + * 2. Command state: validity of it value will tell is led indication currently active; + * 3. Storage: all command related information will be stored in it context. + */ +static ptt_evt_id_t led_indication_evt; + +static void cmd_uart_idle_packet_proc(void); + +static enum ptt_ret cmd_uart_call_ota_cmd(enum ptt_cmd cmd, const struct ptt_evt_ctx_data_s *ctx); + +static enum ptt_ret cmd_uart_parse_waveform_timings(const uint8_t *uart_cmd_payload, + int32_t *pulse_duration, int32_t *interval, + int32_t *duration_p); + +/* "find" command routines */ +static enum ptt_ret cmd_uart_find_idle(void); +static void cmd_uart_find_channel_was_set(void); +static void cmd_uart_find_delay(ptt_evt_id_t timer_evt_id); +static void cmd_uart_find_send_set_channel(void); +static void cmd_uart_find_process_finish(ptt_evt_id_t ota_cmd_evt); +static void cmd_uart_find_process_timeout(ptt_evt_id_t ota_cmd_evt); + +/* "setchannel" command routines */ +static enum ptt_ret cmd_uart_set_channel(void); +static void cmd_uart_set_channel_was_set(void); +static void cmd_uart_set_channel_delay(ptt_evt_id_t timer_evt_id); +static void cmd_uart_set_channel_process_timeout(ptt_evt_id_t ota_cmd_evt); +static void cmd_uart_set_channel_process_finish(ptt_evt_id_t ota_cmd_evt); +static enum ptt_ret cmd_uart_set_channel_payload_check(void); + +/* "lsetchannel" command routine */ +static enum ptt_ret cmd_uart_l_set_channel(void); + +/* "rsetchannel" command routine */ +static enum ptt_ret cmd_uart_r_set_channel(void); + +/* "lgetchannel" command routine */ +static enum ptt_ret cmd_uart_l_get_channel(void); + +/* "lsetpower" command routine */ +static enum ptt_ret cmd_uart_l_set_power(void); +static enum ptt_ret parse_power(const uint8_t *uart_cmd_payload, uint16_t *mode, int8_t *power_p); + +/* "lsetpanid" command routine */ +static enum ptt_ret cmd_uart_l_set_pan_id(void); + +/* "lsetextended" command routine */ +static enum ptt_ret cmd_uart_l_set_extended_address(void); + +/* "lsetshort" command routine */ +static enum ptt_ret cmd_uart_l_set_short_address(void); + +/* "lsetpayload" command routine */ +static enum ptt_ret cmd_uart_l_set_payload(void); + +/* "rsetpower" command routine */ +static enum ptt_ret cmd_uart_r_set_power(void); + +/* "lgetpower" command routine */ +static enum ptt_ret cmd_uart_l_get_power(void); + +/* "lpingtimeout" command routine */ +static enum ptt_ret cmd_uart_l_ping_timeout(void); + +/* "lgetcca" command routine*/ +static enum ptt_ret cmd_uart_l_get_cca(void); + +/* "lgeted" command routine*/ +static enum ptt_ret cmd_uart_l_get_ed(void); + +/* "lgetrssi" command routine */ +static enum ptt_ret cmd_uart_l_get_rssi(void); +static void cmd_uart_l_get_rssi_delay(ptt_evt_id_t timer_evt_id); + +/* "lstart" command routine */ +static enum ptt_ret cmd_uart_l_start(void); +static void cmd_uart_l_start_process_rf_packet(ptt_evt_id_t new_rf_pkt_evt); + +/* "lend" command routine */ +static void cmd_uart_l_end(ptt_evt_id_t new_uart_cmd); + +/* "lgetlqi" command routine */ +static enum ptt_ret cmd_uart_l_get_lqi(void); +static void cmd_uart_l_get_lqi_delay(ptt_evt_id_t timer_evt_id); +static void cmd_uart_l_get_lqi_process_rf_packet(ptt_evt_id_t new_rf_pkt_evt); + +/* "lsetantenna" command routine */ +static enum ptt_ret cmd_uart_l_set_antenna(void); + +/* "lgetantenna" command routine */ +static enum ptt_ret cmd_uart_l_get_antenna(void); + +/* "rsetantenna" command routine */ +static enum ptt_ret cmd_uart_r_set_antenna(void); + +/* "ltx" command routine */ +static enum ptt_ret cmd_uart_l_tx(void); +static void cmd_uart_l_tx_process_next_packet(void); +static void cmd_uart_l_tx_delay(ptt_evt_id_t timer_evt_id); +static void cmd_uart_l_tx_process_ack(ptt_evt_id_t evt_id); +static void cmd_uart_l_tx_finished(ptt_evt_id_t evt_id); +static void cmd_uart_l_tx_failed(ptt_evt_id_t evt_id); +static void cmd_uart_l_tx_end(ptt_evt_id_t new_uart_cmd); + +/* "lclk" command routine */ +static enum ptt_ret cmd_uart_l_clk(void); +static void cmd_uart_l_clk_stop(ptt_evt_id_t new_uart_cmd); + +/* "lsetgpio" command routine */ +static enum ptt_ret cmd_uart_l_set_gpio(void); + +/* "lgetgpio" command routine */ +static enum ptt_ret cmd_uart_l_get_gpio(void); + +/* "lcarrier" command routine */ +static enum ptt_ret cmd_uart_l_carrier(void); +static void cmd_uart_l_carrier_duration_delay(ptt_evt_id_t timer_evt_id); +static void cmd_uart_l_carrier_pulse_delay(ptt_evt_id_t timer_evt_id); +static void cmd_uart_l_carrier_interval_delay(ptt_evt_id_t timer_evt_id); + +/* "lstream" command routine */ +static enum ptt_ret cmd_uart_l_stream(void); +static void cmd_uart_l_stream_duration_delay(ptt_evt_id_t timer_evt_id); +static void cmd_uart_l_stream_pulse_delay(ptt_evt_id_t timer_evt_id); +static void cmd_uart_l_stream_interval_delay(ptt_evt_id_t timer_evt_id); +static enum ptt_ret cmd_uart_l_stream_start(void); + +/* "lsetdcdc" command routine */ +static enum ptt_ret cmd_uart_l_set_dcdc(void); + +/* "lgetdcdc" command routine */ +static enum ptt_ret cmd_uart_l_get_dcdc(void); + +/* "lseticache" command routine */ +static enum ptt_ret cmd_uart_l_set_icache(void); + +/* "lgeticache" command routine */ +static enum ptt_ret cmd_uart_l_get_icache(void); + +/* "lgettemp" command routine */ +static enum ptt_ret cmd_uart_l_get_temp(void); + +/* "lindication" command routine */ +static enum ptt_ret cmd_uart_l_indication(void); +static void cmd_uart_l_indication_off(ptt_evt_id_t evt_id); + +void cmd_uart_l_indication_proc(void); + +/* "lsleep" command routine */ +static enum ptt_ret cmd_uart_l_sleep(void); + +/* "lreceive" command routine */ +static enum ptt_ret cmd_uart_l_receive(void); + +/* UART command lock routines */ +static inline void cmd_uart_cmd_lock(ptt_evt_id_t new_uart_cmd); +static inline void cmd_change_uart_cmd_state(ptt_evt_state_t state); +static inline bool cmd_is_uart_cmd_locked(void); +static inline bool cmd_is_uart_cmd_locked_by(ptt_evt_id_t evt_id); +static void cmd_uart_cmd_unlock(void); + +#ifdef TESTS +#include "test_cmd_uart_wrappers.c" +#endif + +void cmd_uart_cmd_init(void) +{ + uart_cmd_evt = PTT_EVENT_UNASSIGNED; + led_indication_evt = PTT_EVENT_UNASSIGNED; +} + +void cmd_uart_cmd_uninit(void) +{ + cmd_uart_cmd_unlock(); + led_indication_evt = PTT_EVENT_UNASSIGNED; +} + +void cmd_rf_cca_done(ptt_evt_id_t evt_id) +{ + assert(cmd_is_uart_cmd_locked_by(evt_id)); + + cmd_uart_send_rsp_cca_done(evt_id); + cmd_uart_cmd_unlock(); +} + +void cmd_rf_cca_failed(ptt_evt_id_t evt_id) +{ + assert(cmd_is_uart_cmd_locked_by(evt_id)); + + cmd_uart_send_rsp_cca_failed(evt_id); + cmd_uart_cmd_unlock(); +} + +void cmd_rf_ed_detected(ptt_evt_id_t evt_id) +{ + assert(cmd_is_uart_cmd_locked_by(evt_id)); + + cmd_uart_send_rsp_ed_detected(evt_id); + cmd_uart_cmd_unlock(); +} + +void cmd_rf_ed_failed(ptt_evt_id_t evt_id) +{ + assert(cmd_is_uart_cmd_locked_by(evt_id)); + + cmd_uart_send_rsp_ed_failed(evt_id); + cmd_uart_cmd_unlock(); +} + +void cmd_uart_pkt_received(ptt_evt_id_t new_uart_cmd) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_uart_cmd); + + if (false == cmd_is_uart_cmd_locked()) { + /* store UART command as currently processed */ + cmd_uart_cmd_lock(new_uart_cmd); + cmd_uart_idle_packet_proc(); + } else { + switch (ptt_event_get_state(uart_cmd_evt)) { + case CMD_UART_STATE_WAITING_FOR_LEND: + cmd_uart_l_end(new_uart_cmd); + ptt_event_free(new_uart_cmd); + break; + + case CMD_UART_STATE_L_CLK_OUT: + cmd_uart_l_clk_stop(new_uart_cmd); + ptt_event_free(new_uart_cmd); + break; + + case CMD_UART_STATE_LTX_WAITING_FOR_ACK: + case CMD_UART_STATE_LTX: + cmd_uart_l_tx_end(new_uart_cmd); + ptt_event_free(new_uart_cmd); + break; + + default: + PTT_TRACE("%s: state isn't idle cmd %d state %d\n", __func__, + ptt_event_get_cmd(uart_cmd_evt), + ptt_event_get_state(uart_cmd_evt)); + ptt_event_free(new_uart_cmd); + break; + } + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_idle_packet_proc(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + enum ptt_uart_cmd uart_cmd = ptt_event_get_cmd(uart_cmd_evt); + + PTT_TRACE("%s: cmd %d\n", __func__, uart_cmd); + + /* handlers are responsible for cleaning current event */ + switch (uart_cmd) { + case PTT_UART_CMD_R_PING: + ret = cmd_uart_call_ota_cmd(PTT_CMD_PING, NULL); + break; + + case PTT_UART_CMD_L_PING_TIMEOUT: + ret = cmd_uart_l_ping_timeout(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_SETCHANNEL: + ret = cmd_uart_set_channel(); + break; + + case PTT_UART_CMD_L_SETCHANNEL: + ret = cmd_uart_l_set_channel(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_SETCHANNEL: + ret = cmd_uart_r_set_channel(); + break; + + case PTT_UART_CMD_L_GET_CHANNEL: + ret = cmd_uart_l_get_channel(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_SET_POWER: + ret = cmd_uart_l_set_power(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_SET_POWER: + ret = cmd_uart_r_set_power(); + break; + + case PTT_UART_CMD_L_GET_POWER: + ret = cmd_uart_l_get_power(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_GET_POWER: + ret = cmd_uart_call_ota_cmd(PTT_CMD_GET_POWER, NULL); + break; + + case PTT_UART_CMD_R_STREAM: + ret = cmd_uart_call_ota_cmd(PTT_CMD_STREAM, ptt_event_get_ctx_data(uart_cmd_evt)); + break; + + case PTT_UART_CMD_R_START: + ret = cmd_uart_call_ota_cmd(PTT_CMD_START_RX_TEST, NULL); + break; + + case PTT_UART_CMD_R_END: + ret = cmd_uart_call_ota_cmd(PTT_CMD_END_RX_TEST, NULL); + break; + + case PTT_UART_CMD_L_REBOOT: + ptt_do_reset_ext(); + /* there is no return from function above */ + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_FIND: + ret = cmd_uart_find_idle(); + break; + + case PTT_UART_CMD_R_HW_VERSION: + ret = cmd_uart_call_ota_cmd(PTT_CMD_GET_HARDWARE_VERSION, NULL); + break; + + case PTT_UART_CMD_R_SW_VERSION: + ret = cmd_uart_call_ota_cmd(PTT_CMD_GET_SOFTWARE_VERSION, NULL); + break; + + case PTT_UART_CMD_L_GET_CCA: + ret = cmd_uart_l_get_cca(); + break; + + case PTT_UART_CMD_L_GET_ED: + ret = cmd_uart_l_get_ed(); + break; + + case PTT_UART_CMD_L_GET_RSSI: + ret = cmd_uart_l_get_rssi(); + break; + + case PTT_UART_CMD_L_SET_PAN_ID: + ret = cmd_uart_l_set_pan_id(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_SET_EXTENDED: + ret = cmd_uart_l_set_extended_address(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_SET_SHORT: + ret = cmd_uart_l_set_short_address(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_SET_PAYLOAD: + ret = cmd_uart_l_set_payload(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_START: + ret = cmd_uart_l_start(); + break; + + case PTT_UART_CMD_L_GET_LQI: + ret = cmd_uart_l_get_lqi(); + break; + + case PTT_UART_CMD_L_SET_ANTENNA: + ret = cmd_uart_l_set_antenna(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_GET_ANTENNA: + ret = cmd_uart_l_get_antenna(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_SET_ANTENNA: + ret = cmd_uart_r_set_antenna(); + break; + + case PTT_UART_CMD_R_GET_ANTENNA: + ret = cmd_uart_call_ota_cmd(PTT_CMD_GET_ANTENNA, NULL); + break; + + case PTT_UART_CMD_L_TX: + ret = cmd_uart_l_tx(); + break; + + case PTT_UART_CMD_L_CLK: + ret = cmd_uart_l_clk(); + break; + + case PTT_UART_CMD_L_SET_GPIO: + ret = cmd_uart_l_set_gpio(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_GET_GPIO: + ret = cmd_uart_l_get_gpio(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_CARRIER: + ret = cmd_uart_l_carrier(); + break; + + case PTT_UART_CMD_L_STREAM: + ret = cmd_uart_l_stream(); + break; + + case PTT_UART_CMD_L_SET_DCDC: + ret = cmd_uart_l_set_dcdc(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_GET_DCDC: + ret = cmd_uart_l_get_dcdc(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_SET_ICACHE: + ret = cmd_uart_l_set_icache(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_GET_ICACHE: + ret = cmd_uart_l_get_icache(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_GET_TEMP: + ret = cmd_uart_l_get_temp(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_INDICATION: + ret = cmd_uart_l_indication(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_SLEEP: + ret = cmd_uart_l_sleep(); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_L_RECEIVE: + ret = cmd_uart_l_receive(); + cmd_uart_cmd_unlock(); + break; + + default: + PTT_TRACE("%s: unknown command cmd %d\n ignored", __func__, uart_cmd); + cmd_uart_cmd_unlock(); + break; + } + + if (ret != PTT_RET_SUCCESS) { + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +void cmt_uart_ota_cmd_timeout_notify(ptt_evt_id_t ota_cmd_evt) +{ + PTT_TRACE("%s: cmd %d state %d\n", __func__, ptt_event_get_cmd(uart_cmd_evt), + ptt_event_get_state(uart_cmd_evt)); + + enum ptt_uart_cmd uart_cmd = ptt_event_get_cmd(uart_cmd_evt); + + switch (uart_cmd) { + case PTT_UART_CMD_R_PING: + cmd_uart_send_rsp_no_ack(uart_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_CMD_SET_CHANNEL: + cmd_uart_set_channel_process_timeout(ota_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_SETCHANNEL: + case PTT_UART_CMD_R_SET_POWER: + case PTT_UART_CMD_R_STREAM: + case PTT_UART_CMD_R_START: + case PTT_UART_CMD_R_SET_ANTENNA: + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_GET_POWER: + cmd_uart_send_rsp_power_error(ota_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_END: + cmd_uart_send_rsp_rx_test_error(uart_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_FIND: + cmd_uart_find_process_timeout(ota_cmd_evt); + break; + + case PTT_UART_CMD_R_HW_VERSION: + cmd_uart_send_rsp_hw_error(uart_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_SW_VERSION: + cmd_uart_send_rsp_sw_error(uart_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_GET_ANTENNA: + cmd_uart_send_rsp_antenna_error(ota_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + default: + PTT_TRACE("%s: unexpected notify ignored\n", __func__); + cmd_uart_cmd_unlock(); + break; + } + + /* it's final destination for event allocated inside call_ota_cmd */ + ptt_event_free(ota_cmd_evt); + + PTT_TRACE_FUNC_EXIT(); +} + +/* ota_cmd result inside ota_cmd_evt data context */ +void cmt_uart_ota_cmd_finish_notify(ptt_evt_id_t ota_cmd_evt) +{ + PTT_TRACE("%s: cmd %d state %d\n", __func__, ptt_event_get_cmd(uart_cmd_evt), + ptt_event_get_state(uart_cmd_evt)); + + enum ptt_uart_cmd uart_cmd = ptt_event_get_cmd(uart_cmd_evt); + + switch (uart_cmd) { + case PTT_UART_CMD_R_PING: + cmd_uart_send_rsack(uart_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_SETCHANNEL: + cmd_uart_set_channel_process_finish(ota_cmd_evt); + break; + + case PTT_UART_CMD_R_SETCHANNEL: + case PTT_UART_CMD_R_SET_POWER: + case PTT_UART_CMD_R_STREAM: + case PTT_UART_CMD_R_START: + case PTT_UART_CMD_R_SET_ANTENNA: + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_GET_POWER: + cmd_uart_send_rsp_power(ota_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_END: + cmd_uart_send_rsp_rx_test(ota_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_FIND: + cmd_uart_find_process_finish(ota_cmd_evt); + break; + + case PTT_UART_CMD_R_HW_VERSION: + cmd_uart_send_rsp_hw(ota_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_SW_VERSION: + cmd_uart_send_rsp_sw(ota_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + case PTT_UART_CMD_R_GET_ANTENNA: + cmd_uart_send_rsp_antenna(ota_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + default: + PTT_TRACE("%s: unexpected notify ignored\n", __func__); + cmd_uart_cmd_unlock(); + break; + } + + /* it's final destination for event allocated inside call_ota_cmd */ + ptt_event_free(ota_cmd_evt); + + PTT_TRACE_FUNC_EXIT(); +} + +void cmd_rf_rx_done(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_rf_pkt_evt); + + if (false == cmd_is_uart_cmd_locked()) { + cmd_ota_rf_rx_done(new_rf_pkt_evt); + PTT_TRACE("%s: pass event to OTA module\n", __func__); + } else { + ptt_evt_state_t state = ptt_event_get_state(uart_cmd_evt); + + switch (state) { + case CMD_UART_STATE_LTX_WAITING_FOR_ACK: + cmd_uart_l_tx_process_ack(new_rf_pkt_evt); + break; + + case CMD_UART_STATE_WAITING_FOR_LEND: + cmd_uart_l_start_process_rf_packet(new_rf_pkt_evt); + break; + + case CMD_UART_STATE_WAITING_FOR_RF_PACKET: + cmd_uart_l_get_lqi_process_rf_packet(new_rf_pkt_evt); + break; + + default: + cmd_ota_rf_rx_done(new_rf_pkt_evt); + PTT_TRACE("%s: pass event to OTA module\n", __func__); + } + } + + cmd_uart_l_indication_proc(); + + ptt_event_free(new_rf_pkt_evt); + PTT_TRACE_FUNC_EXIT(); +} + +void cmd_rf_rx_failed(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_rf_pkt_evt); + + if (true == cmd_is_uart_cmd_locked()) { + ptt_evt_state_t state = ptt_event_get_state(uart_cmd_evt); + + switch (state) { + case CMD_UART_STATE_WAITING_FOR_LEND: + cmd_uart_send_rsp_l_start_rx_fail(new_rf_pkt_evt); + break; + + default: + PTT_TRACE("%s: unexpected event for current state\n", __func__); + break; + } + } + + ptt_event_free(new_rf_pkt_evt); + PTT_TRACE_FUNC_EXIT(); +} + +void cmd_rf_tx_finished(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + if (false == cmd_is_uart_cmd_locked()) { + PTT_TRACE("%s: passing evt to ota module\n", __func__); + cmd_ota_rf_tx_finished(evt_id); + } else { + ptt_evt_state_t state = ptt_event_get_state(uart_cmd_evt); + + switch (state) { + case CMD_UART_STATE_LTX_WAITING_FOR_ACK: + cmd_uart_l_tx_finished(evt_id); + break; + + default: + PTT_TRACE("%s: passing evt to ota module\n", __func__); + cmd_ota_rf_tx_finished(evt_id); + break; + } + } + + PTT_TRACE_FUNC_EXIT(); +} + +void cmd_rf_tx_failed(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + if (false == cmd_is_uart_cmd_locked()) { + PTT_TRACE("%s: passing evt to ota module\n", __func__); + cmd_ota_rf_tx_failed(evt_id); + } else { + ptt_evt_state_t state = ptt_event_get_state(uart_cmd_evt); + + switch (state) { + case CMD_UART_STATE_LTX_WAITING_FOR_ACK: + cmd_uart_l_tx_failed(evt_id); + break; + + default: + PTT_TRACE("%s: passing evt to ota module\n", __func__); + cmd_ota_rf_tx_failed(evt_id); + break; + } + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_uart_l_ping_timeout(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + /* by protocol, timeout consists from two bytes */ + uint16_t timeout = ptt_betoh16_val(ctx_data->arr); + + ptt_ctrl_set_rsp_timeout(timeout); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret cmd_uart_set_channel_payload_check(void) +{ + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint32_t mask = ptt_betoh32_val(ctx_data->arr); + enum ptt_ret ret = PTT_RET_SUCCESS; + + if ((mask < (1u << PTT_CHANNEL_MIN)) || (mask > (1u << PTT_CHANNEL_MAX)) || + (!(mask && !(mask & (mask - 1))))) { + /* check that more that one bit is set*/ + ret = PTT_RET_INVALID_VALUE; + } + + return ret; +} + +static enum ptt_ret cmd_uart_set_channel(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = cmd_uart_set_channel_payload_check(); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_uart_cmd_state(CMD_UART_STATE_SET_CHANNEL); + + ret = cmd_uart_call_ota_cmd(PTT_CMD_SET_CHANNEL, + ptt_event_get_ctx_data(uart_cmd_evt)); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static void cmd_uart_set_channel_was_set(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint32_t mask = ptt_betoh32_val(ctx_data->arr); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + /* set channel to CMD */ + ret = ptt_rf_set_channel_mask(uart_cmd_evt, mask); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_uart_cmd_state(CMD_UART_STATE_WAIT_DELAY); + ret = ptt_timer_add(ptt_ctrl_get_rsp_timeout(), cmd_uart_set_channel_delay, + uart_cmd_evt); + } + + if (ret != PTT_RET_SUCCESS) { + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static void cmd_uart_set_channel_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(true == cmd_is_uart_cmd_locked_by(timer_evt_id)); + + cmd_change_uart_cmd_state(CMD_UART_STATE_PING); + enum ptt_ret ret = cmd_uart_call_ota_cmd(PTT_CMD_PING, NULL); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: cmd_uart_call_ota_cmd returns error code: %d\n", __func__, ret); + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_set_channel_process_timeout(ptt_evt_id_t ota_cmd_evt) +{ + PTT_TRACE_FUNC_ENTER(); + + enum cmd_uart_state_t state = ptt_event_get_state(uart_cmd_evt); + + PTT_TRACE("%s: state %d\n", __func__, state); + + switch (state) { + case CMD_UART_STATE_PING: + cmd_uart_send_rsp_no_ack(uart_cmd_evt); + break; + + default: + PTT_TRACE("%s: unexpected timeout\n", __func__); + break; + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_set_channel_process_finish(ptt_evt_id_t ota_cmd_evt) +{ + PTT_TRACE_FUNC_ENTER(); + + enum cmd_uart_state_t state = ptt_event_get_state(uart_cmd_evt); + + PTT_TRACE("%s state %d\n", __func__, state); + + switch (state) { + case CMD_UART_STATE_SET_CHANNEL: + cmd_uart_set_channel_was_set(); + break; + + case CMD_UART_STATE_PING: + /* uart_cmd_evt data ctx has current channel */ + cmd_uart_send_rsack(uart_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + default: + PTT_TRACE("%s: unexpected finish\n", __func__); + cmd_uart_cmd_unlock(); + break; + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_uart_l_set_channel(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = cmd_uart_set_channel_payload_check(); + + if (ret == PTT_RET_SUCCESS) { + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint32_t mask = ptt_betoh32_val(ctx_data->arr); + + /* set channel to CMD */ + ret = ptt_rf_set_channel_mask(uart_cmd_evt, mask); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret cmd_uart_r_set_channel(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_uart_cmd_state(CMD_UART_STATE_SET_CHANNEL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t channel = ctx_data->arr[0]; + enum ptt_ret ret = PTT_RET_SUCCESS; + + if ((channel < PTT_CHANNEL_MIN) || (channel > PTT_CHANNEL_MAX)) { + ret = PTT_RET_INVALID_VALUE; + } else { + uint32_t mask = 1u << channel; + + ptt_htobe32((uint8_t *)(&mask), ctx_data->arr); + ctx_data->len = sizeof(mask); + + ret = cmd_uart_call_ota_cmd(PTT_CMD_SET_CHANNEL, + ptt_event_get_ctx_data(uart_cmd_evt)); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret cmd_uart_l_get_channel(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + ctx_data->arr[0] = ptt_rf_get_channel(); + ctx_data->len = 1; + + cmd_uart_send_rsp_l_channel(uart_cmd_evt); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret parse_power(const uint8_t *uart_cmd_payload, uint16_t *mode_p, int8_t *power_p) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + uint16_t mode; + uint8_t *p = (uint8_t *)&mode; + int8_t power; + + do { + if ((uart_cmd_payload == NULL) || (mode_p == NULL) || (power_p == NULL)) { + ret = PTT_RET_INVALID_VALUE; + break; + } + static char *save; + char *token_str = strtok_r(PTT_CAST_TO_STR(uart_cmd_payload), + UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if (token_str == NULL) { + ret = PTT_RET_INVALID_VALUE; + break; + } + ret = ptt_parser_string_to_uint8(token_str, &p[0], 0); + + if (ret == PTT_RET_SUCCESS) { + token_str = strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if (token_str == NULL) { + ret = PTT_RET_INVALID_VALUE; + break; + } + ret = ptt_parser_string_to_uint8(token_str, &p[1], 0); + + if (ret == PTT_RET_SUCCESS) { + token_str = strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if ((token_str == NULL) || + (strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save) != NULL)) { + ret = PTT_RET_INVALID_VALUE; + } else { + ret = ptt_parser_string_to_int8(token_str, &power, 10); + } + } + } + } while (false); + + if (ret == PTT_RET_SUCCESS) { + ptt_betoh16(p, (uint8_t *)mode_p); + *power_p = power; + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret cmd_uart_l_set_power(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_data_s *data = ptt_event_get_data(uart_cmd_evt); + uint16_t mode; + int8_t power; + + assert(data != NULL); + + uint8_t *uart_cmd_payload = data->arr + sizeof(UART_CMD_L_SET_POWER_TEXT); + + ret = parse_power(uart_cmd_payload, &mode, &power); + + if (ret == PTT_RET_SUCCESS) { + /* @todo: handle mode */ + /* set power to CMD */ + ret = ptt_rf_set_power(uart_cmd_evt, power); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret cmd_uart_r_set_power(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_data_s *data = ptt_event_get_data(uart_cmd_evt); + uint16_t mode; + int8_t power; + + assert(ctx_data != NULL); + + assert(data != NULL); + + uint8_t *uart_cmd_payload = data->arr + sizeof(UART_CMD_R_SET_POWER_TEXT); + + ret = parse_power(uart_cmd_payload, &mode, &power); + + if (ret == PTT_RET_SUCCESS) { + /* @todo: handle mode */ + ctx_data->arr[0] = (uint8_t)power; + ctx_data->len = sizeof(power); + + ret = cmd_uart_call_ota_cmd(PTT_CMD_SET_POWER, + ptt_event_get_ctx_data(uart_cmd_evt)); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret cmd_uart_l_get_power(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + ctx_data->arr[0] = (uint8_t)ptt_rf_get_power(); + ctx_data->len = 1; + + cmd_uart_send_rsp_power(uart_cmd_evt); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret cmd_uart_l_get_cca(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + if (ctx_data->len == 0) { + cmd_uart_send_rsp_cca_failed(uart_cmd_evt); + ret = PTT_RET_INVALID_VALUE; + } else { + ret = ptt_rf_cca(uart_cmd_evt, ctx_data->arr[0]); + } + + if (ret != PTT_RET_SUCCESS) { + cmd_uart_send_rsp_cca_failed(uart_cmd_evt); + } + + PTT_TRACE_FUNC_EXIT(); + return ret; +} + +static enum ptt_ret cmd_uart_l_get_ed(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + ret = ptt_rf_ed(uart_cmd_evt, PTT_ED_TIME_US); + + if (ret != PTT_RET_SUCCESS) { + cmd_uart_send_rsp_ed_failed(uart_cmd_evt); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_get_rssi(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = ptt_rf_rssi_measure_begin(uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_uart_cmd_state(CMD_UART_STATE_WAIT_DELAY); + ret = ptt_timer_add(PTT_RSSI_TIME_MS, cmd_uart_l_get_rssi_delay, uart_cmd_evt); + } + + if (ret != PTT_RET_SUCCESS) { + cmd_uart_send_rsp_rssi_failed(uart_cmd_evt); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_uart_l_get_rssi_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(true == cmd_is_uart_cmd_locked_by(timer_evt_id)); + + ptt_rssi_t rssi; + enum ptt_ret ret = ptt_rf_rssi_last_get(timer_evt_id, &rssi); + + if ((ret == PTT_RET_SUCCESS) && (rssi != PTT_RSSI_ERROR_VALUE)) { + ptt_event_set_ctx_data(timer_evt_id, PTT_CAST_TO_UINT8_P(&rssi), sizeof(rssi)); + + cmd_uart_send_rsp_rssi_done(timer_evt_id); + } else { + cmd_uart_send_rsp_rssi_failed(timer_evt_id); + } + + cmd_uart_cmd_unlock(); + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static enum ptt_ret cmd_uart_l_set_pan_id(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + uint8_t pan_id[PTT_PANID_ADDRESS_SIZE]; + uint8_t pan_id_le[PTT_PANID_ADDRESS_SIZE]; + struct ptt_evt_data_s *data = ptt_event_get_data(uart_cmd_evt); + + assert(data != NULL); + + uint8_t *payload = data->arr + sizeof(UART_CMD_L_SET_PAN_ID_TEXT); + + static char *save; + char *id_str = strtok_r(PTT_CAST_TO_STR(payload), UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if ((id_str == NULL) || (strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save) != NULL)) { + /* lets be sure that there are no extra parameters */ + ret = PTT_RET_INVALID_VALUE; + } else { + /* to pass only 0xYYYY type of values */ + if ((strlen(id_str) == UART_SET_PAN_ID_SYM_NUM) && (id_str[0] == '0') && + (id_str[1] == 'x')) { + ret = ptt_parser_string_to_uint16(id_str, (uint16_t *)pan_id, 16); + + if (ret == PTT_RET_SUCCESS) { + /* parser will return host endian number, + * we need to be sure than it is little endian + */ + ptt_htole16(pan_id, pan_id_le); + + ret = ptt_rf_set_pan_id(uart_cmd_evt, pan_id_le); + } + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_set_extended_address(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + uint8_t extended_addr[PTT_EXTENDED_ADDRESS_SIZE] = { 0 }; + uint8_t extended_addr_le[PTT_EXTENDED_ADDRESS_SIZE] = { 0 }; + struct ptt_evt_data_s *data = ptt_event_get_data(uart_cmd_evt); + + assert(data != NULL); + + uint8_t *payload = data->arr + sizeof(UART_CMD_L_SET_EXTENDED_TEXT); + + static char *save; + char *addr_str = strtok_r(PTT_CAST_TO_STR(payload), UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if ((addr_str == NULL) || (strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save) != NULL)) { + /* lets be sure that there are no extra parameters */ + ret = PTT_RET_INVALID_VALUE; + } else { + /* to pass only 0xYYYYYYYYYYYYYYYY type of values */ + if ((strlen(addr_str) == UART_SET_EXTENDED_SYM_NUM) && (addr_str[0] == '0') && + (addr_str[1] == 'x')) { + uint8_t written_len = 0; + + ret = ptt_parser_hex_string_to_uint8_array( + addr_str, extended_addr, + ARRAY_SIZE(extended_addr), &written_len); + + if (written_len != PTT_EXTENDED_ADDRESS_SIZE) { + ret = PTT_RET_INVALID_VALUE; + } + if (ret == PTT_RET_SUCCESS) { + /* parser works only with bytes, + * so endianness is unchanged => it is big endian + */ + /* converting big endian address to little endian */ + for (uint8_t i = 0; i < PTT_EXTENDED_ADDRESS_SIZE; i++) { + extended_addr_le[i] = + extended_addr[PTT_EXTENDED_ADDRESS_SIZE - 1 - i]; + } + + ret = ptt_rf_set_extended_address(uart_cmd_evt, extended_addr_le); + } + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_set_short_address(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + uint8_t short_addr[PTT_SHORT_ADDRESS_SIZE]; + uint8_t short_addr_le[PTT_SHORT_ADDRESS_SIZE]; + struct ptt_evt_data_s *data = ptt_event_get_data(uart_cmd_evt); + + assert(data != NULL); + + uint8_t *payload = data->arr + sizeof(UART_CMD_L_SET_SHORT_TEXT); + + static char *save; + char *addr_str = strtok_r(PTT_CAST_TO_STR(payload), UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if ((addr_str == NULL) || (strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save) != NULL)) { + /* lets be sure that there are no extra parameters */ + ret = PTT_RET_INVALID_VALUE; + } else { + /* to pass only 0xYYYY type of values */ + if ((strlen(addr_str) == UART_SET_SHORT_SYM_NUM) && (addr_str[0] == '0') && + (addr_str[1] == 'x')) { + ret = ptt_parser_string_to_uint16(addr_str, (uint16_t *)short_addr, 16); + + if (ret == PTT_RET_SUCCESS) { + /* parser will return host endian number, + * we need to be sure than it is little endian + */ + ptt_htole16(short_addr, short_addr_le); + + ret = ptt_rf_set_short_address(uart_cmd_evt, short_addr_le); + } + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_set_payload(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_data_s *data = ptt_event_get_data(uart_cmd_evt); + uint8_t payload[PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE] = { 0 }; + + assert(data != NULL); + + uint8_t *uart_cmd_payload = data->arr + sizeof(UART_CMD_L_SET_PAYLOAD_TEXT); + + static char *save; + char *token_str = + strtok_r(PTT_CAST_TO_STR(uart_cmd_payload), UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if (token_str == NULL) { + ret = PTT_RET_INVALID_VALUE; + } else { + uint8_t payload_len; + + ret = ptt_parser_string_to_uint8(token_str, &payload_len, 0); + + if (ret == PTT_RET_SUCCESS) { + struct ptt_ltx_payload_s *ltx_payload; + + ltx_payload = ptt_rf_get_custom_ltx_payload(); + + assert(ltx_payload != NULL); + + token_str = strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if ((token_str == NULL) || + (strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save) != NULL)) { + /* lets be sure that there are no extra parameters */ + ret = PTT_RET_INVALID_VALUE; + } else { + uint8_t actual_len; + + ret = ptt_parser_hex_string_to_uint8_array( + token_str, payload, PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE, + &actual_len); + if (actual_len != payload_len) { + ret = PTT_RET_INVALID_VALUE; + } + + if (ret == PTT_RET_SUCCESS) { + ltx_payload->len = actual_len; + memcpy(ltx_payload->arr, payload, ltx_payload->len); + } + } + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_start(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = ptt_rf_start_statistic(uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + /* we will store counter for protocol packets in context. + * Lets erase it just in case + */ + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint32_t *proto_pkts = (uint32_t *)ctx_data->arr; + + *proto_pkts = 0; + + cmd_change_uart_cmd_state(CMD_UART_STATE_WAITING_FOR_LEND); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_uart_l_start_process_rf_packet(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_rf_pkt_evt); + + struct ptt_evt_data_s *rf_data = ptt_event_get_data(new_rf_pkt_evt); + + assert(rf_data != NULL); + + if (ptt_proto_check_packet(rf_data->arr, rf_data->len)) { + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint32_t *proto_pkts = (uint32_t *)ctx_data->arr; + + ++(*proto_pkts); + } + + cmd_uart_send_rsp_l_start_new_packet(new_rf_pkt_evt); + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_l_end(ptt_evt_id_t new_uart_cmd) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_uart_cmd uart_cmd = ptt_event_get_cmd(new_uart_cmd); + + if (uart_cmd == PTT_UART_CMD_L_END) { + enum ptt_ret ret = ptt_rf_end_statistic(uart_cmd_evt); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: ptt_rf_end_statistic returns %d", __func__, ret); + } else { + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint32_t *proto_pkts = (uint32_t *)ctx_data->arr; + + cmd_uart_send_rsp_l_end(new_uart_cmd, *proto_pkts); + } + + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_uart_l_get_lqi(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + ret = ptt_timer_add(PTT_LQI_DELAY_MS, cmd_uart_l_get_lqi_delay, uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_uart_cmd_state(CMD_UART_STATE_WAITING_FOR_RF_PACKET); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_uart_l_get_lqi_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(true == cmd_is_uart_cmd_locked_by(timer_evt_id)); + + cmd_uart_send_rsp_lqi_failed(timer_evt_id); + + cmd_uart_cmd_unlock(); + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_l_get_lqi_process_rf_packet(ptt_evt_id_t new_rf_pkt_evt) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_rf_pkt_evt); + + ptt_timer_remove(uart_cmd_evt); + cmd_uart_send_rsp_lqi_done(new_rf_pkt_evt); + + cmd_uart_cmd_unlock(); + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_uart_l_set_antenna(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t antenna = ctx_data->arr[0]; + + enum ptt_ret ret = ptt_rf_set_antenna(uart_cmd_evt, antenna); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_set_dcdc(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + enum ptt_ret ret = PTT_RET_SUCCESS; + uint8_t activate = ctx_data->arr[0]; + + if ((activate == 0) || (activate == 1)) { + ptt_ctrl_set_dcdc(activate); + } else { + ret = PTT_RET_INVALID_VALUE; + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_get_dcdc(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + bool dcdc_active = ptt_ctrl_get_dcdc(); + + ctx_data->arr[0] = dcdc_active; + ctx_data->len = sizeof(dcdc_active); + + cmd_uart_send_rsp_get_dcdc(uart_cmd_evt); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_set_icache(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t enable = ctx_data->arr[0]; + enum ptt_ret ret = PTT_RET_SUCCESS; + + if ((enable == 0) || (enable == 1)) { + ptt_ctrl_set_icache(enable); + } else { + ret = PTT_RET_INVALID_VALUE; + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_get_icache(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + bool icache_active = ptt_ctrl_get_icache(); + + ctx_data->arr[0] = icache_active; + ctx_data->len = sizeof(icache_active); + + cmd_uart_send_rsp_get_icache(uart_cmd_evt); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_indication(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t activate = ctx_data->arr[0]; + enum ptt_ret ret = PTT_RET_SUCCESS; + + if ((activate == 1) && (led_indication_evt == PTT_EVENT_UNASSIGNED)) { + ret = ptt_event_alloc(&led_indication_evt); + + if (ret == PTT_RET_SUCCESS) { + /* setting default value just in case */ + struct ptt_evt_ctx_data_s *ctx_data = + ptt_event_get_ctx_data(led_indication_evt); + + assert(ctx_data != NULL); + + bool *is_timer_active = (bool *)ctx_data->arr; + + *is_timer_active = false; + } + } else if ((activate == 0) && (led_indication_evt != PTT_EVENT_UNASSIGNED)) { + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(led_indication_evt); + + assert(ctx_data != NULL); + + bool is_timer_active = *((bool *)ctx_data->arr); + + if (is_timer_active) { + ptt_timer_remove(led_indication_evt); + cmd_uart_l_indication_off(led_indication_evt); + } + + ptt_event_free(led_indication_evt); + led_indication_evt = PTT_EVENT_UNASSIGNED; + } else { + ret = PTT_RET_INVALID_VALUE; + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +/* this function used as a callback for timer */ +static void cmd_uart_l_indication_off(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER(); + + PTT_UNUSED(evt_id); + + ptt_ctrl_led_indication_off(); + + assert(led_indication_evt != PTT_EVENT_UNASSIGNED); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(led_indication_evt); + + assert(ctx_data != NULL); + + bool *is_timer_active = (bool *)ctx_data->arr; + + if (false == *is_timer_active) { + PTT_TRACE("%s: WARNING: is_timer_active variable is false\n", __func__); + } + + *is_timer_active = false; + + PTT_TRACE_FUNC_EXIT(); +} + +void cmd_uart_l_indication_proc(void) +{ + if (led_indication_evt != PTT_EVENT_UNASSIGNED) { + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(led_indication_evt); + + assert(ctx_data != NULL); + + bool *is_timer_active = (bool *)ctx_data->arr; + + if (false == *is_timer_active) { + enum ptt_ret led_ret = + ptt_timer_add(PTT_LED_INDICATION_BLINK_TIMEOUT_MS, + cmd_uart_l_indication_off, led_indication_evt); + + if (led_ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: ptt_timer_add for LED indication returns error: %d", + __func__, led_ret); + } else { + ptt_ctrl_led_indication_on(); + *is_timer_active = true; + } + } + } +} + +static enum ptt_ret cmd_uart_l_tx(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_data_s *data = ptt_event_get_data(uart_cmd_evt); + + assert(data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t *uart_cmd_payload = data->arr + sizeof(UART_CMD_L_TX_TEXT); + static char *save; + char *token_str = + strtok_r(PTT_CAST_TO_STR(uart_cmd_payload), UART_TEXT_PAYLOAD_DELIMETERS, &save); + + struct cmd_uart_ltx_info_s *ltx_info = (struct cmd_uart_ltx_info_s *)ctx_data->arr; + + ltx_info->is_stop_requested = false; + + if (token_str == NULL) { + ltx_info->max_repeats_cnt = PTT_CUSTOM_LTX_DEFAULT_REPEATS; + ltx_info->timeout = PTT_CUSTOM_LTX_DEFAULT_TIMEOUT_MS; + } else { + ret = ptt_parser_string_to_uint8(token_str, &(ltx_info->max_repeats_cnt), 0); + + if (ret == PTT_RET_SUCCESS) { + token_str = strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if ((token_str == NULL) || + (strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save) != NULL)) { + /* lets be sure that there are no extra parameters */ + ret = PTT_RET_INVALID_VALUE; + } else { + ret = ptt_parser_string_to_uint16(token_str, &(ltx_info->timeout), + 0); + + if (ltx_info->timeout > PTT_CUSTOM_LTX_TIMEOUT_MAX_VALUE) { + ret = PTT_RET_INVALID_VALUE; + } + } + } + } + + if (ret == PTT_RET_SUCCESS) { + if (ltx_info->max_repeats_cnt == 0) { + ltx_info->is_infinite = true; + } else { + ltx_info->is_infinite = false; + } + + ltx_info->repeats_cnt = 0; + ltx_info->ack_cnt = 0; + cmd_change_uart_cmd_state(CMD_UART_STATE_LTX); + cmd_uart_l_tx_process_next_packet(); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_uart_l_tx_end(ptt_evt_id_t new_uart_cmd) +{ + PTT_TRACE_FUNC_ENTER(); + + if (ptt_event_get_cmd(new_uart_cmd) == PTT_UART_CMD_L_TX_END) { + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + struct cmd_uart_ltx_info_s *ltx_info = (struct cmd_uart_ltx_info_s *)ctx_data->arr; + + if (ltx_info->is_infinite) { + /* This will cause the ltx routine to stop sending packets + * Requesting it ensures that all replies are received before stopping + */ + ltx_info->is_stop_requested = true; + } + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_uart_l_get_antenna(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t antenna = ptt_rf_get_antenna(); + + ctx_data->arr[0] = antenna; + ctx_data->len = sizeof(antenna); + + cmd_uart_send_rsp_antenna(uart_cmd_evt); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_get_temp(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + int32_t temp; + enum ptt_ret ret = ptt_ctrl_get_temp(&temp); + + if (ret == PTT_RET_SUCCESS) { + *((int32_t *)ctx_data) = temp; + ctx_data->len = sizeof(temp); + + cmd_uart_send_rsp_get_temp(uart_cmd_evt); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_uart_l_tx_process_next_packet(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + struct cmd_uart_ltx_info_s *ltx_info = (struct cmd_uart_ltx_info_s *)ctx_data->arr; + + if ((!ltx_info->is_infinite && (ltx_info->max_repeats_cnt <= ltx_info->repeats_cnt)) || + ltx_info->is_stop_requested) { + cmd_uart_cmd_unlock(); + } else { + ++(ltx_info->repeats_cnt); + + ret = ptt_timer_add(ltx_info->timeout, cmd_uart_l_tx_delay, uart_cmd_evt); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: ptt_timer_add returned %d, aborting ltx\n", __func__, ret); + cmd_uart_cmd_unlock(); + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static void cmd_uart_l_tx_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(cmd_is_uart_cmd_locked_by(timer_evt_id)); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_ltx_payload_s *ltx_payload = ptt_rf_get_custom_ltx_payload(); + /* we will use payload_len instead of ltx_payload->len to be able to generate new random + * payload for every sent packet + */ + uint8_t payload_len = ltx_payload->len; + + if (payload_len == 0) { + ptt_random_vector_generate(&payload_len, sizeof(payload_len)); + + /* make sure that size we get is not bigger that out buffer */ + payload_len %= PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE + 1; + + if (payload_len == 0) { + payload_len = PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE / 2; + } + + ptt_random_vector_generate(ltx_payload->arr, payload_len); + } + + if (ret == PTT_RET_SUCCESS) { + ptt_evt_id_t sender_event_id; + + ret = ptt_event_alloc(&sender_event_id); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_uart_cmd_state(CMD_UART_STATE_LTX_WAITING_FOR_ACK); + ret = ptt_rf_send_packet(sender_event_id, ltx_payload->arr, payload_len); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: ptt_rf_send_packet returns %d, aborting ltx\n", + __func__, ret); + ptt_event_free(sender_event_id); + cmd_uart_cmd_unlock(); + } + } else { + PTT_TRACE("%s: ptt_event_alloc returns %d, aborting ltx\n", __func__, ret); + cmd_uart_cmd_unlock(); + ret = PTT_RET_INVALID_VALUE; + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static void cmd_uart_l_tx_finished(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + if (!cmd_is_uart_cmd_locked()) { + PTT_TRACE("%s: uart module is not locked, aborting ltx\n", __func__); + cmd_uart_cmd_unlock(); + } else { + ptt_evt_state_t state = ptt_event_get_state(uart_cmd_evt); + + if (state != CMD_UART_STATE_LTX_WAITING_FOR_ACK) { + PTT_TRACE("%s: uart module state is unexpected, aborting ltx\n", __func__); + cmd_uart_cmd_unlock(); + } else { + cmd_change_uart_cmd_state(CMD_UART_STATE_LTX); + cmd_uart_l_tx_process_next_packet(); + } + } + + ptt_event_free(evt_id); + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_l_tx_process_ack(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + struct ptt_evt_data_s *data = ptt_event_get_data(evt_id); + + assert(data != NULL); + + /* if ACK is not NULL */ + if ((data->arr != NULL) && (data->len != 0)) { + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + struct cmd_uart_ltx_info_s *ltx_info = (struct cmd_uart_ltx_info_s *)ctx_data->arr; + + cmd_uart_send_rsp_ltx_ack(evt_id, ltx_info->ack_cnt); + + ++(ltx_info->ack_cnt); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_l_tx_failed(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + if (!cmd_is_uart_cmd_locked()) { + PTT_TRACE("%s: uart module is not locked, aborting ltx\n", __func__); + cmd_uart_cmd_unlock(); + } else { + ptt_evt_state_t state = ptt_event_get_state(uart_cmd_evt); + + if (state != CMD_UART_STATE_LTX_WAITING_FOR_ACK) { + PTT_TRACE("%s: uart module state is unexpected, aborting ltx\n", __func__); + cmd_uart_cmd_unlock(); + } else { + cmd_change_uart_cmd_state(CMD_UART_STATE_LTX); + cmd_uart_send_rsp_ltx_failed(evt_id); + cmd_uart_l_tx_process_next_packet(); + } + } + + ptt_event_free(evt_id); + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_uart_find_idle(void) +{ + uint32_t mask = 1u << PTT_CHANNEL_MIN; + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + /* set 0x0B channel as the first channel for find procedure */ + enum ptt_ret ret = ptt_rf_set_channel_mask(uart_cmd_evt, mask); + + if (ret == PTT_RET_SUCCESS) { + ptt_htobe32((uint8_t *)(&mask), ctx_data->arr); + ctx_data->len = sizeof(mask); + + cmd_change_uart_cmd_state(CMD_UART_STATE_SET_CHANNEL); + + ret = cmd_uart_call_ota_cmd(PTT_CMD_SET_CHANNEL, + ptt_event_get_ctx_data(uart_cmd_evt)); + } + + return ret; +} + +static enum ptt_ret cmd_uart_r_set_antenna(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = + cmd_uart_call_ota_cmd(PTT_CMD_SET_ANTENNA, ptt_event_get_ctx_data(uart_cmd_evt)); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_uart_find_channel_was_set(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cmd_change_uart_cmd_state(CMD_UART_STATE_WAIT_DELAY); + enum ptt_ret ret = + ptt_timer_add(ptt_ctrl_get_rsp_timeout(), cmd_uart_find_delay, uart_cmd_evt); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: add_timer returns error code: %d\n", __func__, ret); + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_find_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(true == cmd_is_uart_cmd_locked_by(timer_evt_id)); + + cmd_change_uart_cmd_state(CMD_UART_STATE_PING); + enum ptt_ret ret = cmd_uart_call_ota_cmd(PTT_CMD_PING, NULL); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: cmd_uart_call_ota_cmd returns error code: %d\n", __func__, ret); + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_find_send_set_channel(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint32_t mask = ptt_betoh32_val(ctx_data->arr); + + if (mask >= (1u << PTT_CHANNEL_MAX)) { + /* not found*/ + cmd_uart_send_rsp_find_timeout(uart_cmd_evt); + cmd_uart_cmd_unlock(); + } else { + mask <<= 1u; + + enum ptt_ret ret = ptt_rf_set_channel_mask(uart_cmd_evt, mask); + + if (ret == PTT_RET_SUCCESS) { + ptt_htobe32((uint8_t *)(&mask), ctx_data->arr); + + cmd_change_uart_cmd_state(CMD_UART_STATE_SET_CHANNEL); + + /* first SET_CHANNEL call is from current CMD channel */ + ret = cmd_uart_call_ota_cmd(PTT_CMD_SET_CHANNEL, + ptt_event_get_ctx_data(uart_cmd_evt)); + } + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: failed with error code: %d\n", __func__, ret); + cmd_uart_cmd_unlock(); + } + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_find_process_finish(ptt_evt_id_t ota_cmd_evt) +{ + PTT_TRACE_FUNC_ENTER(); + + enum cmd_uart_state_t state = ptt_event_get_state(uart_cmd_evt); + + PTT_TRACE("%s: state %d\n", __func__, state); + + switch (state) { + case CMD_UART_STATE_SET_CHANNEL: + cmd_uart_find_channel_was_set(); + break; + + case CMD_UART_STATE_PING: + /* uart_cmd_evt data ctx has current channel */ + cmd_uart_send_rsp_find(uart_cmd_evt); + cmd_uart_cmd_unlock(); + break; + + default: + PTT_TRACE("%s: unexpected finish\n", __func__); + cmd_uart_cmd_unlock(); + break; + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_find_process_timeout(ptt_evt_id_t ota_cmd_evt) +{ + PTT_TRACE_FUNC_ENTER(); + + enum cmd_uart_state_t state = ptt_event_get_state(uart_cmd_evt); + + PTT_TRACE("%s: state %d\n", __func__, state); + + switch (state) { + case CMD_UART_STATE_PING: + cmd_uart_find_send_set_channel(); + break; + + default: + PTT_TRACE("%s: unexpected timeout\n", __func__); + cmd_uart_cmd_unlock(); + break; + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_uart_l_clk(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t pin = ctx_data->arr[0]; + bool mode = (bool)ctx_data->arr[1]; + + /* if mode is false just skip it, output clk is already disabled */ + if (mode == PTT_VALUE_ON) { + if (ptt_clk_out_ext(pin, mode)) { + cmd_change_uart_cmd_state(CMD_UART_STATE_L_CLK_OUT); + } else { + ret = PTT_RET_INVALID_VALUE; + } + } else { + ret = PTT_RET_INVALID_VALUE; + } + + PTT_TRACE_FUNC_EXIT(); + return ret; +} + +static void cmd_uart_l_clk_stop(ptt_evt_id_t new_uart_cmd) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_uart_cmd uart_cmd = ptt_event_get_cmd(new_uart_cmd); + + if (uart_cmd == PTT_UART_CMD_L_CLK) { + struct ptt_evt_ctx_data_s *ctx_data_new = ptt_event_get_ctx_data(new_uart_cmd); + + assert(ctx_data_new != NULL); + + uint8_t pin_new = ctx_data_new->arr[0]; + bool mode_new = (bool)ctx_data_new->arr[1]; + + struct ptt_evt_ctx_data_s *ctx_data_old = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data_old != NULL); + + uint8_t pin_old = ctx_data_old->arr[0]; + bool mode_old = (bool)ctx_data_old->arr[1]; + + if ((pin_old == pin_new) && (mode_old) && (mode_new == PTT_VALUE_OFF)) { + if (ptt_clk_out_ext(pin_new, mode_new)) { + cmd_uart_cmd_unlock(); + } + } + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret cmd_uart_l_set_gpio(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t pin = ctx_data->arr[0]; + uint8_t value = ctx_data->arr[1]; + + if ((value == PTT_VALUE_OFF) || (value == PTT_VALUE_ON)) { + if (!ptt_set_gpio_ext(pin, value)) { + ret = PTT_RET_INVALID_VALUE; + } + } else { + ret = PTT_RET_INVALID_VALUE; + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret cmd_uart_l_get_gpio(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t pin = ctx_data->arr[0]; + uint8_t *value = &ctx_data->arr[1]; + + if (!ptt_get_gpio_ext(pin, value)) { + cmd_uart_send_rsp_l_get_gpio_error(uart_cmd_evt); + ret = PTT_RET_INVALID_VALUE; + } else { + ctx_data->len++; + cmd_uart_send_rsp_l_get_gpio(uart_cmd_evt); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret cmd_uart_parse_waveform_timings(const uint8_t *uart_cmd_payload, + int32_t *pulse_duration, int32_t *interval, + int32_t *duration_p) +{ + if (uart_cmd_payload == NULL) { + return PTT_RET_INVALID_VALUE; + } + + enum ptt_ret ret = PTT_RET_SUCCESS; + static char *save; + char *token_str = + strtok_r(PTT_CAST_TO_STR(uart_cmd_payload), UART_TEXT_PAYLOAD_DELIMETERS, &save); + + /* arguments parsing */ + if (token_str == NULL) { + ret = PTT_RET_INVALID_VALUE; + } else { + ret = ptt_parser_string_to_int32(token_str, pulse_duration, 0); + + if (ret == PTT_RET_SUCCESS) { + token_str = strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if (token_str == NULL) { + ret = PTT_RET_INVALID_VALUE; + } else { + ret = ptt_parser_string_to_int32(token_str, interval, 0); + + if (ret == PTT_RET_SUCCESS) { + token_str = + strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save); + + if ((token_str == NULL) || + /* lets be sure that there are no extra parameters */ + (strtok_r(NULL, UART_TEXT_PAYLOAD_DELIMETERS, &save) != + NULL)) { + ret = PTT_RET_INVALID_VALUE; + } else { + ret = ptt_parser_string_to_int32(token_str, + duration_p, 0); + } + } + } + } + } + + return ret; +} + +static enum ptt_ret cmd_uart_l_carrier(void) +{ + PTT_TRACE_FUNC_ENTER(); + + int32_t transmission_duration; + struct cmd_uart_waveform_timings_s timings_info = { 0 }; + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_data_s *data = ptt_event_get_data(uart_cmd_evt); + + assert(data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t *uart_cmd_payload = data->arr + sizeof(UART_CMD_L_CARRIER_TEXT); + + ret = cmd_uart_parse_waveform_timings(uart_cmd_payload, &(timings_info.pulse_duration), + &(timings_info.interval), &transmission_duration); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: error occurs due payload parsing: %d. Aborting command handling", + __func__, ret); + } else { + /* range checks */ + /* The values are only stored in the ctx_data if the parsing is successful */ + memcpy(ctx_data->arr, &timings_info, sizeof(struct cmd_uart_waveform_timings_s)); + + bool is_pulse_duration_valid = + (timings_info.pulse_duration >= PTT_L_CARRIER_PULSE_MIN) && + (timings_info.pulse_duration <= PTT_L_CARRIER_PULSE_MAX); + bool is_interval_valid = (timings_info.interval >= PTT_L_CARRIER_INTERVAL_MIN) && + (timings_info.interval <= PTT_L_CARRIER_INTERVAL_MAX); + bool is_transmission_duration_valid = + (transmission_duration == 0) || + ((transmission_duration >= PTT_L_CARRIER_DURATION_MIN) && + (transmission_duration <= PTT_L_CARRIER_DURATION_MAX)); + + if (!is_pulse_duration_valid || !is_interval_valid || + !is_transmission_duration_valid) { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE("%s: error during arg range checks: %d. Aborting", __func__, ret); + } else { + /* arm timers */ + /* Transmission duration equal zero means infinite transmission */ + if (transmission_duration != 0) { + ret = ptt_timer_add(transmission_duration, + cmd_uart_l_carrier_duration_delay, + uart_cmd_evt); + } + + if (ret == PTT_RET_SUCCESS) { + ret = ptt_timer_add(timings_info.pulse_duration, + cmd_uart_l_carrier_pulse_delay, uart_cmd_evt); + } + + if (ret != PTT_RET_SUCCESS) { + ptt_timer_remove(uart_cmd_evt); + + PTT_TRACE("%s: error occurs during timers arming: %d. Aborting", + __func__, ret); + } else { + /* start sending carrier */ + ret = ptt_rf_start_continuous_carrier(uart_cmd_evt); + + if (ret != PTT_RET_SUCCESS) { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE( + "%s: rf_start_continuous_carrier is false.Aborting", + __func__); + } else { + cmd_change_uart_cmd_state(CMD_UART_STATE_L_CARRIER_PULSE); + } + } + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_uart_l_carrier_duration_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(cmd_is_uart_cmd_locked_by(timer_evt_id)); + + enum ptt_ret ret = ptt_rf_stop_continuous_carrier(uart_cmd_evt); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: WARNING ptt_rf_stop_continuous_carrier returns error %d\n", __func__, + ret); + } + + ptt_timer_remove(timer_evt_id); + + cmd_uart_cmd_unlock(); + + PTT_TRACE_FUNC_EXIT(); +} + +static void cmd_uart_l_carrier_pulse_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(cmd_is_uart_cmd_locked_by(timer_evt_id)); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + struct cmd_uart_waveform_timings_s *info = + (struct cmd_uart_waveform_timings_s *)(ctx_data->arr); + + enum ptt_ret ret = + ptt_timer_add(info->interval, cmd_uart_l_carrier_interval_delay, uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + ret = ptt_rf_stop_continuous_carrier(uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_uart_cmd_state(CMD_UART_STATE_L_CARRIER_INTERVAL); + } else { + PTT_TRACE("%s: ptt_rf_stop_continuous_carrier returns error: %d. Aborting", + __func__, ret); + } + } else { + PTT_TRACE("%s: error occurs during timer arming: %d. Aborting command handling", + __func__, ret); + } + + if (ret != PTT_RET_SUCCESS) { + ptt_timer_remove(uart_cmd_evt); + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static void cmd_uart_l_carrier_interval_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(cmd_is_uart_cmd_locked_by(timer_evt_id)); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + struct cmd_uart_waveform_timings_s *info = + (struct cmd_uart_waveform_timings_s *)(ctx_data->arr); + + enum ptt_ret ret = + ptt_timer_add(info->pulse_duration, cmd_uart_l_carrier_pulse_delay, uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + ret = ptt_rf_start_continuous_carrier(uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_uart_cmd_state(CMD_UART_STATE_L_CARRIER_PULSE); + } else { + PTT_TRACE("%s: ptt_rf_start_continuous_carrier returns error: %d. Aborting", + __func__, ret); + } + } else { + PTT_TRACE("%s: error occurs during timer arming: %d. Aborting command handling", + __func__, ret); + } + + if (ret != PTT_RET_SUCCESS) { + ptt_timer_remove(uart_cmd_evt); + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static enum ptt_ret cmd_uart_l_stream_start(void) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_ltx_payload_s *ltx_payload = ptt_rf_get_custom_ltx_payload(); + /* we will use payload_len instead of ltx_payload->len to be able to generate new random + * payload + */ + uint8_t payload_len = ltx_payload->len; + + if (payload_len == 0) { + ptt_random_vector_generate(&payload_len, sizeof(payload_len)); + + payload_len %= PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE + 1; + + if (payload_len == 0) { + payload_len = PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE / 2; + } + + ptt_random_vector_generate(ltx_payload->arr, payload_len); + } + + ret = ptt_rf_start_modulated_stream(uart_cmd_evt, ltx_payload->arr, payload_len); + + return ret; +} + +static enum ptt_ret cmd_uart_l_stream(void) +{ + PTT_TRACE_FUNC_ENTER(); + + int32_t transmission_duration; + struct cmd_uart_waveform_timings_s timings_info = { 0 }; + enum ptt_ret ret = PTT_RET_SUCCESS; + struct ptt_evt_data_s *data = ptt_event_get_data(uart_cmd_evt); + + assert(data != NULL); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + uint8_t *uart_cmd_payload = data->arr + sizeof(UART_CMD_L_STREAM_TEXT); + + ret = cmd_uart_parse_waveform_timings(uart_cmd_payload, &(timings_info.pulse_duration), + &(timings_info.interval), &transmission_duration); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: error occurs due payload parsing: %d. Aborting command handling", + __func__, ret); + } else { + /* range checks */ + /* The values are only stored in the ctx_data if the parsing is successful */ + memcpy(ctx_data->arr, &timings_info, sizeof(struct cmd_uart_waveform_timings_s)); + + bool is_pulse_duration_valid = + (timings_info.pulse_duration >= PTT_L_CARRIER_PULSE_MIN) && + (timings_info.pulse_duration <= PTT_L_CARRIER_PULSE_MAX); + bool is_interval_valid = (timings_info.interval >= PTT_L_CARRIER_INTERVAL_MIN) && + (timings_info.interval <= PTT_L_CARRIER_INTERVAL_MAX); + bool is_transmission_duration_valid = + (transmission_duration == 0) || + ((transmission_duration >= PTT_L_CARRIER_DURATION_MIN) && + (transmission_duration <= PTT_L_CARRIER_DURATION_MAX)); + + if (!is_pulse_duration_valid || !is_interval_valid || + !is_transmission_duration_valid) { + ret = PTT_RET_INVALID_VALUE; + PTT_TRACE("%s: error occurs during arguments range checks: %d. Aborting", + __func__, ret); + } else { + /* arm timers */ + /* Transmission duration equal zero means infinite transmission */ + if (transmission_duration != 0) { + ret = ptt_timer_add(transmission_duration, + cmd_uart_l_stream_duration_delay, uart_cmd_evt); + } + + if (ret == PTT_RET_SUCCESS) { + ret = ptt_timer_add(timings_info.pulse_duration, + cmd_uart_l_stream_pulse_delay, uart_cmd_evt); + } + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: error occurs during timers arming: %d. Aborting", + __func__, ret); + ptt_timer_remove(uart_cmd_evt); + } else { + /* start sending stream */ + ret = cmd_uart_l_stream_start(); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: cmd_uart_l_stream_start return %d. Aborting", + __func__, ret); + ptt_timer_remove(uart_cmd_evt); + } else { + cmd_change_uart_cmd_state(CMD_UART_STATE_L_STREAM_PULSE); + } + } + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static void cmd_uart_l_stream_duration_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(cmd_is_uart_cmd_locked_by(timer_evt_id)); + + enum ptt_ret ret = ptt_rf_stop_modulated_stream(uart_cmd_evt); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: WARNING ptt_rf_stop_modulated_stream returns error %d\n", __func__, + ret); + } + + ptt_timer_remove(timer_evt_id); + + cmd_uart_cmd_unlock(); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static void cmd_uart_l_stream_pulse_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(cmd_is_uart_cmd_locked_by(timer_evt_id)); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + struct cmd_uart_waveform_timings_s *info = + (struct cmd_uart_waveform_timings_s *)(ctx_data->arr); + + enum ptt_ret ret = + ptt_timer_add(info->interval, cmd_uart_l_stream_interval_delay, uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + ret = ptt_rf_stop_modulated_stream(uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_uart_cmd_state(CMD_UART_STATE_L_STREAM_INTERVAL); + } else { + PTT_TRACE("%s: ptt_rf_stop_modulated_stream returns error: %d. Aborting", + __func__, ret); + } + } else { + PTT_TRACE("%s: error occurs during timer arming: %d. Aborting command handling", + __func__, ret); + } + + if (ret != PTT_RET_SUCCESS) { + ptt_timer_remove(uart_cmd_evt); + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static void cmd_uart_l_stream_interval_delay(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(timer_evt_id); + + assert(cmd_is_uart_cmd_locked_by(timer_evt_id)); + + struct ptt_evt_ctx_data_s *ctx_data = ptt_event_get_ctx_data(uart_cmd_evt); + + assert(ctx_data != NULL); + + struct cmd_uart_waveform_timings_s *info = + (struct cmd_uart_waveform_timings_s *)(ctx_data->arr); + + enum ptt_ret ret = + ptt_timer_add(info->pulse_duration, cmd_uart_l_stream_pulse_delay, uart_cmd_evt); + + if (ret == PTT_RET_SUCCESS) { + ret = cmd_uart_l_stream_start(); + + if (ret == PTT_RET_SUCCESS) { + cmd_change_uart_cmd_state(CMD_UART_STATE_L_STREAM_PULSE); + } else { + PTT_TRACE("%s: cmd_uart_l_stream_start returns error: %d. Aborting", + __func__, ret); + } + } else { + PTT_TRACE("%s: error occurs during timer arming: %d. Aborting command handling", + __func__, ret); + } + + if (ret != PTT_RET_SUCCESS) { + ptt_timer_remove(uart_cmd_evt); + cmd_uart_cmd_unlock(); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static enum ptt_ret cmd_uart_l_sleep(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = ptt_rf_sleep(); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_l_receive(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = ptt_rf_receive(); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret cmd_uart_call_ota_cmd(enum ptt_cmd cmd, const struct ptt_evt_ctx_data_s *ctx) +{ + PTT_TRACE_FUNC_ENTER(); + + ptt_evt_id_t new_ota_cmd; + + enum ptt_ret ret = ptt_event_alloc(&new_ota_cmd); + + if (ret == PTT_RET_SUCCESS) { + ptt_event_set_cmd(new_ota_cmd, cmd); + + if (ctx != NULL) { + memcpy(ptt_event_get_ctx_data(new_ota_cmd), ctx, + sizeof(struct ptt_evt_ctx_data_s)); + } + + ret = cmd_ota_cmd_process(new_ota_cmd); + + if (ret != PTT_RET_SUCCESS) { + ptt_event_free(new_ota_cmd); + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static inline void cmd_change_uart_cmd_state(ptt_evt_state_t state) +{ + PTT_TRACE("%s: %d", __func__, state); + + ptt_event_set_state(uart_cmd_evt, state); +} + +static inline void cmd_uart_cmd_lock(ptt_evt_id_t new_uart_cmd) +{ + assert(uart_cmd_evt == PTT_EVENT_UNASSIGNED); + + uart_cmd_evt = new_uart_cmd; + ptt_handler_busy(); +} + +static void cmd_uart_cmd_unlock(void) +{ + if (uart_cmd_evt != PTT_EVENT_UNASSIGNED) { + ptt_event_free(uart_cmd_evt); + uart_cmd_evt = PTT_EVENT_UNASSIGNED; + ptt_handler_free(); + ptt_uart_print_prompt(); + } +} + +static inline bool cmd_is_uart_cmd_locked(void) +{ + return (uart_cmd_evt == PTT_EVENT_UNASSIGNED) ? false : true; +} + +static inline bool cmd_is_uart_cmd_locked_by(ptt_evt_id_t evt_id) +{ + return (evt_id == uart_cmd_evt) ? true : false; +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_dut_mode.c b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_dut_mode.c new file mode 100644 index 000000000000..c1ef79ce2095 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_dut_mode.c @@ -0,0 +1,614 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: implementation of Zigbee RF Performance Test Plan DUT mode */ + +#include +#include + +#include "ctrl/ptt_trace.h" +#include "rf/ptt_rf.h" + +#include "ptt_proto.h" + +#include "ptt_ctrl_internal.h" +#include "ptt_events_internal.h" +#include "ptt_modes.h" +#include "ptt_zb_perf_dut_mode.h" + +#ifdef TESTS +#include "test_dut_conf.h" +#endif + +/** currently processed event */ +static ptt_evt_id_t cur_evt; + +/* current event handlers */ +static void dut_rf_tx_finished(ptt_evt_id_t evt_id); +static void dut_rf_tx_failed(ptt_evt_id_t evt_id); +static void dut_idle_packet_proc(void); +static enum ptt_ret dut_ping(void); +static enum ptt_ret dut_set_channel(void); +static enum ptt_ret dut_set_power(void); +static enum ptt_ret dut_get_power(void); +static enum ptt_ret dut_stream(void); +static enum ptt_ret dut_start_rx_test(void); +static enum ptt_ret dut_hw_version(void); +static enum ptt_ret dut_sw_version(void); +static enum ptt_ret dut_set_antenna(void); +static enum ptt_ret dut_get_antenna(void); + +/* new event handlers */ +static void dut_rf_rx_done(ptt_evt_id_t new_evt_id); +static void dut_end_rx_test(ptt_evt_id_t new_evt_id); + +static void dut_stream_stop(ptt_evt_id_t timer_evt_id); + +static ptt_pkt_len_t dut_form_stat_report(uint8_t *pkt, ptt_pkt_len_t pkt_max_size); + +static inline void dut_change_cur_state(ptt_evt_state_t state); +static inline void dut_store_cur_evt(ptt_evt_id_t evt_id); +static inline void dut_reset_cur_evt(void); + +#ifdef TESTS +#include "test_dut_wrappers.c" +#endif + +enum ptt_ret ptt_zb_perf_dut_mode_init(void) +{ + PTT_TRACE_FUNC_ENTER(); + + cur_evt = PTT_EVENT_UNASSIGNED; + struct ptt_ext_evts_handlers_s *handlers = ptt_ctrl_get_handlers(); + + handlers->rf_tx_finished = dut_rf_tx_finished; + handlers->rf_tx_failed = dut_rf_tx_failed; + handlers->rf_rx_done = dut_rf_rx_done; + + PTT_TRACE_FUNC_EXIT(); + return PTT_RET_SUCCESS; +} + +enum ptt_ret ptt_zb_perf_dut_mode_uninit(void) +{ + PTT_TRACE_FUNC_ENTER(); + + if (cur_evt != PTT_EVENT_UNASSIGNED) { + dut_reset_cur_evt(); + } + + PTT_TRACE_FUNC_EXIT(); + return PTT_RET_SUCCESS; +} + +static void dut_rf_rx_done(ptt_evt_id_t new_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_evt_id); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(new_evt_id); + + assert(evt_data != NULL); + + if (!ptt_proto_check_packet(evt_data->arr, evt_data->len)) { + PTT_TRACE("%s not protocol packet received and ignored\n", __func__); + ptt_event_free(new_evt_id); + } else { + ptt_event_set_cmd(new_evt_id, evt_data->arr[PTT_CMD_CODE_START]); + + if (cur_evt == PTT_EVENT_UNASSIGNED) { + /* store the event as currently processed */ + dut_store_cur_evt(new_evt_id); + dut_idle_packet_proc(); + } else { + switch (ptt_event_get_state(cur_evt)) { + case DUT_STATE_RX_TEST_WAIT_FOR_END: + dut_end_rx_test(new_evt_id); + break; + + default: + PTT_TRACE("%s: state isn't idle cmd %d state %d\n", __func__, + ptt_event_get_cmd(cur_evt), ptt_event_get_state(cur_evt)); + ptt_event_free(new_evt_id); + break; + } + } + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void dut_idle_packet_proc(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + PTT_TRACE("%s: cmd %d state %d\n", __func__, ptt_event_get_cmd(cur_evt), + ptt_event_get_state(cur_evt)); + + switch (ptt_event_get_cmd(cur_evt)) { + case PTT_CMD_PING: + ret = dut_ping(); + break; + + case PTT_CMD_SET_CHANNEL: + ret = dut_set_channel(); + dut_reset_cur_evt(); + break; + + case PTT_CMD_SET_POWER: + ret = dut_set_power(); + dut_reset_cur_evt(); + break; + + case PTT_CMD_GET_POWER: + ret = dut_get_power(); + break; + + case PTT_CMD_STREAM: + ret = dut_stream(); + break; + + case PTT_CMD_START_RX_TEST: + ret = dut_start_rx_test(); + break; + + case PTT_CMD_GET_HARDWARE_VERSION: + ret = dut_hw_version(); + break; + + case PTT_CMD_GET_SOFTWARE_VERSION: + ret = dut_sw_version(); + break; + + case PTT_CMD_SET_ANTENNA: + ret = dut_set_antenna(); + dut_reset_cur_evt(); + break; + + case PTT_CMD_GET_ANTENNA: + ret = dut_get_antenna(); + break; + + default: + PTT_TRACE("%s: unknown command cmd %d state %d\n", __func__, + ptt_event_get_cmd(cur_evt), ptt_event_get_state(cur_evt)); + dut_reset_cur_evt(); + break; + } + + if (ret != PTT_RET_SUCCESS) { + dut_reset_cur_evt(); + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void dut_rf_tx_finished(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + assert(evt_id == cur_evt); + + PTT_TRACE("%s: cmd %d state %d\n", __func__, ptt_event_get_cmd(cur_evt), + ptt_event_get_state(cur_evt)); + + switch (ptt_event_get_state(cur_evt)) { + case DUT_STATE_ACK_SENDING: + case DUT_STATE_POWER_SENDING: + case DUT_STATE_RX_TEST_REPORT_SENDING: + case DUT_STATE_HW_VERSION_SENDING: + case DUT_STATE_SW_VERSION_SENDING: + case DUT_STATE_ANTENNA_SENDING: + dut_reset_cur_evt(); + break; + + default: + PTT_TRACE("%s: inappropriate state cmd %d state %d\n", __func__, + ptt_event_get_cmd(cur_evt), ptt_event_get_state(cur_evt)); + break; + } + + PTT_TRACE_FUNC_EXIT(); +} + +static void dut_rf_tx_failed(ptt_evt_id_t evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(evt_id); + + assert(evt_id == cur_evt); + + PTT_TRACE("%s: cmd %d state %d\n", __func__, ptt_event_get_cmd(cur_evt), + ptt_event_get_state(cur_evt)); + + switch (ptt_event_get_state(cur_evt)) { + case DUT_STATE_ACK_SENDING: + case DUT_STATE_POWER_SENDING: + case DUT_STATE_RX_TEST_REPORT_SENDING: + case DUT_STATE_HW_VERSION_SENDING: + case DUT_STATE_SW_VERSION_SENDING: + case DUT_STATE_ANTENNA_SENDING: + dut_reset_cur_evt(); + break; + + default: + PTT_TRACE("%s: inappropriate state cmd %d state %d\n", __func__, + ptt_event_get_cmd(cur_evt), ptt_event_get_state(cur_evt)); + break; + } + + PTT_TRACE_FUNC_EXIT(); +} + +static enum ptt_ret dut_ping(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + uint8_t *p = evt_data->arr; + + dut_change_cur_state(DUT_STATE_ACK_SENDING); + + evt_data->len = ptt_proto_construct_header(p, PTT_CMD_ACK, PTT_EVENT_DATA_SIZE); + + enum ptt_ret ret = ptt_rf_send_packet(cur_evt, evt_data->arr, evt_data->len); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret dut_set_channel(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + if ((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN + PTT_PAYLOAD_LEN_SET_CHANNEL) != evt_data->len) { + PTT_TRACE("%s: invalid length %d\n", __func__, evt_data->len); + ret = PTT_RET_INVALID_COMMAND; + } else { + uint32_t mask = ptt_betoh32_val(&evt_data->arr[PTT_PAYLOAD_START]); + + ret = ptt_rf_set_channel_mask(cur_evt, mask); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret dut_set_power(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + if ((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN + PTT_PAYLOAD_LEN_SET_POWER) != evt_data->len) { + PTT_TRACE("%s: invalid length %d\n", __func__, evt_data->len); + ret = PTT_RET_INVALID_COMMAND; + } else { + int8_t power = (int8_t)(evt_data->arr[PTT_PAYLOAD_START]); + + ret = ptt_rf_set_power(cur_evt, power); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret dut_get_power(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + uint8_t *p = evt_data->arr; + + dut_change_cur_state(DUT_STATE_POWER_SENDING); + + evt_data->len = + ptt_proto_construct_header(p, PTT_CMD_GET_POWER_RESPONSE, PTT_EVENT_DATA_SIZE); + p[evt_data->len] = ptt_rf_get_power(); + evt_data->len++; + + enum ptt_ret ret = ptt_rf_send_packet(cur_evt, evt_data->arr, evt_data->len); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret dut_set_antenna(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + if ((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN + PTT_PAYLOAD_LEN_SET_ANTENNA) != evt_data->len) { + PTT_TRACE("%s: invalid length %d\n", __func__, evt_data->len); + ret = PTT_RET_INVALID_COMMAND; + } else { + uint8_t antenna = evt_data->arr[PTT_PAYLOAD_START]; + + ret = ptt_rf_set_antenna(cur_evt, antenna); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret dut_get_antenna(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + uint8_t *p = evt_data->arr; + + dut_change_cur_state(DUT_STATE_ANTENNA_SENDING); + + evt_data->len = + ptt_proto_construct_header(p, PTT_CMD_GET_ANTENNA_RESPONSE, PTT_EVENT_DATA_SIZE); + p[evt_data->len] = ptt_rf_get_antenna(); + evt_data->len++; + + enum ptt_ret ret = ptt_rf_send_packet(cur_evt, evt_data->arr, evt_data->len); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + return ret; +} + +static enum ptt_ret dut_stream(void) +{ + PTT_TRACE_FUNC_ENTER(); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + if ((PTT_PREAMBLE_LEN + PTT_CMD_CODE_LEN + PTT_PAYLOAD_LEN_STREAM) != evt_data->len) { + PTT_TRACE("%s: invalid length %d\n", __func__, evt_data->len); + ret = PTT_RET_INVALID_COMMAND; + } else { + uint16_t duration = ptt_betoh16_val(&evt_data->arr[PTT_PAYLOAD_START]); + + if (duration != 0) { + ret = ptt_timer_add(duration, dut_stream_stop, cur_evt); + + if (ret == PTT_RET_SUCCESS) { + struct ptt_ltx_payload_s *ltx_payload = + ptt_rf_get_custom_ltx_payload(); + + ltx_payload->len = PTT_CUSTOM_LTX_PAYLOAD_MAX_SIZE; + + ptt_random_vector_generate(ltx_payload->arr, ltx_payload->len); + + ret = ptt_rf_start_modulated_stream(cur_evt, ltx_payload->arr, + ltx_payload->len); + + if (ret == PTT_RET_SUCCESS) { + dut_change_cur_state(DUT_STATE_STREAM_EMITTING); + } else { + ptt_timer_remove(cur_evt); + PTT_TRACE("%s: start_modulated_stream returns %d. Aborting", + __func__, ret); + } + } + } else { + dut_reset_cur_evt(); + } + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static void dut_stream_stop(ptt_evt_id_t timer_evt_id) +{ + PTT_TRACE_FUNC_ENTER(); + + assert(timer_evt_id == cur_evt); + + enum ptt_ret ret = ptt_rf_stop_modulated_stream(cur_evt); + + dut_reset_cur_evt(); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static enum ptt_ret dut_start_rx_test(void) +{ + PTT_TRACE_FUNC_ENTER(); + + /* we will store protocol packets counter in context of cur_evt, + * lets erase it just in case + */ + struct ptt_evt_ctx_data_s *cur_ctx_data = ptt_event_get_ctx_data(cur_evt); + + assert(cur_ctx_data != NULL); + + uint32_t *proto_pkts = (uint32_t *)cur_ctx_data; + + *proto_pkts = 0; + + enum ptt_ret ret = ptt_rf_start_statistic(cur_evt); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: ret %d\n", __func__, ret); + ret = PTT_RET_INVALID_COMMAND; + } else { + dut_change_cur_state(DUT_STATE_RX_TEST_WAIT_FOR_END); + } + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static void dut_end_rx_test(ptt_evt_id_t new_evt_id) +{ + PTT_TRACE_FUNC_ENTER_WITH_EVT(new_evt_id); + + enum ptt_ret ret = PTT_RET_SUCCESS; + + struct ptt_evt_ctx_data_s *cur_ctx_data = ptt_event_get_ctx_data(cur_evt); + + assert(cur_ctx_data != NULL); + + uint32_t *proto_pkts = (uint32_t *)cur_ctx_data; + + ++(*proto_pkts); + + if (ptt_event_get_cmd(new_evt_id) == PTT_CMD_END_RX_TEST) { + ret = ptt_rf_end_statistic(cur_evt); + + if (ret != PTT_RET_SUCCESS) { + PTT_TRACE("%s: ret %d\n", __func__, ret); + } else { + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + uint8_t *p = evt_data->arr; + + dut_change_cur_state(DUT_STATE_RX_TEST_REPORT_SENDING); + + evt_data->len = + ptt_proto_construct_header(p, PTT_CMD_REPORT, PTT_EVENT_DATA_SIZE); + evt_data->len += dut_form_stat_report(&p[evt_data->len], + PTT_EVENT_DATA_SIZE - evt_data->len); + + ret = ptt_rf_send_packet(cur_evt, evt_data->arr, evt_data->len); + } + } + + ptt_event_free(new_evt_id); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); +} + +static enum ptt_ret dut_hw_version(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + uint8_t *p = evt_data->arr; + + dut_change_cur_state(DUT_STATE_HW_VERSION_SENDING); + + evt_data->len = ptt_proto_construct_header(p, PTT_CMD_GET_HARDWARE_VERSION_RESPONSE, + PTT_EVENT_DATA_SIZE); + p[evt_data->len] = ptt_ctrl_get_hw_version(); + evt_data->len++; + + enum ptt_ret ret = ptt_rf_send_packet(cur_evt, evt_data->arr, evt_data->len); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static enum ptt_ret dut_sw_version(void) +{ + PTT_TRACE_FUNC_ENTER(); + + struct ptt_evt_data_s *evt_data = ptt_event_get_data(cur_evt); + + assert(evt_data != NULL); + + uint8_t *p = evt_data->arr; + + dut_change_cur_state(DUT_STATE_SW_VERSION_SENDING); + + evt_data->len = ptt_proto_construct_header(p, PTT_CMD_GET_SOFTWARE_VERSION_RESPONSE, + PTT_EVENT_DATA_SIZE); + p[evt_data->len] = ptt_ctrl_get_sw_version(); + evt_data->len++; + + enum ptt_ret ret = ptt_rf_send_packet(cur_evt, evt_data->arr, evt_data->len); + + PTT_TRACE_FUNC_EXIT_WITH_VALUE(ret); + + return ret; +} + +static ptt_pkt_len_t dut_form_stat_report(uint8_t *pkt, ptt_pkt_len_t pkt_max_size) +{ + assert(pkt != NULL); + assert(pkt_max_size >= PTT_PAYLOAD_LEN_REPORT); + + ptt_pkt_len_t len = 0; + uint8_t *p = pkt; + struct ptt_rf_stat_s stat = ptt_rf_get_stat_report(); + + struct ptt_evt_ctx_data_s *cur_ctx_data = ptt_event_get_ctx_data(cur_evt); + + assert(cur_ctx_data != NULL); + + uint32_t *proto_pkts = (uint32_t *)cur_ctx_data; + + ptt_htobe32((uint8_t *)&stat.total_pkts, &p[len]); + len += sizeof(stat.total_pkts); + + ptt_htobe32((uint8_t *)proto_pkts, &p[len]); + len += sizeof(*proto_pkts); + + ptt_htobe32((uint8_t *)&stat.total_lqi, &p[len]); + len += sizeof(stat.total_lqi); + + ptt_htobe32((uint8_t *)&stat.total_rssi, &p[len]); + len += sizeof(stat.total_rssi); + + assert(len == PTT_PAYLOAD_LEN_REPORT); + + return len; +} + +static inline void dut_change_cur_state(ptt_evt_state_t state) +{ + PTT_TRACE("%s: state %d", __func__, state); + + ptt_event_set_state(cur_evt, state); +} + +static inline void dut_store_cur_evt(ptt_evt_id_t evt_id) +{ + assert(cur_evt == PTT_EVENT_UNASSIGNED); + + cur_evt = evt_id; +} + +static inline void dut_reset_cur_evt(void) +{ + ptt_event_free(cur_evt); + cur_evt = PTT_EVENT_UNASSIGNED; +} diff --git a/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_dut_mode.h b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_dut_mode.h new file mode 100644 index 000000000000..84d7ca741aa2 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ctrl/ptt_zb_perf_dut_mode.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: implementation of Zigbee RF Performance Test Plan DUT mode */ + +#ifndef PTT_MODE_ZB_PERF_DUT_H__ +#define PTT_MODE_ZB_PERF_DUT_H__ + +#include + +#include "ctrl/ptt_ctrl.h" +#include "ctrl/ptt_events.h" +#include "ctrl/ptt_timers.h" +#include "ctrl/ptt_uart.h" + +#include "ptt_errors.h" + +/** possible states of library in DUT mode */ +enum dut_state_t { + DUT_STATE_IDLE = 0, /**< waiting for next command */ + DUT_STATE_ACK_SENDING, /**< rf module send ack command */ + DUT_STATE_POWER_SENDING, /**< DUT sends power */ + DUT_STATE_STREAM_EMITTING, /**< DUT emits modulated stream */ + DUT_STATE_RX_TEST_WAIT_FOR_END, /**< rf module wait for end_rx_test command */ + DUT_STATE_RX_TEST_REPORT_SENDING, /**< rf module send end_rx_test command */ + DUT_STATE_HW_VERSION_SENDING, /**< DUT sends hardware version */ + DUT_STATE_SW_VERSION_SENDING, /**< DUT sends software version */ + DUT_STATE_ANTENNA_SENDING, /**< DUT sends antenna */ + DUT_STATE_N /**< states count */ +}; + +#endif /* PTT_MODE_ZB_PERF_DUT_H__ */ diff --git a/samples/peripheral/802154_phy_test/src/main.c b/samples/peripheral/802154_phy_test/src/main.c new file mode 100644 index 000000000000..c194a69da489 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/main.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +#include +#include + +#include "rf_proc.h" +#include "timer_proc.h" +#include "comm_proc.h" +#include "periph_proc.h" + +#include + LOG_MODULE_REGISTER(phy_tt); + +/* size of stack area used by each thread */ +#define RF_THREAD_STACKSIZE (1024u) +#define COMM_THREAD_STACKSIZE (1024u) + +/* scheduling priority used by each thread */ +#define RF_THREAD_PRIORITY (7u) +#define COMM_THREAD_PRIORITY (7u) + +void ptt_do_reset_ext(void) +{ + NVIC_SystemReset(); +} + +static int setup(const struct device *dev) +{ + LOG_INF("Setup started"); + + ARG_UNUSED(dev); + + periph_init(); + + rf_init(); + + comm_init(); + + /* initialize ptt library */ + ptt_init(launch_ptt_process_timer, ptt_get_max_time()); + + return 0; +} + +SYS_INIT(setup, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); + +K_THREAD_DEFINE(rf_id, RF_THREAD_STACKSIZE, rf_thread, NULL, NULL, NULL, RF_THREAD_PRIORITY, 0, 0); + +K_THREAD_DEFINE(comm_id, COMM_THREAD_STACKSIZE, comm_proc, NULL, NULL, NULL, COMM_THREAD_PRIORITY, + 0, 0); diff --git a/samples/peripheral/802154_phy_test/src/periph_proc.c b/samples/peripheral/802154_phy_test/src/periph_proc.c new file mode 100644 index 000000000000..f96802c1e5ef --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/periph_proc.c @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: Periphery configuring and processing */ + +#include +#include + +#include + +#include "periph_proc.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#if defined(DPPI_PRESENT) +#include +#else +#include +#endif + +#include +LOG_MODULE_REGISTER(periph); + +/* Timer instance used for HFCLK output */ +#define PTT_CLK_TIMER 2 + +static struct onoff_client hfclk_cli; +static nrfx_timer_t clk_timer = NRFX_TIMER_INSTANCE(PTT_CLK_TIMER); + +/* The devicetree node identifier for the "led0" alias. */ +#define LED0_NODE DT_ALIAS(led0) + +#if DT_NODE_HAS_STATUS(LED0_NODE, okay) +#define LED0 DT_GPIO_LABEL(LED0_NODE, gpios) +#define PIN DT_GPIO_PIN(LED0_NODE, gpios) +#define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios) +#else +/* A build error here means your board isn't set up to blink an LED. */ +#error "Unsupported board: led0 devicetree alias is not defined" +#define LED0 "" +#define PIN 0 +#define FLAGS 0 +#endif + +#define CLOCK_NODE DT_INST(0, nordic_nrf_clock) + +static const struct device *indication_led_dev; +static const struct device *gpio_port0_dev; + +/* Check if the system has GPIO port 1 */ +#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio1), okay) +static const struct device *gpio_port1_dev; + +#endif + +#if defined(DPPI_PRESENT) +uint8_t ppi_channel; + +#else +nrf_ppi_channel_t ppi_channel; + +#endif + +static void hfclk_on_callback(struct onoff_manager *mgr, struct onoff_client *cli, uint32_t state, + int res) +{ + /* do nothing */ +} + +static void clk_timer_handler(nrf_timer_event_t event_type, void *context) +{ + /* do nothing */ +} + +void periph_init(void) +{ + nrfx_err_t err_code; + int ret; + + /* Enable HFCLK */ + struct onoff_manager *mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF); + + __ASSERT_NO_MSG(mgr != NULL); + + sys_notify_init_callback(&hfclk_cli.notify, hfclk_on_callback); + + ret = onoff_request(mgr, &hfclk_cli); + __ASSERT_NO_MSG(ret >= 0); + + nrfx_timer_config_t clk_timer_cfg = NRFX_TIMER_DEFAULT_CONFIG; + + err_code = nrfx_timer_init(&clk_timer, &clk_timer_cfg, clk_timer_handler); + NRFX_ASSERT(err_code); + + err_code = nrfx_gpiote_init(0); + NRFX_ASSERT(err_code); + + indication_led_dev = device_get_binding(LED0); + assert(indication_led_dev); + + ret = gpio_pin_configure(indication_led_dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS); + + assert(ret == 0); + gpio_pin_set(indication_led_dev, PIN, false); + + gpio_port0_dev = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0))); + assert(gpio_port0_dev); + +#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio1), okay) + gpio_port1_dev = device_get_binding(DT_LABEL(DT_NODELABEL(gpio1))); + assert(gpio_port1_dev); +#endif +} + +uint32_t ptt_random_get_ext(void) +{ + return sys_rand32_get(); +} + +bool ptt_clk_out_ext(uint8_t pin, bool mode) +{ + uint32_t compare_evt_addr; + nrfx_err_t err; + + if (!nrf_gpio_pin_present_check(pin)) { + return false; + } + + if (mode) { + nrfx_timer_extended_compare(&clk_timer, (nrf_timer_cc_channel_t)0, 1, + NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false); + + nrfx_gpiote_out_config_t const out_config = { + .action = NRF_GPIOTE_POLARITY_TOGGLE, + .init_state = 0, + .task_pin = true, + }; + + /* Initialize output pin. SET task will turn the LED on, + * CLR will turn it off and OUT will toggle it. + */ + err = nrfx_gpiote_out_init(pin, &out_config); + if (err != NRFX_SUCCESS) { + LOG_ERR("nrfx_gpiote_out_init error: %08x", err); + return false; + } + + compare_evt_addr = + nrfx_timer_event_address_get(&clk_timer, NRF_TIMER_EVENT_COMPARE0); + + nrfx_gpiote_out_task_enable(pin); + + /* Allocate a (D)PPI channel. */ +#if defined(DPPI_PRESENT) + err = nrfx_dppi_channel_alloc(&ppi_channel); +#else + err = nrfx_ppi_channel_alloc(&ppi_channel); +#endif + if (err != NRFX_SUCCESS) { + LOG_ERR("(D)PPI channel allocation error: %08x", err); + return false; + } + + nrfx_gppi_channel_endpoints_setup( + ppi_channel, compare_evt_addr, + nrf_gpiote_task_address_get(NRF_GPIOTE, nrfx_gpiote_in_event_get(pin))); + + /* Enable (D)PPI channel. */ +#if defined(DPPI_PRESENT) + err = nrfx_dppi_channel_enable(ppi_channel); +#else + err = nrfx_ppi_channel_enable(ppi_channel); +#endif + if (err != NRFX_SUCCESS) { + LOG_ERR("Failed to enable (D)PPI channel, error: %08x", err); + return false; + } + + nrfx_timer_enable(&clk_timer); + } else { + nrfx_timer_disable(&clk_timer); + nrfx_gpiote_out_task_disable(pin); +#if defined(DPPI_PRESENT) + err = nrfx_dppi_channel_free(ppi_channel); +#else + err = nrfx_ppi_channel_free(ppi_channel); +#endif + if (err != NRFX_SUCCESS) { + LOG_ERR("Failed to disable (D)PPI channel, error: %08x", err); + return false; + } + nrfx_gpiote_out_uninit(pin); + } + + return true; +} + +static const struct device *get_pin_port(uint32_t *pin) +{ + switch (nrf_gpio_pin_port_number_extract(pin)) { + case 0: + return gpio_port0_dev; + +#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio1), okay) + case 1: + return gpio_port1_dev; + +#endif + default: + return NULL; + } +} + +bool ptt_set_gpio_ext(uint8_t pin, uint8_t value) +{ + int ret; + const struct device *port; + uint32_t pin_nr = pin; + + if (nrf_gpio_pin_present_check(pin_nr)) { + port = get_pin_port(&pin_nr); + if (port == NULL) { + return false; + } + + ret = gpio_pin_configure(port, pin_nr, GPIO_OUTPUT); + + if (ret == 0) { + ret = gpio_pin_set(port, pin_nr, value); + if (ret == 0) { + return true; + } + } + } + + return false; +} + +bool ptt_get_gpio_ext(uint8_t pin, uint8_t *value) +{ + int ret; + const struct device *port; + uint32_t pin_nr = pin; + + if (nrf_gpio_pin_present_check(pin_nr)) { + port = get_pin_port(&pin_nr); + if (port == NULL) { + return false; + } + + ret = gpio_pin_configure(port, pin_nr, GPIO_INPUT); + + if (ret == 0) { + *value = gpio_pin_get(port, pin_nr); + return true; + } + } + + return false; +} + +void ptt_set_dcdc_ext(bool enable) +{ +#if NRF_POWER_HAS_DCDCEN + nrf_power_dcdcen_set(NRF_POWER, enable); +#endif + +#if NRF_POWER_HAS_DCDCEN_VDDH + nrf_power_dcdcen_vddh_set(NRF_POWER, enable); +#endif + +#if !NRF_POWER_HAS_DCDCEN && !NRF_POWER_HAS_DCDCEN_VDDH +#pragma message "DC-DC related commands have no effect!" +#endif +} + +bool ptt_get_dcdc_ext(void) +{ +#if NRF_POWER_HAS_DCDCEN && NRF_POWER_HAS_DCDCEN_VDDH + return (nrf_power_dcdcen_get(NRF_POWER) || nrf_power_dcdcen_vddh_get(NRF_POWER)); +#elif NRF_POWER_HAS_DCDCEN + return nrf_power_dcdcen_get(NRF_POWER); +#elif NRF_POWER_HAS_DCDCEN_VDDH + return nrf_power_dcdcen_vddh_get(NRF_POWER); +#else + return false; +#endif +} + +void ptt_set_icache_ext(bool enable) +{ +#if defined(NVMC_FEATURE_CACHE_PRESENT) + if (enable) { + nrfx_nvmc_icache_enable(); + } else { + nrfx_nvmc_icache_disable(); + } +#else +#pragma message "ICACHE related command have no effect" +#endif +} + +bool ptt_get_icache_ext(void) +{ +#if defined(NVMC_FEATURE_CACHE_PRESENT) + return nrf_nvmc_icache_enable_check(NRF_NVMC); +#else + return false; +#endif +} + +bool ptt_get_temp_ext(int32_t *temp) +{ + if (temp == NULL) { + return false; + } + + *temp = nrf_802154_temperature_get(); + + return true; +} + +void ptt_ctrl_led_indication_on_ext(void) +{ + gpio_pin_set(indication_led_dev, PIN, true); +} + +void ptt_ctrl_led_indication_off_ext(void) +{ + gpio_pin_set(indication_led_dev, PIN, false); +} diff --git a/samples/peripheral/802154_phy_test/src/ptt_conf.c b/samples/peripheral/802154_phy_test/src/ptt_conf.c new file mode 100644 index 000000000000..500650c0b910 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/ptt_conf.c @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: Production configuration routines */ + +#include +#include +#include + +bool ptt_get_mode_mask_ext(uint32_t *mode_mask) +{ + assert(mode_mask != NULL); + +#ifdef CONFIG_PTT_DUT_MODE + *mode_mask = 0x00000001; +#elif CONFIG_PTT_CMD_MODE + *mode_mask = 0x00000002; +#else + *mode_mask = 0x00000003; +#endif + return true; +} + +bool ptt_get_channel_mask_ext(uint32_t *channel_mask) +{ + assert(channel_mask != NULL); + + *channel_mask = CONFIG_PTT_CHANNEL_MASK; + return true; +} + +bool ptt_get_power_ext(int8_t *power) +{ + assert(power != NULL); + + *power = CONFIG_PTT_POWER; + return true; +} + +bool ptt_get_antenna_ext(uint8_t *antenna) +{ + assert(antenna != NULL); + +#if CONFIG_PTT_ANTENNA_DIVERSITY + *antenna = CONFIG_PTT_ANTENNA_NUMBER; + return true; +#else + return false; +#endif +} + +bool ptt_get_sw_version_ext(uint8_t *sw_version) +{ + assert(sw_version != NULL); + + *sw_version = CONFIG_PTT_SW_VERSION; + return true; +} + +bool ptt_get_hw_version_ext(uint8_t *hw_version) +{ + assert(hw_version != NULL); + + *hw_version = CONFIG_PTT_HW_VERSION; + return true; +} + +bool ptt_get_ant_mode_ext(uint8_t *ant_mode) +{ + assert(ant_mode != NULL); + +#if CONFIG_PTT_ANTENNA_DIVERSITY +#if CONFIG_PTT_ANT_MODE_AUTO + /* TODO: Implement when antenna diversity is supported in NCS */ +#elif CONFIG_PTT_ANT_MODE_MANUAL + /* TODO: Implement when antenna diversity is supported in NCS */ +#else + /* TODO: Implement when antenna diversity is supported in NCS */ +#endif + return true; +#else + return false; +#endif +} + +bool ptt_get_ant_num_ext(uint8_t *ant_num) +{ + assert(ant_num != NULL); + +#if CONFIG_PTT_ANTENNA_DIVERSITY + *ant_num = CONFIG_PTT_ANTENNA_NUMBER; + return true; +#else + return false; +#endif +} diff --git a/samples/peripheral/802154_phy_test/src/rf/ptt_rf.c b/samples/peripheral/802154_phy_test/src/rf/ptt_rf.c new file mode 100644 index 000000000000..39ec36e8b8b1 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/rf/ptt_rf.c @@ -0,0 +1,631 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: interface part of radio module */ + +#include +#include + +#include "ctrl/ptt_ctrl.h" +#include "ctrl/ptt_trace.h" +#include "rf/ptt_rf.h" +#include "ptt.h" + +#include "ptt_rf_api.h" +#include "ptt_rf_internal.h" + +struct ptt_rf_ctx_s ptt_rf_ctx; + +static enum ptt_ret ptt_rf_try_lock(ptt_evt_id_t evt_id); +static inline bool ptt_rf_is_locked(void); +static inline bool ptt_rf_is_locked_by(ptt_evt_id_t evt_id); +static inline ptt_evt_id_t ptt_rf_unlock(void); + +static enum ptt_ret ptt_rf_promiscuous_set(bool value); + +static void ptt_rf_stat_inc(int8_t rssi, uint8_t lqi); + +static void ptt_rf_set_default_channel(void); +static void ptt_rf_set_default_power(void); +static void ptt_rf_set_default_antenna(void); + +void ptt_rf_init(void) +{ + PTT_TRACE("%s ->\n", __func__); + ptt_rf_ctx = (struct ptt_rf_ctx_s){ 0 }; + ptt_rf_unlock(); + + ptt_rf_set_default_channel(); + ptt_rf_set_default_power(); + ptt_rf_set_default_antenna(); + + /* we need raw PHY packets without any filtering */ + ptt_rf_promiscuous_set(true); + ptt_rf_receive_ext(); + PTT_TRACE("%s -<\n", __func__); +} + +void ptt_rf_uninit(void) +{ + PTT_TRACE("%s\n", __func__); +} + +void ptt_rf_reset(void) +{ + PTT_TRACE("%s ->\n", __func__); + ptt_rf_uninit(); + ptt_rf_init(); + PTT_TRACE("%s -<\n", __func__); +} + +static void ptt_rf_set_default_channel(void) +{ + uint32_t channel_mask; + enum ptt_ret ret = PTT_RET_SUCCESS; + + /* try to set channel from prod config */ + if (ptt_get_channel_mask_ext(&channel_mask)) { + ret = ptt_rf_set_channel_mask(PTT_RF_EVT_UNLOCKED, channel_mask); + if (ret != PTT_RET_SUCCESS) { + /* set default channel */ + ptt_rf_set_channel(PTT_RF_EVT_UNLOCKED, PTT_RF_DEFAULT_CHANNEL); + } + } else { + /* set default channel */ + ptt_rf_set_channel(PTT_RF_EVT_UNLOCKED, PTT_RF_DEFAULT_CHANNEL); + } +} + +static void ptt_rf_set_default_power(void) +{ + int8_t power = PTT_RF_DEFAULT_POWER; + + /* set power from prod config */ + if (ptt_get_power_ext(&power)) { + ptt_rf_set_power(PTT_RF_EVT_UNLOCKED, power); + } else { + ptt_rf_set_power(PTT_RF_EVT_UNLOCKED, PTT_RF_DEFAULT_POWER); + } +} + +static void ptt_rf_set_default_antenna(void) +{ + uint8_t antenna = PTT_RF_DEFAULT_ANTENNA; + + /* set antenna from prod config */ + if (ptt_get_antenna_ext(&antenna)) { + ptt_rf_set_antenna(PTT_RF_EVT_UNLOCKED, antenna); + } else { + ptt_rf_set_antenna(PTT_RF_EVT_UNLOCKED, PTT_RF_DEFAULT_ANTENNA); + } +} + +void ptt_rf_push_packet(const uint8_t *pkt, ptt_pkt_len_t len, int8_t rssi, uint8_t lqi) +{ + ptt_rf_stat_inc(rssi, lqi); + ptt_ctrl_rf_push_packet(pkt, len, rssi, lqi); +} + +void ptt_rf_tx_finished(void) +{ + if (ptt_rf_is_locked()) { + /* have to unlock before passing control out of RF module */ + ptt_evt_id_t evt_id = ptt_rf_unlock(); + + ptt_ctrl_rf_tx_finished(evt_id); + } else { + PTT_TRACE("%s: called, but rf module is not locked\n", __func__); + /* we get event although we didn't send a packet, just pass it */ + } +} + +void ptt_rf_tx_failed(ptt_rf_tx_error_t tx_error) +{ + if (ptt_rf_is_locked()) { + /* have to unlock before passing control out of RF module */ + ptt_evt_id_t evt_id = ptt_rf_unlock(); + + ptt_ctrl_rf_tx_failed(evt_id, tx_error); + } else { + PTT_TRACE("%s: called, but rf module is not locked\n", __func__); + /* we get event although we didn't send a packet, just pass it */ + } +} + +void ptt_rf_rx_failed(ptt_rf_rx_error_t rx_error) +{ + ptt_ctrl_rf_rx_failed(rx_error); +} + +void ptt_rf_cca_done(bool result) +{ + if (ptt_rf_is_locked()) { + /* have to unlock before passing control out of RF module */ + ptt_evt_id_t evt_id = ptt_rf_unlock(); + + ptt_ctrl_rf_cca_done(evt_id, result); + } else { + PTT_TRACE("%s: called, but rf module is not locked\n", __func__); + /* we get event although we didn't send a packet, just pass it */ + } +} + +void ptt_rf_cca_failed(void) +{ + if (ptt_rf_is_locked()) { + /* have to unlock before passing control out of RF module */ + ptt_evt_id_t evt_id = ptt_rf_unlock(); + + ptt_ctrl_rf_cca_failed(evt_id); + } else { + PTT_TRACE("%s: called, but rf module is not locked\n", __func__); + /* we get event although we didn't send a packet, just pass it */ + } +} + +enum ptt_ret ptt_rf_cca(ptt_evt_id_t evt_id, uint8_t mode) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + /* will be unlocked inside ptt_rf_cca_done/ptt_rf_cca_failed functions */ + if (false == ptt_rf_cca_ext(mode)) { + ret = PTT_RET_BUSY; + } + + if (ret != PTT_RET_SUCCESS) { + ptt_rf_unlock(); + } + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +void ptt_rf_ed_detected(ptt_ed_t result) +{ + if (ptt_rf_is_locked()) { + /* have to unlock before passing control out of RF module */ + ptt_evt_id_t evt_id = ptt_rf_unlock(); + + ptt_ctrl_rf_ed_detected(evt_id, result); + } else { + PTT_TRACE("%s: called, but rf module does not locked\n", __func__); + /* we get event although we didn't send a packet, just pass it */ + } +} + +void ptt_rf_ed_failed(void) +{ + if (ptt_rf_is_locked()) { + /* have to unlock before passing control out of RF module */ + ptt_evt_id_t evt_id = ptt_rf_unlock(); + + ptt_ctrl_rf_ed_failed(evt_id); + } else { + PTT_TRACE("%s: called, but rf module does not locked\n", __func__); + /* we get event although we didn't send a packet, just pass it */ + } +} + +enum ptt_ret ptt_rf_ed(ptt_evt_id_t evt_id, uint32_t time_us) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + /* will be unlocked inside ptt_rf_ed_detected/ptt_rf_ed_failed functions */ + if (false == ptt_rf_ed_ext(time_us)) { + ret = PTT_RET_BUSY; + } + + if (ret != PTT_RET_SUCCESS) { + ptt_rf_unlock(); + } + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_rssi_measure_begin(ptt_evt_id_t evt_id) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + if (false == ptt_rf_rssi_measure_begin_ext()) { + ret = PTT_RET_BUSY; + } + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_rssi_last_get(ptt_evt_id_t evt_id, ptt_rssi_t *rssi) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + *rssi = ptt_rf_rssi_last_get_ext(); + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_send_packet(ptt_evt_id_t evt_id, const uint8_t *pkt, ptt_pkt_len_t len) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + if ((pkt == NULL) || (len == 0)) { + ret = PTT_RET_INVALID_VALUE; + } + + if (ret == PTT_RET_SUCCESS) { + /* will be unlocked inside ptt_rf_tx_finished/ptt_rf_tx_failed functions */ + if (false == ptt_rf_send_packet_ext(pkt, len, ptt_rf_ctx.cca_on_tx)) { + ret = PTT_RET_BUSY; + } + } + + if (ret != PTT_RET_SUCCESS) { + ptt_rf_unlock(); + } + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_set_channel_mask(ptt_evt_id_t evt_id, uint32_t mask) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + uint8_t channel = ptt_rf_convert_channel_mask_to_num(mask); + + if ((channel < PTT_CHANNEL_MIN) || (channel > PTT_CHANNEL_MAX)) { + ret = PTT_RET_INVALID_VALUE; + } else { + ret = ptt_rf_set_channel(evt_id, channel); + } + + return ret; +} + +enum ptt_ret ptt_rf_set_channel(ptt_evt_id_t evt_id, uint8_t channel) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + if ((channel < PTT_CHANNEL_MIN) || (channel > PTT_CHANNEL_MAX)) { + ret = PTT_RET_INVALID_VALUE; + } + + if (ret == PTT_RET_SUCCESS) { + ptt_rf_ctx.channel = channel; + ptt_rf_set_channel_ext(ptt_rf_ctx.channel); + } + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_set_short_address(ptt_evt_id_t evt_id, const uint8_t *short_addr) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + ptt_rf_set_short_address_ext(short_addr); + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_set_extended_address(ptt_evt_id_t evt_id, const uint8_t *extended_addr) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + ptt_rf_set_extended_address_ext(extended_addr); + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_set_pan_id(ptt_evt_id_t evt_id, const uint8_t *pan_id) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + ptt_rf_set_pan_id_ext(pan_id); + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +uint8_t ptt_rf_convert_channel_mask_to_num(uint32_t mask) +{ + uint8_t channel_num = 0; + + for (uint8_t i = PTT_CHANNEL_MIN; i <= PTT_CHANNEL_MAX; i++) { + if (((mask >> i) & 1u) == 1u) { + channel_num = i; + break; + } + } + + return channel_num; +} + +uint8_t ptt_rf_get_channel(void) +{ + return ptt_rf_ctx.channel; +} + +enum ptt_ret ptt_rf_set_power(ptt_evt_id_t evt_id, int8_t power) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + ptt_rf_set_power_ext(power); + ptt_rf_ctx.power = power; + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +int8_t ptt_rf_get_power(void) +{ + ptt_rf_ctx.power = ptt_rf_get_power_ext(); + return ptt_rf_ctx.power; +} + +enum ptt_ret ptt_rf_set_antenna(ptt_evt_id_t evt_id, uint8_t antenna) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + ptt_rf_set_antenna_ext(antenna); + ptt_rf_ctx.antenna = antenna; + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +uint8_t ptt_rf_get_antenna(void) +{ + ptt_rf_ctx.antenna = ptt_rf_get_antenna_ext(); + return ptt_rf_ctx.antenna; +} + +enum ptt_ret ptt_rf_start_statistic(ptt_evt_id_t evt_id) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + ptt_rf_ctx.stat = (struct ptt_rf_stat_s){ 0 }; + ptt_rf_ctx.stat_enabled = true; + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_end_statistic(ptt_evt_id_t evt_id) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_is_locked_by(evt_id)) { + ptt_rf_ctx.stat_enabled = false; + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +struct ptt_rf_stat_s ptt_rf_get_stat_report(void) +{ + return ptt_rf_ctx.stat; +} + +enum ptt_ret ptt_rf_start_modulated_stream(ptt_evt_id_t evt_id, const uint8_t *pkt, + ptt_pkt_len_t len) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + if ((pkt == NULL) || (len == 0)) { + ret = PTT_RET_INVALID_VALUE; + } + + if (ret == PTT_RET_SUCCESS) { + /* will be unlocked inside ptt_rf_stop_modulated_stream */ + if (false == ptt_rf_modulated_stream_ext(pkt, len)) { + ret = PTT_RET_BUSY; + } + } + + if (ret != PTT_RET_SUCCESS) { + ptt_rf_unlock(); + } + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_stop_modulated_stream(ptt_evt_id_t evt_id) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_is_locked_by(evt_id)) { + if (false == ptt_rf_receive_ext()) { + ret = PTT_RET_BUSY; + } + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_start_continuous_carrier(ptt_evt_id_t evt_id) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_try_lock(evt_id) == PTT_RET_SUCCESS) { + /* will be unlocked inside ptt_rf_stop_continuous_stream */ + if (false == ptt_rf_continuous_carrier_ext()) { + ret = PTT_RET_BUSY; + + ptt_rf_unlock(); + } + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_stop_continuous_carrier(ptt_evt_id_t evt_id) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_is_locked_by(evt_id)) { + if (false == ptt_rf_receive_ext()) { + ret = PTT_RET_BUSY; + } + + ptt_rf_unlock(); + } else { + ret = PTT_RET_BUSY; + } + + return ret; +} + +static enum ptt_ret ptt_rf_promiscuous_set(bool value) +{ + ptt_rf_promiscuous_set_ext(value); + + return 0; +} + +enum ptt_ret ptt_rf_receive(void) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_is_locked() || (false == ptt_rf_receive_ext())) { + ret = PTT_RET_BUSY; + } + + return ret; +} + +enum ptt_ret ptt_rf_sleep(void) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_is_locked() || (false == ptt_rf_sleep_ext())) { + ret = PTT_RET_BUSY; + } + + return ret; +} + +static inline ptt_evt_id_t ptt_rf_unlock(void) +{ + ptt_evt_id_t evt_id = ptt_rf_ctx.evt_lock; + + ptt_rf_ctx.evt_lock = PTT_RF_EVT_UNLOCKED; + + return evt_id; +} + +static inline bool ptt_rf_is_locked(void) +{ + return (ptt_rf_ctx.evt_lock == PTT_RF_EVT_UNLOCKED) ? false : true; +} + +static inline bool ptt_rf_is_locked_by(ptt_evt_id_t evt_id) +{ + return (evt_id == ptt_rf_ctx.evt_lock) ? true : false; +} + +static enum ptt_ret ptt_rf_try_lock(ptt_evt_id_t evt_id) +{ + enum ptt_ret ret = PTT_RET_SUCCESS; + + if (ptt_rf_is_locked()) { + ret = PTT_RET_BUSY; + } + + if (ret == PTT_RET_SUCCESS) { + ptt_rf_ctx.evt_lock = evt_id; + } + + return ret; +} + +static void ptt_rf_stat_inc(int8_t rssi, uint8_t lqi) +{ + if (ptt_rf_ctx.stat_enabled) { + ptt_rf_ctx.stat.total_pkts++; + /* according to B.3.10: + * Assumes no RSSI values measured that are greater than zero dBm + */ + if (rssi > 0) { + rssi = 0; + } + ptt_rf_ctx.stat.total_rssi += (rssi * (-1)); + ptt_rf_ctx.stat.total_lqi += lqi; + } +} + +inline struct ptt_ltx_payload_s *ptt_rf_get_custom_ltx_payload(void) +{ + return &(ptt_rf_ctx.ltx_payload); +} diff --git a/samples/peripheral/802154_phy_test/src/rf/ptt_rf_internal.h b/samples/peripheral/802154_phy_test/src/rf/ptt_rf_internal.h new file mode 100644 index 000000000000..2496b39ce712 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/rf/ptt_rf_internal.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: internal RF defines */ + +#ifndef PTT_RF_INTERNAL_H__ +#define PTT_RF_INTERNAL_H__ + +#include + +#include "ptt_types.h" + +#include "ctrl/ptt_events.h" + +#include "rf/ptt_rf.h" + +#define PTT_RF_EVT_UNLOCKED (PTT_EVENT_UNASSIGNED) +#define PTT_RF_DEFAULT_CHANNEL (PTT_CHANNEL_MIN) +/* @todo: arbitrary selected, change PTT_RF_DEFAULT_POWER to appropriate value after testing */ +#define PTT_RF_DEFAULT_POWER (-20) +#define PTT_RF_DEFAULT_ANTENNA 0u + +/** RF module context */ +struct ptt_rf_ctx_s { + uint8_t channel; /**< configured RF channel */ + int8_t power; /**< configured RF power */ + uint8_t antenna; /**< configured RF antenna */ + ptt_evt_id_t evt_lock; /**< current event processing by RF module */ + bool cca_on_tx; /**< perform CCA before transmission or not */ + bool stat_enabled; /**< statistic gathering enabled */ + struct ptt_rf_stat_s stat; /**< received packets statistic */ + struct ptt_ltx_payload_s ltx_payload; /**< raw payload for 'custom ltx' command */ +}; + +#endif /* PTT_RF_INTERNAL_H__ */ diff --git a/samples/peripheral/802154_phy_test/src/rf_proc.c b/samples/peripheral/802154_phy_test/src/rf_proc.c new file mode 100644 index 000000000000..783f1491923e --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/rf_proc.c @@ -0,0 +1,433 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: Adaptation layer for RF configuring and processing */ + +#include +#include +#include + +#include + +#include "nrf_802154.h" + +#include "rf_proc.h" + +#include "ptt.h" + +#include +LOG_MODULE_REGISTER(rf_proc); + +/**< Maximum size of RF pool of received packets */ +#define RF_RX_POOL_N 16u + +static struct rf_rx_pkt_s rf_rx_pool[RF_RX_POOL_N]; +static struct rf_rx_pkt_s ack_packet; +static uint8_t temp_tx_pkt[RF_PSDU_MAX_SIZE]; + +static inline void rf_rx_pool_init(void); +static void rf_rx_pool_clear(void); + +static void rf_tx_finished_fn(struct k_work *work) +{ + ptt_rf_tx_finished(); +} + +K_WORK_DEFINE(rf_tx_finished_wq, rf_tx_finished_fn); + +static void rf_tx_ack_received_fn(struct k_work *work) +{ + ptt_rf_push_packet(ack_packet.data, ack_packet.length, ack_packet.rssi, ack_packet.lqi); + nrf_802154_buffer_free_raw(ack_packet.rf_buf); +} + +K_WORK_DEFINE(rf_tx_ack_received_wq, rf_tx_ack_received_fn); + +static void rf_cca_failed_fn(struct k_work *work) +{ + ptt_rf_cca_failed(); +} + +K_WORK_DEFINE(rf_cca_failed_wq, rf_cca_failed_fn); + +static void rf_ed_failed_fn(struct k_work *work) +{ + ptt_rf_ed_failed(); +} + +K_WORK_DEFINE(rf_ed_failed_wq, rf_ed_failed_fn); + +struct rf_rx_failed_info { + struct k_work work; + ptt_rf_tx_error_t rx_error; +} rf_rx_failed_info; +static void rf_rx_failed_fn(struct k_work *work) +{ + ptt_rf_rx_failed(rf_rx_failed_info.rx_error); +} + +struct rf_tx_failed_info { + struct k_work work; + ptt_rf_tx_error_t tx_error; +} rf_tx_failed_info; +static void rf_tx_failed_fn(struct k_work *work) +{ + ptt_rf_tx_failed(rf_tx_failed_info.tx_error); +} + +struct rf_cca_done_info { + struct k_work work; + bool channel_free; +} rf_cca_done_info; +static void rf_cca_done_fn(struct k_work *work) +{ + ptt_rf_cca_done((bool)rf_cca_done_info.channel_free); +} + +struct rf_ed_detected_info { + struct k_work work; + uint8_t result; +} rf_ed_detected_info; +static void rf_ed_detected_fn(struct k_work *work) +{ + ptt_rf_ed_detected((ptt_ed_t)rf_ed_detected_info.result); +} + +#if CONFIG_PTT_ANTENNA_DIVERSITY +#warning "Antenna diversity enabled but not yet supported in NCS" +/* TODO: Implement when antenna diversity is supported in NCS */ +static void configure_antenna_diversity(void); + +#endif /* CONFIG_PTT_ANTENNA_DIVERSITY */ + +void rf_init(void) +{ + k_work_init(&rf_rx_failed_info.work, rf_rx_failed_fn); + k_work_init(&rf_tx_failed_info.work, rf_tx_failed_fn); + k_work_init(&rf_cca_done_info.work, rf_cca_done_fn); + k_work_init(&rf_ed_detected_info.work, rf_ed_detected_fn); + + /* clear a pool for received packets */ + rf_rx_pool_init(); + ack_packet = (struct rf_rx_pkt_s){ 0 }; + + /* nrf radio driver initialization */ + nrf_802154_init(); + +#if CONFIG_PTT_ANTENNA_DIVERSITY + /* TODO: Implement when antenna diversity is supported in NCS */ + configure_antenna_diversity(); +#endif +} + +void rf_uninit(void) +{ + /* free packets and marks them as free */ + rf_rx_pool_clear(); + ack_packet = (struct rf_rx_pkt_s){ 0 }; + nrf_802154_deinit(); +} + +#if CONFIG_PTT_ANTENNA_DIVERSITY +static void configure_antenna_diversity(void) +{ + /* TODO: Implement when antenna diversity is supported in NCS */ +} + +#endif /* CONFIG_PTT_ANTENNA_DIVERSITY */ + +static void rf_process_rx_packets(void) +{ + struct rf_rx_pkt_s *rx_pkt = NULL; + + for (uint8_t i = 0; i < RF_RX_POOL_N; i++) { + rx_pkt = &rf_rx_pool[i]; + if (rx_pkt->data != NULL) { + ptt_rf_push_packet(rx_pkt->data, rx_pkt->length, rx_pkt->rssi, rx_pkt->lqi); + nrf_802154_buffer_free_raw(rx_pkt->rf_buf); + rx_pkt->data = NULL; + } + } +} + +void rf_thread(void) +{ + while (1) { + rf_process_rx_packets(); + k_sleep(K_MSEC(1)); + } +} + +void nrf_802154_received_raw(uint8_t *data, int8_t power, uint8_t lqi) +{ + struct rf_rx_pkt_s *rx_pkt = NULL; + bool pkt_placed = false; + + assert(data != NULL); + + for (uint8_t i = 0; i < RF_RX_POOL_N; i++) { + if (rf_rx_pool[i].data == NULL) { + rx_pkt = &rf_rx_pool[i]; + rx_pkt->rf_buf = data; + rx_pkt->data = &data[1]; + rx_pkt->length = data[0] - RF_FCS_SIZE; + rx_pkt->rssi = power; + rx_pkt->lqi = lqi; + pkt_placed = true; + break; + } + } + if (false == pkt_placed) { + LOG_ERR("Not enough space to store packet. Will drop it."); + nrf_802154_buffer_free_raw(data); + } +} + +void nrf_802154_receive_failed(nrf_802154_rx_error_t error, uint32_t id) +{ + LOG_INF("rx failed error %d!", error); + + /* mapping nrf_802154 errors into PTT RF errors */ + /* actually only invalid ACK FCS matters at the moment */ + if (error == NRF_802154_RX_ERROR_INVALID_FCS) { + rf_rx_failed_info.rx_error = PTT_RF_RX_ERROR_INVALID_FCS; + } else { + rf_rx_failed_info.rx_error = PTT_RF_RX_ERROR_OPERATION_FAILED; + } + + k_work_submit(&rf_rx_failed_info.work); +} + +void nrf_802154_transmitted_raw(uint8_t *frame, + const nrf_802154_transmit_done_metadata_t *metadata) +{ + ARG_UNUSED(frame); + + if (metadata->data.transmitted.p_ack != NULL) { + ack_packet = (struct rf_rx_pkt_s){ 0 }; + + ack_packet.data = metadata->data.transmitted.p_ack; + ack_packet.length = metadata->data.transmitted.length; + ack_packet.rssi = metadata->data.transmitted.power; + ack_packet.lqi = metadata->data.transmitted.lqi; + ack_packet.rf_buf = metadata->data.transmitted.p_ack; + + k_work_submit(&rf_tx_ack_received_wq); + } + + k_work_submit(&rf_tx_finished_wq); +} + +void nrf_802154_transmit_failed(uint8_t *frame, nrf_802154_tx_error_t error, + const nrf_802154_transmit_done_metadata_t *p_metadata) +{ + ARG_UNUSED(frame); + + LOG_INF("tx failed error %d!", error); + + /* mapping nrf_802154 errors into PTT RF errors */ + if (error == NRF_802154_TX_ERROR_INVALID_ACK) { + rf_tx_failed_info.tx_error = PTT_RF_TX_ERROR_INVALID_ACK_FCS; + } else if (error == NRF_802154_TX_ERROR_NO_ACK) { + rf_tx_failed_info.tx_error = PTT_RF_TX_ERROR_NO_ACK; + } else { + rf_tx_failed_info.tx_error = PTT_RF_TX_ERROR_OPERATION_FAILED; + } + + k_work_submit(&rf_tx_failed_info.work); +} + +void nrf_802154_cca_done(bool channel_free) +{ + LOG_INF("CCA finished with result %d", channel_free); + + rf_cca_done_info.channel_free = channel_free; + k_work_submit(&rf_cca_done_info.work); +} + +void nrf_802154_cca_failed(nrf_802154_cca_error_t error) +{ + ARG_UNUSED(error); + + LOG_INF("CCA failed error %d!", error); + + k_work_submit(&rf_cca_failed_wq); +} + +void nrf_802154_energy_detected(uint8_t result) +{ + LOG_INF("ED finished with result %d", result); + + rf_ed_detected_info.result = result; + k_work_submit(&rf_ed_detected_info.work); +} + +void nrf_802154_energy_detection_failed(nrf_802154_ed_error_t error) +{ + ARG_UNUSED(error); + + LOG_INF("ED failed error %d!", error); + + k_work_submit(&rf_ed_failed_wq); +} + +void ptt_rf_set_channel_ext(uint8_t channel) +{ + nrf_802154_channel_set(channel); +} + +void ptt_rf_set_power_ext(int8_t power) +{ + nrf_802154_tx_power_set(power); +} + +int8_t ptt_rf_get_power_ext(void) +{ + return nrf_802154_tx_power_get(); +} + +void ptt_rf_set_antenna_ext(uint8_t antenna) +{ +#if CONFIG_PTT_ANTENNA_DIVERSITY + /* TODO: Implement when antenna diversity is supported in NCS */ +#endif +} + +uint8_t ptt_rf_get_antenna_ext(void) +{ +#if CONFIG_PTT_ANTENNA_DIVERSITY + /* TODO: Implement when antenna diversity is supported in NCS */ + return 0; +#else + return 0; +#endif +} + +void ptt_rf_promiscuous_set_ext(bool value) +{ + nrf_802154_promiscuous_set(value); +} + +bool ptt_rf_receive_ext(void) +{ + return nrf_802154_receive(); +} + +void ptt_rf_set_pan_id_ext(const uint8_t *pan_id) +{ + nrf_802154_pan_id_set(pan_id); +} + +void ptt_rf_set_extended_address_ext(const uint8_t *extended_address) +{ + nrf_802154_extended_address_set(extended_address); +} + +void ptt_rf_set_short_address_ext(const uint8_t *short_address) +{ + nrf_802154_short_address_set(short_address); +} + +bool ptt_rf_cca_ext(uint8_t mode) +{ + bool ret = false; + + if ((mode >= NRF_RADIO_CCA_MODE_CARRIER) && (mode <= NRF_RADIO_CCA_MODE_CARRIER_OR_ED)) { + nrf_802154_cca_cfg_t cca_cfg; + + nrf_802154_cca_cfg_get(&cca_cfg); + + cca_cfg.mode = mode; + + nrf_802154_cca_cfg_set(&cca_cfg); + + ret = nrf_802154_cca(); + } else { + ret = false; + } + + return ret; +} + +bool ptt_rf_ed_ext(uint32_t time_us) +{ + return nrf_802154_energy_detection(time_us); +} + +bool ptt_rf_rssi_measure_begin_ext(void) +{ + return nrf_802154_rssi_measure_begin(); +} + +int8_t ptt_rf_rssi_last_get_ext(void) +{ + return nrf_802154_rssi_last_get(); +} + +bool ptt_rf_send_packet_ext(const uint8_t *pkt, ptt_pkt_len_t len, bool cca) +{ + bool ret = false; + + if ((pkt == NULL) || (len > RF_PSDU_MAX_SIZE - RF_FCS_SIZE)) { + ret = false; + } else { + /* temp_tx_pkt is protected inside ptt rf by locking mechanism */ + temp_tx_pkt[0] = len + RF_FCS_SIZE; + memcpy(&temp_tx_pkt[RF_PSDU_START], pkt, len); + const nrf_802154_transmit_metadata_t metadata = { + .cca = cca + }; + ret = nrf_802154_transmit_raw(temp_tx_pkt, &metadata); + } + + return ret; +} + +bool ptt_rf_modulated_stream_ext(const uint8_t *pkt, ptt_pkt_len_t len) +{ + bool ret = false; + + if ((pkt == NULL) || (len > RF_PSDU_MAX_SIZE - RF_FCS_SIZE)) { + ret = false; + } else { + /* temp_tx_pkt is protected inside ptt rf by locking mechanism */ + temp_tx_pkt[0] = len + RF_FCS_SIZE; + memcpy(&temp_tx_pkt[RF_PSDU_START], pkt, len); + + ret = nrf_802154_modulated_carrier(temp_tx_pkt); + } + + return ret; +} + +bool ptt_rf_sleep_ext(void) +{ + return nrf_802154_sleep(); +} + +bool ptt_rf_continuous_carrier_ext(void) +{ + return nrf_802154_continuous_carrier(); +} + +static inline void rf_rx_pool_init(void) +{ + for (uint8_t i = 0; i < RF_RX_POOL_N; i++) { + rf_rx_pool[i] = (struct rf_rx_pkt_s){ 0 }; + } +} + +static void rf_rx_pool_clear(void) +{ + struct rf_rx_pkt_s *rx_pkt = NULL; + + for (uint8_t i = 0; i < RF_RX_POOL_N; i++) { + rx_pkt = &rf_rx_pool[i]; + if (rx_pkt->data != NULL) { + nrf_802154_buffer_free_raw(rx_pkt->rf_buf); + rx_pkt->data = NULL; + } + } +} diff --git a/samples/peripheral/802154_phy_test/src/timer_proc.c b/samples/peripheral/802154_phy_test/src/timer_proc.c new file mode 100644 index 000000000000..ca1346d306b5 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/timer_proc.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: timer configuring and processing */ + +#include + +#include "timer_proc.h" + +#include "ptt.h" + +#include +LOG_MODULE_REGISTER(timer); + +static void ptt_process_timer_handler(struct k_timer *timer); +static void schedule_ptt_process(struct k_work *work); + +K_TIMER_DEFINE(app_timer, ptt_process_timer_handler, NULL); + +K_WORK_DEFINE(schedule_ptt_processor, schedule_ptt_process); + +static void ptt_process_timer_handler(struct k_timer *timer) +{ + k_work_submit(&schedule_ptt_processor); +} + +ptt_time_t ptt_get_current_time(void) +{ + return k_uptime_get_32(); +} + +ptt_time_t ptt_get_max_time(void) +{ + /* The maximum possible time is the maximum for a uint32_t */ + return UINT32_MAX; +} + +void launch_ptt_process_timer(ptt_time_t timeout) +{ + if (timeout == 0) { + /* schedule immediately */ + k_work_submit(&schedule_ptt_processor); + } else { + /* Schedule a single shot timer to trigger after the timeout */ + k_timer_start(&app_timer, K_MSEC(timeout), K_MSEC(0)); + } +} + +/* scheduler context */ +static void schedule_ptt_process(struct k_work *work) +{ + ptt_process(ptt_get_current_time()); +} diff --git a/samples/peripheral/802154_phy_test/src/uart_proc.c b/samples/peripheral/802154_phy_test/src/uart_proc.c new file mode 100644 index 000000000000..669eeeaa5869 --- /dev/null +++ b/samples/peripheral/802154_phy_test/src/uart_proc.c @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +/* Purpose: UART configuring and processing */ + +/* UART handler waits for a string with new line symbol in the end. The handler reads a packet + * from UARTE driver per a byte and looks for a new line symbol or waits until a timer is expired + * to process received sequence without new line symbol. Then the packet is pushed to the library. + */ + +#include +#include + +#include +#include + +#include "comm_proc.h" +#include "uart_proc.h" + +#include +LOG_MODULE_REGISTER(uart); + +static struct text_proc_s text_proc_uart; +static struct k_timer uart_timer; +static const struct device *uart_dev; + +RING_BUF_DECLARE(uart_rb, 10240); + +static void uart_irq_handler(const struct device *dev, void *context) +{ + uint8_t *data_tx; + + uart_irq_update(dev); + if (uart_irq_tx_ready(dev)) { + int nr_bytes_read = + ring_buf_get_claim(&uart_rb, &data_tx, CONFIG_UART_0_NRF_TX_BUFFER_SIZE); + int sent = uart_fifo_fill(dev, data_tx, nr_bytes_read); + + ring_buf_get_finish(&uart_rb, sent); + if (ring_buf_is_empty(&uart_rb)) { + uart_irq_tx_disable(dev); + } + } + + if (uart_irq_rx_ready(dev)) { + uint8_t buf[10]; + int len = uart_fifo_read(dev, buf, sizeof(buf)); + + if (len) { + /* Call this */ + comm_input_process(&text_proc_uart, buf, UART_BYTES_TO_READ); + } + } +} + +void uart_init(void) +{ + LOG_INF("Init"); + + uart_dev = device_get_binding("UART_0"); + __ASSERT(uart_dev, "Failed to get the device"); + uart_irq_callback_user_data_set(uart_dev, uart_irq_handler, NULL); + uart_irq_rx_enable(uart_dev); + + text_proc_uart = (struct text_proc_s){ 0 }; + text_proc_uart.timer = uart_timer; + k_timer_init(&text_proc_uart.timer, comm_input_timeout_handler, NULL); + k_work_init(&text_proc_uart.work, comm_text_processor_fn); +} + +int32_t uart_send(const uint8_t *pkt, ptt_pkt_len_t len, bool add_crlf) +{ + while (ring_buf_space_get(&uart_rb) < len) { + LOG_WRN("queue full, waiting for free space"); + k_sleep(K_MSEC(1)); + } + + uart_irq_tx_disable(uart_dev); + ring_buf_put(&uart_rb, pkt, len); + if (add_crlf) { + ring_buf_put(&uart_rb, COMM_APPENDIX, COMM_APPENDIX_SIZE); + } + uart_irq_tx_enable(uart_dev); + + return len; +} diff --git a/samples/peripheral/radio_test/CMakeLists.txt b/samples/peripheral/radio_test/CMakeLists.txt index 6762a2d9667e..4cae49f86525 100644 --- a/samples/peripheral/radio_test/CMakeLists.txt +++ b/samples/peripheral/radio_test/CMakeLists.txt @@ -6,19 +6,6 @@ cmake_minimum_required(VERSION 3.13.1) -option(NRF21540EK_FEM "Enable support for the nRF21540-EK FEM." OFF) - -if(NRF21540EK_FEM) - set(DTC_OVERLAY_FILE - "${CMAKE_CURRENT_SOURCE_DIR}/configuration/dts-nrf21540-fem.overlay" - CACHE STRING "" FORCE) - - if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay") - set(DTC_OVERLAY_FILE "${DTC_OVERLAY_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay" - CACHE STRING "" FORCE) - endif() -endif() - find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(NONE) diff --git a/samples/peripheral/radio_test/README.rst b/samples/peripheral/radio_test/README.rst index 0decdbc891c1..f7a5bb793d56 100644 --- a/samples/peripheral/radio_test/README.rst +++ b/samples/peripheral/radio_test/README.rst @@ -59,8 +59,6 @@ The sample also requires one of the following testing devices: nRF21540 front-end module ========================= -.. |fem_file_path| replace:: :file:`samples/peripheral/radio_test/configuration` - .. include:: /includes/sample_dtm_radio_test_fem.txt The nRF21540 transmitted power gain, antenna and an activation delay can be configured using the user interface :ref:`radio_test_ui`. @@ -138,7 +136,7 @@ Building and running However, you must still program the application core to boot up the network core. You can use any sample for this, for example :ref:`nrf5340_empty_app_core`. The :ref:`nrf5340_empty_app_core` is built and programmed automatically by default. - If you want to program another sample for the application core, unset the :option:'CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE' option. + If you want to program another sample for the application core, unset the :kconfig:'CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE' option. .. _radio_test_testing: diff --git a/samples/peripheral/radio_test/configuration/dts-nrf21540-fem.overlay b/samples/peripheral/radio_test/configuration/dts-nrf21540-fem.overlay deleted file mode 100644 index f22bae3d2468..000000000000 --- a/samples/peripheral/radio_test/configuration/dts-nrf21540-fem.overlay +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2021 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - - / { - nrf_radio_fem: nrf21540_fem { - compatible = "nordic,nrf21540-fem"; - tx-en-gpios = <&arduino_header 11 GPIO_ACTIVE_HIGH>; /* D5 */ - rx-en-gpios = <&arduino_header 9 GPIO_ACTIVE_HIGH>; /* D3 */ - pdn-gpios = <&arduino_header 15 GPIO_ACTIVE_HIGH>; /* D9 */ - ant-sel-gpios = <&arduino_header 10 GPIO_ACTIVE_HIGH>; /* D4 */ - mode-gpios = <&arduino_header 8 GPIO_ACTIVE_HIGH>; /* D2 */ - spi-if = <&nrf_radio_fem_spi>; - }; -}; - -fem_spi: &arduino_spi { - status = "okay"; - cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */ - - nrf_radio_fem_spi: nrf21540_fem_spi@0 { - compatible = "nordic,nrf21540-fem-spi"; - status = "okay"; - reg = <0>; - label = "FEM_SPI_IF"; - spi-max-frequency = <8000000>; - }; -}; diff --git a/samples/profiler/README.rst b/samples/profiler/README.rst index 80d56b24de0d..62a1fff78acc 100644 --- a/samples/profiler/README.rst +++ b/samples/profiler/README.rst @@ -31,7 +31,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns, nrf52840dk_nrf52840, nrf52dk_nrf52832 + :rows: nrf9160dk_nrf9160_ns, nrf52840dk_nrf52840, nrf52dk_nrf52832 Building and running ******************** diff --git a/samples/profiler/sample.yaml b/samples/profiler/sample.yaml index db1f5a0b4606..690137c206a1 100644 --- a/samples/profiler/sample.yaml +++ b/samples/profiler/sample.yaml @@ -8,5 +8,5 @@ tests: integration_platforms: - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: ci_build diff --git a/samples/sensor/bh1749/README.rst b/samples/sensor/bh1749/README.rst index af3dc7a963d4..ed040818eac3 100644 --- a/samples/sensor/bh1749/README.rst +++ b/samples/sensor/bh1749/README.rst @@ -21,7 +21,7 @@ The sample supports the following nRF9160-based device: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: thingy91_nrf9160ns + :rows: thingy91_nrf9160_ns Building and Running ******************** diff --git a/samples/spm/README.rst b/samples/spm/README.rst index d37454628a3a..eae92ba6ca73 100644 --- a/samples/spm/README.rst +++ b/samples/spm/README.rst @@ -42,12 +42,12 @@ Requirements for the application firmware For more details, see the partition configuration file for the chosen board (e.g. `nrf9160dk_nrf9160_partition_conf.dts`_ for the nRF9160 DK). Note that if you build your application firmware with the |NCS|, this requirement is automatically fulfilled. -* The application firmware must be built as a non-secure firmware for the build target (e.g. nrf9160dk_nrf9160ns for the nRF9160 DK). +* The application firmware must be built as a non-secure firmware for the build target (e.g. nrf9160dk_nrf9160_ns for the nRF9160 DK). Automatic building of SPM ========================= -The sample is automatically built by the non-secure applications when the non-secure build target is used (e.g. nrf9160dk_nrf9160ns). +The sample is automatically built by the non-secure applications when the non-secure build target is used (e.g. nrf9160dk_nrf9160_ns). However, it is not a part of the non-secure application. Instead of programming SPM and the non-secure application at the same time, you might want to program them individually. diff --git a/samples/tfm/tfm_hello_world/README.rst b/samples/tfm/tfm_hello_world/README.rst index 097f2b0ab904..e60e34cfddeb 100644 --- a/samples/tfm/tfm_hello_world/README.rst +++ b/samples/tfm/tfm_hello_world/README.rst @@ -22,7 +22,7 @@ The sample supports the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf5340dk_nrf5340_cpuappns, nrf9160dk_nrf9160ns + :rows: nrf5340dk_nrf5340_cpuapp_ns, nrf9160dk_nrf9160_ns Building and Running ******************** diff --git a/samples/tfm/tfm_hello_world/boards/nrf9160dk_nrf9160ns.overlay b/samples/tfm/tfm_hello_world/boards/nrf9160dk_nrf9160_ns.overlay similarity index 100% rename from samples/tfm/tfm_hello_world/boards/nrf9160dk_nrf9160ns.overlay rename to samples/tfm/tfm_hello_world/boards/nrf9160dk_nrf9160_ns.overlay diff --git a/samples/tfm/tfm_hello_world/sample.yaml b/samples/tfm/tfm_hello_world/sample.yaml index d5ba5aef618f..6c8ee424a964 100644 --- a/samples/tfm/tfm_hello_world/sample.yaml +++ b/samples/tfm/tfm_hello_world/sample.yaml @@ -4,10 +4,10 @@ sample: name: hello world TFM common: tags: tfm - platform_allow: nrf5340dk_nrf5340_cpuappns nrf9160dk_nrf9160ns + platform_allow: nrf5340dk_nrf5340_cpuapp_ns nrf9160dk_nrf9160_ns integration_platforms: - - nrf5340dk_nrf5340_cpuappns - - nrf9160dk_nrf9160ns + - nrf5340dk_nrf5340_cpuapp_ns + - nrf9160dk_nrf9160_ns harness: console harness_config: type: multi_line diff --git a/samples/zigbee/common/dts-nrf21540-fem.overlay b/samples/zigbee/common/dts-nrf21540-fem.overlay deleted file mode 100644 index 569d29f10248..000000000000 --- a/samples/zigbee/common/dts-nrf21540-fem.overlay +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright (c) 2021 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -/ { - nrf_radio_fem: nrf21540_fem { - compatible = "nordic,nrf21540-fem"; - tx-en-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; - rx-en-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>; - pdn-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>; - ant-sel-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; - }; -}; diff --git a/samples/zigbee/light_bulb/README.rst b/samples/zigbee/light_bulb/README.rst index ac19449c9633..7c4c83ba39ac 100644 --- a/samples/zigbee/light_bulb/README.rst +++ b/samples/zigbee/light_bulb/README.rst @@ -41,8 +41,6 @@ Configuration FEM support =========== -.. |fem_file_path| replace:: :file:`samples/zigbee/common` - .. include:: /includes/sample_fem_support.txt User interface diff --git a/samples/zigbee/light_switch/README.rst b/samples/zigbee/light_switch/README.rst index 5c43cdeacc3a..565bfc2ca2d1 100644 --- a/samples/zigbee/light_switch/README.rst +++ b/samples/zigbee/light_switch/README.rst @@ -59,7 +59,7 @@ The sleepy behavior can be enabled by pressing **Button 3** while the light swit Multiprotocol Bluetooth LE extension ==================================== -This optional extension demonstrates dynamic concurrent switching between two protocols, Bluetooth LE and Zigbee. +This optional extension demonstrates dynamic concurrent switching between two protocols, Bluetooth® LE and Zigbee. It uses :ref:`nus_service_readme` library. When this extension is enabled, you can use: @@ -119,8 +119,6 @@ For more information about using configuration overlay files, see :ref:`zephyr:i FEM support =========== -.. |fem_file_path| replace:: :file:`samples/zigbee/common` - .. include:: /includes/sample_fem_support.txt .. _zigbee_light_switch_user_interface: diff --git a/samples/zigbee/ncp/README.rst b/samples/zigbee/ncp/README.rst index 97c8107deaa1..1c9eed2bdb5b 100644 --- a/samples/zigbee/ncp/README.rst +++ b/samples/zigbee/ncp/README.rst @@ -50,7 +50,7 @@ Overview The sample demonstrates using a Nordic Semiconductor's Development Kit as Zigbee Network Co-Processor. -The sample uses the :option:`CONFIG_ZIGBEE_LIBRARY_NCP_DEV` Kconfig option, which is available as part of the :ref:`nrfxlib:zboss_configuration`. +The sample uses the :kconfig:`CONFIG_ZIGBEE_LIBRARY_NCP_DEV` Kconfig option, which is available as part of the :ref:`nrfxlib:zboss_configuration`. The NCP Kconfig option extends the compilation process with an implementation of the ZBOSS API serialization through NCP commands. It also implements the ZBOSS default signal handler function, which controls the ZBOSS and commissioning logic. @@ -70,7 +70,7 @@ Serial communication setup ========================== The communication channel uses Zephyr's :ref:`zephyr:uart_api` API. -This serial device is selected with :option:`CONFIG_ZIGBEE_UART_DEVICE_NAME`. +This serial device is selected with :kconfig:`CONFIG_ZIGBEE_UART_DEVICE_NAME`. By default, the NCP sample communicates through the UART serialization (``UART0``). As a result, Zephyr's logger is configured to use ``UART1``, which is available through GPIO pins (**P1.00** and **P1.01**). @@ -112,7 +112,7 @@ MCUboot When the `Communication through USB`_ is selected, MCUboot in this sample is built with support for single application slot, and uses the USB DFU class driver to allow uploading image over USB. -If you want to use the default UART serial communication channel, you can enable MCUboot by setting the :option:`CONFIG_BOOTLOADER_MCUBOOT` Kconfig option. +If you want to use the default UART serial communication channel, you can enable MCUboot by setting the :kconfig:`CONFIG_BOOTLOADER_MCUBOOT` Kconfig option. To use the same MCUboot configuration as in `Communication through USB`_, you need to provide MCUboot with the Kconfig options included in the :file:`child_image/mcuboot_usb.conf` file. See :ref:`ug_multi_image_variables` for how to set the required options. @@ -158,8 +158,6 @@ to upgrade the dongle, you can use one of the following options: FEM support =========== -.. |fem_file_path| replace:: :file:`samples/zigbee/common` - .. include:: /includes/sample_fem_support.txt .. _zigbee_ncp_user_interface: diff --git a/samples/zigbee/ncp/sample.yaml b/samples/zigbee/ncp/sample.yaml index 45cba7c10909..7386fad4aa60 100644 --- a/samples/zigbee/ncp/sample.yaml +++ b/samples/zigbee/ncp/sample.yaml @@ -27,6 +27,6 @@ tests: build_only: true platform_allow: nrf52840dk_nrf52840 tags: ci_build - extra_args: DTC_OVERLAY_FILE=boards/nrf52840dk_nrf52840.overlay;../common/dts-nrf21540-fem.overlay + extra_args: SHIELD=nrf21540_ek integration_platforms: - nrf52840dk_nrf52840 diff --git a/samples/zigbee/network_coordinator/README.rst b/samples/zigbee/network_coordinator/README.rst index 2619e8747b6f..5c0487641ffc 100644 --- a/samples/zigbee/network_coordinator/README.rst +++ b/samples/zigbee/network_coordinator/README.rst @@ -43,8 +43,6 @@ Configuration FEM support =========== -.. |fem_file_path| replace:: :file:`samples/zigbee/common` - .. include:: /includes/sample_fem_support.txt User interface diff --git a/samples/zigbee/template/CMakeLists.txt b/samples/zigbee/template/CMakeLists.txt new file mode 100644 index 000000000000..851fc1414ed0 --- /dev/null +++ b/samples/zigbee/template/CMakeLists.txt @@ -0,0 +1,17 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +cmake_minimum_required(VERSION 3.17.3) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project("Zigbee application template") + +# NORDIC SDK APP START +target_sources(app PRIVATE + src/main.c +) +# NORDIC SDK APP END diff --git a/samples/zigbee/template/README.rst b/samples/zigbee/template/README.rst new file mode 100644 index 000000000000..6f17fa70e6fb --- /dev/null +++ b/samples/zigbee/template/README.rst @@ -0,0 +1,95 @@ +.. _zigbee_template_sample: + +Zigbee: Template +################ + +.. contents:: + :local: + :depth: 2 + +This :ref:`Zigbee ` sample is a minimal implementation of the Zigbee Router role. + +You can use this sample as the starting point for developing your own Zigbee device. + +Requirements +************ + +The sample supports the following development kits: + +.. table-from-rows:: /includes/sample_board_rows.txt + :header: heading + :rows: nrf52840dk_nrf52840, nrf52833dk_nrf52833, nrf5340dk_nrf5340_cpuapp, nrf21540dk_nrf52840 + +You can use one or more of the development kits listed above and mix different development kits. + +For this sample to work, the following samples also need to be programmed: + +* The :ref:`Zigbee network coordinator ` sample on one separate device. + +Overview +******** + +The Zigbee template sample takes the Zigbee Router role and implements two clusters (Basic and Identify) that used to be required by the Zigbee Home Automation profile. +The Basic cluster provides attributes and commands for determining basic information about the node. +The Identify cluster allows to put the device into the identification mode, which provides a way to locate the device. + +User interface +************** + +LED 3: + Turns on when the device joins the network. + +LED 4: + Blinks to indicate that the identification mode is on. + +Button 4: + Toggles the identification mode on the device. + +Building and running +******************** +.. |sample path| replace:: :file:`samples/zigbee/template` + +|enable_zigbee_before_testing| + +.. include:: /includes/build_and_run.txt + +.. _zigbee_application_template_testing: + +Testing +======= + +After programming the sample to your development kit, test it by performing the following steps: + +1. Turn on the development kit that runs the network coordinator sample. + When **LED 3** turns on, this development kit has become the Coordinator of the Zigbee network and the network is established. +#. Turn on the development kit that runs the template sample. + When **LED 3** turns on, the light bulb has become a Router inside the network. + + .. tip:: + If **LED 3** does not turn on, press **Button 1** on the Coordinator to reopen the network. + +The device running the template sample is now part of the Zigbee network as a Router. +As a result, the network range is extended by the template application radio range. + +Dependencies +************ + +This sample uses the following |NCS| libraries: + +* :file:`include/zigbee/zigbee_error_handler.h` +* :ref:`lib_zigbee_application_utilities` +* Zigbee subsystem: + + * :file:`zb_nrf_platform.h` + +* :ref:`dk_buttons_and_leds_readme` + +This sample uses the following `sdk-nrfxlib`_ libraries: + +* :ref:`nrfxlib:zboss` |zboss_version| (`API documentation`_) + +In addition, it uses the following Zephyr libraries: + +* :file:`include/zephyr.h` +* :file:`include/device.h` +* :ref:`zephyr:logging_api` diff --git a/samples/zigbee/template/boards/nrf21540dk_nrf52840.overlay b/samples/zigbee/template/boards/nrf21540dk_nrf52840.overlay new file mode 100644 index 000000000000..129fb915f3d3 --- /dev/null +++ b/samples/zigbee/template/boards/nrf21540dk_nrf52840.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + chosen { + zephyr,entropy = &rng; + }; +}; diff --git a/samples/zigbee/template/boards/nrf52833dk_nrf52833.overlay b/samples/zigbee/template/boards/nrf52833dk_nrf52833.overlay new file mode 100644 index 000000000000..129fb915f3d3 --- /dev/null +++ b/samples/zigbee/template/boards/nrf52833dk_nrf52833.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + chosen { + zephyr,entropy = &rng; + }; +}; diff --git a/samples/zigbee/template/boards/nrf52840dk_nrf52840.overlay b/samples/zigbee/template/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 000000000000..129fb915f3d3 --- /dev/null +++ b/samples/zigbee/template/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + chosen { + zephyr,entropy = &rng; + }; +}; diff --git a/samples/zigbee/template/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/zigbee/template/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 000000000000..67fefbb9fbad --- /dev/null +++ b/samples/zigbee/template/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1,18 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_MAIN_STACK_SIZE=2048 + +# Use software cryptography on nRF5340 +CONFIG_CRYPTO=n +CONFIG_CRYPTO_NRF_ECB=n +CONFIG_TINYCRYPT=y +CONFIG_CTR_DRBG_CSPRNG_GENERATOR=y +CONFIG_ZIGBEE_USE_SOFTWARE_AES=y +CONFIG_ENTROPY_CC3XX=y + +# Networking +CONFIG_MPSL=n diff --git a/samples/zigbee/template/prj.conf b/samples/zigbee/template/prj.conf new file mode 100644 index 000000000000..71899eaf60a4 --- /dev/null +++ b/samples/zigbee/template/prj.conf @@ -0,0 +1,43 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +CONFIG_NCS_SAMPLES_DEFAULTS=y + +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_SERIAL=y +CONFIG_GPIO=y + +# Make sure printk is not printing to the UART console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +CONFIG_HEAP_MEM_POOL_SIZE=2048 +CONFIG_MAIN_THREAD_PRIORITY=7 + +CONFIG_ZIGBEE=y +CONFIG_ZIGBEE_APP_UTILS=y +CONFIG_ZIGBEE_ROLE_ROUTER=y + +# Enable DK LED and Buttons library +CONFIG_DK_LIBRARY=y + +# This example requires more workqueue stack +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 + +# Enable nRF ECB driver +CONFIG_CRYPTO=y +CONFIG_CRYPTO_NRF_ECB=y +CONFIG_CRYPTO_INIT_PRIORITY=80 + +# Cryptocell is not supported through CSPRNG driver API: NCSDK-4813 +CONFIG_ENTROPY_CC3XX=n + +# Networking +CONFIG_NET_IPV6_MLD=n +CONFIG_NET_IPV6_NBR_CACHE=n +CONFIG_NET_IPV6_RA_RDNSS=n +CONFIG_NET_IP_ADDR_CHECK=n +CONFIG_NET_UDP=n diff --git a/samples/zigbee/template/sample.yaml b/samples/zigbee/template/sample.yaml new file mode 100644 index 000000000000..261217d1a29b --- /dev/null +++ b/samples/zigbee/template/sample.yaml @@ -0,0 +1,13 @@ +sample: + name: Zigbee application template + description: Zigbee application template +tests: + zigbee.template: + build_only: true + platform_allow: nrf52840dk_nrf52840 nrf52833dk_nrf52833 nrf5340dk_nrf5340_cpuapp nrf21540dk_nrf52840 + tags: ci_build smoke + integration_platforms: + - nrf52840dk_nrf52840 + - nrf52833dk_nrf52833 + - nrf5340dk_nrf5340_cpuapp + - nrf21540dk_nrf52840 diff --git a/samples/zigbee/template/src/main.c b/samples/zigbee/template/src/main.c new file mode 100644 index 000000000000..aba4161260d0 --- /dev/null +++ b/samples/zigbee/template/src/main.c @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/** @file + * + * @brief Zigbee application template. + */ + +#include +#include +#include + +#include +#include +#include +#include + + +/* Device endpoint, used to receive ZCL commands. */ +#define APP_TEMPLATE_ENDPOINT 10 + +/* Type of power sources available for the device. + * For possible values see section 3.2.2.2.8 of ZCL specification. + */ +#define BULB_INIT_BASIC_POWER_SOURCE ZB_ZCL_BASIC_POWER_SOURCE_DC_SOURCE + +/* LED indicating that device successfully joined Zigbee network. */ +#define ZIGBEE_NETWORK_STATE_LED DK_LED3 + +/* LED used for device identification. */ +#define IDENTIFY_LED DK_LED4 + +/* Button used to enter the Identify mode. */ +#define IDENTIFY_MODE_BUTTON DK_BTN4_MSK + + +LOG_MODULE_REGISTER(app); + +/* Main application customizable context. + * Stores all settings and static values. + */ +struct zb_device_ctx { + zb_zcl_basic_attrs_t basic_attr; + zb_zcl_identify_attrs_t identify_attr; +}; + +/* Zigbee device application context storage. */ +static struct zb_device_ctx dev_ctx; + +ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST( + identify_attr_list, + &dev_ctx.identify_attr.identify_time); + +ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST( + basic_attr_list, + &dev_ctx.basic_attr.zcl_version, + &dev_ctx.basic_attr.power_source); + +ZB_HA_DECLARE_RANGE_EXTENDER_CLUSTER_LIST( + app_template_clusters, + identify_attr_list, + basic_attr_list); + +ZB_HA_DECLARE_RANGE_EXTENDER_EP( + app_template_ep, + APP_TEMPLATE_ENDPOINT, + app_template_clusters); + +ZBOSS_DECLARE_DEVICE_CTX_1_EP( + app_template_ctx, + app_template_ep); + + +/**@brief Function for initializing all clusters attributes. */ +static void app_clusters_attr_init(void) +{ + /* Basic cluster attributes data */ + dev_ctx.basic_attr.zcl_version = ZB_ZCL_VERSION; + dev_ctx.basic_attr.power_source = BULB_INIT_BASIC_POWER_SOURCE; + + /* Identify cluster attributes data. */ + dev_ctx.identify_attr.identify_time = + ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE; +} + +/**@brief Function to toggle the identify LED + * + * @param bufid Unused parameter, required by ZBOSS scheduler API. + */ +static void toggle_identify_led(zb_bufid_t bufid) +{ + static int blink_status; + + dk_set_led(IDENTIFY_LED, (++blink_status) % 2); + ZB_SCHEDULE_APP_ALARM(toggle_identify_led, bufid, ZB_MILLISECONDS_TO_BEACON_INTERVAL(100)); +} + +/**@brief Function to handle identify notification events on the first endpoint. + * + * @param bufid Unused parameter, required by ZBOSS scheduler API. + */ +static void identify_cb(zb_bufid_t bufid) +{ + zb_ret_t zb_err_code; + + if (bufid) { + /* Schedule a self-scheduling function that will toggle the LED */ + ZB_SCHEDULE_APP_CALLBACK(toggle_identify_led, bufid); + } else { + /* Cancel the toggling function alarm and turn off LED */ + zb_err_code = ZB_SCHEDULE_APP_ALARM_CANCEL(toggle_identify_led, ZB_ALARM_ANY_PARAM); + ZVUNUSED(zb_err_code); + + dk_set_led(IDENTIFY_LED, 0); + } +} + +/**@breif Starts identifying the device. + * + * @param bufid Unused parameter, required by ZBOSS scheduler API. + */ +static void start_identifying(zb_bufid_t bufid) +{ + zb_ret_t zb_err_code; + + ZVUNUSED(bufid); + + /* Check if endpoint is in identifying mode, + * if not put desired endpoint in identifying mode. + */ + if (dev_ctx.identify_attr.identify_time == + ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE) { + LOG_INF("Enter identify mode"); + zb_err_code = zb_bdb_finding_binding_target( + APP_TEMPLATE_ENDPOINT); + ZB_ERROR_CHECK(zb_err_code); + } else { + LOG_INF("Cancel identify mode"); + zb_bdb_finding_binding_target_cancel(); + } +} + +/**@brief Callback for button events. + * + * @param[in] button_state Bitmask containing buttons state. + * @param[in] has_changed Bitmask containing buttons + * that have changed their state. + */ +static void button_changed(uint32_t button_state, uint32_t has_changed) +{ + /* Calculate bitmask of buttons that are pressed + * and have changed their state. + */ + uint32_t buttons = button_state & has_changed; + + if (buttons & IDENTIFY_MODE_BUTTON) { + ZB_SCHEDULE_APP_CALLBACK(start_identifying, 0); + } +} + +/**@brief Function for initializing LEDs and Buttons. */ +static void configure_gpio(void) +{ + int err; + + err = dk_buttons_init(button_changed); + if (err) { + LOG_ERR("Cannot init buttons (err: %d)", err); + } + + err = dk_leds_init(); + if (err) { + LOG_ERR("Cannot init LEDs (err: %d)", err); + } +} + +/**@brief Zigbee stack event handler. + * + * @param[in] bufid Reference to the Zigbee stack buffer + * used to pass signal. + */ +void zboss_signal_handler(zb_bufid_t bufid) +{ + /* Update network status LED. */ + zigbee_led_status_update(bufid, ZIGBEE_NETWORK_STATE_LED); + + /* No application-specific behavior is required. + * Call default signal handler. + */ + ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid)); + + /* All callbacks should either reuse or free passed buffers. + * If bufid == 0, the buffer is invalid (not passed). + */ + if (bufid) { + zb_buf_free(bufid); + } +} + +void error(void) +{ + dk_set_leds_state(DK_ALL_LEDS_MSK, DK_NO_LEDS_MSK); + + while (true) { + /* Spin forever */ + k_sleep(K_MSEC(1000)); + } +} + +void main(void) +{ + LOG_INF("Starting Zigbee application template example"); + + /* Initialize */ + configure_gpio(); + + /* Register device context (endpoints). */ + ZB_AF_REGISTER_DEVICE_CTX(&app_template_ctx); + + app_clusters_attr_init(); + + /* Register handlers to identify notifications */ + ZB_AF_SET_IDENTIFY_NOTIFICATION_HANDLER(APP_TEMPLATE_ENDPOINT, identify_cb); + + /* Start Zigbee default thread */ + zigbee_enable(); + + LOG_INF("Zigbee application template started"); +} diff --git a/scripts/get_pulls_in_range.py b/scripts/get_pulls_in_range.py index 92a6db3fb064..c5d94f7eb788 100755 --- a/scripts/get_pulls_in_range.py +++ b/scripts/get_pulls_in_range.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 +# Copyright (c) 2020-2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 + import argparse from contextlib import closing from collections import defaultdict diff --git a/scripts/hid_configurator/README.rst b/scripts/hid_configurator/README.rst index 453c7157fcc4..ce162918dcf2 100644 --- a/scripts/hid_configurator/README.rst +++ b/scripts/hid_configurator/README.rst @@ -22,7 +22,7 @@ It can be used for the following purposes: Overview ******** -The script looks for nRF Desktop devices connected to the host through USB, Bluetooth, or nRF Desktop dongle. +The script looks for nRF Desktop devices connected to the host through USB, Bluetooth®, or nRF Desktop dongle. The devices are identified based on Vendor ID. The script exchanges data with the device using :ref:`nrf_desktop_config_channel`. diff --git a/scripts/partition_manager/partition_manager.rst b/scripts/partition_manager/partition_manager.rst index eee9f76795f9..d04824c29f9d 100644 --- a/scripts/partition_manager/partition_manager.rst +++ b/scripts/partition_manager/partition_manager.rst @@ -100,7 +100,7 @@ In particular, partition definitions are global per domain, and must be identica If the same partition is defined twice with different configurations within a domain, the Partition Manager will fail. .. note:: - If Partition Manager configurations are only defined by subsystems, so that only one image is included in the build, you must set the option :option:`CONFIG_PM_SINGLE_IMAGE` to execute the Partition Manager script. + If Partition Manager configurations are only defined by subsystems, so that only one image is included in the build, you must set the option :kconfig:`CONFIG_PM_SINGLE_IMAGE` to execute the Partition Manager script. .. _pm_yaml_format: @@ -500,10 +500,10 @@ External flash regions always use the start_to_end placement strategy. To use external flash, you must provide information about the device to the Partition Manager through these Kconfig options: -* :option:`CONFIG_PM_EXTERNAL_FLASH` - enable external flash -* :option:`CONFIG_PM_EXTERNAL_FLASH_DEV_NAME` - specify the name of the flash device -* :option:`CONFIG_PM_EXTERNAL_FLASH_BASE` - specify the base address -* :option:`CONFIG_PM_EXTERNAL_FLASH_SIZE` - specify the available flash size (from the base address) +* :kconfig:`CONFIG_PM_EXTERNAL_FLASH` - enable external flash +* :kconfig:`CONFIG_PM_EXTERNAL_FLASH_DEV_NAME` - specify the name of the flash device +* :kconfig:`CONFIG_PM_EXTERNAL_FLASH_BASE` - specify the base address +* :kconfig:`CONFIG_PM_EXTERNAL_FLASH_SIZE` - specify the available flash size (from the base address) The following example assumes that the flash device has been initialized as follows in the flash driver: diff --git a/scripts/shell/ble_console/README.rst b/scripts/shell/ble_console/README.rst index 3f83e475cac5..3fffe20274ee 100644 --- a/scripts/shell/ble_console/README.rst +++ b/scripts/shell/ble_console/README.rst @@ -7,7 +7,7 @@ Bluetooth LE Console :local: :depth: 2 -Bluetooth LE Console (located in :file:`scripts/shell/ble_console`) is a desktop application that can be used to communicate with an nRF device over Bluetooth Low Energy using the :ref:`shell_bt_nus_readme`. +Bluetooth® LE Console (located in :file:`scripts/shell/ble_console`) is a desktop application that can be used to communicate with an nRF device over Bluetooth® Low Energy using the :ref:`shell_bt_nus_readme`. The application supports Linux only and cannot be run on Windows. You should run it on a natively installed Linux. diff --git a/scripts/west_commands/ncs_commands.py b/scripts/west_commands/ncs_commands.py index 2b7f50b0bcb9..5827e37424c9 100644 --- a/scripts/west_commands/ncs_commands.py +++ b/scripts/west_commands/ncs_commands.py @@ -28,7 +28,7 @@ def add_zephyr_rev_arg(parser): parser.add_argument('-z', '--zephyr-rev', metavar='REF', help='''zephyr git ref (commit, branch, etc.); - default: upstream/master''') + default: upstream/main''') def add_projects_arg(parser): parser.add_argument('projects', metavar='PROJECT', nargs='*', @@ -142,7 +142,7 @@ def validate_zephyr_rev(self, args): if args.zephyr_rev: zephyr_rev = args.zephyr_rev else: - zephyr_rev = 'upstream/master' + zephyr_rev = 'upstream/main' zephyr_project = self.manifest.get_projects(['zephyr'])[0] try: self.zephyr_sha = zephyr_project.sha(zephyr_rev) @@ -262,7 +262,8 @@ def print_loot(self, name, project, z_project, args, json_data): return log.banner(name_path) - log.inf(f'NCS commit (manifest-rev): {nsha}, upstream commit: {zsha}') + log.inf(f' NCS commit: {nsha}\n' + f'upstream commit: {zsha}') log.inf('OOT patches: ' + (f'{len(loot)} total' if loot else 'none') + (', output limited by --file' if args.files else '')) @@ -288,6 +289,9 @@ def print_loot(self, name, project, z_project, args, json_data): if args.json: json_data[name] = { + 'path': project.path, + 'ncs-commit': nsha, + 'upstream-commit': zsha, 'shas': json_sha_list, 'shortlogs': json_shortlog_list, } @@ -319,14 +323,14 @@ def do_run(self, args, unknown_args): # Get a dict containing projects that are in the NCS which are # *not* imported from Zephyr in nrf/west.yml. We will treat # these specially to make the output easier to understand. - ignored_imports = Manifest.from_file( - import_flags=ImportFlag.IGNORE_PROJECTS) - in_nrf = set(p.name for p in - ignored_imports.projects[MANIFEST_PROJECT_INDEX + 1:]) + ncs_only = Manifest.from_file(import_flags=ImportFlag.IGNORE_PROJECTS) + ncs_only_projects = ncs_only.projects[MANIFEST_PROJECT_INDEX + 1:] + ncs_only_names = set(p.name for p in ncs_only_projects) # This is a dict mapping names of projects which *are* imported # from zephyr to the Project instances. - self.imported_pmap = {name: project for name, project in - self.ncs_pmap.items() if name not in in_nrf} + self.imported_pmap = {name: project + for name, project in self.ncs_pmap.items() + if name not in ncs_only_names} log.inf('Comparing your manifest-rev branches with zephyr/west.yml ' f'at {self.zephyr_rev}' + @@ -442,7 +446,8 @@ def allowed_project(self, zp): else: status = f'diverged: {ahead} ahead, {behind} behind' - commits = f'NCS commit: {nsha}, upstream commit: {zsha}' + commits = (f' NCS commit: {nsha}\n' + f'upstream commit: {zsha}') if 'up to date' in status or 'ahead by' in status: if log.VERBOSE > log.VERBOSE_NONE: # Up to date or ahead: only print in verbose mode. @@ -485,6 +490,7 @@ def _name_and_path(project): 'modules/hal/quicklogic', 'modules/hal/silabs', 'modules/hal/stm32', + 'modules/hal/telink', 'modules/hal/ti', 'modules/hal/xtensa', 'modules/lib/tensorflow', diff --git a/scripts/west_commands/ncs_west_helpers.py b/scripts/west_commands/ncs_west_helpers.py index f9163de9ae19..7f1c428e1154 100644 --- a/scripts/west_commands/ncs_west_helpers.py +++ b/scripts/west_commands/ncs_west_helpers.py @@ -237,11 +237,39 @@ def _downstream_outstanding_commits(self): def _likely_merged_commits(self): # Compute patches which are downstream and probably were - # merged upstream, using a shortlog edit distance heuristic. - # This is a map from pygit2 commit objects for downstream - # patches, to a list of pygit2 commit objects that are - # upstream patches which have similar shortlogs and the same - # authors. + # merged upstream, using the following heuristics: + # + # 1. downstream patches with small shortlog edit distances + # from upstream patches + # + # 2. downstream patches with shortlogs that are prefixes of + # upstream patches + # + # Heuristic #1 catches patches with typos in the shortlogs + # that reviewers asked to be fixed, etc. E.g. upstream + # shortlog + # + # Bluetoth: do foo + # + # matches downstream shortlog + # + # [nrf fromlist] Bluetooth: do foo + # + # Heuristic #2 catches situations where we had to shorten our + # downstream shortlog to fit the "[nrf xyz]" sauce tag at the + # beginning and still fit within CI's shortlog length + # restrictions. E.g. upstream shortlog + # + # subsys: do a thing that is very useful for everyone + # + # matches downstream shortlog + # + # [nrf fromlist] subsys: do a thing that is very + # + # The return value is a map from pygit2 commit objects for + # downstream patches, to a list of pygit2 commit objects that + # are upstream patches which have similar shortlogs and the + # same authors. likely_merged = OrderedDict() for dc in self.downstream_outstanding: @@ -252,8 +280,14 @@ def ed(upstream_commit): shortlog_no_sauce(sl, self._downstream_sauce), commit_shortlog(upstream_commit)) - matches = [c for c in self.upstream_new if - ed(c) < self._edit_dist_threshold] + matches = [ + uc for uc in self.upstream_new if + # Heuristic #1: + ed(uc) < self._edit_dist_threshold or + # Heuristic #2: + commit_shortlog(uc).startswith(sl) + ] + if len(matches) != 0: likely_merged[dc] = matches diff --git a/subsys/bluetooth/mesh/gen_battery_cli.c b/subsys/bluetooth/mesh/gen_battery_cli.c index d535f770a150..6afdf7cdaf68 100644 --- a/subsys/bluetooth/mesh/gen_battery_cli.c +++ b/subsys/bluetooth/mesh/gen_battery_cli.c @@ -43,16 +43,17 @@ int bt_mesh_gen_bat_decode_status(struct net_buf_simple *buf, return 0; } -static void handle_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_battery_cli *cli = model->user_data; struct bt_mesh_battery_status status; struct bt_mesh_battery_status *rsp; + int err; - if (bt_mesh_gen_bat_decode_status(buf, &status)) { - return; + err = bt_mesh_gen_bat_decode_status(buf, &status); + if (err) { + return err; } if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, BT_MESH_BATTERY_OP_STATUS, ctx->addr, @@ -64,12 +65,14 @@ static void handle_status(struct bt_mesh_model *model, if (cli->status_handler) { cli->status_handler(cli, ctx, &status); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_battery_cli_op[] = { { BT_MESH_BATTERY_OP_STATUS, - BT_MESH_BATTERY_MSG_LEN_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_BATTERY_MSG_LEN_STATUS), handle_status, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_battery_srv.c b/subsys/bluetooth/mesh/gen_battery_srv.c index 1d00f1308cf8..693d59fcf76b 100644 --- a/subsys/bluetooth/mesh/gen_battery_srv.c +++ b/subsys/bluetooth/mesh/gen_battery_srv.c @@ -58,7 +58,7 @@ static void rsp_status(struct bt_mesh_model *model, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { struct bt_mesh_battery_srv *srv = model->user_data; @@ -67,10 +67,16 @@ static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, srv->get(srv, ctx, &status); rsp_status(model, ctx, &status); + + return 0; } const struct bt_mesh_model_op _bt_mesh_battery_srv_op[] = { - { BT_MESH_BATTERY_OP_GET, BT_MESH_BATTERY_MSG_LEN_GET, handle_get }, + { + BT_MESH_BATTERY_OP_GET, + BT_MESH_LEN_EXACT(BT_MESH_BATTERY_MSG_LEN_GET), + handle_get, + }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/gen_dtt_cli.c b/subsys/bluetooth/mesh/gen_dtt_cli.c index f06411df6ee4..a34e49059634 100644 --- a/subsys/bluetooth/mesh/gen_dtt_cli.c +++ b/subsys/bluetooth/mesh/gen_dtt_cli.c @@ -7,14 +7,9 @@ #include #include "model_utils.h" -static void handle_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_DTT_MSG_LEN_STATUS) { - return; - } - struct bt_mesh_dtt_cli *cli = model->user_data; int32_t transition_time = model_transition_decode(net_buf_simple_pull_u8(buf)); @@ -29,10 +24,16 @@ static void handle_status(struct bt_mesh_model *model, if (cli->status_handler) { cli->status_handler(cli, ctx, transition_time); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_dtt_cli_op[] = { - { BT_MESH_DTT_OP_STATUS, BT_MESH_DTT_MSG_LEN_STATUS, handle_status }, + { + BT_MESH_DTT_OP_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_DTT_MSG_LEN_STATUS), + handle_status, + }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/gen_dtt_srv.c b/subsys/bluetooth/mesh/gen_dtt_srv.c index 36a913cb8d08..dfc6e5ecd83a 100644 --- a/subsys/bluetooth/mesh/gen_dtt_srv.c +++ b/subsys/bluetooth/mesh/gen_dtt_srv.c @@ -24,32 +24,26 @@ static void rsp_status(struct bt_mesh_dtt_srv *srv, (void)bt_mesh_model_send(srv->model, rx_ctx, &msg, NULL, NULL); } -static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_DTT_MSG_LEN_GET) { - return; - } - struct bt_mesh_dtt_srv *srv = model->user_data; rsp_status(srv, ctx); + + return 0; } -static void set_dtt(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int set_dtt(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_DTT_MSG_LEN_SET) { - return; - } - struct bt_mesh_dtt_srv *srv = model->user_data; uint32_t old_time = srv->transition_time; uint32_t new_time = model_transition_decode(net_buf_simple_pull_u8(buf)); if (new_time == SYS_FOREVER_MS) { /* Invalid parameter */ - return; + return -EINVAL; } srv->transition_time = new_time; @@ -69,25 +63,38 @@ static void set_dtt(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, } (void)bt_mesh_dtt_srv_pub(srv, NULL); + + return 0; } -static void handle_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_dtt(model, ctx, buf, true); + return set_dtt(model, ctx, buf, true); } -static void handle_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_dtt(model, ctx, buf, false); + return set_dtt(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_dtt_srv_op[] = { - { BT_MESH_DTT_OP_GET, BT_MESH_DTT_MSG_LEN_GET, handle_get }, - { BT_MESH_DTT_OP_SET, BT_MESH_DTT_MSG_LEN_SET, handle_set }, - { BT_MESH_DTT_OP_SET_UNACK, BT_MESH_DTT_MSG_LEN_SET, handle_set_unack }, + { + BT_MESH_DTT_OP_GET, + BT_MESH_LEN_EXACT(BT_MESH_DTT_MSG_LEN_GET), + handle_get, + }, + { + BT_MESH_DTT_OP_SET, + BT_MESH_LEN_EXACT(BT_MESH_DTT_MSG_LEN_SET), + handle_set, + }, + { + BT_MESH_DTT_OP_SET_UNACK, + BT_MESH_LEN_EXACT(BT_MESH_DTT_MSG_LEN_SET), + handle_set_unack, + }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/gen_loc_cli.c b/subsys/bluetooth/mesh/gen_loc_cli.c index 39787860ade9..620fbabdeccd 100644 --- a/subsys/bluetooth/mesh/gen_loc_cli.c +++ b/subsys/bluetooth/mesh/gen_loc_cli.c @@ -8,14 +8,9 @@ #include "model_utils.h" #include "gen_loc_internal.h" -static void handle_global_loc(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_global_loc(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LOC_MSG_LEN_GLOBAL_STATUS) { - return; - } - struct bt_mesh_loc_cli *cli = model->user_data; struct bt_mesh_loc_global loc; struct bt_mesh_loc_global *rsp; @@ -31,16 +26,13 @@ static void handle_global_loc(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->global_status) { cli->handlers->global_status(cli, ctx, &loc); } + + return 0; } -static void handle_local_loc(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_local_loc(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LOC_MSG_LEN_LOCAL_STATUS) { - return; - } - struct bt_mesh_loc_cli *cli = model->user_data; struct bt_mesh_loc_local loc; struct bt_mesh_loc_local *rsp; @@ -56,17 +48,19 @@ static void handle_local_loc(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->local_status) { cli->handlers->local_status(cli, ctx, &loc); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_loc_cli_op[] = { { BT_MESH_LOC_OP_GLOBAL_STATUS, - BT_MESH_LOC_MSG_LEN_GLOBAL_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_LOC_MSG_LEN_GLOBAL_STATUS), handle_global_loc, }, { BT_MESH_LOC_OP_LOCAL_STATUS, - BT_MESH_LOC_MSG_LEN_LOCAL_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_LOC_MSG_LEN_LOCAL_STATUS), handle_local_loc, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_loc_srv.c b/subsys/bluetooth/mesh/gen_loc_srv.c index ff43a2ad4a51..0bdb1d2fb7e7 100644 --- a/subsys/bluetooth/mesh/gen_loc_srv.c +++ b/subsys/bluetooth/mesh/gen_loc_srv.c @@ -44,29 +44,22 @@ static void rsp_global(struct bt_mesh_model *model, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static void handle_global_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_global_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LOC_MSG_LEN_GLOBAL_GET) { - return; - } - struct bt_mesh_loc_srv *srv = model->user_data; struct bt_mesh_loc_global global = LOC_GLOBAL_DEFAULT; srv->handlers->global_get(srv, ctx, &global); rsp_global(model, ctx, &global); + + return 0; } -static void global_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int global_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_LOC_MSG_LEN_GLOBAL_SET) { - return; - } - struct bt_mesh_loc_srv *srv = model->user_data; struct bt_mesh_loc_global global; @@ -82,20 +75,21 @@ static void global_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, srv->pub_op != BT_MESH_LOC_OP_GLOBAL_STATUS) { (void)bt_mesh_loc_srv_global_pub(srv, NULL, &global); } + + return 0; } -static void handle_global_set(struct bt_mesh_model *model, +static int handle_global_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - global_set(model, ctx, buf, true); + return global_set(model, ctx, buf, true); } -static void handle_global_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_global_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - global_set(model, ctx, buf, false); + return global_set(model, ctx, buf, false); } /* Local location */ @@ -113,29 +107,23 @@ static void rsp_local(struct bt_mesh_model *model, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static void handle_local_get(struct bt_mesh_model *model, +static int handle_local_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LOC_MSG_LEN_LOCAL_GET) { - return; - } - struct bt_mesh_loc_srv *srv = model->user_data; struct bt_mesh_loc_local local = LOC_LOCAL_DEFAULT; srv->handlers->local_get(srv, ctx, &local); rsp_local(model, ctx, &local); + + return 0; } -static void local_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int local_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_LOC_MSG_LEN_LOCAL_SET) { - return; - } - struct bt_mesh_loc_srv *srv = model->user_data; struct bt_mesh_loc_local local; @@ -151,31 +139,33 @@ static void local_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, srv->pub_op != BT_MESH_LOC_OP_LOCAL_STATUS) { (void)bt_mesh_loc_srv_local_pub(srv, NULL, &local); } + + return 0; } -static void handle_local_set(struct bt_mesh_model *model, +static int handle_local_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - local_set(model, ctx, buf, true); + return local_set(model, ctx, buf, true); } -static void handle_local_set_unack(struct bt_mesh_model *model, +static int handle_local_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - local_set(model, ctx, buf, false); + return local_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_loc_srv_op[] = { { BT_MESH_LOC_OP_GLOBAL_GET, - BT_MESH_LOC_MSG_LEN_GLOBAL_GET, + BT_MESH_LEN_EXACT(BT_MESH_LOC_MSG_LEN_GLOBAL_GET), handle_global_get, }, { BT_MESH_LOC_OP_LOCAL_GET, - BT_MESH_LOC_MSG_LEN_LOCAL_GET, + BT_MESH_LEN_EXACT(BT_MESH_LOC_MSG_LEN_LOCAL_GET), handle_local_get, }, BT_MESH_MODEL_OP_END @@ -183,22 +173,22 @@ const struct bt_mesh_model_op _bt_mesh_loc_srv_op[] = { const struct bt_mesh_model_op _bt_mesh_loc_setup_srv_op[] = { { BT_MESH_LOC_OP_GLOBAL_SET, - BT_MESH_LOC_MSG_LEN_GLOBAL_SET, + BT_MESH_LEN_EXACT(BT_MESH_LOC_MSG_LEN_GLOBAL_SET), handle_global_set, }, { BT_MESH_LOC_OP_GLOBAL_SET_UNACK, - BT_MESH_LOC_MSG_LEN_GLOBAL_SET, + BT_MESH_LEN_EXACT(BT_MESH_LOC_MSG_LEN_GLOBAL_SET), handle_global_set_unack, }, { BT_MESH_LOC_OP_LOCAL_SET, - BT_MESH_LOC_MSG_LEN_LOCAL_SET, + BT_MESH_LEN_EXACT(BT_MESH_LOC_MSG_LEN_LOCAL_SET), handle_local_set, }, { BT_MESH_LOC_OP_LOCAL_SET_UNACK, - BT_MESH_LOC_MSG_LEN_LOCAL_SET, + BT_MESH_LEN_EXACT(BT_MESH_LOC_MSG_LEN_LOCAL_SET), handle_local_set_unack, }, BT_MESH_MODEL_OP_END diff --git a/subsys/bluetooth/mesh/gen_lvl_cli.c b/subsys/bluetooth/mesh/gen_lvl_cli.c index ad6dfb361f7e..395619142b10 100644 --- a/subsys/bluetooth/mesh/gen_lvl_cli.c +++ b/subsys/bluetooth/mesh/gen_lvl_cli.c @@ -7,13 +7,13 @@ #include #include "model_utils.h" -static void handle_status(struct bt_mesh_model *model, +static int handle_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { if (buf->len != BT_MESH_LVL_MSG_MINLEN_STATUS && buf->len != BT_MESH_LVL_MSG_MAXLEN_STATUS) { - return; + return -EMSGSIZE; } struct bt_mesh_lvl_cli *cli = model->user_data; @@ -39,10 +39,16 @@ static void handle_status(struct bt_mesh_model *model, if (cli->status_handler) { cli->status_handler(cli, ctx, &status); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_lvl_cli_op[] = { - { BT_MESH_LVL_OP_STATUS, BT_MESH_LVL_MSG_MINLEN_STATUS, handle_status }, + { + BT_MESH_LVL_OP_STATUS, + BT_MESH_LEN_MIN(BT_MESH_LVL_MSG_MINLEN_STATUS), + handle_status, + }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/gen_lvl_srv.c b/subsys/bluetooth/mesh/gen_lvl_srv.c index 8032fbd12bb1..ffe91fe8ea77 100644 --- a/subsys/bluetooth/mesh/gen_lvl_srv.c +++ b/subsys/bluetooth/mesh/gen_lvl_srv.c @@ -36,27 +36,25 @@ static void rsp_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, bt_mesh_model_send(model, ctx, &rsp, NULL, 0); } -static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LVL_MSG_LEN_GET) { - return; - } - struct bt_mesh_lvl_srv *srv = model->user_data; struct bt_mesh_lvl_status status = { 0 }; srv->handlers->get(srv, ctx, &status); rsp_status(model, ctx, &status); + + return 0; } -static void set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_LVL_MSG_MINLEN_SET && buf->len != BT_MESH_LVL_MSG_MAXLEN_SET) { - return; + return -EMSGSIZE; } struct bt_mesh_lvl_srv *srv = model->user_data; @@ -80,14 +78,16 @@ static void set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, } (void)bt_mesh_lvl_srv_pub(srv, NULL, &status); + + return 0; } -static void delta_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int delta_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_LVL_MSG_MINLEN_DELTA_SET && buf->len != BT_MESH_LVL_MSG_MAXLEN_DELTA_SET) { - return; + return -EMSGSIZE; } struct bt_mesh_lvl_srv *srv = model->user_data; @@ -111,14 +111,16 @@ static void delta_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, } (void)bt_mesh_lvl_srv_pub(srv, NULL, &status); + + return 0; } -static void move_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int move_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_LVL_MSG_MINLEN_MOVE_SET && buf->len != BT_MESH_LVL_MSG_MAXLEN_MOVE_SET) { - return; + return -EMSGSIZE; } struct bt_mesh_lvl_srv *srv = model->user_data; @@ -151,85 +153,82 @@ static void move_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, } (void)bt_mesh_lvl_srv_pub(srv, ctx, &status); + + return 0; } /* Message handlers */ -static void handle_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set(model, ctx, buf, true); + return set(model, ctx, buf, true); } -static void handle_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set(model, ctx, buf, false); + return set(model, ctx, buf, false); } -static void handle_delta_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_delta_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - delta_set(model, ctx, buf, true); + return delta_set(model, ctx, buf, true); } -static void handle_delta_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_delta_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - delta_set(model, ctx, buf, false); + return delta_set(model, ctx, buf, false); } -static void handle_move_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_move_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - move_set(model, ctx, buf, true); + return move_set(model, ctx, buf, true); } -static void handle_move_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_move_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - move_set(model, ctx, buf, false); + return move_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_lvl_srv_op[] = { { BT_MESH_LVL_OP_GET, - BT_MESH_LVL_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_LVL_MSG_LEN_GET), handle_get, }, { BT_MESH_LVL_OP_SET, - BT_MESH_LVL_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_LVL_MSG_MINLEN_SET), handle_set, }, { BT_MESH_LVL_OP_SET_UNACK, - BT_MESH_LVL_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_LVL_MSG_MINLEN_SET), handle_set_unack, }, { BT_MESH_LVL_OP_DELTA_SET, - BT_MESH_LVL_MSG_MINLEN_DELTA_SET, + BT_MESH_LEN_MIN(BT_MESH_LVL_MSG_MINLEN_DELTA_SET), handle_delta_set, }, { BT_MESH_LVL_OP_DELTA_SET_UNACK, - BT_MESH_LVL_MSG_MINLEN_DELTA_SET, + BT_MESH_LEN_MIN(BT_MESH_LVL_MSG_MINLEN_DELTA_SET), handle_delta_set_unack, }, { BT_MESH_LVL_OP_MOVE_SET, - BT_MESH_LVL_MSG_MINLEN_MOVE_SET, + BT_MESH_LEN_MIN(BT_MESH_LVL_MSG_MINLEN_MOVE_SET), handle_move_set, }, { BT_MESH_LVL_OP_MOVE_SET_UNACK, - BT_MESH_LVL_MSG_MINLEN_MOVE_SET, + BT_MESH_LEN_MIN(BT_MESH_LVL_MSG_MINLEN_MOVE_SET), handle_move_set_unack, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_onoff_cli.c b/subsys/bluetooth/mesh/gen_onoff_cli.c index d7ef4dd6f6aa..8c77e33b2ec5 100644 --- a/subsys/bluetooth/mesh/gen_onoff_cli.c +++ b/subsys/bluetooth/mesh/gen_onoff_cli.c @@ -35,21 +35,22 @@ static int decode_status(struct net_buf_simple *buf, return 0; } -static void handle_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (buf->len != BT_MESH_ONOFF_MSG_MINLEN_STATUS && buf->len != BT_MESH_ONOFF_MSG_MAXLEN_STATUS) { - return; + return -EMSGSIZE; } struct bt_mesh_onoff_cli *cli = model->user_data; struct bt_mesh_onoff_status status; struct bt_mesh_onoff_status *rsp; + int err; - if (decode_status(buf, &status)) { - return; + err = decode_status(buf, &status); + if (err) { + return err; } if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, BT_MESH_ONOFF_OP_STATUS, ctx->addr, @@ -61,12 +62,14 @@ static void handle_status(struct bt_mesh_model *model, if (cli->status_handler) { cli->status_handler(cli, ctx, &status); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_onoff_cli_op[] = { { BT_MESH_ONOFF_OP_STATUS, - BT_MESH_ONOFF_MSG_MINLEN_STATUS, + BT_MESH_LEN_MIN(BT_MESH_ONOFF_MSG_MINLEN_STATUS), handle_status, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_onoff_srv.c b/subsys/bluetooth/mesh/gen_onoff_srv.c index bcaff7b963e3..5db57d23284f 100644 --- a/subsys/bluetooth/mesh/gen_onoff_srv.c +++ b/subsys/bluetooth/mesh/gen_onoff_srv.c @@ -34,27 +34,25 @@ static void rsp_status(struct bt_mesh_model *model, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_ONOFF_MSG_LEN_GET) { - return; - } - struct bt_mesh_onoff_srv *srv = model->user_data; struct bt_mesh_onoff_status status = { 0 }; srv->handlers->get(srv, ctx, &status); rsp_status(model, ctx, &status); + + return 0; } -static void onoff_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int onoff_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_ONOFF_MSG_MINLEN_SET && buf->len != BT_MESH_ONOFF_MSG_MAXLEN_SET) { - return; + return -EMSGSIZE; } struct bt_mesh_onoff_srv *srv = model->user_data; @@ -66,7 +64,7 @@ static void onoff_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, uint8_t tid = net_buf_simple_pull_u8(buf); if (on_off > 1) { - return; + return -EINVAL; } set.on_off = on_off; @@ -101,35 +99,36 @@ static void onoff_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (ack) { rsp_status(model, ctx, &status); } + + return 0; } -static void handle_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - onoff_set(model, ctx, buf, true); + return onoff_set(model, ctx, buf, true); } -static void handle_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - onoff_set(model, ctx, buf, false); + return onoff_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_onoff_srv_op[] = { { BT_MESH_ONOFF_OP_GET, - BT_MESH_ONOFF_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_ONOFF_MSG_LEN_GET), handle_get, }, { BT_MESH_ONOFF_OP_SET, - BT_MESH_ONOFF_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_ONOFF_MSG_MINLEN_SET), handle_set, }, { BT_MESH_ONOFF_OP_SET_UNACK, - BT_MESH_ONOFF_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_ONOFF_MSG_MINLEN_SET), handle_set_unack, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_plvl_cli.c b/subsys/bluetooth/mesh/gen_plvl_cli.c index bd8e99ce1ab1..e29525908098 100644 --- a/subsys/bluetooth/mesh/gen_plvl_cli.c +++ b/subsys/bluetooth/mesh/gen_plvl_cli.c @@ -6,13 +6,12 @@ #include #include "model_utils.h" -static void handle_power_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_power_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (buf->len != BT_MESH_PLVL_MSG_MINLEN_LEVEL_STATUS && buf->len != BT_MESH_PLVL_MSG_MAXLEN_LEVEL_STATUS) { - return; + return -EMSGSIZE; } struct bt_mesh_plvl_cli *cli = model->user_data; @@ -38,16 +37,13 @@ static void handle_power_status(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->power_status) { cli->handlers->power_status(cli, ctx, &status); } + + return 0; } -static void handle_last_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_last_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PLVL_MSG_LEN_LAST_STATUS) { - return; - } - struct bt_mesh_plvl_cli *cli = model->user_data; uint16_t last = net_buf_simple_pull_le16(buf); uint16_t *rsp; @@ -61,16 +57,13 @@ static void handle_last_status(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->last_status) { cli->handlers->last_status(cli, ctx, last); } + + return 0; } -static void handle_default_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PLVL_MSG_LEN_DEFAULT_STATUS) { - return; - } - struct bt_mesh_plvl_cli *cli = model->user_data; uint16_t default_lvl = net_buf_simple_pull_le16(buf); uint16_t *rsp; @@ -84,16 +77,13 @@ static void handle_default_status(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->default_status) { cli->handlers->default_status(cli, ctx, default_lvl); } + + return 0; } -static void handle_range_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PLVL_MSG_LEN_RANGE_STATUS) { - return; - } - struct bt_mesh_plvl_cli *cli = model->user_data; struct bt_mesh_plvl_range_status status; struct bt_mesh_plvl_range_status *rsp; @@ -111,27 +101,29 @@ static void handle_range_status(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->range_status) { cli->handlers->range_status(cli, ctx, &status); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_plvl_cli_op[] = { { BT_MESH_PLVL_OP_LEVEL_STATUS, - BT_MESH_PLVL_MSG_MINLEN_LEVEL_STATUS, + BT_MESH_LEN_MIN(BT_MESH_PLVL_MSG_MINLEN_LEVEL_STATUS), handle_power_status, }, { BT_MESH_PLVL_OP_LAST_STATUS, - BT_MESH_PLVL_MSG_LEN_LAST_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_LAST_STATUS), handle_last_status, }, { BT_MESH_PLVL_OP_DEFAULT_STATUS, - BT_MESH_PLVL_MSG_LEN_DEFAULT_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_DEFAULT_STATUS), handle_default_status, }, { BT_MESH_PLVL_OP_RANGE_STATUS, - BT_MESH_PLVL_MSG_LEN_RANGE_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_RANGE_STATUS), handle_range_status, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_plvl_srv.c b/subsys/bluetooth/mesh/gen_plvl_srv.c index 19fb7fb88c7d..861c147c1752 100644 --- a/subsys/bluetooth/mesh/gen_plvl_srv.c +++ b/subsys/bluetooth/mesh/gen_plvl_srv.c @@ -111,23 +111,20 @@ static void rsp_plvl_status(struct bt_mesh_model *model, bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); } -static void handle_lvl_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_lvl_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PLVL_MSG_LEN_LEVEL_GET) { - return; - } - struct bt_mesh_plvl_srv *srv = model->user_data; struct bt_mesh_plvl_status status = { 0 }; srv->handlers->power_get(srv, ctx, &status); rsp_plvl_status(model, ctx, &status); + + return 0; } -static void change_lvl(struct bt_mesh_plvl_srv *srv, +static int change_lvl(struct bt_mesh_plvl_srv *srv, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_plvl_set *set, struct bt_mesh_plvl_status *status) @@ -149,14 +146,16 @@ static void change_lvl(struct bt_mesh_plvl_srv *srv, memset(status, 0, sizeof(*status)); srv->handlers->power_set(srv, ctx, set, status); + + return 0; } -static void plvl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int plvl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_PLVL_MSG_MINLEN_LEVEL_SET && buf->len != BT_MESH_PLVL_MSG_MAXLEN_LEVEL_SET) { - return; + return -EMSGSIZE; } struct bt_mesh_plvl_srv *srv = model->user_data; @@ -183,30 +182,25 @@ static void plvl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (ack) { rsp_plvl_status(model, ctx, &status); } + + return 0; } -static void handle_plvl_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_plvl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - plvl_set(model, ctx, buf, true); + return plvl_set(model, ctx, buf, true); } -static void handle_plvl_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_plvl_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - plvl_set(model, ctx, buf, false); + return plvl_set(model, ctx, buf, false); } -static void handle_last_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_last_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PLVL_MSG_LEN_LAST_GET) { - return; - } - struct bt_mesh_plvl_srv *srv = model->user_data; BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PLVL_OP_LAST_STATUS, @@ -215,16 +209,13 @@ static void handle_last_get(struct bt_mesh_model *model, net_buf_simple_add_le16(&rsp, srv->last); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_default_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PLVL_MSG_LEN_DEFAULT_GET) { - return; - } - struct bt_mesh_plvl_srv *srv = model->user_data; BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PLVL_OP_DEFAULT_STATUS, @@ -233,15 +224,13 @@ static void handle_default_get(struct bt_mesh_model *model, net_buf_simple_add_le16(&rsp, srv->default_power); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void set_default(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int set_default(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_PLVL_MSG_LEN_DEFAULT_SET) { - return; - } - struct bt_mesh_plvl_srv *srv = model->user_data; uint16_t new = net_buf_simple_pull_le16(buf); @@ -257,7 +246,7 @@ static void set_default(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx } if (!ack) { - return; + return 0; } BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PLVL_OP_DEFAULT_STATUS, @@ -266,30 +255,25 @@ static void set_default(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx net_buf_simple_add_le16(&rsp, srv->default_power); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_default_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_default(model, ctx, buf, true); + return set_default(model, ctx, buf, true); } -static void handle_default_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_default(model, ctx, buf, false); + return set_default(model, ctx, buf, false); } -static void handle_range_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PLVL_MSG_LEN_RANGE_GET) { - return; - } - struct bt_mesh_plvl_srv *srv = model->user_data; BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PLVL_OP_RANGE_STATUS, @@ -301,15 +285,13 @@ static void handle_range_get(struct bt_mesh_model *model, net_buf_simple_add_le16(&rsp, srv->range.max); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_PLVL_MSG_LEN_RANGE_SET) { - return; - } - struct bt_mesh_plvl_srv *srv = model->user_data; struct bt_mesh_plvl_range new; @@ -321,7 +303,7 @@ static void set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, * parameters. */ if (new.min == 0 || new.max == 0 || new.min > new.max) { - return; + return -EINVAL; } if (new.min != srv->range.min || new.max != srv->range.max) { @@ -336,7 +318,7 @@ static void set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, } if (!ack) { - return; + return 0; } BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PLVL_OP_RANGE_STATUS, @@ -348,51 +330,51 @@ static void set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, net_buf_simple_add_le16(&rsp, srv->range.max); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_range_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_range(model, ctx, buf, true); + return set_range(model, ctx, buf, true); } -static void handle_range_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_range(model, ctx, buf, false); + return set_range(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_plvl_srv_op[] = { { BT_MESH_PLVL_OP_LEVEL_GET, - BT_MESH_PLVL_MSG_LEN_LEVEL_GET, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_LEVEL_GET), handle_lvl_get, }, { BT_MESH_PLVL_OP_LEVEL_SET, - BT_MESH_PLVL_MSG_MINLEN_LEVEL_SET, + BT_MESH_LEN_MIN(BT_MESH_PLVL_MSG_MINLEN_LEVEL_SET), handle_plvl_set, }, { BT_MESH_PLVL_OP_LEVEL_SET_UNACK, - BT_MESH_PLVL_MSG_MINLEN_LEVEL_SET, + BT_MESH_LEN_MIN(BT_MESH_PLVL_MSG_MINLEN_LEVEL_SET), handle_plvl_set_unack, }, { BT_MESH_PLVL_OP_LAST_GET, - BT_MESH_PLVL_MSG_LEN_LAST_GET, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_LAST_GET), handle_last_get, }, { BT_MESH_PLVL_OP_DEFAULT_GET, - BT_MESH_PLVL_MSG_LEN_DEFAULT_GET, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_DEFAULT_GET), handle_default_get, }, { BT_MESH_PLVL_OP_RANGE_GET, - BT_MESH_PLVL_MSG_LEN_RANGE_GET, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_RANGE_GET), handle_range_get, }, BT_MESH_MODEL_OP_END, @@ -401,22 +383,22 @@ const struct bt_mesh_model_op _bt_mesh_plvl_srv_op[] = { const struct bt_mesh_model_op _bt_mesh_plvl_setup_srv_op[] = { { BT_MESH_PLVL_OP_DEFAULT_SET, - BT_MESH_PLVL_MSG_LEN_DEFAULT_SET, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_DEFAULT_SET), handle_default_set, }, { BT_MESH_PLVL_OP_DEFAULT_SET_UNACK, - BT_MESH_PLVL_MSG_LEN_DEFAULT_SET, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_DEFAULT_SET), handle_default_set_unack, }, { BT_MESH_PLVL_OP_RANGE_SET, - BT_MESH_PLVL_MSG_LEN_RANGE_SET, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_RANGE_SET), handle_range_set, }, { BT_MESH_PLVL_OP_RANGE_SET_UNACK, - BT_MESH_PLVL_MSG_LEN_RANGE_SET, + BT_MESH_LEN_EXACT(BT_MESH_PLVL_MSG_LEN_RANGE_SET), handle_range_set_unack, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_ponoff_cli.c b/subsys/bluetooth/mesh/gen_ponoff_cli.c index edf7362fc287..8c116f6cf3f6 100644 --- a/subsys/bluetooth/mesh/gen_ponoff_cli.c +++ b/subsys/bluetooth/mesh/gen_ponoff_cli.c @@ -7,20 +7,15 @@ #include #include "model_utils.h" -static void handle_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PONOFF_MSG_LEN_STATUS) { - return; - } - struct bt_mesh_ponoff_cli *cli = model->user_data; enum bt_mesh_on_power_up on_power_up = net_buf_simple_pull_u8(buf); enum bt_mesh_on_power_up *rsp; if (on_power_up >= BT_MESH_ON_POWER_UP_INVALID) { - return; + return -EINVAL; } if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, BT_MESH_PONOFF_OP_STATUS, ctx->addr, @@ -33,12 +28,14 @@ static void handle_status(struct bt_mesh_model *model, if (cli->status_handler) { cli->status_handler(cli, ctx, on_power_up); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_ponoff_cli_op[] = { { BT_MESH_PONOFF_OP_STATUS, - BT_MESH_PONOFF_MSG_LEN_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_PONOFF_MSG_LEN_STATUS), handle_status, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_ponoff_srv.c b/subsys/bluetooth/mesh/gen_ponoff_srv.c index c5f795fa9cc2..2ea438922a35 100644 --- a/subsys/bluetooth/mesh/gen_ponoff_srv.c +++ b/subsys/bluetooth/mesh/gen_ponoff_srv.c @@ -103,14 +103,12 @@ static void send_rsp(struct bt_mesh_ponoff_srv *srv, bt_mesh_model_send(srv->ponoff_model, ctx, &msg, NULL, NULL); } -static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PONOFF_MSG_LEN_GET) { - return; - } - send_rsp(model->user_data, ctx); + + return 0; } static void set_on_power_up(struct bt_mesh_ponoff_srv *srv, @@ -136,19 +134,14 @@ static void set_on_power_up(struct bt_mesh_ponoff_srv *srv, store_state(srv); } -static void handle_set_msg(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int handle_set_msg(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_PONOFF_MSG_LEN_SET) { - return; - } - struct bt_mesh_ponoff_srv *srv = model->user_data; enum bt_mesh_on_power_up new = net_buf_simple_pull_u8(buf); if (new >= BT_MESH_ON_POWER_UP_INVALID) { - return; + return -EINVAL; } set_on_power_up(srv, ctx, new); @@ -158,19 +151,20 @@ static void handle_set_msg(struct bt_mesh_model *model, } (void)bt_mesh_ponoff_srv_pub(srv, NULL); + + return 0; } -static void handle_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - handle_set_msg(model, ctx, buf, true); + return handle_set_msg(model, ctx, buf, true); } -static void handle_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - handle_set_msg(model, ctx, buf, false); + return handle_set_msg(model, ctx, buf, false); } /* Need to intercept the onoff state to get the right value on power up. */ @@ -201,19 +195,23 @@ static void onoff_intercept_get(struct bt_mesh_onoff_srv *onoff_srv, } const struct bt_mesh_model_op _bt_mesh_ponoff_srv_op[] = { - { BT_MESH_PONOFF_OP_GET, BT_MESH_PONOFF_MSG_LEN_GET, handle_get }, + { + BT_MESH_PONOFF_OP_GET, + BT_MESH_LEN_EXACT(BT_MESH_PONOFF_MSG_LEN_GET), + handle_get, + }, BT_MESH_MODEL_OP_END, }; const struct bt_mesh_model_op _bt_mesh_ponoff_setup_srv_op[] = { { BT_MESH_PONOFF_OP_SET, - BT_MESH_PONOFF_MSG_LEN_SET, + BT_MESH_LEN_EXACT(BT_MESH_PONOFF_MSG_LEN_SET), handle_set, }, { BT_MESH_PONOFF_OP_SET_UNACK, - BT_MESH_PONOFF_MSG_LEN_SET, + BT_MESH_LEN_EXACT(BT_MESH_PONOFF_MSG_LEN_SET), handle_set_unack, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_prop_cli.c b/subsys/bluetooth/mesh/gen_prop_cli.c index 6eda77e1702a..860e3b174729 100644 --- a/subsys/bluetooth/mesh/gen_prop_cli.c +++ b/subsys/bluetooth/mesh/gen_prop_cli.c @@ -24,13 +24,13 @@ struct prop_list_ctx { int status; }; -static void properties_status(struct bt_mesh_model *model, +static int properties_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, enum bt_mesh_prop_srv_kind kind) { if ((buf->len % 2) != 0) { - return; + return -EMSGSIZE; } struct bt_mesh_prop_cli *cli = model->user_data; @@ -56,44 +56,42 @@ static void properties_status(struct bt_mesh_model *model, if (cli->prop_list) { cli->prop_list(cli, ctx, kind, &list); } + + return 0; } -static void handle_mfr_properties_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_mfr_properties_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - properties_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_MFR); + return properties_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_MFR); } -static void handle_admin_properties_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_admin_properties_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - properties_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_ADMIN); + return properties_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_ADMIN); } -static void handle_user_properties_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_user_properties_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - properties_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_USER); + return properties_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_USER); } -static void handle_client_properties_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_client_properties_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - properties_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_CLIENT); + return properties_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_CLIENT); } -static void property_status(struct bt_mesh_model *model, +static int property_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, enum bt_mesh_prop_srv_kind kind) { if (buf->len < BT_MESH_PROP_MSG_MINLEN_PROP_STATUS || buf->len > BT_MESH_PROP_MSG_MAXLEN_PROP_STATUS) { - return; + return -EMSGSIZE; } struct bt_mesh_prop_cli *cli = model->user_data; @@ -116,63 +114,62 @@ static void property_status(struct bt_mesh_model *model, if (cli->prop_status) { cli->prop_status(cli, ctx, kind, &val); } + + return 0; } -static void handle_mfr_property_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_mfr_property_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - property_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_MFR); + return property_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_MFR); } -static void handle_admin_property_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_admin_property_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - property_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_ADMIN); + return property_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_ADMIN); } -static void handle_user_property_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_user_property_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - property_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_USER); + return property_status(model, ctx, buf, BT_MESH_PROP_SRV_KIND_USER); } const struct bt_mesh_model_op _bt_mesh_prop_cli_op[] = { { BT_MESH_PROP_OP_MFR_PROPS_STATUS, - BT_MESH_PROP_MSG_MINLEN_PROPS_STATUS, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_PROPS_STATUS), handle_mfr_properties_status, }, { BT_MESH_PROP_OP_ADMIN_PROPS_STATUS, - BT_MESH_PROP_MSG_MINLEN_PROPS_STATUS, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_PROPS_STATUS), handle_admin_properties_status, }, { BT_MESH_PROP_OP_USER_PROPS_STATUS, - BT_MESH_PROP_MSG_MINLEN_PROPS_STATUS, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_PROPS_STATUS), handle_user_properties_status, }, { BT_MESH_PROP_OP_CLIENT_PROPS_STATUS, - BT_MESH_PROP_MSG_MINLEN_PROPS_STATUS, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_PROPS_STATUS), handle_client_properties_status, }, { BT_MESH_PROP_OP_MFR_PROP_STATUS, - BT_MESH_PROP_MSG_MINLEN_PROP_STATUS, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_PROP_STATUS), handle_mfr_property_status, }, { BT_MESH_PROP_OP_ADMIN_PROP_STATUS, - BT_MESH_PROP_MSG_MINLEN_PROP_STATUS, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_PROP_STATUS), handle_admin_property_status, }, { BT_MESH_PROP_OP_USER_PROP_STATUS, - BT_MESH_PROP_MSG_MINLEN_PROP_STATUS, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_PROP_STATUS), handle_user_property_status, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/gen_prop_srv.c b/subsys/bluetooth/mesh/gen_prop_srv.c index 234ee53539fa..da4086047cfb 100644 --- a/subsys/bluetooth/mesh/gen_prop_srv.c +++ b/subsys/bluetooth/mesh/gen_prop_srv.c @@ -114,34 +114,26 @@ static void pub_list_build(const struct bt_mesh_prop_srv *srv, /* Owner properties */ -static void handle_owner_properties_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_owner_properties_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PROP_MSG_LEN_PROPS_GET) { - return; - } - BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PROP_OP_ADMIN_PROPS_STATUS, BT_MESH_PROP_MSG_MAXLEN_PROPS_STATUS); pub_list_build(model->user_data, &rsp, 0); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_owner_property_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_owner_property_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PROP_MSG_LEN_PROP_GET) { - return; - } - struct bt_mesh_prop_srv *srv = model->user_data; uint16_t id = net_buf_simple_pull_le16(buf); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } const struct bt_mesh_prop *prop = prop_get(srv, id); @@ -174,26 +166,31 @@ static void handle_owner_property_get(struct bt_mesh_model *model, respond: bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void owner_property_set(struct bt_mesh_model *model, +static int owner_property_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { if ((IS_MFR_SRV(model) && (buf->len != 3)) || (buf->len > BT_MESH_PROP_MSG_MAXLEN_ADMIN_PROP_SET || buf->len < BT_MESH_PROP_MSG_MINLEN_ADMIN_PROP_SET)) { - return; + return -EMSGSIZE; } struct bt_mesh_prop_srv *srv = model->user_data; uint16_t id = net_buf_simple_pull_le16(buf); enum bt_mesh_prop_access user_access = net_buf_simple_pull_u8(buf); - if (id == BT_MESH_PROP_ID_PROHIBITED || - (IS_MFR_SRV(model) && (user_access & BT_MESH_PROP_ACCESS_WRITE)) || + if (id == BT_MESH_PROP_ID_PROHIBITED) { + return -EINVAL; + } + + if ((IS_MFR_SRV(model) && (user_access & BT_MESH_PROP_ACCESS_WRITE)) || user_access > BT_MESH_PROP_ACCESS_READ_WRITE) { - return; + return -EPERM; } BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PROP_OP_ADMIN_PROP_STATUS, @@ -237,7 +234,7 @@ static void owner_property_set(struct bt_mesh_model *model, /* User callbacks wipe the id to indicate invalid * behavior */ - return; + return -EINVAL; } } @@ -248,41 +245,41 @@ static void owner_property_set(struct bt_mesh_model *model, if (ack) { bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); } + + return 0; } -static void handle_owner_property_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_owner_property_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - owner_property_set(model, ctx, buf, true); + return owner_property_set(model, ctx, buf, true); } -static void handle_owner_property_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_owner_property_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - owner_property_set(model, ctx, buf, false); + return owner_property_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_prop_admin_srv_op[] = { { BT_MESH_PROP_OP_ADMIN_PROPS_GET, - BT_MESH_PROP_MSG_LEN_PROPS_GET, + BT_MESH_LEN_EXACT(BT_MESH_PROP_MSG_LEN_PROPS_GET), handle_owner_properties_get, }, { BT_MESH_PROP_OP_ADMIN_PROP_GET, - BT_MESH_PROP_MSG_LEN_PROP_GET, + BT_MESH_LEN_EXACT(BT_MESH_PROP_MSG_LEN_PROP_GET), handle_owner_property_get, }, { BT_MESH_PROP_OP_ADMIN_PROP_SET, - BT_MESH_PROP_MSG_MINLEN_ADMIN_PROP_SET, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_ADMIN_PROP_SET), handle_owner_property_set, }, { BT_MESH_PROP_OP_ADMIN_PROP_SET_UNACK, - BT_MESH_PROP_MSG_MINLEN_ADMIN_PROP_SET, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_ADMIN_PROP_SET), handle_owner_property_set_unack, }, BT_MESH_MODEL_OP_END, @@ -291,35 +288,30 @@ const struct bt_mesh_model_op _bt_mesh_prop_admin_srv_op[] = { const struct bt_mesh_model_op _bt_mesh_prop_mfr_srv_op[] = { { BT_MESH_PROP_OP_MFR_PROPS_GET, - BT_MESH_PROP_MSG_LEN_PROPS_GET, + BT_MESH_LEN_EXACT(BT_MESH_PROP_MSG_LEN_PROPS_GET), handle_owner_properties_get, }, { BT_MESH_PROP_OP_MFR_PROP_GET, - BT_MESH_PROP_MSG_LEN_PROP_GET, + BT_MESH_LEN_EXACT(BT_MESH_PROP_MSG_LEN_PROP_GET), handle_owner_property_get, }, { BT_MESH_PROP_OP_MFR_PROP_SET, - BT_MESH_PROP_MSG_LEN_MFR_PROP_SET, + BT_MESH_LEN_EXACT(BT_MESH_PROP_MSG_LEN_MFR_PROP_SET), handle_owner_property_set, }, { BT_MESH_PROP_OP_MFR_PROP_SET_UNACK, - BT_MESH_PROP_MSG_LEN_MFR_PROP_SET, + BT_MESH_LEN_EXACT(BT_MESH_PROP_MSG_LEN_MFR_PROP_SET), handle_owner_property_set_unack, }, BT_MESH_MODEL_OP_END, }; -static void handle_client_properties_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_client_properties_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PROP_MSG_LEN_CLIENT_PROPS_GET) { - return; - } - uint16_t start_prop = net_buf_simple_pull_le16(buf); BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PROP_OP_CLIENT_PROPS_STATUS, @@ -327,11 +319,16 @@ static void handle_client_properties_get(struct bt_mesh_model *model, pub_list_build(model->user_data, &rsp, start_prop); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } const struct bt_mesh_model_op _bt_mesh_prop_client_srv_op[] = { - { BT_MESH_PROP_OP_CLIENT_PROPS_GET, - BT_MESH_PROP_MSG_LEN_CLIENT_PROPS_GET, handle_client_properties_get }, + { + BT_MESH_PROP_OP_CLIENT_PROPS_GET, + BT_MESH_LEN_EXACT(BT_MESH_PROP_MSG_LEN_CLIENT_PROPS_GET), + handle_client_properties_get, + }, BT_MESH_MODEL_OP_END, }; @@ -368,14 +365,9 @@ static struct bt_mesh_prop *user_prop_get(struct bt_mesh_model *model, uint16_t return NULL; } -static void handle_user_properties_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_user_properties_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PROP_MSG_LEN_PROPS_GET) { - return; - } - BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PROP_OP_PROPS_STATUS, BT_MESH_PROP_MSG_MAXLEN_PROPS_STATUS); @@ -409,20 +401,17 @@ static void handle_user_properties_get(struct bt_mesh_model *model, } bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_user_property_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_user_property_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_PROP_MSG_LEN_PROP_GET) { - return; - } - uint16_t id = net_buf_simple_pull_le16(buf); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_PROP_OP_USER_PROP_STATUS, @@ -457,15 +446,16 @@ static void handle_user_property_get(struct bt_mesh_model *model, respond: bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void user_property_set(struct bt_mesh_model *model, +static int user_property_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { - if (buf->len < BT_MESH_PROP_MSG_MINLEN_USER_PROP_SET || - buf->len > BT_MESH_PROP_MSG_MAXLEN_USER_PROP_SET) { - return; + if (buf->len > BT_MESH_PROP_MSG_MAXLEN_USER_PROP_SET) { + return -EMSGSIZE; } uint16_t id = net_buf_simple_pull_le16(buf); @@ -478,7 +468,7 @@ static void user_property_set(struct bt_mesh_model *model, net_buf_simple_add_le16(&rsp, id); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } struct bt_mesh_prop_srv *user_srv = model->user_data; @@ -515,7 +505,7 @@ static void user_property_set(struct bt_mesh_model *model, if (value.meta.id == BT_MESH_PROP_ID_PROHIBITED) { /* User callbacks wipe the id to indicate invalid behavior */ - return; + return -EINVAL; } net_buf_simple_add(&rsp, value.size); @@ -526,28 +516,43 @@ static void user_property_set(struct bt_mesh_model *model, if (ack) { bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); } + + return 0; } -static void handle_user_property_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_user_property_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - user_property_set(model, ctx, buf, true); + return user_property_set(model, ctx, buf, true); } -static void handle_user_property_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_user_property_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - user_property_set(model, ctx, buf, false); + return user_property_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_prop_user_srv_op[] = { - { BT_MESH_PROP_OP_USER_PROPS_GET, 0, handle_user_properties_get }, - { BT_MESH_PROP_OP_USER_PROP_GET, 2, handle_user_property_get }, - { BT_MESH_PROP_OP_USER_PROP_SET, 2, handle_user_property_set }, - { BT_MESH_PROP_OP_USER_PROP_SET_UNACK, 2, - handle_user_property_set_unack }, + { + BT_MESH_PROP_OP_USER_PROPS_GET, + BT_MESH_LEN_EXACT(BT_MESH_PROP_MSG_LEN_PROPS_GET), + handle_user_properties_get, + }, + { + BT_MESH_PROP_OP_USER_PROP_GET, + BT_MESH_LEN_EXACT(BT_MESH_PROP_MSG_LEN_PROP_GET), + handle_user_property_get, + }, + { + BT_MESH_PROP_OP_USER_PROP_SET, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_USER_PROP_SET), + handle_user_property_set, + }, + { + BT_MESH_PROP_OP_USER_PROP_SET_UNACK, + BT_MESH_LEN_MIN(BT_MESH_PROP_MSG_MINLEN_USER_PROP_SET), + handle_user_property_set_unack, + }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/light_ctl_cli.c b/subsys/bluetooth/mesh/light_ctl_cli.c index ab39fad03de7..72791edaa495 100644 --- a/subsys/bluetooth/mesh/light_ctl_cli.c +++ b/subsys/bluetooth/mesh/light_ctl_cli.c @@ -7,13 +7,12 @@ #include #include "model_utils.h" -static void ctl_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_ctl_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (buf->len != BT_MESH_LIGHT_CTL_MSG_MINLEN_STATUS && buf->len != BT_MESH_LIGHT_CTL_MSG_MAXLEN_STATUS) { - return; + return -EMSGSIZE; } struct bt_mesh_light_ctl_cli *cli = model->user_data; @@ -24,7 +23,7 @@ static void ctl_status_handle(struct bt_mesh_model *model, status.current_temp = net_buf_simple_pull_le16(buf); if ((status.current_temp < BT_MESH_LIGHT_TEMP_MIN) || (status.current_temp > BT_MESH_LIGHT_TEMP_MAX)) { - return; + return -EINVAL; } if (buf->len == 5) { @@ -32,7 +31,7 @@ static void ctl_status_handle(struct bt_mesh_model *model, status.target_temp = net_buf_simple_pull_le16(buf); if ((status.target_temp < BT_MESH_LIGHT_TEMP_MIN) || (status.target_temp > BT_MESH_LIGHT_TEMP_MAX)) { - return; + return -EINVAL; } status.remaining_time = @@ -52,16 +51,13 @@ static void ctl_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->ctl_status) { cli->handlers->ctl_status(cli, ctx, &status); } + + return 0; } -static void temp_range_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_temp_range_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_CTL_MSG_LEN_TEMP_RANGE_STATUS) { - return; - } - struct bt_mesh_light_ctl_cli *cli = model->user_data; struct bt_mesh_light_temp_range_status status; struct bt_mesh_light_temp_range_status *rsp; @@ -79,15 +75,16 @@ static void temp_range_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->temp_range_status) { cli->handlers->temp_range_status(cli, ctx, &status); } + + return 0; } -static void temp_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_temp_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (buf->len != BT_MESH_LIGHT_CTL_MSG_MINLEN_TEMP_STATUS && buf->len != BT_MESH_LIGHT_CTL_MSG_MAXLEN_TEMP_STATUS) { - return; + return -EMSGSIZE; } struct bt_mesh_light_ctl_cli *cli = model->user_data; @@ -97,7 +94,7 @@ static void temp_status_handle(struct bt_mesh_model *model, status.current.temp = net_buf_simple_pull_le16(buf); if ((status.current.temp < BT_MESH_LIGHT_TEMP_MIN) || (status.current.temp > BT_MESH_LIGHT_TEMP_MAX)) { - return; + return -EINVAL; } status.current.delta_uv = net_buf_simple_pull_le16(buf); @@ -106,7 +103,7 @@ static void temp_status_handle(struct bt_mesh_model *model, status.target.temp = net_buf_simple_pull_le16(buf); if ((status.target.temp < BT_MESH_LIGHT_TEMP_MIN) || (status.target.temp > BT_MESH_LIGHT_TEMP_MAX)) { - return; + return -EINVAL; } status.target.delta_uv = net_buf_simple_pull_le16(buf); @@ -127,16 +124,13 @@ static void temp_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->temp_status) { cli->handlers->temp_status(cli, ctx, &status); } + + return 0; } -static void default_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_CTL_MSG_LEN_DEFAULT_MSG) { - return; - } - struct bt_mesh_light_ctl_cli *cli = model->user_data; struct bt_mesh_light_ctl status; struct bt_mesh_light_ctl *rsp; @@ -145,7 +139,7 @@ static void default_status_handle(struct bt_mesh_model *model, status.temp = net_buf_simple_pull_le16(buf); if ((status.temp < BT_MESH_LIGHT_TEMP_MIN) || (status.temp > BT_MESH_LIGHT_TEMP_MAX)) { - return; + return -EINVAL; } status.delta_uv = net_buf_simple_pull_le16(buf); @@ -159,28 +153,30 @@ static void default_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->default_status) { cli->handlers->default_status(cli, ctx, &status); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_light_ctl_cli_op[] = { { BT_MESH_LIGHT_CTL_STATUS, - BT_MESH_LIGHT_CTL_MSG_MINLEN_STATUS, - ctl_status_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTL_MSG_MINLEN_STATUS), + handle_ctl_status, }, { BT_MESH_LIGHT_TEMP_RANGE_STATUS, - BT_MESH_LIGHT_CTL_MSG_LEN_TEMP_RANGE_STATUS, - temp_range_status_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_TEMP_RANGE_STATUS), + handle_temp_range_status, }, { BT_MESH_LIGHT_TEMP_STATUS, - BT_MESH_LIGHT_CTL_MSG_MINLEN_TEMP_STATUS, - temp_status_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTL_MSG_MINLEN_TEMP_STATUS), + handle_temp_status, }, { BT_MESH_LIGHT_CTL_DEFAULT_STATUS, - BT_MESH_LIGHT_CTL_MSG_LEN_DEFAULT_MSG, - default_status_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_DEFAULT_MSG), + handle_default_status, }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/light_ctl_srv.c b/subsys/bluetooth/mesh/light_ctl_srv.c index a1dc01770897..0750cc5fbff2 100644 --- a/subsys/bluetooth/mesh/light_ctl_srv.c +++ b/subsys/bluetooth/mesh/light_ctl_srv.c @@ -50,12 +50,12 @@ static void ctl_get(struct bt_mesh_light_ctl_srv *srv, status->remaining_time = MAX(temp.remaining_time, light.remaining_time); } -static void ctl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int ctl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_LIGHT_CTL_MSG_MINLEN_SET && buf->len != BT_MESH_LIGHT_CTL_MSG_MAXLEN_SET) { - return; + return -EMSGSIZE; } struct bt_mesh_light_ctl_srv *srv = model->user_data; @@ -74,7 +74,7 @@ static void ctl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if ((temp.params.temp < BT_MESH_LIGHT_TEMP_MIN) || (temp.params.temp > BT_MESH_LIGHT_TEMP_MAX)) { - return; + return -EINVAL; } if (light.lvl != 0) { @@ -113,31 +113,32 @@ static void ctl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (IS_ENABLED(CONFIG_BT_MESH_SCENE_SRV)) { bt_mesh_scene_invalidate(srv->model); } + + return 0; } -static void handle_ctl_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_ctl_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctl_srv *srv = model->user_data; struct bt_mesh_light_ctl_status status = { 0 }; ctl_get(srv, ctx, &status); bt_mesh_light_ctl_pub(srv, ctx, &status); + + return 0; } -static void handle_ctl_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_ctl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - ctl_set(model, ctx, buf, true); + return ctl_set(model, ctx, buf, true); } -static void handle_ctl_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_ctl_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - ctl_set(model, ctx, buf, false); + return ctl_set(model, ctx, buf, false); } static void range_encode_status(struct net_buf_simple *buf, @@ -186,37 +187,28 @@ static enum bt_mesh_model_status temp_range_set(struct bt_mesh_model *model, return BT_MESH_MODEL_SUCCESS; } -static void handle_temp_range_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_temp_range_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_CTL_MSG_LEN_GET) { - return; - } - temp_range_rsp(model, ctx, BT_MESH_MODEL_SUCCESS); + + return 0; } -static void handle_temp_range_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_temp_range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_CTL_MSG_LEN_TEMP_RANGE_SET) { - return; - } - temp_range_rsp(model, ctx, temp_range_set(model, ctx, buf)); + + return 0; } -static void handle_temp_range_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_temp_range_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_CTL_MSG_LEN_TEMP_RANGE_SET) { - return; - } - temp_range_set(model, ctx, buf); + + return 0; } static void default_encode_status(struct net_buf_simple *buf, @@ -240,7 +232,7 @@ static void default_rsp(struct bt_mesh_model *model, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static void default_set(struct bt_mesh_model *model, +static int default_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { struct bt_mesh_light_ctl_srv *srv = model->user_data; @@ -253,7 +245,7 @@ static void default_set(struct bt_mesh_model *model, if ((temp.temp < BT_MESH_LIGHT_TEMP_MIN) || (temp.temp > BT_MESH_LIGHT_TEMP_MAX)) { - return; + return -EINVAL; } lightness_srv_default_set(&srv->lightness_srv, ctx, light); @@ -264,65 +256,54 @@ static void default_set(struct bt_mesh_model *model, if (ack) { default_rsp(model, ctx); } + + return 0; } -static void handle_default_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_CTL_MSG_LEN_GET) { - return; - } - default_rsp(model, ctx); + + return 0; } -static void handle_default_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_CTL_MSG_LEN_DEFAULT_MSG) { - return; - } - - default_set(model, ctx, buf, true); + return default_set(model, ctx, buf, true); } -static void handle_default_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_CTL_MSG_LEN_DEFAULT_MSG) { - return; - } - - default_set(model, ctx, buf, false); + return default_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_light_ctl_srv_op[] = { { BT_MESH_LIGHT_CTL_GET, - BT_MESH_LIGHT_CTL_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_GET), handle_ctl_get, }, { BT_MESH_LIGHT_CTL_SET, - BT_MESH_LIGHT_CTL_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTL_MSG_MINLEN_SET), handle_ctl_set, }, { BT_MESH_LIGHT_CTL_SET_UNACK, - BT_MESH_LIGHT_CTL_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTL_MSG_MINLEN_SET), handle_ctl_set_unack, }, { BT_MESH_LIGHT_TEMP_RANGE_GET, - BT_MESH_LIGHT_CTL_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_GET), handle_temp_range_get, }, { BT_MESH_LIGHT_CTL_DEFAULT_GET, - BT_MESH_LIGHT_CTL_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_GET), handle_default_get, }, BT_MESH_MODEL_OP_END, @@ -331,22 +312,22 @@ const struct bt_mesh_model_op _bt_mesh_light_ctl_srv_op[] = { const struct bt_mesh_model_op _bt_mesh_light_ctl_setup_srv_op[] = { { BT_MESH_LIGHT_TEMP_RANGE_SET, - BT_MESH_LIGHT_CTL_MSG_LEN_TEMP_RANGE_SET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_TEMP_RANGE_SET), handle_temp_range_set, }, { BT_MESH_LIGHT_TEMP_RANGE_SET_UNACK, - BT_MESH_LIGHT_CTL_MSG_LEN_TEMP_RANGE_SET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_TEMP_RANGE_SET), handle_temp_range_set_unack, }, { BT_MESH_LIGHT_CTL_DEFAULT_SET, - BT_MESH_LIGHT_CTL_MSG_LEN_DEFAULT_MSG, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_DEFAULT_MSG), handle_default_set, }, { BT_MESH_LIGHT_CTL_DEFAULT_SET_UNACK, - BT_MESH_LIGHT_CTL_MSG_LEN_DEFAULT_MSG, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_DEFAULT_MSG), handle_default_set_unack, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/light_ctrl_cli.c b/subsys/bluetooth/mesh/light_ctrl_cli.c index e446ee34b981..38638c3e825d 100644 --- a/subsys/bluetooth/mesh/light_ctrl_cli.c +++ b/subsys/bluetooth/mesh/light_ctrl_cli.c @@ -17,20 +17,15 @@ struct prop_status_ctx { union prop_value val; }; -static void handle_mode(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_mode(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { bool *ack_buf; struct bt_mesh_light_ctrl_cli *cli = model->user_data; - - if (buf->len != 1) { - return; - } - uint8_t enabled = net_buf_simple_pull_u8(buf); if (enabled > 1) { - return; + return -EINVAL; } if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, BT_MESH_LIGHT_CTRL_OP_MODE_STATUS, ctx->addr, @@ -42,23 +37,19 @@ static void handle_mode(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx if (cli->handlers && cli->handlers->mode) { cli->handlers->mode(cli, ctx, enabled); } + + return 0; } -static void handle_occupancy(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_occupancy(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { bool *ack_buf; struct bt_mesh_light_ctrl_cli *cli = model->user_data; - - if (buf->len != 1) { - return; - } - uint8_t enabled = net_buf_simple_pull_u8(buf); if (enabled > 1) { - return; + return -EINVAL; } if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, BT_MESH_LIGHT_CTRL_OP_OM_STATUS, ctx->addr, @@ -70,11 +61,12 @@ static void handle_occupancy(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->occupancy_mode) { cli->handlers->occupancy_mode(cli, ctx, enabled); } + + return 0; } -static void handle_light_onoff(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_light_onoff(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_cli *cli = model->user_data; struct bt_mesh_onoff_status status; @@ -83,7 +75,7 @@ static void handle_light_onoff(struct bt_mesh_model *model, uint8_t onoff = net_buf_simple_pull_u8(buf); if (onoff > 1) { - return; + return -EINVAL; } status.present_on_off = onoff; @@ -91,7 +83,7 @@ static void handle_light_onoff(struct bt_mesh_model *model, if (buf->len == 2) { onoff = net_buf_simple_pull_u8(buf); if (onoff > 1) { - return; + return -EINVAL; } status.target_on_off = onoff; @@ -101,7 +93,7 @@ static void handle_light_onoff(struct bt_mesh_model *model, status.target_on_off = onoff; status.remaining_time = 0; } else { - return; + return -EMSGSIZE; } if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, BT_MESH_LIGHT_CTRL_OP_LIGHT_ONOFF_STATUS, @@ -113,10 +105,12 @@ static void handle_light_onoff(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->light_onoff) { cli->handlers->light_onoff(cli, ctx, &status); } + + return 0; } -static void handle_prop(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_prop(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_cli *cli = model->user_data; struct prop_status_ctx *rsp; @@ -132,7 +126,7 @@ static void handle_prop(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx if (coeff) { if (buf->len != sizeof(float)) { - return; + return -EINVAL; } memcpy(&value.coeff, @@ -141,12 +135,12 @@ static void handle_prop(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx } else { format = prop_format_get(id); if (!format) { - return; + return -ENOENT; } err = sensor_ch_decode(buf, format, &value.prop); if (err) { - return; + return -EINVAL; } } @@ -164,27 +158,29 @@ static void handle_prop(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx } else if (cli->handlers && cli->handlers->prop) { cli->handlers->prop(cli, ctx, id, &value.prop); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_light_ctrl_cli_op[] = { { BT_MESH_LIGHT_CTRL_OP_MODE_STATUS, - 1, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_MODE_STATUS), handle_mode, }, { BT_MESH_LIGHT_CTRL_OP_OM_STATUS, - 1, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_OM_STATUS), handle_occupancy, }, { BT_MESH_LIGHT_CTRL_OP_LIGHT_ONOFF_STATUS, - 1, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTRL_MSG_MINLEN_LIGHT_ONOFF_STATUS), handle_light_onoff, }, { BT_MESH_LIGHT_CTRL_OP_PROP_STATUS, - 2, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTRL_MSG_MINLEN_PROP_STATUS), handle_prop, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/light_ctrl_srv.c b/subsys/bluetooth/mesh/light_ctrl_srv.c index ae46dcd7f6be..c08c49cc8bdc 100644 --- a/subsys/bluetooth/mesh/light_ctrl_srv.c +++ b/subsys/bluetooth/mesh/light_ctrl_srv.c @@ -750,26 +750,19 @@ static void mode_rsp(struct bt_mesh_light_ctrl_srv *srv, model_send(srv->model, ctx, &rsp); } -static void handle_mode_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_mode_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; - if (buf->len != 0) { - return; - } - mode_rsp(srv, ctx); + + return 0; } static int mode_set(struct bt_mesh_light_ctrl_srv *srv, struct net_buf_simple *buf) { - if (buf->len != 1) { - return -EINVAL; - } - uint8_t mode = net_buf_simple_pull_u8(buf); if (mode > 1) { @@ -787,32 +780,28 @@ static int mode_set(struct bt_mesh_light_ctrl_srv *srv, return 0; } -static void handle_mode_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_mode_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; int err; err = mode_set(srv, buf); if (err) { - return; + return err; } mode_rsp(srv, ctx); + + return 0; } -static void handle_mode_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_mode_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; - int err; - err = mode_set(srv, buf); - if (err) { - return; - } + return mode_set(srv, buf); } static void om_rsp(struct bt_mesh_light_ctrl_srv *srv, @@ -826,26 +815,19 @@ static void om_rsp(struct bt_mesh_light_ctrl_srv *srv, model_send(srv->model, ctx, &rsp); } -static void handle_om_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_om_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; - if (buf->len != 0) { - return; - } - om_rsp(srv, ctx); + + return 0; } static int om_set(struct bt_mesh_light_ctrl_srv *srv, struct net_buf_simple *buf) { - if (buf->len != 1) { - return -EINVAL; - } - uint8_t mode = net_buf_simple_pull_u8(buf); if (mode > 1) { @@ -864,57 +846,49 @@ static int om_set(struct bt_mesh_light_ctrl_srv *srv, return 0; } -static void handle_om_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_om_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; int err; err = om_set(srv, buf); if (err) { - return; + return err; } om_rsp(srv, ctx); + + return 0; } -static void handle_om_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_om_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; - int err; - err = om_set(srv, buf); - if (err) { - return; - } + return om_set(srv, buf); } -static void handle_light_onoff_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_light_onoff_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; - if (buf->len != 0) { - return; - } - BT_DBG("Get Light OnOff"); light_onoff_status_send(srv, ctx, srv->state); + + return 0; } -static void light_onoff_set(struct bt_mesh_light_ctrl_srv *srv, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int light_onoff_set(struct bt_mesh_light_ctrl_srv *srv, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { uint8_t onoff = net_buf_simple_pull_u8(buf); if (onoff > 1) { - return; + return -EINVAL; } uint8_t tid = net_buf_simple_pull_u8(buf); @@ -945,29 +919,28 @@ static void light_onoff_set(struct bt_mesh_light_ctrl_srv *srv, if (ack) { light_onoff_status_send(srv, ctx, prev_state); } + + return 0; } -static void handle_light_onoff_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_light_onoff_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; - light_onoff_set(srv, ctx, buf, true); + return light_onoff_set(srv, ctx, buf, true); } -static void handle_light_onoff_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_light_onoff_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; - light_onoff_set(srv, ctx, buf, false); + return light_onoff_set(srv, ctx, buf, false); } -static void handle_sensor_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_sensor_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; int err; @@ -1009,7 +982,7 @@ static void handle_sensor_status(struct bt_mesh_model *model, err = sensor_value_decode(buf, type, &value); if (err) { - return; + return -ENOENT; } BT_DBG("Sensor 0x%04x: %s", id, bt_mesh_sensor_ch_str(&value)); @@ -1037,57 +1010,59 @@ static void handle_sensor_status(struct bt_mesh_model *model, turn_on(srv, NULL, true); } } + + return 0; } const struct bt_mesh_model_op _bt_mesh_light_ctrl_srv_op[] = { { BT_MESH_LIGHT_CTRL_OP_MODE_GET, - 0, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_MODE_GET), handle_mode_get, }, { BT_MESH_LIGHT_CTRL_OP_MODE_SET, - 1, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_MODE_SET), handle_mode_set, }, { BT_MESH_LIGHT_CTRL_OP_MODE_SET_UNACK, - 1, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_MODE_SET), handle_mode_set_unack, }, { BT_MESH_LIGHT_CTRL_OP_OM_GET, - 0, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_OM_GET), handle_om_get, }, { BT_MESH_LIGHT_CTRL_OP_OM_SET, - 1, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_OM_SET), handle_om_set, }, { BT_MESH_LIGHT_CTRL_OP_OM_SET_UNACK, - 1, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_OM_SET), handle_om_set_unack, }, { BT_MESH_LIGHT_CTRL_OP_LIGHT_ONOFF_GET, - 0, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_LIGHT_ONOFF_GET), handle_light_onoff_get, }, { BT_MESH_LIGHT_CTRL_OP_LIGHT_ONOFF_SET, - 2, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTRL_MSG_MINLEN_LIGHT_ONOFF_SET), handle_light_onoff_set, }, { BT_MESH_LIGHT_CTRL_OP_LIGHT_ONOFF_SET_UNACK, - 2, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTRL_MSG_MINLEN_LIGHT_ONOFF_SET), handle_light_onoff_set_unack, }, { BT_MESH_SENSOR_OP_STATUS, - 3, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_STATUS), handle_sensor_status, }, BT_MESH_MODEL_OP_END, @@ -1293,7 +1268,7 @@ static int prop_set(struct net_buf_simple *buf, return 0; } -static void prop_tx(struct bt_mesh_light_ctrl_srv *srv, +static int prop_tx(struct bt_mesh_light_ctrl_srv *srv, struct bt_mesh_msg_ctx *ctx, uint16_t id) { int err; @@ -1306,53 +1281,51 @@ static void prop_tx(struct bt_mesh_light_ctrl_srv *srv, err = prop_get(&buf, srv, id); if (err) { - return; + return -ENOENT; } model_send(srv->setup_srv, ctx, &buf); + + return 0; } -static void handle_prop_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_prop_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; - - if (buf->len != 2) { - return; - } - uint16_t id = net_buf_simple_pull_le16(buf); - prop_tx(srv, ctx, id); + return prop_tx(srv, ctx, id); + + return 0; } -static void handle_prop_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_prop_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; - int err; - uint16_t id = net_buf_simple_pull_le16(buf); + int err; err = prop_set(buf, srv, id); + if (err) { + return err; + } - if (!err) { - prop_tx(srv, ctx, id); - prop_tx(srv, NULL, id); + (void)prop_tx(srv, ctx, id); + (void)prop_tx(srv, NULL, id); - if (IS_ENABLED(CONFIG_BT_MESH_SCENE_SRV)) { - bt_mesh_scene_invalidate(srv->model); - } + if (IS_ENABLED(CONFIG_BT_MESH_SCENE_SRV)) { + bt_mesh_scene_invalidate(srv->model); } store(srv, FLAG_STORE_CFG); + + return 0; } -static void handle_prop_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_prop_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_ctrl_srv *srv = model->user_data; int err; @@ -1360,21 +1333,37 @@ static void handle_prop_set_unack(struct bt_mesh_model *model, uint16_t id = net_buf_simple_pull_le16(buf); err = prop_set(buf, srv, id); - if (!err) { - prop_tx(srv, NULL, id); + if (err) { + return err; + } - if (IS_ENABLED(CONFIG_BT_MESH_SCENE_SRV)) { - bt_mesh_scene_invalidate(srv->model); - } + (void)prop_tx(srv, NULL, id); + + if (IS_ENABLED(CONFIG_BT_MESH_SCENE_SRV)) { + bt_mesh_scene_invalidate(srv->model); } store(srv, FLAG_STORE_CFG); + + return 0; } const struct bt_mesh_model_op _bt_mesh_light_ctrl_setup_srv_op[] = { - { BT_MESH_LIGHT_CTRL_OP_PROP_GET, 2, handle_prop_get }, - { BT_MESH_LIGHT_CTRL_OP_PROP_SET, 3, handle_prop_set }, - { BT_MESH_LIGHT_CTRL_OP_PROP_SET_UNACK, 3, handle_prop_set_unack }, + { + BT_MESH_LIGHT_CTRL_OP_PROP_GET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTRL_MSG_LEN_PROP_GET), + handle_prop_get, + }, + { + BT_MESH_LIGHT_CTRL_OP_PROP_SET, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTRL_MSG_MINLEN_PROP_SET), + handle_prop_set, + }, + { + BT_MESH_LIGHT_CTRL_OP_PROP_SET_UNACK, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTRL_MSG_MINLEN_PROP_SET), + handle_prop_set_unack, + }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/light_hsl_cli.c b/subsys/bluetooth/mesh/light_hsl_cli.c index 22f5bb2d422d..4c61dfe2ae72 100644 --- a/subsys/bluetooth/mesh/light_hsl_cli.c +++ b/subsys/bluetooth/mesh/light_hsl_cli.c @@ -34,9 +34,8 @@ static int status_decode(struct bt_mesh_light_hsl_cli *cli, return 0; } -static void hsl_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_hsl_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_hsl_cli *cli = model->user_data; struct bt_mesh_light_hsl_status status; @@ -45,17 +44,18 @@ static void hsl_status_handle(struct bt_mesh_model *model, err = status_decode(cli, ctx, buf, BT_MESH_LIGHT_HSL_OP_STATUS, &status); if (err) { - return; + return err; } if (cli->handlers && cli->handlers->status) { cli->handlers->status(cli, ctx, &status); } + + return 0; } -static void hsl_target_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_hsl_target_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_hsl_cli *cli = model->user_data; struct bt_mesh_light_hsl_status status; @@ -64,21 +64,22 @@ static void hsl_target_status_handle(struct bt_mesh_model *model, err = status_decode(cli, ctx, buf, BT_MESH_LIGHT_HSL_OP_TARGET_STATUS, &status); if (err) { - return; + return err; } if (cli->handlers && cli->handlers->target_status) { cli->handlers->target_status(cli, ctx, &status); } + + return 0; } -static void default_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (buf->len != BT_MESH_LIGHT_HSL_MSG_MINLEN_STATUS && buf->len != BT_MESH_LIGHT_HSL_MSG_MAXLEN_STATUS) { - return; + return -EMSGSIZE; } struct bt_mesh_light_hsl_cli *cli = model->user_data; @@ -96,16 +97,13 @@ static void default_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->default_status) { cli->handlers->default_status(cli, ctx, &status); } + + return 0; } -static void range_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_RANGE_STATUS) { - return; - } - struct bt_mesh_light_hsl_cli *cli = model->user_data; struct bt_mesh_light_hsl_range_status status; struct bt_mesh_light_hsl_range_status *rsp; @@ -122,11 +120,12 @@ static void range_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->range_status) { cli->handlers->range_status(cli, ctx, &status); } + + return 0; } -static void hue_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_hue_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_hsl_cli *cli = model->user_data; struct bt_mesh_light_hue_status status; @@ -134,7 +133,7 @@ static void hue_status_handle(struct bt_mesh_model *model, if (buf->len != BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE_STATUS && buf->len != BT_MESH_LIGHT_HSL_MSG_MAXLEN_HUE_STATUS) { - return; + return -EMSGSIZE; } status.current = net_buf_simple_pull_le16(buf); @@ -156,11 +155,12 @@ static void hue_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->hue_status) { cli->handlers->hue_status(cli, ctx, &status); } + + return 0; } -static void saturation_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_saturation_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_hsl_cli *cli = model->user_data; struct bt_mesh_light_sat_status status; @@ -168,7 +168,7 @@ static void saturation_status_handle(struct bt_mesh_model *model, if (buf->len != BT_MESH_LIGHT_HSL_MSG_MINLEN_SAT_STATUS && buf->len != BT_MESH_LIGHT_HSL_MSG_MAXLEN_SAT_STATUS) { - return; + return -EMSGSIZE; } status.current = net_buf_simple_pull_le16(buf); @@ -190,38 +190,40 @@ static void saturation_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->saturation_status) { cli->handlers->saturation_status(cli, ctx, &status); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_light_hsl_cli_op[] = { { BT_MESH_LIGHT_HSL_OP_STATUS, - BT_MESH_LIGHT_HSL_MSG_MINLEN_STATUS, - hsl_status_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_STATUS), + handle_hsl_status, }, { BT_MESH_LIGHT_HSL_OP_TARGET_STATUS, - BT_MESH_LIGHT_HSL_MSG_MINLEN_STATUS, - hsl_target_status_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_STATUS), + handle_hsl_target_status, }, { BT_MESH_LIGHT_HSL_OP_DEFAULT_STATUS, - BT_MESH_LIGHT_HSL_MSG_LEN_DEFAULT, - default_status_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_DEFAULT), + handle_default_status, }, { BT_MESH_LIGHT_HSL_OP_RANGE_STATUS, - BT_MESH_LIGHT_HSL_MSG_LEN_RANGE_STATUS, - range_status_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_RANGE_STATUS), + handle_range_status, }, { BT_MESH_LIGHT_HUE_OP_STATUS, - BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE_STATUS, - hue_status_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE_STATUS), + handle_hue_status, }, { BT_MESH_LIGHT_SAT_OP_STATUS, - BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE_STATUS, - saturation_status_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE_STATUS), + handle_saturation_status, }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/light_hsl_srv.c b/subsys/bluetooth/mesh/light_hsl_srv.c index e5bfc51ff5ac..a57082115eeb 100644 --- a/subsys/bluetooth/mesh/light_hsl_srv.c +++ b/subsys/bluetooth/mesh/light_hsl_srv.c @@ -55,29 +55,27 @@ static void hsl_get(struct bt_mesh_light_hsl_srv *srv, srv->hue.handlers->get(&srv->hue, ctx, &hue); srv->sat.handlers->get(&srv->sat, ctx, &sat); - srv->lightness.handlers->light_get(&srv->lightness, ctx, &lightness); + srv->lightness->handlers->light_get(srv->lightness, ctx, &lightness); *status = (struct bt_mesh_light_hsl_status)HSL_STATUS_INIT( &hue, &sat, &lightness, current); } -static void hsl_get_handle(struct bt_mesh_model *model, +static int handle_hsl_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { struct bt_mesh_light_hsl_srv *srv = model->user_data; struct bt_mesh_light_hsl_status status; - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_GET) { - return; - } - hsl_get(srv, ctx, &status); (void)bt_mesh_light_hsl_srv_pub(srv, ctx, &status); + + return 0; } -static void hsl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int hsl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { struct bt_mesh_light_hsl_srv *srv = model->user_data; struct bt_mesh_model_transition transition; @@ -93,7 +91,7 @@ static void hsl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (buf->len != BT_MESH_LIGHT_HSL_MSG_MINLEN_SET && buf->len != BT_MESH_LIGHT_HSL_MSG_MAXLEN_SET) { - return; + return -EMSGSIZE; } set.l.lvl = repr_to_light(net_buf_simple_pull_le16(buf), ACTUAL); @@ -109,7 +107,7 @@ static void hsl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, (void)bt_mesh_light_hsl_srv_pub(srv, ctx, &status); } - return; + return 0; } set.h.transition = model_transition_get(srv->model, &transition, buf); @@ -128,8 +126,8 @@ static void hsl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, bt_mesh_light_hue_srv_set(&srv->hue, ctx, &set.h, &hue); bt_mesh_light_sat_srv_set(&srv->sat, ctx, &set.s, &sat); - lightness_srv_disable_control(&srv->lightness); - lightness_srv_change_lvl(&srv->lightness, ctx, &set.l, &lightness, true); + lightness_srv_disable_control(srv->lightness); + lightness_srv_change_lvl(srv->lightness, ctx, &set.l, &lightness, true); srv->pub_pending = false; @@ -146,23 +144,25 @@ static void hsl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (IS_ENABLED(CONFIG_BT_MESH_SCENE_SRV)) { bt_mesh_scene_invalidate(srv->model); } + + return 0; } -static void hsl_set_handle(struct bt_mesh_model *model, +static int handle_hsl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - hsl_set(model, ctx, buf, true); + return hsl_set(model, ctx, buf, true); } -static void hsl_set_unack_handle(struct bt_mesh_model *model, +static int handle_hsl_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - hsl_set(model, ctx, buf, false); + return hsl_set(model, ctx, buf, false); } -static void hsl_target_get_handle(struct bt_mesh_model *model, +static int handle_hsl_target_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { @@ -171,13 +171,9 @@ static void hsl_target_get_handle(struct bt_mesh_model *model, struct bt_mesh_light_hue_status hue; struct bt_mesh_light_sat_status sat; - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_GET) { - return; - } - srv->hue.handlers->get(&srv->hue, ctx, &hue); srv->sat.handlers->get(&srv->sat, ctx, &sat); - srv->lightness.handlers->light_get(&srv->lightness, ctx, &lightness); + srv->lightness->handlers->light_get(srv->lightness, ctx, &lightness); struct bt_mesh_light_hsl_status status = HSL_STATUS_INIT(&hue, &sat, &lightness, target); @@ -187,6 +183,8 @@ static void hsl_target_get_handle(struct bt_mesh_model *model, hsl_status_encode(&rsp, BT_MESH_LIGHT_HSL_OP_TARGET_STATUS, &status); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } static void default_rsp(struct bt_mesh_model *model, @@ -194,7 +192,7 @@ static void default_rsp(struct bt_mesh_model *model, { struct bt_mesh_light_hsl_srv *srv = model->user_data; const struct bt_mesh_light_hsl hsl = { - .lightness = srv->lightness.default_light, + .lightness = srv->lightness->default_light, .hue = srv->hue.dflt, .saturation = srv->sat.dflt, }; @@ -207,7 +205,7 @@ static void default_rsp(struct bt_mesh_model *model, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static void default_set(struct bt_mesh_model *model, +static int default_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { struct bt_mesh_light_hsl_srv *srv = model->user_data; @@ -215,43 +213,39 @@ static void default_set(struct bt_mesh_model *model, light_hsl_buf_pull(buf, &val); - lightness_srv_default_set(&srv->lightness, ctx, val.lightness); + lightness_srv_default_set(srv->lightness, ctx, val.lightness); bt_mesh_light_hue_srv_default_set(&srv->hue, ctx, val.hue); bt_mesh_light_sat_srv_default_set(&srv->sat, ctx, val.saturation); + + return 0; } -static void default_get_handle(struct bt_mesh_model *model, +static int handle_default_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_GET) { - return; - } - default_rsp(model, ctx); + + return 0; } -static void default_set_handle(struct bt_mesh_model *model, +static int handle_default_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_DEFAULT) { - return; - } - default_set(model, ctx, buf); default_rsp(model, ctx); + + return 0; } -static void default_set_unack_handle(struct bt_mesh_model *model, +static int handle_default_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_DEFAULT) { - return; - } - default_set(model, ctx, buf); + + return 0; } static void range_encode_status(struct net_buf_simple *buf, @@ -286,9 +280,8 @@ static void range_rsp(struct bt_mesh_model *model, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static enum bt_mesh_model_status range_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_hsl_srv *srv = model->user_data; struct bt_mesh_light_hsl_range hue, sat; @@ -296,90 +289,90 @@ static enum bt_mesh_model_status range_set(struct bt_mesh_model *model, hue.min = net_buf_simple_pull_le16(buf); hue.max = net_buf_simple_pull_le16(buf); if (hue.max < hue.min) { - return BT_MESH_MODEL_ERROR_INVALID_RANGE_MIN; + return -EINVAL; } sat.min = net_buf_simple_pull_le16(buf); sat.max = net_buf_simple_pull_le16(buf); if (sat.max < sat.min) { - return BT_MESH_MODEL_ERROR_INVALID_RANGE_MIN; + return -EINVAL; } bt_mesh_light_hue_srv_range_set(&srv->hue, ctx, &hue); bt_mesh_light_sat_srv_range_set(&srv->sat, ctx, &sat); - return BT_MESH_MODEL_SUCCESS; + return 0; } -static void range_get_handle(struct bt_mesh_model *model, +static int handle_range_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_GET) { - return; - } - range_rsp(model, ctx, BT_MESH_MODEL_SUCCESS); + + return 0; } -static void range_set_handle(struct bt_mesh_model *model, +static int handle_range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_RANGE_SET) { - return; - } + int err; /* According to Test specification MMDL/SR/LHSLSE/BI-01-C, ignore * message if max < min: */ - if (range_set(model, ctx, buf) == BT_MESH_MODEL_SUCCESS) { - range_rsp(model, ctx, BT_MESH_MODEL_SUCCESS); + err = range_set(model, ctx, buf); + if (err) { + return err; } + + range_rsp(model, ctx, BT_MESH_MODEL_SUCCESS); + + return 0; } -static void range_set_unack_handle(struct bt_mesh_model *model, +static int handle_range_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_RANGE_SET) { - return; - } - - range_set(model, ctx, buf); + /* According to Test specification MMDL/SR/LHSLSE/BI-01-C, ignore + * message if max < min: + */ + return range_set(model, ctx, buf); } const struct bt_mesh_model_op _bt_mesh_light_hsl_srv_op[] = { { BT_MESH_LIGHT_HSL_OP_GET, - BT_MESH_LIGHT_HSL_MSG_LEN_GET, - hsl_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_GET), + handle_hsl_get, }, { BT_MESH_LIGHT_HSL_OP_SET, - BT_MESH_LIGHT_HSL_MSG_MINLEN_SET, - hsl_set_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_SET), + handle_hsl_set, }, { BT_MESH_LIGHT_HSL_OP_SET_UNACK, - BT_MESH_LIGHT_HSL_MSG_MINLEN_SET, - hsl_set_unack_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_SET), + handle_hsl_set_unack, }, { BT_MESH_LIGHT_HSL_OP_TARGET_GET, - BT_MESH_LIGHT_HSL_MSG_LEN_GET, - hsl_target_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_GET), + handle_hsl_target_get, }, { BT_MESH_LIGHT_HSL_OP_DEFAULT_GET, - BT_MESH_LIGHT_HSL_MSG_LEN_GET, - default_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_GET), + handle_default_get, }, { BT_MESH_LIGHT_HSL_OP_RANGE_GET, - BT_MESH_LIGHT_HSL_MSG_LEN_GET, - range_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_GET), + handle_range_get, }, BT_MESH_MODEL_OP_END, }; @@ -387,23 +380,23 @@ const struct bt_mesh_model_op _bt_mesh_light_hsl_srv_op[] = { const struct bt_mesh_model_op _bt_mesh_light_hsl_setup_srv_op[] = { { BT_MESH_LIGHT_HSL_OP_DEFAULT_SET, - BT_MESH_LIGHT_HSL_MSG_LEN_DEFAULT, - default_set_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_DEFAULT), + handle_default_set, }, { BT_MESH_LIGHT_HSL_OP_DEFAULT_SET_UNACK, - BT_MESH_LIGHT_HSL_MSG_LEN_DEFAULT, - default_set_unack_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_DEFAULT), + handle_default_set_unack, }, { BT_MESH_LIGHT_HSL_OP_RANGE_SET, - BT_MESH_LIGHT_HSL_MSG_LEN_RANGE_SET, - range_set_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_RANGE_SET), + handle_range_set, }, { BT_MESH_LIGHT_HSL_OP_RANGE_SET_UNACK, - BT_MESH_LIGHT_HSL_MSG_LEN_RANGE_SET, - range_set_unack_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_RANGE_SET), + handle_range_set_unack, }, BT_MESH_MODEL_OP_END, }; @@ -413,11 +406,11 @@ static ssize_t scene_store(struct bt_mesh_model *model, uint8_t data[]) struct bt_mesh_light_hsl_srv *srv = model->user_data; struct bt_mesh_lightness_status status = { 0 }; - if (atomic_test_bit(&srv->lightness.flags, LIGHTNESS_SRV_FLAG_EXTENDED_BY_LIGHT_CTRL)) { + if (atomic_test_bit(&srv->lightness->flags, LIGHTNESS_SRV_FLAG_EXTENDED_BY_LIGHT_CTRL)) { return 0; } - srv->lightness.handlers->light_get(&srv->lightness, NULL, &status); + srv->lightness->handlers->light_get(srv->lightness, NULL, &status); sys_put_le16(status.remaining_time ? light_to_repr(status.target, ACTUAL) : status.current, &data[0]); @@ -431,7 +424,7 @@ static void scene_recall(struct bt_mesh_model *model, const uint8_t data[], { struct bt_mesh_light_hsl_srv *srv = model->user_data; - if (atomic_test_bit(&srv->lightness.flags, LIGHTNESS_SRV_FLAG_EXTENDED_BY_LIGHT_CTRL)) { + if (atomic_test_bit(&srv->lightness->flags, LIGHTNESS_SRV_FLAG_EXTENDED_BY_LIGHT_CTRL)) { return; } @@ -441,7 +434,7 @@ static void scene_recall(struct bt_mesh_model *model, const uint8_t data[], .transition = transition, }; - lightness_srv_change_lvl(&srv->lightness, NULL, &light_set, &light_status, false); + lightness_srv_change_lvl(srv->lightness, NULL, &light_set, &light_status, false); } static void scene_recall_complete(struct bt_mesh_model *model) @@ -453,7 +446,7 @@ static void scene_recall_complete(struct bt_mesh_model *model) srv->hue.handlers->get(&srv->hue, NULL, &hue_status); srv->sat.handlers->get(&srv->sat, NULL, &sat_status); - srv->lightness.handlers->light_get(&srv->lightness, NULL, &light_status); + srv->lightness->handlers->light_get(srv->lightness, NULL, &light_status); struct bt_mesh_light_hsl_status hsl = HSL_STATUS_INIT(&hue_status, &sat_status, &light_status, current); @@ -502,7 +495,7 @@ static int bt_mesh_light_hsl_srv_init(struct bt_mesh_model *model) * stack, but it makes it a lot easier to extend this model, as * we won't have to support multiple extenders. */ - bt_mesh_model_extend(model, srv->lightness.lightness_model); + bt_mesh_model_extend(model, srv->lightness->lightness_model); bt_mesh_model_extend( model, bt_mesh_model_find( bt_mesh_model_elem(model), @@ -534,7 +527,7 @@ static int bt_mesh_light_hsl_srv_start(struct bt_mesh_model *model) bt_mesh_dtt_srv_transition_get(model, &transition); - switch (srv->lightness.ponoff.on_power_up) { + switch (srv->lightness->ponoff.on_power_up) { case BT_MESH_ON_POWER_UP_ON: case BT_MESH_ON_POWER_UP_OFF: hue.lvl = srv->hue.dflt; @@ -565,7 +558,7 @@ static int bt_mesh_light_hsl_srv_start(struct bt_mesh_model *model) /* The lightness server updated its "last" value in its * start function, which has already completed: */ - .lightness = srv->lightness.last, + .lightness = srv->lightness->last, }, .remaining_time = 0, }; diff --git a/subsys/bluetooth/mesh/light_hue_srv.c b/subsys/bluetooth/mesh/light_hue_srv.c index 4622c1ce0f32..dda8abe3eda3 100644 --- a/subsys/bluetooth/mesh/light_hue_srv.c +++ b/subsys/bluetooth/mesh/light_hue_srv.c @@ -65,12 +65,12 @@ static void encode_status(struct net_buf_simple *buf, } } -static void hue_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int hue_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE && buf->len != BT_MESH_LIGHT_HSL_MSG_MAXLEN_HUE) { - return; + return -EMSGSIZE; } struct bt_mesh_light_hue_srv *srv = model->user_data; @@ -95,7 +95,7 @@ static void hue_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, */ srv->handlers->get(srv, NULL, &status); (void)bt_mesh_light_hue_srv_pub(srv, ctx, &status); - return; + return 0; } if (buf->len == 2) { @@ -133,52 +133,49 @@ static void hue_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (IS_ENABLED(CONFIG_BT_MESH_SCENE_SRV)) { bt_mesh_scene_invalidate(srv->model); } + + return 0; } -static void hue_get_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_hue_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_GET) { - return; - } - struct bt_mesh_light_hue_srv *srv = model->user_data; struct bt_mesh_light_hue_status status = { 0 }; srv->handlers->get(srv, ctx, &status); (void)bt_mesh_light_hue_srv_pub(srv, ctx, &status); + + return 0; } -static void hue_set_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_hue_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - hue_set(model, ctx, buf, true); + return hue_set(model, ctx, buf, true); } -static void hue_set_unack_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_hue_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - hue_set(model, ctx, buf, false); + return hue_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_light_hue_srv_op[] = { { BT_MESH_LIGHT_HUE_OP_GET, - BT_MESH_LIGHT_HSL_MSG_LEN_GET, - hue_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_GET), + handle_hue_get, }, { BT_MESH_LIGHT_HUE_OP_SET, - BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE, - hue_set_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE), + handle_hue_set, }, { BT_MESH_LIGHT_HUE_OP_SET_UNACK, - BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE, - hue_set_unack_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_HUE), + handle_hue_set_unack, }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/light_sat_srv.c b/subsys/bluetooth/mesh/light_sat_srv.c index 968a7f120409..2316c2f7e318 100644 --- a/subsys/bluetooth/mesh/light_sat_srv.c +++ b/subsys/bluetooth/mesh/light_sat_srv.c @@ -65,12 +65,12 @@ static void encode_status(struct net_buf_simple *buf, } } -static void sat_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int sat_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_LIGHT_HSL_MSG_MINLEN_SAT && buf->len != BT_MESH_LIGHT_HSL_MSG_MAXLEN_SAT) { - return; + return -EMSGSIZE; } struct bt_mesh_light_sat_srv *srv = model->user_data; @@ -94,7 +94,7 @@ static void sat_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, */ srv->handlers->get(srv, NULL, &status); (void)bt_mesh_light_sat_srv_pub(srv, ctx, &status); - return; + return 0; } if (buf->len == 2) { @@ -132,52 +132,52 @@ static void sat_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (IS_ENABLED(CONFIG_BT_MESH_SCENE_SRV)) { bt_mesh_scene_invalidate(srv->model); } + + return 0; } -static void sat_get_handle(struct bt_mesh_model *model, +static int handle_sat_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_HSL_MSG_LEN_GET) { - return; - } - struct bt_mesh_light_sat_srv *srv = model->user_data; struct bt_mesh_light_sat_status status = { 0 }; srv->handlers->get(srv, ctx, &status); (void)bt_mesh_light_sat_srv_pub(srv, ctx, &status); + + return 0; } -static void sat_set_handle(struct bt_mesh_model *model, +static int handle_sat_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - sat_set(model, ctx, buf, true); + return sat_set(model, ctx, buf, true); } -static void sat_set_unack_handle(struct bt_mesh_model *model, +static int handle_sat_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - sat_set(model, ctx, buf, false); + return sat_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_light_sat_srv_op[] = { { BT_MESH_LIGHT_SAT_OP_GET, - BT_MESH_LIGHT_HSL_MSG_LEN_GET, - sat_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_HSL_MSG_LEN_GET), + handle_sat_get, }, { BT_MESH_LIGHT_SAT_OP_SET, - BT_MESH_LIGHT_HSL_MSG_MINLEN_SAT, - sat_set_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_SAT), + handle_sat_set, }, { BT_MESH_LIGHT_SAT_OP_SET_UNACK, - BT_MESH_LIGHT_HSL_MSG_MINLEN_SAT, - sat_set_unack_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_HSL_MSG_MINLEN_SAT), + handle_sat_set_unack, }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/light_temp_srv.c b/subsys/bluetooth/mesh/light_temp_srv.c index 688c3430fac0..4949ee152a3e 100644 --- a/subsys/bluetooth/mesh/light_temp_srv.c +++ b/subsys/bluetooth/mesh/light_temp_srv.c @@ -64,12 +64,12 @@ static void encode_status(struct net_buf_simple *buf, } } -static void temp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int temp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_LIGHT_CTL_MSG_MINLEN_TEMP_SET && buf->len != BT_MESH_LIGHT_CTL_MSG_MAXLEN_TEMP_SET) { - return; + return -EMSGSIZE; } struct bt_mesh_light_temp_srv *srv = model->user_data; @@ -83,7 +83,7 @@ static void temp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if ((set.params.temp < BT_MESH_LIGHT_TEMP_MIN) || (set.params.temp > BT_MESH_LIGHT_TEMP_MAX)) { - return; + return -EINVAL; } if (tid_check_and_update(&srv->prev_transaction, tid, ctx) != 0) { @@ -106,52 +106,52 @@ static void temp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (ack) { (void)bt_mesh_light_temp_srv_pub(srv, ctx, &status); } + + return 0; } -static void temp_get_handle(struct bt_mesh_model *model, +static int handle_temp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_CTL_MSG_LEN_GET) { - return; - } - struct bt_mesh_light_temp_srv *srv = model->user_data; struct bt_mesh_light_temp_status status = { 0 }; srv->handlers->get(srv, ctx, &status); (void)bt_mesh_light_temp_srv_pub(srv, ctx, &status); + + return 0; } -static void temp_set_handle(struct bt_mesh_model *model, +static int handle_temp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - temp_set(model, ctx, buf, true); + return temp_set(model, ctx, buf, true); } -static void temp_set_unack_handle(struct bt_mesh_model *model, +static int handle_temp_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - temp_set(model, ctx, buf, false); + return temp_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_light_temp_srv_op[] = { { BT_MESH_LIGHT_TEMP_GET, - BT_MESH_LIGHT_CTL_MSG_LEN_GET, - temp_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_CTL_MSG_LEN_GET), + handle_temp_get, }, { BT_MESH_LIGHT_TEMP_SET, - BT_MESH_LIGHT_CTL_MSG_MINLEN_TEMP_SET, - temp_set_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTL_MSG_MINLEN_TEMP_SET), + handle_temp_set, }, { BT_MESH_LIGHT_TEMP_SET_UNACK, - BT_MESH_LIGHT_CTL_MSG_MINLEN_TEMP_SET, - temp_set_unack_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_CTL_MSG_MINLEN_TEMP_SET), + handle_temp_set_unack, }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/light_xyl_cli.c b/subsys/bluetooth/mesh/light_xyl_cli.c index c15bacbbddc4..db13fefe516a 100644 --- a/subsys/bluetooth/mesh/light_xyl_cli.c +++ b/subsys/bluetooth/mesh/light_xyl_cli.c @@ -16,7 +16,7 @@ static int status_decode(struct bt_mesh_light_xyl_cli *cli, if (buf->len != BT_MESH_LIGHT_XYL_MSG_MINLEN_STATUS && buf->len != BT_MESH_LIGHT_XYL_MSG_MAXLEN_STATUS) { - return -EAGAIN; + return -EMSGSIZE; } status->params.lightness = net_buf_simple_pull_le16(buf); @@ -34,9 +34,8 @@ static int status_decode(struct bt_mesh_light_xyl_cli *cli, return 0; } -static void xyl_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_xyl_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_xyl_cli *cli = model->user_data; struct bt_mesh_light_xyl_status status; @@ -47,11 +46,12 @@ static void xyl_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->xyl_status && !err) { cli->handlers->xyl_status(cli, ctx, &status); } + + return err; } -static void target_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_target_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_light_xyl_cli *cli = model->user_data; struct bt_mesh_light_xyl_status status; @@ -62,16 +62,13 @@ static void target_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->target_status && !err) { cli->handlers->target_status(cli, ctx, &status); } + + return err; } -static void default_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_XYL_MSG_LEN_DEFAULT) { - return; - } - struct bt_mesh_light_xyl_cli *cli = model->user_data; struct bt_mesh_light_xyl status; struct bt_mesh_light_xyl *rsp; @@ -89,16 +86,13 @@ static void default_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->default_status) { cli->handlers->default_status(cli, ctx, &status); } + + return 0; } -static void range_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_XYL_MSG_LEN_RANGE_STATUS) { - return; - } - struct bt_mesh_light_xyl_cli *cli = model->user_data; struct bt_mesh_light_xyl_range_status status; struct bt_mesh_light_xyl_range_status *rsp; @@ -118,28 +112,30 @@ static void range_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->range_status) { cli->handlers->range_status(cli, ctx, &status); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_light_xyl_cli_op[] = { { BT_MESH_LIGHT_XYL_OP_STATUS, - BT_MESH_LIGHT_XYL_MSG_MINLEN_STATUS, - xyl_status_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_XYL_MSG_MINLEN_STATUS), + handle_xyl_status, }, { BT_MESH_LIGHT_XYL_OP_TARGET_STATUS, - BT_MESH_LIGHT_XYL_MSG_MINLEN_STATUS, - target_status_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_XYL_MSG_MINLEN_STATUS), + handle_target_status, }, { BT_MESH_LIGHT_XYL_OP_DEFAULT_STATUS, - BT_MESH_LIGHT_XYL_MSG_LEN_DEFAULT, - default_status_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_DEFAULT), + handle_default_status, }, { BT_MESH_LIGHT_XYL_OP_RANGE_STATUS, - BT_MESH_LIGHT_XYL_MSG_LEN_RANGE_STATUS, - range_status_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_RANGE_STATUS), + handle_range_status, }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/light_xyl_srv.c b/subsys/bluetooth/mesh/light_xyl_srv.c index ed07b78d4676..0d6d33c95107 100644 --- a/subsys/bluetooth/mesh/light_xyl_srv.c +++ b/subsys/bluetooth/mesh/light_xyl_srv.c @@ -54,8 +54,8 @@ static void xyl_get(struct bt_mesh_light_xyl_srv *srv, struct bt_mesh_lightness_status lightness = { 0 }; struct bt_mesh_light_xy_status xy = { 0 }; - srv->lightness_srv.handlers->light_get(&srv->lightness_srv, ctx, - &lightness); + srv->lightness_srv->handlers->light_get(srv->lightness_srv, ctx, + &lightness); srv->handlers->xy_get(srv, ctx, &xy); status->params.xy = xy.current; @@ -87,12 +87,12 @@ static void xyl_rsp(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *rx_ctx, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static void xyl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int xyl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { if (buf->len != BT_MESH_LIGHT_XYL_MSG_MINLEN_SET && buf->len != BT_MESH_LIGHT_XYL_MSG_MAXLEN_SET) { - return; + return -EMSGSIZE; } struct bt_mesh_light_xyl_srv *srv = model->user_data; @@ -108,17 +108,8 @@ static void xyl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, set.params.y = net_buf_simple_pull_le16(buf); uint8_t tid = net_buf_simple_pull_u8(buf); - if (set.params.x > srv->range.max.x) { - set.params.x = srv->range.max.x; - } else if (set.params.x < srv->range.min.x) { - set.params.x = srv->range.min.x; - } - - if (set.params.y > srv->range.max.y) { - set.params.y = srv->range.max.y; - } else if (set.params.y < srv->range.min.y) { - set.params.y = srv->range.min.y; - } + set.params.x = CLAMP(set.params.x, srv->range.min.x, srv->range.max.x); + set.params.y = CLAMP(set.params.y, srv->range.min.y, srv->range.max.y); if (tid_check_and_update(&srv->prev_transaction, tid, ctx) != 0) { /* If this is the same transaction, we don't need to send it @@ -128,15 +119,15 @@ static void xyl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, xyl_get(srv, NULL, &xyl_status); xyl_rsp(model, ctx, &xyl_status, BT_MESH_LIGHT_XYL_OP_STATUS); - return; + return 0; } } set.transition = model_transition_get(srv->model, &transition, buf); light.transition = set.transition; - lightness_srv_disable_control(&srv->lightness_srv); - lightness_srv_change_lvl(&srv->lightness_srv, ctx, &light, &light_rsp, true); + lightness_srv_disable_control(srv->lightness_srv); + lightness_srv_change_lvl(srv->lightness_srv, ctx, &light, &light_rsp, true); srv->handlers->xy_set(srv, ctx, &set, &status); srv->xy_last.x = set.params.x; srv->xy_last.y = set.params.y; @@ -154,51 +145,47 @@ static void xyl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (ack) { xyl_rsp(model, ctx, &xyl_status, BT_MESH_LIGHT_XYL_OP_STATUS); } + + return 0; } -static void xyl_get_handle(struct bt_mesh_model *model, +static int handle_xyl_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_XYL_MSG_LEN_GET) { - return; - } - struct bt_mesh_light_xyl_srv *srv = model->user_data; struct bt_mesh_light_xyl_status status = { 0 }; xyl_get(srv, ctx, &status); xyl_rsp(model, ctx, &status, BT_MESH_LIGHT_XYL_OP_STATUS); + + return 0; } -static void xyl_set_handle(struct bt_mesh_model *model, +static int handle_xyl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - xyl_set(model, ctx, buf, true); + return xyl_set(model, ctx, buf, true); } -static void xyl_set_unack_handle(struct bt_mesh_model *model, +static int handle_xyl_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - xyl_set(model, ctx, buf, false); + return xyl_set(model, ctx, buf, false); } -static void target_get_handle(struct bt_mesh_model *model, +static int handle_target_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_XYL_MSG_LEN_GET) { - return; - } - struct bt_mesh_light_xyl_srv *srv = model->user_data; struct bt_mesh_light_xy_status status = { 0 }; struct bt_mesh_lightness_status light = { 0 }; - srv->lightness_srv.handlers->light_get(&srv->lightness_srv, ctx, - &light); + srv->lightness_srv->handlers->light_get(srv->lightness_srv, ctx, + &light); srv->handlers->xy_get(srv, ctx, &status); struct bt_mesh_light_xyl_status xyl_status = { @@ -208,13 +195,15 @@ static void target_get_handle(struct bt_mesh_model *model, }; xyl_rsp(model, ctx, &xyl_status, BT_MESH_LIGHT_XYL_OP_TARGET_STATUS); + + return 0; } static void default_encode_status(struct bt_mesh_light_xyl_srv *srv, struct net_buf_simple *buf) { bt_mesh_model_msg_init(buf, BT_MESH_LIGHT_XYL_OP_DEFAULT_STATUS); - net_buf_simple_add_le16(buf, srv->lightness_srv.default_light); + net_buf_simple_add_le16(buf, srv->lightness_srv->default_light); net_buf_simple_add_le16(buf, srv->xy_default.x); net_buf_simple_add_le16(buf, srv->xy_default.y); } @@ -230,21 +219,17 @@ static void default_rsp(struct bt_mesh_model *model, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static void default_set(struct bt_mesh_model *model, +static int default_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_LIGHT_XYL_MSG_LEN_DEFAULT) { - return; - } - struct bt_mesh_light_xyl_srv *srv = model->user_data; struct bt_mesh_light_xy old_default = srv->xy_default; uint16_t light = repr_to_light(net_buf_simple_pull_le16(buf), ACTUAL); srv->xy_default.x = net_buf_simple_pull_le16(buf); srv->xy_default.y = net_buf_simple_pull_le16(buf); - lightness_srv_default_set(&srv->lightness_srv, ctx, light); + lightness_srv_default_set(srv->lightness_srv, ctx, light); store_state(srv); if (srv->handlers->default_update) { @@ -257,31 +242,31 @@ static void default_set(struct bt_mesh_model *model, if (ack) { default_rsp(model, ctx); } + + return 0; } -static void default_get_handle(struct bt_mesh_model *model, +static int handle_default_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_XYL_MSG_LEN_GET) { - return; - } - default_rsp(model, ctx); + + return 0; } -static void default_set_handle(struct bt_mesh_model *model, +static int handle_default_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - default_set(model, ctx, buf, true); + return default_set(model, ctx, buf, true); } -static void default_set_unack_handle(struct bt_mesh_model *model, +static int handle_default_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - default_set(model, ctx, buf, false); + return default_set(model, ctx, buf, false); } static void range_encode_status(struct net_buf_simple *buf, @@ -308,13 +293,9 @@ static void range_rsp(struct bt_mesh_model *model, (void)bt_mesh_model_send(model, rx_ctx, &msg, NULL, NULL); } -static void range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_LIGHT_XYL_MSG_LEN_RANGE_SET) { - return; - } - struct bt_mesh_light_xyl_srv *srv = model->user_data; struct bt_mesh_light_xy_range new_range; struct bt_mesh_light_xy_range old_range; @@ -327,8 +308,7 @@ static void range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if ((new_range.min.x > new_range.max.x) || (new_range.min.y > new_range.max.y)) { - status_code = BT_MESH_MODEL_STATUS_INVALID; - return; + return -EINVAL; } status_code = BT_MESH_MODEL_SUCCESS; @@ -345,63 +325,63 @@ static void range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, if (ack) { range_rsp(model, ctx, status_code); } + + return 0; } -static void range_get_handle(struct bt_mesh_model *model, +static int handle_range_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHT_XYL_MSG_LEN_GET) { - return; - } - range_rsp(model, ctx, BT_MESH_MODEL_SUCCESS); + + return 0; } -static void range_set_handle(struct bt_mesh_model *model, +static int handle_range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - range_set(model, ctx, buf, true); + return range_set(model, ctx, buf, true); } -static void range_set_unack_handle(struct bt_mesh_model *model, +static int handle_range_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - range_set(model, ctx, buf, false); + return range_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_light_xyl_srv_op[] = { { BT_MESH_LIGHT_XYL_OP_GET, - BT_MESH_LIGHT_XYL_MSG_LEN_GET, - xyl_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_GET), + handle_xyl_get, }, { BT_MESH_LIGHT_XYL_OP_SET, - BT_MESH_LIGHT_XYL_MSG_MINLEN_SET, - xyl_set_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_XYL_MSG_MINLEN_SET), + handle_xyl_set, }, { BT_MESH_LIGHT_XYL_OP_SET_UNACK, - BT_MESH_LIGHT_XYL_MSG_MINLEN_SET, - xyl_set_unack_handle, + BT_MESH_LEN_MIN(BT_MESH_LIGHT_XYL_MSG_MINLEN_SET), + handle_xyl_set_unack, }, { BT_MESH_LIGHT_XYL_OP_TARGET_GET, - BT_MESH_LIGHT_XYL_MSG_LEN_GET, - target_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_GET), + handle_target_get, }, { BT_MESH_LIGHT_XYL_OP_DEFAULT_GET, - BT_MESH_LIGHT_XYL_MSG_LEN_GET, - default_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_GET), + handle_default_get, }, { BT_MESH_LIGHT_XYL_OP_RANGE_GET, - BT_MESH_LIGHT_XYL_MSG_LEN_GET, - range_get_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_GET), + handle_range_get, }, BT_MESH_MODEL_OP_END, }; @@ -409,23 +389,23 @@ const struct bt_mesh_model_op _bt_mesh_light_xyl_srv_op[] = { const struct bt_mesh_model_op _bt_mesh_light_xyl_setup_srv_op[] = { { BT_MESH_LIGHT_XYL_OP_DEFAULT_SET, - BT_MESH_LIGHT_XYL_MSG_LEN_DEFAULT, - default_set_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_DEFAULT), + handle_default_set, }, { BT_MESH_LIGHT_XYL_OP_DEFAULT_SET_UNACK, - BT_MESH_LIGHT_XYL_MSG_LEN_DEFAULT, - default_set_unack_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_DEFAULT), + handle_default_set_unack, }, { BT_MESH_LIGHT_XYL_OP_RANGE_SET, - BT_MESH_LIGHT_XYL_MSG_LEN_RANGE_SET, - range_set_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_RANGE_SET), + handle_range_set, }, { BT_MESH_LIGHT_XYL_OP_RANGE_SET_UNACK, - BT_MESH_LIGHT_XYL_MSG_LEN_RANGE_SET, - range_set_unack_handle, + BT_MESH_LEN_EXACT(BT_MESH_LIGHT_XYL_MSG_LEN_RANGE_SET), + handle_range_set_unack, }, BT_MESH_MODEL_OP_END, }; @@ -442,7 +422,7 @@ static ssize_t scene_store(struct bt_mesh_model *model, uint8_t data[]) struct bt_mesh_lightness_status light = { 0 }; struct scene_data *scene = (struct scene_data *)&data[0]; - srv->lightness_srv.handlers->light_get(&srv->lightness_srv, NULL, &light); + srv->lightness_srv->handlers->light_get(srv->lightness_srv, NULL, &light); srv->handlers->xy_get(srv, NULL, &xy_rsp); if (xy_rsp.remaining_time) { @@ -480,7 +460,7 @@ static void scene_recall(struct bt_mesh_model *model, const uint8_t data[], srv->xy_last.y = xy_set.params.y; store_state(srv); - if (atomic_test_bit(&srv->lightness_srv.flags, + if (atomic_test_bit(&srv->lightness_srv->flags, LIGHTNESS_SRV_FLAG_EXTENDED_BY_LIGHT_CTRL)) { return; } @@ -491,7 +471,7 @@ static void scene_recall(struct bt_mesh_model *model, const uint8_t data[], .transition = transition, }; - lightness_srv_change_lvl(&srv->lightness_srv, NULL, &light, &light_status, false); + lightness_srv_change_lvl(srv->lightness_srv, NULL, &light, &light_status, false); } static void scene_recall_complete(struct bt_mesh_model *model) @@ -502,7 +482,7 @@ static void scene_recall_complete(struct bt_mesh_model *model) struct bt_mesh_light_xy_status xy_status = { 0 }; srv->handlers->xy_get(srv, NULL, &xy_status); - srv->lightness_srv.handlers->light_get(&srv->lightness_srv, NULL, &light_status); + srv->lightness_srv->handlers->light_get(srv->lightness_srv, NULL, &light_status); xyl_status.params.xy = xy_status.current; xyl_status.params.lightness = light_status.current; @@ -553,7 +533,7 @@ static int bt_mesh_light_xyl_srv_init(struct bt_mesh_model *model) * stack, but it makes it a lot easier to extend this model, as * we won't have to support multiple extenders. */ - bt_mesh_model_extend(model, srv->lightness_srv.lightness_model); + bt_mesh_model_extend(model, srv->lightness_srv->lightness_model); bt_mesh_model_extend( model, bt_mesh_model_find( bt_mesh_model_elem(model), @@ -586,14 +566,14 @@ static int bt_mesh_light_xyl_srv_start(struct bt_mesh_model *model) struct bt_mesh_light_xyl_srv *srv = model->user_data; struct bt_mesh_light_xy_status status; struct bt_mesh_model_transition transition = { - .time = srv->lightness_srv.ponoff.dtt.transition_time, + .time = srv->lightness_srv->ponoff.dtt.transition_time, .delay = 0, }; struct bt_mesh_light_xy_set set = { .transition = &transition, }; - switch (srv->lightness_srv.ponoff.on_power_up) { + switch (srv->lightness_srv->ponoff.on_power_up) { case BT_MESH_ON_POWER_UP_ON: /* Intentional fallthrough */ case BT_MESH_ON_POWER_UP_OFF: diff --git a/subsys/bluetooth/mesh/lightness_cli.c b/subsys/bluetooth/mesh/lightness_cli.c index 301912c63a6f..b948d901969e 100644 --- a/subsys/bluetooth/mesh/lightness_cli.c +++ b/subsys/bluetooth/mesh/lightness_cli.c @@ -7,12 +7,12 @@ #include "model_utils.h" #include "lightness_internal.h" -static void light_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, enum light_repr repr) +static int light_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, enum light_repr repr) { if (buf->len != BT_MESH_LIGHTNESS_MSG_MINLEN_STATUS && buf->len != BT_MESH_LIGHTNESS_MSG_MAXLEN_STATUS) { - return; + return -EMSGSIZE; } struct bt_mesh_lightness_cli *cli = model->user_data; @@ -39,30 +39,25 @@ static void light_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ct if (cli->handlers && cli->handlers->light_status) { cli->handlers->light_status(cli, ctx, &status); } + + return 0; } -static void handle_light_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_light_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - light_status(model, ctx, buf, ACTUAL); + return light_status(model, ctx, buf, ACTUAL); } -static void handle_light_linear_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_light_linear_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - light_status(model, ctx, buf, LINEAR); + return light_status(model, ctx, buf, LINEAR); } -static void handle_last_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_last_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHTNESS_MSG_LEN_LAST_STATUS) { - return; - } - struct bt_mesh_lightness_cli *cli = model->user_data; uint16_t last = repr_to_light(net_buf_simple_pull_le16(buf), ACTUAL); uint16_t *rsp; @@ -76,16 +71,13 @@ static void handle_last_status(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->last_light_status) { cli->handlers->last_light_status(cli, ctx, last); } + + return 0; } -static void handle_default_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_STATUS) { - return; - } - struct bt_mesh_lightness_cli *cli = model->user_data; uint16_t default_lvl = repr_to_light(net_buf_simple_pull_le16(buf), ACTUAL); @@ -100,16 +92,13 @@ static void handle_default_status(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->default_status) { cli->handlers->default_status(cli, ctx, default_lvl); } + + return 0; } -static void handle_range_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHTNESS_MSG_LEN_RANGE_STATUS) { - return; - } - struct bt_mesh_lightness_cli *cli = model->user_data; struct bt_mesh_lightness_range_status status; struct bt_mesh_lightness_range_status *rsp; @@ -127,32 +116,34 @@ static void handle_range_status(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->range_status) { cli->handlers->range_status(cli, ctx, &status); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_lightness_cli_op[] = { { BT_MESH_LIGHTNESS_OP_STATUS, - BT_MESH_LIGHTNESS_MSG_MINLEN_STATUS, + BT_MESH_LEN_MIN(BT_MESH_LIGHTNESS_MSG_MINLEN_STATUS), handle_light_status, }, { BT_MESH_LIGHTNESS_OP_LINEAR_STATUS, - BT_MESH_LIGHTNESS_MSG_MINLEN_STATUS, + BT_MESH_LEN_MIN(BT_MESH_LIGHTNESS_MSG_MINLEN_STATUS), handle_light_linear_status, }, { BT_MESH_LIGHTNESS_OP_LAST_STATUS, - BT_MESH_LIGHTNESS_MSG_LEN_LAST_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_LAST_STATUS), handle_last_status, }, { BT_MESH_LIGHTNESS_OP_DEFAULT_STATUS, - BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_STATUS), handle_default_status, }, { BT_MESH_LIGHTNESS_OP_RANGE_STATUS, - BT_MESH_LIGHTNESS_MSG_LEN_RANGE_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_RANGE_STATUS), handle_range_status, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/lightness_srv.c b/subsys/bluetooth/mesh/lightness_srv.c index 279cc9f5bf07..f127b494ba22 100644 --- a/subsys/bluetooth/mesh/lightness_srv.c +++ b/subsys/bluetooth/mesh/lightness_srv.c @@ -133,14 +133,9 @@ static void rsp_lightness_status(struct bt_mesh_model *model, bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); } -static void handle_light_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, enum light_repr repr) +static int handle_light_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, enum light_repr repr) { - if (buf->len != BT_MESH_LIGHTNESS_MSG_LEN_GET) { - return; - } - BT_DBG("%s", repr_str[repr]); struct bt_mesh_lightness_srv *srv = model->user_data; @@ -149,20 +144,20 @@ static void handle_light_get(struct bt_mesh_model *model, srv->handlers->light_get(srv, ctx, &status); rsp_lightness_status(model, ctx, &status, repr); + + return 0; } -static void handle_actual_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_actual_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - handle_light_get(model, ctx, buf, ACTUAL); + return handle_light_get(model, ctx, buf, ACTUAL); } -static void handle_linear_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_linear_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - handle_light_get(model, ctx, buf, LINEAR); + return handle_light_get(model, ctx, buf, LINEAR); } void lightness_srv_disable_control(struct bt_mesh_lightness_srv *srv) @@ -226,14 +221,12 @@ void lightness_srv_change_lvl(struct bt_mesh_lightness_srv *srv, } } -static void lightness_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack, - enum light_repr repr) +static int lightness_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack, enum light_repr repr) { if (buf->len != BT_MESH_LIGHTNESS_MSG_MINLEN_SET && buf->len != BT_MESH_LIGHTNESS_MSG_MAXLEN_SET) { - return; + return -EMSGSIZE; } struct bt_mesh_lightness_srv *srv = model->user_data; @@ -270,44 +263,37 @@ static void lightness_set(struct bt_mesh_model *model, if (ack) { rsp_lightness_status(model, ctx, &status, repr); } + + return 0; } -static void handle_actual_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_actual_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - lightness_set(model, ctx, buf, true, ACTUAL); + return lightness_set(model, ctx, buf, true, ACTUAL); } -static void handle_actual_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_actual_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - lightness_set(model, ctx, buf, false, ACTUAL); + return lightness_set(model, ctx, buf, false, ACTUAL); } -static void handle_linear_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_linear_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - lightness_set(model, ctx, buf, true, LINEAR); + return lightness_set(model, ctx, buf, true, LINEAR); } -static void handle_linear_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_linear_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - lightness_set(model, ctx, buf, false, LINEAR); + return lightness_set(model, ctx, buf, false, LINEAR); } -static void handle_last_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_last_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHTNESS_MSG_LEN_LAST_GET) { - return; - } - struct bt_mesh_lightness_srv *srv = model->user_data; BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_LIGHTNESS_OP_LAST_STATUS, @@ -316,16 +302,13 @@ static void handle_last_get(struct bt_mesh_model *model, net_buf_simple_add_le16(&rsp, light_to_repr(srv->last, ACTUAL)); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_default_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_GET) { - return; - } - struct bt_mesh_lightness_srv *srv = model->user_data; BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_LIGHTNESS_OP_DEFAULT_STATUS, @@ -335,6 +318,8 @@ static void handle_default_get(struct bt_mesh_model *model, net_buf_simple_add_le16(&rsp, light_to_repr(srv->default_light, ACTUAL)); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } void lightness_srv_default_set(struct bt_mesh_lightness_srv *srv, @@ -356,19 +341,15 @@ void lightness_srv_default_set(struct bt_mesh_lightness_srv *srv, store_state(srv); } -static void set_default(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int set_default(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_SET) { - return; - } - struct bt_mesh_lightness_srv *srv = model->user_data; uint16_t new = repr_to_light(net_buf_simple_pull_le16(buf), ACTUAL); lightness_srv_default_set(srv, ctx, new); if (!ack) { - return; + return 0; } BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_LIGHTNESS_OP_DEFAULT_STATUS, @@ -377,30 +358,25 @@ static void set_default(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx net_buf_simple_add_le16(&rsp, srv->default_light); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_default_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_default(model, ctx, buf, true); + return set_default(model, ctx, buf, true); } -static void handle_default_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_default_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_default(model, ctx, buf, false); + return set_default(model, ctx, buf, false); } -static void handle_range_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_LIGHTNESS_MSG_LEN_RANGE_GET) { - return; - } - struct bt_mesh_lightness_srv *srv = model->user_data; BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_LIGHTNESS_OP_RANGE_STATUS, @@ -412,15 +388,13 @@ static void handle_range_get(struct bt_mesh_model *model, net_buf_simple_add_le16(&rsp, light_to_repr(srv->range.max, ACTUAL)); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool ack) +static int set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { - if (buf->len != BT_MESH_LIGHTNESS_MSG_LEN_RANGE_SET) { - return; - } - struct bt_mesh_lightness_srv *srv = model->user_data; struct bt_mesh_lightness_range new; @@ -432,7 +406,7 @@ static void set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, * parameters. */ if (new.min == 0 || new.max == 0 || new.min > new.max) { - return; + return -EINVAL; } if (new.min != srv->range.min || new.max != srv->range.max) { @@ -447,7 +421,7 @@ static void set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, } if (!ack) { - return; + return 0; } BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_LIGHTNESS_OP_RANGE_STATUS, @@ -459,66 +433,66 @@ static void set_range(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, net_buf_simple_add_le16(&rsp, light_to_repr(srv->range.max, ACTUAL)); bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_range_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_range(model, ctx, buf, true); + return set_range(model, ctx, buf, true); } -static void handle_range_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_range_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - set_range(model, ctx, buf, false); + return set_range(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_lightness_srv_op[] = { { BT_MESH_LIGHTNESS_OP_GET, - BT_MESH_LIGHTNESS_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_GET), handle_actual_get, }, { BT_MESH_LIGHTNESS_OP_SET, - BT_MESH_LIGHTNESS_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_LIGHTNESS_MSG_MINLEN_SET), handle_actual_set, }, { BT_MESH_LIGHTNESS_OP_SET_UNACK, - BT_MESH_LIGHTNESS_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_LIGHTNESS_MSG_MINLEN_SET), handle_actual_set_unack, }, { BT_MESH_LIGHTNESS_OP_LINEAR_GET, - BT_MESH_LIGHTNESS_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_GET), handle_linear_get, }, { BT_MESH_LIGHTNESS_OP_LINEAR_SET, - BT_MESH_LIGHTNESS_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_LIGHTNESS_MSG_MINLEN_SET), handle_linear_set, }, { BT_MESH_LIGHTNESS_OP_LINEAR_SET_UNACK, - BT_MESH_LIGHTNESS_MSG_MINLEN_SET, + BT_MESH_LEN_MIN(BT_MESH_LIGHTNESS_MSG_MINLEN_SET), handle_linear_set_unack, }, { BT_MESH_LIGHTNESS_OP_LAST_GET, - BT_MESH_LIGHTNESS_MSG_LEN_LAST_GET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_LAST_GET), handle_last_get, }, { BT_MESH_LIGHTNESS_OP_DEFAULT_GET, - BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_GET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_GET), handle_default_get, }, { BT_MESH_LIGHTNESS_OP_RANGE_GET, - BT_MESH_LIGHTNESS_MSG_LEN_RANGE_GET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_RANGE_GET), handle_range_get, }, BT_MESH_MODEL_OP_END, @@ -527,22 +501,22 @@ const struct bt_mesh_model_op _bt_mesh_lightness_srv_op[] = { const struct bt_mesh_model_op _bt_mesh_lightness_setup_srv_op[] = { { BT_MESH_LIGHTNESS_OP_DEFAULT_SET, - BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_SET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_SET), handle_default_set, }, { BT_MESH_LIGHTNESS_OP_DEFAULT_SET_UNACK, - BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_SET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_DEFAULT_SET), handle_default_set_unack, }, { BT_MESH_LIGHTNESS_OP_RANGE_SET, - BT_MESH_LIGHTNESS_MSG_LEN_RANGE_SET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_RANGE_SET), handle_range_set, }, { BT_MESH_LIGHTNESS_OP_RANGE_SET_UNACK, - BT_MESH_LIGHTNESS_MSG_LEN_RANGE_SET, + BT_MESH_LEN_EXACT(BT_MESH_LIGHTNESS_MSG_LEN_RANGE_SET), handle_range_set_unack, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/scene_cli.c b/subsys/bluetooth/mesh/scene_cli.c index 2ed679cadf74..97bca39aa5d9 100644 --- a/subsys/bluetooth/mesh/scene_cli.c +++ b/subsys/bluetooth/mesh/scene_cli.c @@ -7,7 +7,7 @@ #include #include "model_utils.h" -static void scene_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int handle_scene_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { struct bt_mesh_scene_state *rsp; @@ -24,7 +24,7 @@ static void scene_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ct state.remaining_time = 0; } else { /* Invalid size */ - return; + return -EMSGSIZE; } if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, BT_MESH_SCENE_OP_STATUS, ctx->addr, @@ -36,10 +36,12 @@ static void scene_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ct if (cli->status) { cli->status(cli, ctx, &state); } + + return 0; } -static void scene_reg(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_scene_reg(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_scene_register *rsp; struct bt_mesh_scene_cli *cli = model->user_data; @@ -47,6 +49,10 @@ static void scene_reg(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, reg.status = net_buf_simple_pull_u8(buf); reg.current = net_buf_simple_pull_le16(buf); + if (buf->len % 2) { + return -EMSGSIZE; + } + reg.count = buf->len / sizeof(uint16_t); reg.scenes = net_buf_simple_pull_mem(buf, buf->len); @@ -82,18 +88,20 @@ static void scene_reg(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, for (int i = 0; i < reg.count; i++) { reg.scenes[i] = sys_cpu_to_le16(reg.scenes[i]); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_scene_cli_op[] = { { BT_MESH_SCENE_OP_STATUS, - BT_MESH_SCENE_MSG_MINLEN_STATUS, - scene_status, + BT_MESH_LEN_MIN(BT_MESH_SCENE_MSG_MINLEN_STATUS), + handle_scene_status, }, { BT_MESH_SCENE_OP_REGISTER_STATUS, - BT_MESH_SCENE_MSG_MINLEN_REGISTER_STATUS, - scene_reg, + BT_MESH_LEN_MIN(BT_MESH_SCENE_MSG_MINLEN_REGISTER_STATUS), + handle_scene_reg, }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/scene_srv.c b/subsys/bluetooth/mesh/scene_srv.c index 8b946cf6aca2..e10250c54b6e 100644 --- a/subsys/bluetooth/mesh/scene_srv.c +++ b/subsys/bluetooth/mesh/scene_srv.c @@ -153,15 +153,17 @@ static int scene_status_send(struct bt_mesh_scene_srv *srv, return model_send(srv->model, ctx, &buf); } -static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_scene_srv *srv = model->user_data; (void)scene_status_send(srv, ctx, BT_MESH_SCENE_SUCCESS); + + return 0; } -static void scene_recall(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int scene_recall(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { struct bt_mesh_scene_srv *srv = model->user_data; @@ -174,7 +176,7 @@ static void scene_recall(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ct scene = net_buf_simple_pull_le16(buf); if (scene == BT_MESH_SCENE_NONE) { - return; /* Prohibited */ + return -EINVAL; /* Prohibited */ } tid = net_buf_simple_pull_u8(buf); @@ -183,7 +185,7 @@ static void scene_recall(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ct if (tid_check_and_update(&srv->tid, tid, ctx)) { BT_DBG("Duplicate TID"); scene_status_send(srv, ctx, BT_MESH_SCENE_SUCCESS); - return; + return 0; } err = bt_mesh_scene_srv_set(srv, scene, has_trans ? &transition : NULL); @@ -198,20 +200,20 @@ static void scene_recall(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ct /* Publish */ scene_status_send(srv, NULL, status); } + + return 0; } -static void handle_recall(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_recall(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - scene_recall(model, ctx, buf, true); + return scene_recall(model, ctx, buf, true); } -static void handle_recall_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_recall_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - scene_recall(model, ctx, buf, false); + return scene_recall(model, ctx, buf, false); } static int scene_register_status_send(struct bt_mesh_scene_srv *srv, @@ -232,34 +234,35 @@ static int scene_register_status_send(struct bt_mesh_scene_srv *srv, return model_send(srv->model, ctx, &buf); } -static void handle_register_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_register_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_scene_srv *srv = model->user_data; - scene_register_status_send(srv, ctx, BT_MESH_SCENE_SUCCESS); + (void)scene_register_status_send(srv, ctx, BT_MESH_SCENE_SUCCESS); + + return 0; } const struct bt_mesh_model_op _bt_mesh_scene_srv_op[] = { { BT_MESH_SCENE_OP_GET, - BT_MESH_SCENE_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_SCENE_MSG_LEN_GET), handle_get, }, { BT_MESH_SCENE_OP_RECALL, - BT_MESH_SCENE_MSG_MINLEN_RECALL, + BT_MESH_LEN_MIN(BT_MESH_SCENE_MSG_MINLEN_RECALL), handle_recall, }, { BT_MESH_SCENE_OP_RECALL_UNACK, - BT_MESH_SCENE_MSG_MINLEN_RECALL, + BT_MESH_LEN_MIN(BT_MESH_SCENE_MSG_MINLEN_RECALL), handle_recall_unack, }, { BT_MESH_SCENE_OP_REGISTER_GET, - BT_MESH_SCENE_MSG_LEN_REGISTER_GET, + BT_MESH_LEN_EXACT(BT_MESH_SCENE_MSG_LEN_REGISTER_GET), handle_register_get, }, BT_MESH_MODEL_OP_END, @@ -563,8 +566,8 @@ static void scene_delete(struct bt_mesh_scene_srv *srv, uint16_t *scene) *scene = srv->all[--srv->count]; } -static void handle_store(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_store(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_scene_srv *srv = model->user_data; enum bt_mesh_scene_status status; @@ -572,34 +575,34 @@ static void handle_store(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ct scene_number = net_buf_simple_pull_le16(buf); if (scene_number == BT_MESH_SCENE_NONE) { - return; + return -EINVAL; } status = scene_store(srv, scene_number); scene_register_status_send(srv, ctx, status); + + return 0; } -static void handle_store_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_store_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_scene_srv *srv = model->user_data; uint16_t scene_number; scene_number = net_buf_simple_pull_le16(buf); if (scene_number == BT_MESH_SCENE_NONE) { - return; + return -EINVAL; } (void)scene_store(srv, scene_number); + + return 0; } -static void handle_delete(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int delete_scene(struct bt_mesh_scene_srv *srv, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - struct bt_mesh_scene_srv *srv = model->user_data; - enum bt_mesh_scene_status status; uint16_t *scene; scene = scene_find(srv, net_buf_simple_pull_le16(buf)); @@ -607,43 +610,52 @@ static void handle_delete(struct bt_mesh_model *model, scene_delete(srv, scene); } - status = BT_MESH_SCENE_SUCCESS; - - scene_register_status_send(srv, ctx, status); + return 0; } -static void handle_delete_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_delete(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_scene_srv *srv = model->user_data; - uint16_t *scene; + int err; - scene = scene_find(srv, net_buf_simple_pull_le16(buf)); - if (scene != BT_MESH_SCENE_NONE) { - scene_delete(srv, scene); + err = delete_scene(srv, ctx, buf); + if (err) { + return err; } + + scene_register_status_send(srv, ctx, BT_MESH_SCENE_SUCCESS); + + return 0; +} + +static int handle_delete_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) +{ + struct bt_mesh_scene_srv *srv = model->user_data; + + return delete_scene(srv, ctx, buf); } const struct bt_mesh_model_op _bt_mesh_scene_setup_srv_op[] = { { BT_MESH_SCENE_OP_STORE, - BT_MESH_SCENE_MSG_LEN_STORE, + BT_MESH_LEN_EXACT(BT_MESH_SCENE_MSG_LEN_STORE), handle_store, }, { BT_MESH_SCENE_OP_STORE_UNACK, - BT_MESH_SCENE_MSG_LEN_STORE, + BT_MESH_LEN_EXACT(BT_MESH_SCENE_MSG_LEN_STORE), handle_store_unack, }, { BT_MESH_SCENE_OP_DELETE, - BT_MESH_SCENE_MSG_LEN_DELETE, + BT_MESH_LEN_EXACT(BT_MESH_SCENE_MSG_LEN_DELETE), handle_delete, }, { BT_MESH_SCENE_OP_DELETE_UNACK, - BT_MESH_SCENE_MSG_LEN_DELETE, + BT_MESH_LEN_EXACT(BT_MESH_SCENE_MSG_LEN_DELETE), handle_delete_unack, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/scheduler_cli.c b/subsys/bluetooth/mesh/scheduler_cli.c index 15258c629a7a..d61c4de896f7 100644 --- a/subsys/bluetooth/mesh/scheduler_cli.c +++ b/subsys/bluetooth/mesh/scheduler_cli.c @@ -8,18 +8,13 @@ #include "scheduler_internal.h" #include "model_utils.h" -static void status_op(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_scheduler_cli *cli = model->user_data; uint16_t schedules; uint16_t *rsp; - if (buf->len != BT_MESH_SCHEDULER_MSG_LEN_STATUS) { - return; - } - schedules = net_buf_simple_pull_le16(buf); if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, BT_MESH_SCHEDULER_OP_STATUS, ctx->addr, @@ -31,11 +26,12 @@ static void status_op(struct bt_mesh_model *model, if (cli->status_handler) { cli->status_handler(cli, ctx, schedules); } + + return 0; } -static void action_status_op(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_action_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_scheduler_cli *cli = model->user_data; struct bt_mesh_schedule_entry action = {0}; @@ -44,7 +40,7 @@ static void action_status_op(struct bt_mesh_model *model, if (buf->len != BT_MESH_SCHEDULER_MSG_LEN_ACTION_STATUS && buf->len != BT_MESH_SCHEDULER_MSG_LEN_ACTION_STATUS_REDUCED) { - return; + return -EMSGSIZE; } if (buf->len == BT_MESH_SCHEDULER_MSG_LEN_ACTION_STATUS) { @@ -66,18 +62,20 @@ static void action_status_op(struct bt_mesh_model *model, buf->len == BT_MESH_SCHEDULER_MSG_LEN_ACTION_STATUS ? &action : NULL); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_scheduler_cli_op[] = { { BT_MESH_SCHEDULER_OP_STATUS, - BT_MESH_SCHEDULER_MSG_LEN_STATUS, - status_op, + BT_MESH_LEN_EXACT(BT_MESH_SCHEDULER_MSG_LEN_STATUS), + handle_status, }, { BT_MESH_SCHEDULER_OP_ACTION_STATUS, - BT_MESH_SCHEDULER_MSG_LEN_ACTION_STATUS_REDUCED, - action_status_op, + BT_MESH_LEN_MIN(BT_MESH_SCHEDULER_MSG_LEN_ACTION_STATUS_REDUCED), + handle_action_status, }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/scheduler_srv.c b/subsys/bluetooth/mesh/scheduler_srv.c index d0fe43d10919..7ff3c020fb86 100644 --- a/subsys/bluetooth/mesh/scheduler_srv.c +++ b/subsys/bluetooth/mesh/scheduler_srv.c @@ -586,10 +586,8 @@ static int send_scheduler_action_status(struct bt_mesh_model *model, return model_send(model, ctx, &buf); } -static void action_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, - bool ack) +static int action_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool ack) { struct bt_mesh_scheduler_srv *srv = model->user_data; uint8_t idx; @@ -606,7 +604,7 @@ static void action_set(struct bt_mesh_model *model, (tmp.action > BT_MESH_SCHEDULER_SCENE_RECALL && tmp.action != BT_MESH_SCHEDULER_NO_ACTIONS) || idx >= BT_MESH_SCHEDULER_ACTION_ENTRY_COUNT) { - return; + return -EINVAL; } srv->sch_reg[idx] = tmp; @@ -635,55 +633,58 @@ static void action_set(struct bt_mesh_model *model, if (ack) { /* reply on the action set command */ send_scheduler_action_status(model, ctx, idx, false); } + + return 0; } -static void handle_scheduler_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_scheduler_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { BT_DBG("Rx: scheduler server get"); send_scheduler_status(model, ctx); + + return 0; } -static void handle_scheduler_action_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_scheduler_action_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_scheduler_srv *srv = model->user_data; uint8_t idx = net_buf_simple_pull_u8(buf); if (idx >= BT_MESH_SCHEDULER_ACTION_ENTRY_COUNT) { - return; + return -ENOENT; } BT_DBG("Rx: scheduler server action index %d get", idx); send_scheduler_action_status(model, ctx, idx, !is_entry_defined(srv, idx)); + + return 0; } -static void handle_scheduler_action_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_scheduler_action_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - action_set(model, ctx, buf, true); + return action_set(model, ctx, buf, true); } -static void handle_scheduler_action_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_scheduler_action_set_unack(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - action_set(model, ctx, buf, false); + return action_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_scheduler_srv_op[] = { { BT_MESH_SCHEDULER_OP_GET, - BT_MESH_SCHEDULER_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_SCHEDULER_MSG_LEN_GET), handle_scheduler_get, }, { BT_MESH_SCHEDULER_OP_ACTION_GET, - BT_MESH_SCHEDULER_MSG_LEN_ACTION_GET, + BT_MESH_LEN_EXACT(BT_MESH_SCHEDULER_MSG_LEN_ACTION_GET), handle_scheduler_action_get, }, BT_MESH_MODEL_OP_END, @@ -692,12 +693,12 @@ const struct bt_mesh_model_op _bt_mesh_scheduler_srv_op[] = { const struct bt_mesh_model_op _bt_mesh_scheduler_setup_srv_op[] = { { BT_MESH_SCHEDULER_OP_ACTION_SET, - BT_MESH_SCHEDULER_MSG_LEN_ACTION_SET, + BT_MESH_LEN_EXACT(BT_MESH_SCHEDULER_MSG_LEN_ACTION_SET), handle_scheduler_action_set, }, { BT_MESH_SCHEDULER_OP_ACTION_SET_UNACK, - BT_MESH_SCHEDULER_MSG_LEN_ACTION_SET, + BT_MESH_LEN_EXACT(BT_MESH_SCHEDULER_MSG_LEN_ACTION_SET), handle_scheduler_action_set_unack, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/sensor_cli.c b/subsys/bluetooth/mesh/sensor_cli.c index 7f7c834a44fd..ffe308338ddd 100644 --- a/subsys/bluetooth/mesh/sensor_cli.c +++ b/subsys/bluetooth/mesh/sensor_cli.c @@ -59,12 +59,11 @@ static void unknown_type(struct bt_mesh_sensor_cli *cli, } } -static void handle_descriptor_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_descriptor_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (buf->len != 2 && buf->len % 8) { - return; + return -EMSGSIZE; } struct bt_mesh_sensor_cli *cli = model->user_data; @@ -101,11 +100,12 @@ static void handle_descriptor_status(struct bt_mesh_model *model, ack_ctx->count = count; bt_mesh_msg_ack_ctx_rx(&cli->ack_ctx); } + + return 0; } -static void handle_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_cli *cli = model->user_data; struct sensor_data_list_rsp *rsp = NULL; @@ -137,7 +137,7 @@ static void handle_status(struct bt_mesh_model *model, if (buf->len < length) { BT_WARN("Invalid length for 0x%04x: %u", id, length); - return; + return -EMSGSIZE; } net_buf_simple_pull(buf, length); unknown_type(cli, ctx, id, BT_MESH_SENSOR_OP_STATUS); @@ -149,7 +149,7 @@ static void handle_status(struct bt_mesh_model *model, if (length != expected_len) { BT_WARN("Invalid length for 0x%04x: %u (expected %u)", id, length, expected_len); - return; + return -EMSGSIZE; } struct sensor_value value[CONFIG_BT_MESH_SENSOR_CHANNELS_MAX]; @@ -157,7 +157,7 @@ static void handle_status(struct bt_mesh_model *model, err = sensor_value_decode(buf, type, value); if (err) { BT_ERR("Invalid format, err=%d", err); - return; /* Invalid format, should ignore message */ + return err; /* Invalid format, should ignore message */ } if (cli->cb && cli->cb->data) { @@ -178,6 +178,8 @@ static void handle_status(struct bt_mesh_model *model, rsp->count = count; bt_mesh_msg_ack_ctx_rx(&cli->ack_ctx); } + + return 0; } static int parse_series_entry(const struct bt_mesh_sensor_type *type, @@ -214,9 +216,8 @@ static int parse_series_entry(const struct bt_mesh_sensor_type *type, return sensor_value_decode(buf, type, entry->value); } -static void handle_column_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_column_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_cli *cli = model->user_data; struct series_data_rsp *rsp; @@ -229,13 +230,13 @@ static void handle_column_status(struct bt_mesh_model *model, type = bt_mesh_sensor_type_get(id); if (!type) { unknown_type(cli, ctx, id, BT_MESH_SENSOR_OP_COLUMN_STATUS); - return; + return -ENOENT; } col_format = bt_mesh_sensor_column_format_get(type); if (!col_format) { BT_WARN("Received unsupported column format 0x%04x", id); - return; + return -ENOENT; } struct bt_mesh_sensor_series_entry entry; @@ -247,7 +248,7 @@ static void handle_column_status(struct bt_mesh_model *model, } if (err) { - return; /* Invalid format, should ignore message */ + return err; /* Invalid format, should ignore message */ } if (cli->cb && cli->cb->series_entry) { @@ -267,11 +268,12 @@ static void handle_column_status(struct bt_mesh_model *model, } bt_mesh_msg_ack_ctx_rx(&cli->ack_ctx); } + + return 0; } -static void handle_series_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_series_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_cli *cli = model->user_data; const struct bt_mesh_sensor_format *col_format; @@ -283,7 +285,7 @@ static void handle_series_status(struct bt_mesh_model *model, type = bt_mesh_sensor_type_get(id); if (!type) { unknown_type(cli, ctx, id, BT_MESH_SENSOR_OP_SERIES_STATUS); - return; + return -ENOENT; } if (bt_mesh_msg_ack_ctx_match(&cli->ack_ctx, BT_MESH_SENSOR_OP_SERIES_STATUS, ctx->addr, @@ -302,7 +304,7 @@ static void handle_series_status(struct bt_mesh_model *model, bt_mesh_msg_ack_ctx_rx(&cli->ack_ctx); } - return; + return -ENOENT; } size_t val_len = (col_format->size * 2) + sensor_value_len(type); @@ -315,7 +317,7 @@ static void handle_series_status(struct bt_mesh_model *model, err = parse_series_entry(type, col_format, buf, &entry); if (err) { BT_ERR("Failed parsing column %u (err: %d)", i, err); - return; + return err; } if (cli->cb && cli->cb->series_entry) { @@ -331,11 +333,12 @@ static void handle_series_status(struct bt_mesh_model *model, rsp->count = count; bt_mesh_msg_ack_ctx_rx(&cli->ack_ctx); } + + return 0; } -static void handle_cadence_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_cadence_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_cli *cli = model->user_data; struct cadence_rsp *rsp; @@ -346,7 +349,7 @@ static void handle_cadence_status(struct bt_mesh_model *model, if (!type) { unknown_type(cli, ctx, id, BT_MESH_SENSOR_OP_CADENCE_STATUS); - return; + return -ENOENT; } if (buf->len == 0 || type->channel_count != 1) { @@ -360,7 +363,7 @@ static void handle_cadence_status(struct bt_mesh_model *model, err = sensor_cadence_decode(buf, type, &cadence.fast_period_div, &cadence.min_int, &cadence.threshold); if (err) { - return; + return err; } if (cli->cb && cli->cb->cadence) { @@ -379,17 +382,18 @@ static void handle_cadence_status(struct bt_mesh_model *model, bt_mesh_msg_ack_ctx_rx(&cli->ack_ctx); } + + return 0; } -static void handle_settings_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_settings_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_cli *cli = model->user_data; struct settings_rsp *rsp; if (buf->len % 2) { - return; + return -EMSGSIZE; } uint16_t id = net_buf_simple_pull_le16(buf); @@ -397,7 +401,7 @@ static void handle_settings_status(struct bt_mesh_model *model, if (!type) { unknown_type(cli, ctx, id, BT_MESH_SENSOR_OP_SETTINGS_STATUS); - return; + return -ENOENT; } /* The list may be unaligned: */ @@ -421,11 +425,12 @@ static void handle_settings_status(struct bt_mesh_model *model, rsp->count = count; bt_mesh_msg_ack_ctx_rx(&cli->ack_ctx); } + + return 0; } -static void handle_setting_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_setting_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_cli *cli = model->user_data; struct setting_rsp *rsp; @@ -442,14 +447,14 @@ static void handle_setting_status(struct bt_mesh_model *model, access = net_buf_simple_pull_u8(buf); if (access != 0x01 && access != 0x03) { - return; + return -EINVAL; } const struct bt_mesh_sensor_type *type = bt_mesh_sensor_type_get(id); if (!type) { unknown_type(cli, ctx, id, BT_MESH_SENSOR_OP_SETTING_STATUS); - return; + return -ENOENT; } @@ -457,7 +462,7 @@ static void handle_setting_status(struct bt_mesh_model *model, if (!setting.type) { unknown_type( cli, ctx, setting_id, BT_MESH_SENSOR_OP_SETTING_STATUS); - return; + return -ENOENT; } setting.writable = (access == 0x03); @@ -472,7 +477,7 @@ static void handle_setting_status(struct bt_mesh_model *model, err = sensor_value_decode(buf, setting.type, setting.value); if (err) { - return; + return err; } if (cli->cb && cli->cb->setting_status) { @@ -486,42 +491,44 @@ static void handle_setting_status(struct bt_mesh_model *model, *rsp->setting = setting; bt_mesh_msg_ack_ctx_rx(&cli->ack_ctx); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_sensor_cli_op[] = { { BT_MESH_SENSOR_OP_DESCRIPTOR_STATUS, - BT_MESH_SENSOR_MSG_MINLEN_DESCRIPTOR_STATUS, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_DESCRIPTOR_STATUS), handle_descriptor_status, }, { BT_MESH_SENSOR_OP_STATUS, - BT_MESH_SENSOR_MSG_MINLEN_STATUS, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_STATUS), handle_status, }, { BT_MESH_SENSOR_OP_COLUMN_STATUS, - BT_MESH_SENSOR_MSG_MINLEN_COLUMN_STATUS, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_COLUMN_STATUS), handle_column_status, }, { BT_MESH_SENSOR_OP_SERIES_STATUS, - BT_MESH_SENSOR_MSG_MINLEN_SERIES_STATUS, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_SERIES_STATUS), handle_series_status, }, { BT_MESH_SENSOR_OP_CADENCE_STATUS, - BT_MESH_SENSOR_MSG_MINLEN_CADENCE_STATUS, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_CADENCE_STATUS), handle_cadence_status, }, { BT_MESH_SENSOR_OP_SETTINGS_STATUS, - BT_MESH_SENSOR_MSG_MINLEN_SETTINGS_STATUS, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_SETTINGS_STATUS), handle_settings_status, }, { BT_MESH_SENSOR_OP_SETTING_STATUS, - BT_MESH_SENSOR_MSG_MINLEN_SETTING_STATUS, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_SETTING_STATUS), handle_setting_status, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/sensor_srv.c b/subsys/bluetooth/mesh/sensor_srv.c index 39556a7bdc6c..efa358bcb006 100644 --- a/subsys/bluetooth/mesh/sensor_srv.c +++ b/subsys/bluetooth/mesh/sensor_srv.c @@ -120,14 +120,14 @@ static int buf_status_add(struct bt_mesh_sensor *sensor, return err; } -static void handle_descriptor_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_descriptor_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_srv *srv = model->user_data; - if (buf->len != 0 && buf->len != 2) { - return; + if (buf->len != BT_MESH_SENSOR_MSG_MINLEN_DESCRIPTOR_GET && + buf->len != BT_MESH_SENSOR_MSG_MAXLEN_DESCRIPTOR_GET) { + return -EMSGSIZE; } NET_BUF_SIMPLE_DEFINE(rsp, BT_MESH_TX_SDU_MAX); @@ -139,7 +139,7 @@ static void handle_descriptor_get(struct bt_mesh_model *model, uint16_t id = net_buf_simple_pull_le16(buf); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } sensor = sensor_get(srv, id); @@ -165,15 +165,18 @@ static void handle_descriptor_get(struct bt_mesh_model *model, respond: bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_srv *srv = model->user_data; - if (buf->len != 0 && buf->len != 2) { - return; + if (buf->len != BT_MESH_SENSOR_MSG_MINLEN_GET && + buf->len != BT_MESH_SENSOR_MSG_MAXLEN_GET) { + return -EMSGSIZE; } NET_BUF_SIMPLE_DEFINE(rsp, BT_MESH_TX_SDU_MAX); @@ -185,7 +188,7 @@ static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, uint16_t id = net_buf_simple_pull_le16(buf); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } sensor = sensor_get(srv, id); @@ -205,6 +208,8 @@ static void handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, respond: bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } static const struct bt_mesh_sensor_column * @@ -221,21 +226,16 @@ column_get(const struct bt_mesh_sensor_series *series, return NULL; } -static void handle_column_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_column_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_srv *srv = model->user_data; int err; - if (buf->len < 2) { - return; - } - uint16_t id = net_buf_simple_pull_le16(buf); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } struct bt_mesh_sensor *sensor = sensor_get(srv, id); @@ -261,7 +261,7 @@ static void handle_column_get(struct bt_mesh_model *model, err = sensor_ch_decode(buf, col_format, &col_x); if (err) { - return; + return err; } BT_DBG("Column %s", bt_mesh_sensor_ch_str(&col_x)); @@ -276,28 +276,25 @@ static void handle_column_get(struct bt_mesh_model *model, err = sensor_column_encode(&rsp, sensor, ctx, col); if (err) { BT_WARN("Failed encoding sensor column: %d", err); - return; + return err; } respond: bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void handle_series_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_series_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_srv *srv = model->user_data; const struct bt_mesh_sensor_format *col_format; - if (buf->len < 2) { - return; - } - uint16_t id = net_buf_simple_pull_le16(buf); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } struct bt_mesh_sensor *sensor = sensor_get(srv, id); @@ -325,18 +322,18 @@ static void handle_series_get(struct bt_mesh_model *model, err = sensor_ch_decode(buf, col_format, &range.start); if (err) { BT_WARN("Range start decode failed: %d", err); - return; + return err; } err = sensor_ch_decode(buf, col_format, &range.end); if (err) { BT_WARN("Range end decode failed: %d", err); - return; + return err; } } else if (buf->len != 0) { /* invalid length */ BT_WARN("Invalid length (%u)", buf->len); - return; + return -EMSGSIZE; } for (uint32_t i = 0; i < sensor->series.column_count; ++i) { @@ -354,41 +351,42 @@ static void handle_series_get(struct bt_mesh_model *model, if (err) { BT_WARN("Failed encoding: %d", err); - return; + return err; } } respond: bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } const struct bt_mesh_model_op _bt_mesh_sensor_srv_op[] = { { BT_MESH_SENSOR_OP_DESCRIPTOR_GET, - BT_MESH_SENSOR_MSG_MINLEN_DESCRIPTOR_GET, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_DESCRIPTOR_GET), handle_descriptor_get, }, { BT_MESH_SENSOR_OP_GET, - BT_MESH_SENSOR_MSG_MINLEN_GET, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_GET), handle_get, }, { BT_MESH_SENSOR_OP_COLUMN_GET, - BT_MESH_SENSOR_MSG_MINLEN_COLUMN_GET, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_COLUMN_GET), handle_column_get, }, { BT_MESH_SENSOR_OP_SERIES_GET, - BT_MESH_SENSOR_MSG_MINLEN_SERIES_GET, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_SERIES_GET), handle_series_get, }, BT_MESH_MODEL_OP_END, }; -static void handle_cadence_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_cadence_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_srv *srv = model->user_data; struct bt_mesh_sensor *sensor; @@ -401,7 +399,7 @@ static void handle_cadence_get(struct bt_mesh_model *model, id = net_buf_simple_pull_le16(buf); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } net_buf_simple_add_le16(&rsp, id); @@ -416,14 +414,16 @@ static void handle_cadence_get(struct bt_mesh_model *model, sensor->state.min_int, &sensor->state.threshold); if (err) { - return; + return err; } respond: bt_mesh_model_send(srv->model, ctx, &rsp, NULL, NULL); + + return 0; } -static void cadence_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int cadence_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { struct bt_mesh_sensor_srv *srv = model->user_data; @@ -436,7 +436,7 @@ static void cadence_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx id = net_buf_simple_pull_le16(buf); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } net_buf_simple_add_le16(&rsp, id); @@ -455,7 +455,7 @@ static void cadence_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx &threshold); if (err) { BT_WARN("Invalid cadence"); - return; + return err; } BT_DBG("Min int: %u div: %u " @@ -480,7 +480,7 @@ static void cadence_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx sensor->state.min_int, &sensor->state.threshold); if (err) { - return; + return err; } model_send(model, NULL, &rsp); @@ -489,32 +489,31 @@ static void cadence_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx if (ack) { bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); } + + return 0; } -static void handle_cadence_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_cadence_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - cadence_set(model, ctx, buf, true); + return cadence_set(model, ctx, buf, true); } -static void handle_cadence_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_cadence_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - cadence_set(model, ctx, buf, false); + return cadence_set(model, ctx, buf, false); } -static void handle_settings_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_settings_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_srv *srv = model->user_data; uint16_t id = net_buf_simple_pull_le16(buf); if (id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } BT_DBG("0x%04x", id); @@ -540,6 +539,8 @@ static void handle_settings_get(struct bt_mesh_model *model, respond: bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } static const struct bt_mesh_sensor_setting * @@ -553,9 +554,8 @@ setting_get(struct bt_mesh_sensor *sensor, uint16_t setting_id) return NULL; } -static void handle_setting_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_setting_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_sensor_srv *srv = model->user_data; uint16_t id = net_buf_simple_pull_le16(buf); @@ -564,7 +564,7 @@ static void handle_setting_get(struct bt_mesh_model *model, if (id == BT_MESH_PROP_ID_PROHIBITED || setting_id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_SENSOR_OP_SETTING_STATUS, @@ -604,9 +604,11 @@ static void handle_setting_get(struct bt_mesh_model *model, respond: bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); + + return 0; } -static void setting_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, +static int setting_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, bool ack) { struct bt_mesh_sensor_srv *srv = model->user_data; @@ -616,7 +618,7 @@ static void setting_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx if (id == BT_MESH_PROP_ID_PROHIBITED || setting_id == BT_MESH_PROP_ID_PROHIBITED) { - return; + return -EINVAL; } BT_MESH_MODEL_BUF_DEFINE(rsp, BT_MESH_SENSOR_OP_SETTING_STATUS, @@ -646,7 +648,7 @@ static void setting_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx setting->type->id, err); /* Invalid parameters: ignore this message */ - return; + return err; } setting->set(sensor, setting, ctx, values); @@ -673,38 +675,59 @@ static void setting_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx if (ack) { bt_mesh_model_send(model, ctx, &rsp, NULL, NULL); } + + return 0; } -static void handle_setting_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_setting_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - setting_set(model, ctx, buf, true); + return setting_set(model, ctx, buf, true); } -static void handle_setting_set_unack(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_setting_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - setting_set(model, ctx, buf, false); + return setting_set(model, ctx, buf, false); } const struct bt_mesh_model_op _bt_mesh_sensor_setup_srv_op[] = { - { BT_MESH_SENSOR_OP_CADENCE_GET, BT_MESH_SENSOR_MSG_LEN_CADENCE_GET, - handle_cadence_get }, - { BT_MESH_SENSOR_OP_CADENCE_SET, BT_MESH_SENSOR_MSG_MINLEN_CADENCE_SET, - handle_cadence_set }, - { BT_MESH_SENSOR_OP_CADENCE_SET_UNACKNOWLEDGED, - BT_MESH_SENSOR_MSG_MINLEN_CADENCE_SET, handle_cadence_set_unack }, - { BT_MESH_SENSOR_OP_SETTINGS_GET, BT_MESH_SENSOR_MSG_LEN_SETTINGS_GET, - handle_settings_get }, - { BT_MESH_SENSOR_OP_SETTING_GET, BT_MESH_SENSOR_MSG_LEN_SETTING_GET, - handle_setting_get }, - { BT_MESH_SENSOR_OP_SETTING_SET, BT_MESH_SENSOR_MSG_MINLEN_SETTING_SET, - handle_setting_set }, - { BT_MESH_SENSOR_OP_SETTING_SET_UNACKNOWLEDGED, - BT_MESH_SENSOR_MSG_MINLEN_SETTING_SET, handle_setting_set_unack }, + { + BT_MESH_SENSOR_OP_CADENCE_GET, + BT_MESH_LEN_EXACT(BT_MESH_SENSOR_MSG_LEN_CADENCE_GET), + handle_cadence_get, + }, + { + BT_MESH_SENSOR_OP_CADENCE_SET, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_CADENCE_SET), + handle_cadence_set, + }, + { + BT_MESH_SENSOR_OP_CADENCE_SET_UNACKNOWLEDGED, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_CADENCE_SET), + handle_cadence_set_unack, + }, + { + BT_MESH_SENSOR_OP_SETTINGS_GET, + BT_MESH_LEN_EXACT(BT_MESH_SENSOR_MSG_LEN_SETTINGS_GET), + handle_settings_get, + }, + { + BT_MESH_SENSOR_OP_SETTING_GET, + BT_MESH_LEN_EXACT(BT_MESH_SENSOR_MSG_LEN_SETTING_GET), + handle_setting_get, + }, + { + BT_MESH_SENSOR_OP_SETTING_SET, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_SETTING_SET), + handle_setting_set, + }, + { + BT_MESH_SENSOR_OP_SETTING_SET_UNACKNOWLEDGED, + BT_MESH_LEN_MIN(BT_MESH_SENSOR_MSG_MINLEN_SETTING_SET), + handle_setting_set_unack, + }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/time_cli.c b/subsys/bluetooth/mesh/time_cli.c index 1e8a5d152837..c9e24f2e819c 100644 --- a/subsys/bluetooth/mesh/time_cli.c +++ b/subsys/bluetooth/mesh/time_cli.c @@ -8,14 +8,10 @@ #include "time_internal.h" #include "model_utils.h" -static void handle_status(struct bt_mesh_model *model, +static int handle_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - if (buf->len != BT_MESH_TIME_MSG_LEN_TIME_STATUS) { - return; - } - struct bt_mesh_time_cli *cli = model->user_data; struct bt_mesh_time_status status; struct bt_mesh_time_status *rsp; @@ -31,16 +27,13 @@ static void handle_status(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->time_status) { cli->handlers->time_status(cli, ctx, &status); } + + return 0; } -static void time_role_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_time_role_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_TIME_MSG_LEN_TIME_ROLE_STATUS) { - return; - } - struct bt_mesh_time_cli *cli = model->user_data; enum bt_mesh_time_role status; uint8_t *rsp; @@ -56,16 +49,13 @@ static void time_role_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->time_role_status) { cli->handlers->time_role_status(cli, ctx, status); } + + return 0; } -static void time_zone_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_time_zone_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_TIME_MSG_LEN_TIME_ZONE_STATUS) { - return; - } - struct bt_mesh_time_cli *cli = model->user_data; struct bt_mesh_time_zone_status status; struct bt_mesh_time_zone_status *rsp; @@ -85,16 +75,13 @@ static void time_zone_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->time_zone_status) { cli->handlers->time_zone_status(cli, ctx, &status); } + + return 0; } -static void tai_utc_delta_status_handle(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_tai_utc_delta_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { - if (buf->len != BT_MESH_TIME_MSG_LEN_TAI_UTC_DELTA_STATUS) { - return; - } - struct bt_mesh_time_cli *cli = model->user_data; struct bt_mesh_time_tai_utc_delta_status status; struct bt_mesh_time_tai_utc_delta_status *rsp; @@ -114,28 +101,30 @@ static void tai_utc_delta_status_handle(struct bt_mesh_model *model, if (cli->handlers && cli->handlers->tai_utc_delta_status) { cli->handlers->tai_utc_delta_status(cli, ctx, &status); } + + return 0; } const struct bt_mesh_model_op _bt_mesh_time_cli_op[] = { { BT_MESH_TIME_OP_TIME_STATUS, - BT_MESH_TIME_MSG_LEN_TIME_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_TIME_STATUS), handle_status, }, { BT_MESH_TIME_OP_TIME_ROLE_STATUS, - BT_MESH_TIME_MSG_LEN_TIME_ROLE_STATUS, - time_role_status_handle, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_TIME_ROLE_STATUS), + handle_time_role_status, }, { BT_MESH_TIME_OP_TIME_ZONE_STATUS, - BT_MESH_TIME_MSG_LEN_TIME_ZONE_STATUS, - time_zone_status_handle, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_TIME_ZONE_STATUS), + handle_time_zone_status, }, { BT_MESH_TIME_OP_TAI_UTC_DELTA_STATUS, - BT_MESH_TIME_MSG_LEN_TAI_UTC_DELTA_STATUS, - tai_utc_delta_status_handle, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_TAI_UTC_DELTA_STATUS), + handle_tai_utc_delta_status, }, BT_MESH_MODEL_OP_END, }; diff --git a/subsys/bluetooth/mesh/time_srv.c b/subsys/bluetooth/mesh/time_srv.c index 796c83ae9cee..286b381ba26f 100644 --- a/subsys/bluetooth/mesh/time_srv.c +++ b/subsys/bluetooth/mesh/time_srv.c @@ -187,15 +187,15 @@ static int send_time_status(struct bt_mesh_model *model, return model_send(model, ctx, &msg); } -static void handle_time_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_time_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_time_srv *srv = model->user_data; if ((srv->data.role != BT_MESH_TIME_CLIENT) && (srv->data.role != BT_MESH_TIME_RELAY)) { - return; + /* Not relevant for this role, ignore. */ + return 0; } struct bt_mesh_time_status status; @@ -205,7 +205,7 @@ static void handle_time_status(struct bt_mesh_model *model, if (status.is_authority <= srv->data.sync.status.is_authority && srv->data.sync.status.uncertainty < status.uncertainty) { /* The new time status is not an improvement, ignore. */ - return; + return 0; } srv->data.sync.uptime = k_uptime_get(); @@ -220,18 +220,20 @@ static void handle_time_status(struct bt_mesh_model *model, if (srv->data.role == BT_MESH_TIME_RELAY) { (void)bt_mesh_time_srv_time_status_send(srv, NULL); } + + return 0; } -static void handle_time_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_time_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { send_time_status(model, ctx, k_uptime_get()); + + return 0; } -static void handle_time_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_time_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_time_srv *srv = model->user_data; @@ -243,18 +245,20 @@ static void handle_time_set(struct bt_mesh_model *model, } send_time_status(model, ctx, srv->data.sync.uptime); + + return 0; } -static void handle_zone_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_zone_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { send_zone_status(model, ctx); + + return 0; } -static void handle_zone_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_zone_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_time_srv *srv = model->user_data; @@ -268,18 +272,20 @@ static void handle_zone_set(struct bt_mesh_model *model, } send_zone_status(model, ctx); + + return 0; } -static void handle_tai_utc_delta_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_tai_utc_delta_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { send_tai_utc_delta_status(model, ctx); + + return 0; } -static void handle_tai_utc_delta_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_tai_utc_delta_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_time_srv *srv = model->user_data; @@ -292,18 +298,20 @@ static void handle_tai_utc_delta_set(struct bt_mesh_model *model, } send_tai_utc_delta_status(model, ctx); + + return 0; } -static void handle_role_get(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_role_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { send_role_status(model, ctx); + + return 0; } -static void handle_role_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_role_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_time_srv *srv = model->user_data; enum bt_mesh_time_role role; @@ -311,34 +319,36 @@ static void handle_role_set(struct bt_mesh_model *model, role = net_buf_simple_pull_u8(buf); if (role != BT_MESH_TIME_NONE && role != BT_MESH_TIME_AUTHORITY && role != BT_MESH_TIME_RELAY && role != BT_MESH_TIME_CLIENT) { - return; + return -EINVAL; } srv->data.role = role; store_state(srv); send_role_status(model, ctx); + + return 0; } const struct bt_mesh_model_op _bt_mesh_time_srv_op[] = { { BT_MESH_TIME_OP_TIME_GET, - BT_MESH_TIME_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_GET), handle_time_get, }, { BT_MESH_TIME_OP_TIME_STATUS, - BT_MESH_TIME_MSG_LEN_TIME_STATUS, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_TIME_STATUS), handle_time_status, }, { BT_MESH_TIME_OP_TIME_ZONE_GET, - BT_MESH_TIME_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_GET), handle_zone_get, }, { BT_MESH_TIME_OP_TAI_UTC_DELTA_GET, - BT_MESH_TIME_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_GET), handle_tai_utc_delta_get, }, BT_MESH_MODEL_OP_END, @@ -347,27 +357,27 @@ const struct bt_mesh_model_op _bt_mesh_time_srv_op[] = { const struct bt_mesh_model_op _bt_mesh_time_setup_srv_op[] = { { BT_MESH_TIME_OP_TIME_SET, - BT_MESH_TIME_MSG_LEN_TIME_SET, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_TIME_SET), handle_time_set, }, { BT_MESH_TIME_OP_TIME_ZONE_SET, - BT_MESH_TIME_MSG_LEN_TIME_ZONE_SET, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_TIME_ZONE_SET), handle_zone_set, }, { BT_MESH_TIME_OP_TAI_UTC_DELTA_SET, - BT_MESH_TIME_MSG_LEN_TAI_UTC_DELTA_SET, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_TAI_UTC_DELTA_SET), handle_tai_utc_delta_set, }, { BT_MESH_TIME_OP_TIME_ROLE_GET, - BT_MESH_TIME_MSG_LEN_GET, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_GET), handle_role_get, }, { BT_MESH_TIME_OP_TIME_ROLE_SET, - BT_MESH_TIME_MSG_LEN_TIME_ROLE_SET, + BT_MESH_LEN_EXACT(BT_MESH_TIME_MSG_LEN_TIME_ROLE_SET), handle_role_set, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bluetooth/mesh/vnd/silvair_enocean_srv.c b/subsys/bluetooth/mesh/vnd/silvair_enocean_srv.c index 9bf58e757a20..bfe2ad2b353c 100644 --- a/subsys/bluetooth/mesh/vnd/silvair_enocean_srv.c +++ b/subsys/bluetooth/mesh/vnd/silvair_enocean_srv.c @@ -208,25 +208,30 @@ static void decommission_device(struct bt_mesh_silvair_enocean_srv *srv) #endif } -static void handle_get(struct bt_mesh_model *model, +static int handle_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { struct bt_mesh_silvair_enocean_srv *srv = model->user_data; + if (buf->len != 0) { + return -EMSGSIZE; + } + if (!bt_addr_le_cmp(&srv->addr, BT_ADDR_LE_NONE)) { status_pub(model, ctx, BT_MESH_SILVAIR_ENOCEAN_STATUS_NOT_SET, NULL); } else { status_pub(model, ctx, BT_MESH_SILVAIR_ENOCEAN_STATUS_SET, srv->addr.a.val); } + + return 0; } -static void handle_set(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { if (buf->len != BT_MESH_SILVAIR_ENOCEAN_PROXY_MSG_MAXLEN - 1) { - return; + return -EMSGSIZE; } struct bt_mesh_silvair_enocean_srv *srv = model->user_data; @@ -245,7 +250,7 @@ static void handle_set(struct bt_mesh_model *model, if (bt_addr_le_cmp(&srv->addr, &addr)) { status_pub(model, ctx, BT_MESH_SILVAIR_ENOCEAN_STATUS_UNSPECIFIED_ERROR, NULL); - return; + return -EINVAL; } } else { /* PTM 215B User Manual: By default, PTM 215B uses static source @@ -264,7 +269,7 @@ static void handle_set(struct bt_mesh_model *model, status_pub(model, ctx, BT_MESH_SILVAIR_ENOCEAN_STATUS_UNSPECIFIED_ERROR, NULL); bt_addr_le_copy(&srv->addr, BT_ADDR_LE_NONE); - return; + return err; } #if CONFIG_BT_ENOCEAN_STORE if (err != -EBUSY) { @@ -276,14 +281,19 @@ static void handle_set(struct bt_mesh_model *model, } status_pub(model, ctx, BT_MESH_SILVAIR_ENOCEAN_STATUS_SET, srv->addr.a.val); + + return 0; } -static void handle_delete(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_delete(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { struct bt_mesh_silvair_enocean_srv *srv = model->user_data; + if (buf->len != 0) { + return -EMSGSIZE; + } + if (bt_addr_le_cmp(&srv->addr, BT_ADDR_LE_NONE)) { decommission_device(srv); } @@ -293,11 +303,12 @@ static void handle_delete(struct bt_mesh_model *model, if (IS_ENABLED(CONFIG_BT_MESH_SILVAIR_ENOCEAN_AUTO_COMMISSION)) { bt_enocean_commissioning_enable(); } + + return 0; } -static void handle_message(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf) +static int handle_message(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf) { uint8_t sub_opcode; @@ -305,21 +316,20 @@ static void handle_message(struct bt_mesh_model *model, switch (sub_opcode) { case BT_MESH_SILVAIR_ENOCEAN_PROXY_SUB_OP_GET: - handle_get(model, ctx, buf); - break; + return handle_get(model, ctx, buf); case BT_MESH_SILVAIR_ENOCEAN_PROXY_SUB_OP_SET: - handle_set(model, ctx, buf); - break; + return handle_set(model, ctx, buf); case BT_MESH_SILVAIR_ENOCEAN_PROXY_SUB_OP_DELETE: - handle_delete(model, ctx, buf); - break; + return handle_delete(model, ctx, buf); } + + return -EOPNOTSUPP; } const struct bt_mesh_model_op _bt_mesh_silvair_enocean_srv_op[] = { { BT_MESH_SILVAIR_ENOCEAN_PROXY_OP, - BT_MESH_SILVAIR_ENOCEAN_PROXY_MSG_MINLEN, + BT_MESH_LEN_MIN(BT_MESH_SILVAIR_ENOCEAN_PROXY_MSG_MINLEN), handle_message, }, BT_MESH_MODEL_OP_END, diff --git a/subsys/bootloader/bl_storage/bl_storage.c b/subsys/bootloader/bl_storage/bl_storage.c index dfa0f42a4cc6..530fca716e15 100644 --- a/subsys/bootloader/bl_storage/bl_storage.c +++ b/subsys/bootloader/bl_storage/bl_storage.c @@ -112,6 +112,30 @@ int verify_public_keys(void) return 0; } +/** + * Helper procedure for public_key_data_read() + * + * Copies @p src into @p dst. Reads from @p src are done 32 bits at a + * time. Writes to @p dst are done a byte at a time. + * + * @param dst destination buffer + * @param src source buffer + * @param size number of *bytes* in src to copy into dst + */ +static void public_key_copy32(uint8_t *dst, const uint32_t *src, size_t size) +{ + while (size) { + uint32_t val = *src++; + + *dst++ = val & 0xFF; + *dst++ = (val >> 8U) & 0xFF; + *dst++ = (val >> 16U) & 0xFF; + *dst++ = (val >> 24U) & 0xFF; + + size -= 4; + } +} + int public_key_data_read(uint32_t key_idx, uint8_t *p_buf, size_t buf_size) { const uint8_t *p_key; @@ -138,7 +162,7 @@ int public_key_data_read(uint32_t key_idx, uint8_t *p_buf, size_t buf_size) BUILD_ASSERT(offsetof(struct bl_storage_data, key_data) % 4 == 0); __ASSERT(((uint32_t)p_key % 4 == 0), "Key address is not word aligned"); - memcpy(p_buf, p_key, CONFIG_SB_PUBLIC_KEY_HASH_LEN); + public_key_copy32(p_buf, (const uint32_t *)p_key, CONFIG_SB_PUBLIC_KEY_HASH_LEN); __DSB(); /* Because of nRF9160 Erratum 7 */ return CONFIG_SB_PUBLIC_KEY_HASH_LEN; diff --git a/subsys/caf/events/net_state_event.c b/subsys/caf/events/net_state_event.c index d049c3cf7fd5..c0386e427a46 100644 --- a/subsys/caf/events/net_state_event.c +++ b/subsys/caf/events/net_state_event.c @@ -46,6 +46,6 @@ EVENT_INFO_DEFINE(net_state_event, profile_net_state_event); EVENT_TYPE_DEFINE(net_state_event, - IS_ENABLED(CONFIG_CAF_INIT_LOG_NET_EVENTS), + IS_ENABLED(CONFIG_CAF_INIT_LOG_NET_STATE_EVENTS), log_net_state_event, &net_state_event_info); diff --git a/subsys/caf/modules/leds.c b/subsys/caf/modules/leds.c index bd2ca27e75af..52f8b3604108 100644 --- a/subsys/caf/modules/leds.c +++ b/subsys/caf/modules/leds.c @@ -20,7 +20,6 @@ LOG_MODULE_REGISTER(MODULE, CONFIG_CAF_LEDS_LOG_LEVEL); #define LED_ID(led) ((led) - &leds[0]) struct led { - const char *label; const struct device *dev; uint8_t color_count; @@ -34,15 +33,13 @@ struct led { #ifdef CONFIG_CAF_LEDS_PWM #define DT_DRV_COMPAT pwm_leds - #define DEFAULT_LABEL(id) STRINGIFY(_CONCAT(LED_PWM_, id)) #elif defined(CONFIG_CAF_LEDS_GPIO) #define DT_DRV_COMPAT gpio_leds - #define DEFAULT_LABEL(id) "leds" #else #error "LED driver must be specified in configuration" #endif -#define _LED_COLOR_ID(id) 0, +#define _LED_COLOR_ID(_unused) 0, #define _LED_COLOR_COUNT(id) \ static const uint8_t led_colors_##id[] = { \ @@ -53,7 +50,7 @@ DT_INST_FOREACH_STATUS_OKAY(_LED_COLOR_COUNT) #define _LED_INSTANCE_DEF(id) \ { \ - .label = DT_INST_PROP_OR(id, label, DEFAULT_LABEL(id)), \ + .dev = DEVICE_DT_GET(DT_DRV_INST(id)), \ .color_count = ARRAY_SIZE(led_colors_##id), \ }, @@ -177,44 +174,20 @@ static void led_update(struct led *led) } } -static void verify_labels(void) -{ - /* Zephyr boards by default define "gpio_leds" compatible DT node called "leds". CAF LEDs - * uses "leds" as a default name to get the related GPIO LED driver binding. In that case - * only one CAF led instance can use the default driver device name. Using the same driver - * device name by multiple instances would result in referring to improper driver device. - */ - if (IS_ENABLED(CONFIG_ASSERT) && IS_ENABLED(CONFIG_CAF_LEDS_GPIO)) { - size_t default_label_cnt = 0; - - for (size_t i = 0; i < ARRAY_SIZE(leds); i++) { - if (!strcmp(leds[i].label, DEFAULT_LABEL(0))) { - default_label_cnt++; - } - } - - __ASSERT_NO_MSG(default_label_cnt <= 1); - } -} - static int leds_init(void) { int err = 0; BUILD_ASSERT(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) > 0, "No LEDs defined"); - verify_labels(); - for (size_t i = 0; (i < ARRAY_SIZE(leds)) && !err; i++) { struct led *led = &leds[i]; __ASSERT_NO_MSG((led->color_count == 1) || (led->color_count == 3)); - led->dev = device_get_binding(led->label); - - if (!led->dev) { - LOG_ERR("Cannot bind %s", led->label); - err = -ENXIO; + if (!device_is_ready(led->dev)) { + LOG_ERR("Device %s is not ready", led->dev->name); + err = -ENODEV; } else { k_work_init_delayable(&led->work, work_handler); led_update(led); @@ -229,8 +202,7 @@ static void leds_start(void) for (size_t i = 0; i < ARRAY_SIZE(leds); i++) { #ifdef CONFIG_PM_DEVICE int err = pm_device_state_set(leds[i].dev, - PM_DEVICE_STATE_ACTIVE, - NULL, NULL); + PM_DEVICE_STATE_ACTIVE); if (err) { LOG_ERR("PWM enable failed"); } @@ -248,8 +220,7 @@ static void leds_stop(void) #ifdef CONFIG_PM_DEVICE int err = pm_device_state_set(leds[i].dev, - PM_DEVICE_STATE_SUSPEND, - NULL, NULL); + PM_DEVICE_STATE_SUSPEND); if (err) { LOG_ERR("PWM disable failed"); } diff --git a/subsys/caf/modules/power_manager.c b/subsys/caf/modules/power_manager.c index 26de9feee07a..f7290b274fb1 100644 --- a/subsys/caf/modules/power_manager.c +++ b/subsys/caf/modules/power_manager.c @@ -60,7 +60,7 @@ static void power_down_counter_reset(void) if ((power_state == POWER_STATE_IDLE) && check_if_power_state_allowed(POWER_MANAGER_LEVEL_SUSPENDED)) { k_work_reschedule(&power_down_trigger, POWER_DOWN_TIMEOUT); - LOG_INF("Power down timer restarted"); + LOG_DBG("Power down timer restarted"); } } diff --git a/subsys/mpsl/CMakeLists.txt b/subsys/mpsl/CMakeLists.txt index a4b5217415bb..50a30c523b3f 100644 --- a/subsys/mpsl/CMakeLists.txt +++ b/subsys/mpsl/CMakeLists.txt @@ -10,4 +10,6 @@ zephyr_library_sources( mpsl_init.c ) +zephyr_library_sources_ifdef(CONFIG_MPSL_CX mpsl_cx.c) +zephyr_library_sources_ifdef(CONFIG_MPSL_CX_THREAD cx/thread/mpsl_cx_thread.c) zephyr_library_sources_ifdef(CONFIG_MPSL_FEM mpsl_fem.c) diff --git a/subsys/mpsl/Kconfig b/subsys/mpsl/Kconfig index f23afc03033a..5b8f3945b97d 100644 --- a/subsys/mpsl/Kconfig +++ b/subsys/mpsl/Kconfig @@ -34,6 +34,7 @@ config MPSL_ASSERT_HANDLER MPSL code encounters an unrecoverable error. rsource "Kconfig.fem" +rsource "Kconfig.cx" module=MPSL module-str=MPSL diff --git a/subsys/mpsl/Kconfig.cx b/subsys/mpsl/Kconfig.cx new file mode 100644 index 000000000000..e0952adc82e0 --- /dev/null +++ b/subsys/mpsl/Kconfig.cx @@ -0,0 +1,65 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +config MPSL_CX + bool "Radio Coexistence interface support [EXPERIMENTAL]" +# Generic coexistence is not yet supported by Bluetooth + depends on !BT + help + Controls if Radio Coexistence interface is to be configured and enabled + when MPSL is initialized. + + Radio Coexistence interface connects nRF5 radio protocols with external + Packet Traffic Arbiter (PTA) which denies or grants access to RF. + +if MPSL_CX + +choice MPSL_CX_CHOICE + prompt "Radio Coexistence interface implementation" + +config MPSL_CX_THREAD + select NRFX_GPIOTE + select GPIO + bool "Thread Radio Coexistence" + help + Radio Coexistence interface implementation according to Thread Radio + Coexistence Practical recommendations for using a 3-wire PTA + implementation for co-located 2.4 GHz radios. + +endchoice # MPSL_CX_CHOICE + +if MPSL_CX_THREAD + +config MPSL_CX_THREAD_PIN_REQUEST + int "GPIO pin id used as coexistence Request signal" + default 13 + help + For port 0 simply use pin number. For port 1 add value 32 to pin number: + P0.04 is 4; P1.04 is 36. + + Note: This configuration will be moved to device tree. + +config MPSL_CX_THREAD_PIN_PRIORITY + int "GPIO pin id used as coexistence Priority signal" + default 14 + help + For port 0 simply use pin number. For port 1 add value 32 to pin number: + P0.04 is 4; P1.04 is 36. + + Note: This configuration will be moved to device tree. + +config MPSL_CX_THREAD_PIN_GRANT + int "GPIO pin id used as coexistence Grant signal" + default 12 + help + For port 0 simply use pin number. For port 1 add value 32 to pin number: + P0.04 is 4; P1.04 is 36. + + Note: This configuration will be moved to device tree. + +endif + +endif # MPSL_CX diff --git a/subsys/mpsl/cx/thread/mpsl_cx_thread.c b/subsys/mpsl/cx/thread/mpsl_cx_thread.c new file mode 100644 index 000000000000..6a7ba4c7f945 --- /dev/null +++ b/subsys/mpsl/cx/thread/mpsl_cx_thread.c @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/** + * @file + * This file implements generic Coexistence interface according to + * Thread Radio Coexistence whitepaper. + * + */ + +#include +#include + +#include +#include + +#include +#include + +#include "hal/nrf_gpio.h" + +/* Value from chapter 7. Logic Timing from Thread Radio Coexistence */ +#define REQUEST_TO_GRANT_US 50U + +static struct mpsl_cx_thread_interface_config config; +static mpsl_cx_cb_t callback; + +static const struct device *req_dev; +static const struct device *pri_dev; +static const struct device *gra_dev; +static gpio_port_value_t req_pin_mask; +static gpio_port_value_t pri_pin_mask; +static gpio_port_value_t gra_pin_mask; +static struct gpio_callback grant_cb; + +static int32_t grant_pin_is_asserted(bool *is_asserted) +{ + int ret; + gpio_port_value_t port_val; + + ret = gpio_port_get_raw(gra_dev, &port_val); + + if (ret != 0) { + return -NRF_EPERM; + } + + *is_asserted = (port_val & gra_pin_mask) ? true : false; + return 0; +} + +static mpsl_cx_op_map_t granted_ops_map(bool grant_is_asserted) +{ + mpsl_cx_op_map_t granted_ops = MPSL_CX_OP_IDLE_LISTEN | MPSL_CX_OP_RX; + + if (grant_is_asserted) { + granted_ops |= MPSL_CX_OP_TX; + } + + return granted_ops; +} + +static int32_t granted_ops_get(mpsl_cx_op_map_t *granted_ops) +{ + int ret; + bool grant_is_asserted; + + ret = grant_pin_is_asserted(&grant_is_asserted); + if (ret < 0) { + return ret; + } + + *granted_ops = granted_ops_map(grant_is_asserted); + return 0; +} + +static void gpiote_irq_handler(const struct device *gpiob, struct gpio_callback *cb, uint32_t pins) +{ + (void)gpiob; + (void)cb; + (void)pins; + + static mpsl_cx_op_map_t last_notified; + int32_t ret; + mpsl_cx_op_map_t granted_ops; + + if (callback != NULL) { + ret = granted_ops_get(&granted_ops); + + __ASSERT(ret == 0, "Getting grant pin state returned unexpected result: %d", ret); + if (ret != 0) { + /* nrfx gpio implementation cannot return failure for this call + * This condition is handled for fail-safe approach. It is assumed + * GRANT is not given, if cannot read its value + */ + granted_ops = granted_ops_map(false); + } + + if (granted_ops != last_notified) { + last_notified = granted_ops; + callback(granted_ops); + } + } +} + +static int32_t gpio_init(uint8_t pin_no, bool input, const struct device **port, + gpio_port_value_t *pin_mask) +{ + gpio_flags_t flags; + bool use_port_1 = (pin_no > P0_PIN_NUM); + + pin_no = use_port_1 ? pin_no - P0_PIN_NUM : pin_no; + *port = device_get_binding(use_port_1 ? "GPIO_1" : "GPIO_0"); + + if (*port == NULL) { + return -NRF_EINVAL; + } + + *pin_mask = 1U << pin_no; + + if (input) { + flags = GPIO_INPUT | GPIO_PULL_UP; + } else { + flags = GPIO_OUTPUT_LOW; + } + + gpio_pin_configure(*port, pin_no, flags); + + return 0; +} + +static int32_t gpiote_init(void) +{ + int32_t ret; + gpio_flags_t flags = GPIO_INT_ENABLE | GPIO_INT_EDGE | GPIO_INT_EDGE_BOTH; + + ret = gpio_init(config.granted_pin, true, &gra_dev, &gra_pin_mask); + if (ret < 0) { + return ret; + } + + ret = gpio_pin_interrupt_configure(gra_dev, config.granted_pin, flags); + if (ret < 0) { + return ret; + } + + gpio_init_callback(&grant_cb, gpiote_irq_handler, gra_pin_mask); + gpio_add_callback(gra_dev, &grant_cb); + + return 0; +} + +static int32_t request(const mpsl_cx_request_t *req_params) +{ + int ret; + + if (req_params == NULL) { + return -NRF_EINVAL; + } + + if (req_params->prio > (UINT8_MAX / 2)) { + ret = gpio_port_set_clr_bits_raw(pri_dev, pri_pin_mask, 0); + } else { + ret = gpio_port_set_clr_bits_raw(pri_dev, 0, pri_pin_mask); + } + + if (ret < 0) { + return -NRF_EPERM; + } + + if (req_params->ops & (MPSL_CX_OP_RX | MPSL_CX_OP_TX)) { + ret = gpio_port_set_clr_bits_raw(req_dev, req_pin_mask, 0); + } else { + ret = gpio_port_set_clr_bits_raw(req_dev, 0, req_pin_mask); + } + + if (ret < 0) { + return -NRF_EPERM; + } + + return 0; +} + +static int32_t release(void) +{ + int ret; + + ret = gpio_port_set_clr_bits_raw(req_dev, 0, req_pin_mask); + if (ret < 0) { + return -NRF_EPERM; + } + + ret = gpio_port_set_clr_bits_raw(pri_dev, 0, pri_pin_mask); + if (ret < 0) { + return -NRF_EPERM; + } + + return 0; +} + +static uint32_t req_grant_delay_get(void) +{ + return REQUEST_TO_GRANT_US; +} + +static int32_t register_callback(mpsl_cx_cb_t cb) +{ + callback = cb; + + return 0; +} + +static const mpsl_cx_interface_t m_mpsl_cx_methods = { + .p_request = request, + .p_release = release, + .p_granted_ops_get = granted_ops_get, + .p_req_grant_delay_get = req_grant_delay_get, + .p_register_callback = register_callback, +}; + +int32_t mpsl_cx_thread_interface_config_set( + struct mpsl_cx_thread_interface_config const * const new_config) +{ + int32_t ret_code; + + config = *new_config; + callback = NULL; + + ret_code = mpsl_cx_interface_set(&m_mpsl_cx_methods); + if (ret_code != 0) { + return ret_code; + } + + ret_code = gpio_init(config.request_pin, false, &req_dev, &req_pin_mask); + if (ret_code != 0) { + return ret_code; + } + + ret_code = gpio_init(config.priority_pin, false, &pri_dev, &pri_pin_mask); + if (ret_code != 0) { + return ret_code; + } + + ret_code = gpiote_init(); + if (ret_code != 0) { + return ret_code; + } + + return 0; +} diff --git a/subsys/mpsl/mpsl_cx.c b/subsys/mpsl/mpsl_cx.c new file mode 100644 index 000000000000..f3bd41b212c0 --- /dev/null +++ b/subsys/mpsl/mpsl_cx.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include "mpsl_cx_internal.h" + +#include +#include + +#if IS_ENABLED(CONFIG_MPSL_CX_THREAD) +static int cx_thread_configure(void) +{ + struct mpsl_cx_thread_interface_config cfg = { + .request_pin = CONFIG_MPSL_CX_THREAD_PIN_REQUEST, + .priority_pin = CONFIG_MPSL_CX_THREAD_PIN_PRIORITY, + .granted_pin = CONFIG_MPSL_CX_THREAD_PIN_GRANT, + }; + + return mpsl_cx_thread_interface_config_set(&cfg); +} +#endif + +int mpsl_cx_configure(void) +{ + int err = 0; + +#if IS_ENABLED(CONFIG_MPSL_CX_THREAD) + err = cx_thread_configure(); +#else +#error Incomplete CONFIG_MPSL_CX configuration. No supported coexistence protocol found. +#endif + + return err; +} diff --git a/subsys/mpsl/mpsl_cx_internal.h b/subsys/mpsl/mpsl_cx_internal.h new file mode 100644 index 000000000000..81fecc96f995 --- /dev/null +++ b/subsys/mpsl/mpsl_cx_internal.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/** + * @file + * @brief Internal MPSL Coexistence initialization + */ + +#ifndef MPSL_CX_INTERNAL__ +#define MPSL_CX_INTERNAL__ + +#ifdef __cplusplus +extern "C" { +#endif + +int mpsl_cx_configure(void); + +#ifdef __cplusplus +} +#endif + +#endif /* MPSL_CX_INTERNAL__ */ diff --git a/subsys/mpsl/mpsl_init.c b/subsys/mpsl/mpsl_init.c index 49dc3775dec0..57c157180dfc 100644 --- a/subsys/mpsl/mpsl_init.c +++ b/subsys/mpsl/mpsl_init.c @@ -12,6 +12,7 @@ #include #include #include +#include "mpsl_cx_internal.h" #include "mpsl_fem_config_common.h" #include "mpsl_fem_internal.h" #include "multithreading_lock.h" @@ -224,7 +225,19 @@ static int mpsl_fem_init(const struct device *dev) #endif } +static int mpsl_cx_init(const struct device *dev) +{ + ARG_UNUSED(dev); + +#if IS_ENABLED(CONFIG_MPSL_CX) + return mpsl_cx_configure(); +#else + return 0; +#endif +} + SYS_INIT(mpsl_lib_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); SYS_INIT(mpsl_signal_thread_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); SYS_INIT(mpsl_fem_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); +SYS_INIT(mpsl_cx_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); diff --git a/subsys/net/lib/ftp_client/src/ftp_client.c b/subsys/net/lib/ftp_client/src/ftp_client.c index 95ac1912f3d9..97f7c59260ed 100644 --- a/subsys/net/lib/ftp_client/src/ftp_client.c +++ b/subsys/net/lib/ftp_client/src/ftp_client.c @@ -5,6 +5,7 @@ */ #include #include +#include #include #include #include @@ -17,9 +18,6 @@ LOG_MODULE_REGISTER(ftp_client, CONFIG_FTP_CLIENT_LOG_LEVEL); #define INVALID_SOCKET -1 #define INVALID_SEC_TAG -1 -#define FTP_MAX_HOSTNAME 64 -#define FTP_MAX_USERNAME 32 -#define FTP_MAX_PASSWORD 32 #define FTP_MAX_BUFFER_SIZE 708 /* align with MSS on modem side */ #define FTP_DATA_TIMEOUT_SEC 60 /* time in seconds to wait for "Transfer complete" */ @@ -30,13 +28,17 @@ LOG_MODULE_REGISTER(ftp_client, CONFIG_FTP_CLIENT_LOG_LEVEL); static K_THREAD_STACK_DEFINE(ftp_stack_area, FTP_STACK_SIZE); static struct ftp_client { + int family; /* Socket address family */ + bool connected; /* Server connected flag */ int cmd_sock; int data_sock; - bool connected; /* Server connected flag */ - struct sockaddr_in remote; /* Server */ int sec_tag; ftp_client_callback_t ctrl_callback; ftp_client_callback_t data_callback; + union { + struct sockaddr_in remote; /* IPv4 server */ + struct sockaddr_in6 remote6; /* IPv6 server */ + }; } client; static struct k_work_q ftp_work_q; @@ -55,17 +57,19 @@ static struct data_task { uint16_t length; /* TX length */ } data_task_param; +static bool ftp_inactivity; + static int parse_return_code(const uint8_t *message, int success_code) { - char code_str[6]; /* max 1xxxx*/ + char success_code_str[6]; /* max 1xxxx*/ int ret = FTP_CODE_500; if (success_code == FTP_CODE_ANY) { return success_code; } - sprintf(code_str, "%d ", success_code); - if (strstr(message, code_str)) { + sprintf(success_code_str, "%d ", success_code); + if (strstr(message, success_code_str)) { ret = success_code; } @@ -75,46 +79,50 @@ static int parse_return_code(const uint8_t *message, int success_code) static int establish_data_channel(const char *pasv_msg) { int ret; - char tmp[16]; + char tmp[8]; char *tmp1, *tmp2; uint16_t data_port; /* Parse Server port from passive message - * e.g. "227 Entering Passive Mode (90,130,70,73,86,111)" + * e.g. "227 Entering Passive Mode (90,130,70,73,86,111)" in case of IPv4 + * e.g. "227 Entering Passive Mode (0,0,0,0,97,78)" in case of IPv6 + * NOTE assume no IP address change from the Control channel */ - tmp1 = strstr(pasv_msg, "("); - tmp1++; - tmp2 = strstr(tmp1, ","); - tmp2++; - tmp1 = strstr(tmp2, ","); - tmp1++; - tmp2 = strstr(tmp1, ","); - tmp2++; - tmp1 = strstr(tmp2, ","); - tmp1++; - tmp2 = strstr(tmp1, ","); - memset(tmp, 0x00, 16); - strncpy(tmp, (const char *)tmp1, (size_t)(tmp2 - tmp1)); - data_port = atoi(tmp) << 8; - tmp2++; - tmp1 = strstr(tmp2, ")"); - memset(tmp, 0x00, 16); - strncpy(tmp, (const char *)tmp2, (size_t)(tmp1 - tmp2)); - data_port += atoi(tmp); - - /* Establish the second connect for data */ + tmp1 = strrchr(pasv_msg, ')'); + if (tmp1 == NULL) { + return -EINVAL; + } + tmp2 = strrchr(pasv_msg, ','); + if (tmp2 == NULL) { + return -EINVAL; + } + memset(tmp, 0x00, sizeof(tmp)); + strncpy(tmp, (const char *)(tmp2 + 1), (size_t)(tmp1 - tmp2 - 1)); + data_port = atoi(tmp); + tmp1 = tmp2 - 1; + while (isdigit((int)(*tmp1))) { + tmp1--; + } + if (*tmp1 != ',') { + return -EINVAL; + } + memset(tmp, 0x00, sizeof(tmp)); + strncpy(tmp, (const char *)(tmp1 + 1), (size_t)(tmp2 - tmp1 - 1)); + data_port += atoi(tmp) << 8; + LOG_DBG("data port: %d", data_port); + + /* open data socket */ if (client.sec_tag <= 0) { - client.data_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + client.data_sock = socket(client.family, SOCK_STREAM, IPPROTO_TCP); } else { - client.data_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TLS_1_2); + client.data_sock = socket(client.family, SOCK_STREAM, IPPROTO_TLS_1_2); } if (client.data_sock < 0) { LOG_ERR("socket(data) failed: %d", -errno); - ret = -errno; + return -errno; } - - if (client.sec_tag > 0) { - sec_tag_t sec_tag_list[1] = { client.sec_tag }; + if (client.sec_tag != INVALID_SEC_TAG) { + sec_tag_t sec_tag_list[] = { client.sec_tag }; ret = setsockopt(client.data_sock, SOL_TLS, TLS_SEC_TAG_LIST, sec_tag_list, sizeof(sec_tag_t)); @@ -125,16 +133,24 @@ static int establish_data_channel(const char *pasv_msg) } } - client.remote.sin_port = htons(data_port); - ret = connect(client.data_sock, (struct sockaddr *)&client.remote, - sizeof(struct sockaddr_in)); + + /* Connect to remote host */ + if (client.family == AF_INET) { + client.remote.sin_port = htons(data_port); + ret = connect(client.data_sock, (struct sockaddr *)&client.remote, + sizeof(struct sockaddr_in)); + } else { + client.remote6.sin6_port = htons(data_port); + ret = connect(client.data_sock, (struct sockaddr *)&client.remote6, + sizeof(struct sockaddr_in6)); + } if (ret < 0) { LOG_ERR("connect(data) failed: %d", -errno); close(client.data_sock); return -errno; } - return ret; + return 0; } static void close_connection(int code, int error) @@ -166,11 +182,13 @@ static void close_connection(int code, int error) if (client.data_sock != INVALID_SOCKET) { close(client.data_sock); } - close(client.cmd_sock); - client.cmd_sock = INVALID_SOCKET; - client.data_sock = INVALID_SOCKET; - client.connected = false; - client.sec_tag = INVALID_SEC_TAG; + if (client.cmd_sock != INVALID_SOCKET) { + close(client.cmd_sock); + client.cmd_sock = INVALID_SOCKET; + client.data_sock = INVALID_SOCKET; + client.connected = false; + client.sec_tag = INVALID_SEC_TAG; + } } /**@brief Send FTP message via socket @@ -180,8 +198,7 @@ static int do_ftp_send_ctrl(const uint8_t *message, int length) int ret = 0; uint32_t offset = 0; - LOG_HEXDUMP_DBG(message, length, "TXC"); - + LOG_DBG("%s", log_strdup(message)); while (offset < length) { ret = send(client.cmd_sock, message + offset, length - offset, 0); if (ret < 0) { @@ -198,6 +215,7 @@ static int do_ftp_send_ctrl(const uint8_t *message, int length) } else { LOG_DBG("CMD sent"); } + ftp_inactivity = false; return ret; } @@ -210,12 +228,10 @@ static int do_ftp_send_data(const char *pasv_msg, uint8_t *message, uint16_t len /* Establish data channel */ ret = establish_data_channel(pasv_msg); - if (ret < 0) { + if (ret) { return ret; } - LOG_HEXDUMP_DBG(message, length, "TXD"); - while (offset < length) { ret = send(client.data_sock, message + offset, length - offset, 0); if (ret < 0) { @@ -223,12 +239,13 @@ static int do_ftp_send_data(const char *pasv_msg, uint8_t *message, uint16_t len ret = -errno; break; } + LOG_DBG("DATA sent %d", ret); offset += ret; ret = 0; } - LOG_DBG("DATA sent"); close(client.data_sock); + ftp_inactivity = false; return ret; } @@ -274,13 +291,12 @@ static int do_ftp_recv_ctrl(bool post_result, int success_code) } ctrl_buf[ret] = 0x00; - LOG_HEXDUMP_DBG(ctrl_buf, ret, "RXC"); - if (post_result) { client.ctrl_callback(ctrl_buf, ret); } - LOG_DBG("CTRL received"); + LOG_DBG("%s", log_strdup(ctrl_buf)); + ftp_inactivity = false; return parse_return_code(ctrl_buf, success_code); } @@ -294,7 +310,7 @@ static void do_ftp_recv_data(const char *pasv_msg) /* Establish data channel */ ret = establish_data_channel(pasv_msg); - if (ret < 0) { + if (ret) { return; } @@ -308,7 +324,7 @@ static void do_ftp_recv_data(const char *pasv_msg) break; } if ((fds[0].revents & POLLIN) != POLLIN) { - LOG_INF("No more data"); + LOG_DBG("No more data"); break; } ret = recv(client.data_sock, data_buf, sizeof(data_buf), 0); @@ -320,13 +336,12 @@ static void do_ftp_recv_data(const char *pasv_msg) /* Server close connection */ break; } - - LOG_HEXDUMP_DBG(data_buf, ret, "RXD"); client.data_callback(data_buf, ret); + LOG_DBG("DATA received %d", ret); } while (true); close(client.data_sock); - LOG_DBG("DATA received"); + ftp_inactivity = false; } static int poll_data_task_done(void) @@ -371,9 +386,13 @@ static void keepalive_handler(struct k_work *work) { int ret; - ret = do_ftp_send_ctrl(CMD_NOOP, sizeof(CMD_NOOP) - 1); - if (ret == 0) { - (void)do_ftp_recv_ctrl(false, FTP_CODE_200); + if (ftp_inactivity) { + ret = do_ftp_send_ctrl(CMD_NOOP, sizeof(CMD_NOOP) - 1); + if (ret == 0) { + (void)do_ftp_recv_ctrl(false, FTP_CODE_200); + } + } else { + ftp_inactivity = true; } } @@ -390,31 +409,58 @@ static void keepalive_timeout(struct k_timer *dummy) } } -int ftp_open(const char *hostname, uint16_t port, int sec_tag) +static int host_lookup(const char *hostname, int family, struct sockaddr *sa) { - int ret; - struct addrinfo *result; + int err; + struct addrinfo *ai; struct addrinfo hints = { - .ai_family = AF_INET + .ai_family = family, + .ai_socktype = SOCK_STREAM }; + err = getaddrinfo(hostname, NULL, &hints, &ai); + if (err) { + LOG_DBG("getaddrinfo(%d) error: %d", family, err); + return -EHOSTUNREACH; + } + + *sa = *(ai->ai_addr); + client.family = family; + freeaddrinfo(ai); + return 0; +} + +int ftp_open(const char *hostname, uint16_t port, int sec_tag) +{ + int ret; + if (client.connected) { LOG_ERR("FTP already connected"); return -EINVAL; } + + /* Attempt IPv6 resolution, fallback to IPv4 if failed */ + ret = host_lookup(hostname, AF_INET6, (struct sockaddr *)(&client.remote6)); + if (ret) { + ret = host_lookup(hostname, AF_INET, (struct sockaddr *)(&client.remote)); + if (ret) { + LOG_ERR("Failed to parse remote host"); + return -EHOSTUNREACH; + } + } + /* open control socket */ - if (sec_tag <= 0) { - client.cmd_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (sec_tag == INVALID_SEC_TAG) { + client.cmd_sock = socket(client.family, SOCK_STREAM, IPPROTO_TCP); } else { - client.cmd_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TLS_1_2); + client.cmd_sock = socket(client.family, SOCK_STREAM, IPPROTO_TLS_1_2); } if (client.cmd_sock < 0) { LOG_ERR("socket(ctrl) failed: %d", -errno); ret = -errno; } - - if (sec_tag > 0) { - sec_tag_t sec_tag_list[1] = { sec_tag }; + if (sec_tag != INVALID_SEC_TAG) { + sec_tag_t sec_tag_list[] = { sec_tag }; ret = setsockopt(client.cmd_sock, SOL_TLS, TLS_SEC_TAG_LIST, sec_tag_list, sizeof(sec_tag_t)); @@ -427,27 +473,21 @@ int ftp_open(const char *hostname, uint16_t port, int sec_tag) } /* Connect to remote host */ - ret = getaddrinfo(hostname, NULL, &hints, &result); - if (ret || result == NULL) { - LOG_ERR("ERROR: getaddrinfo(ctrl) failed %d", ret); - close(client.cmd_sock); - return ret; + if (client.family == AF_INET) { + client.remote.sin_port = htons(port); + ret = connect(client.cmd_sock, (struct sockaddr *)&client.remote, + sizeof(struct sockaddr_in)); + } else { + client.remote6.sin6_port = htons(port); + ret = connect(client.cmd_sock, (struct sockaddr *)&client.remote6, + sizeof(struct sockaddr_in6)); } - client.remote.sin_family = AF_INET; - client.remote.sin_port = htons(port); - client.remote.sin_addr.s_addr = - ((struct sockaddr_in *)result->ai_addr)->sin_addr.s_addr; - ret = connect(client.cmd_sock, (struct sockaddr *)&client.remote, - sizeof(struct sockaddr_in)); if (ret < 0) { LOG_ERR("connect(ctrl) failed: %d", -errno); close(client.cmd_sock); - freeaddrinfo(result); return -errno; } - freeaddrinfo(result); - /* Receive server greeting */ ret = do_ftp_recv_ctrl(true, FTP_CODE_220); if (ret != FTP_CODE_220) { @@ -509,11 +549,14 @@ int ftp_close(void) if (client.connected) { ret = do_ftp_send_ctrl(CMD_QUIT, sizeof(CMD_QUIT) - 1); if (ret == 0) { - ret = do_ftp_recv_ctrl(true, FTP_CODE_221); + /* Some FTP servers do not reply QUIT */ + (void)do_ftp_recv_ctrl(true, FTP_CODE_221); + } else { + return ret; } } close_connection(FTP_CODE_200, 0); - return ret; + return FTP_CODE_221; } int ftp_status(void) diff --git a/subsys/net/lib/nrf_cloud/Kconfig b/subsys/net/lib/nrf_cloud/Kconfig index 7e0d3c7a6357..d2d457e5ba93 100644 --- a/subsys/net/lib/nrf_cloud/Kconfig +++ b/subsys/net/lib/nrf_cloud/Kconfig @@ -200,7 +200,6 @@ menu "nRF Cloud A-GPS" config NRF_CLOUD_AGPS bool "Enable nRF Cloud Assisted GPS" - depends on NRF9160_GPS depends on MODEM_INFO depends on MODEM_INFO_ADD_NETWORK @@ -230,7 +229,6 @@ menu "nRF Cloud P-GPS" config NRF_CLOUD_PGPS bool "Enable nRF Cloud Predicted GPS" - depends on NRF9160_GPS depends on MODEM_INFO depends on MODEM_INFO_ADD_NETWORK select STREAM_FLASH_ERASE @@ -293,6 +291,13 @@ endif config NRF_CLOUD_CONNECTION_POLL_THREAD bool "Poll cloud connection in a separate thread" +config NRF_CLOUD_MQTT_KEEPALIVE + int "Maximum number of keep alive time for MQTT (in seconds)" + default MQTT_KEEPALIVE + help + Keep alive time for MQTT (in seconds) connection to nRF Cloud, + allow overwriting CONFIG_MQTT_KEEPALIVE value. + module=NRF_CLOUD module-dep=LOG module-str=Log level for nRF Cloud diff --git a/subsys/net/lib/nrf_cloud/src/nrf_cloud_agps.c b/subsys/net/lib/nrf_cloud/src/nrf_cloud_agps.c index 4fb69e2f436b..63af12c02bf3 100644 --- a/subsys/net/lib/nrf_cloud/src/nrf_cloud_agps.c +++ b/subsys/net/lib/nrf_cloud/src/nrf_cloud_agps.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -339,22 +340,22 @@ static int send_to_modem(void *data, size_t data_len, agps_print(type, data); } - /* At this point, GPS driver or app-provided socket is assumed. */ if (gps_dev) { - return gps_agps_write(gps_dev, type_socket2gps(type), data, - data_len); - } - - err = nrf_sendto(fd, data, data_len, 0, &type, sizeof(type)); - if (err < 0) { - LOG_ERR("Failed to send AGPS data to modem, errno: %d", errno); - err = -errno; + /* GPS driver */ + err = gps_agps_write(gps_dev, type_socket2gps(type), data, data_len); + } else if (fd != -1) { + /* GNSS socket */ + err = nrf_sendto(fd, data, data_len, 0, &type, sizeof(type)); + if (err < 0) { + err = -errno; + } else { + err = 0; + } } else { - err = 0; + /* GNSS API */ + err = nrf_modem_gnss_agps_write(data, data_len, type); } - LOG_DBG("A-GSP data sent to modem"); - return err; } @@ -704,13 +705,12 @@ int nrf_cloud_agps_process(const char *buf, size_t buf_len, const int *socket) gps_dev = NULL; fd = *socket; - } else if (gps_dev == NULL) { + } else { gps_dev = device_get_binding("NRF9160_GPS"); - if (gps_dev == NULL) { - LOG_ERR("GPS is not enabled, A-GPS response unhandled"); - LOG_DBG("A-GPS_inject_active UNLOCKED"); - k_sem_give(&agps_injection_active); - return -ENODEV; + if (gps_dev != NULL) { + LOG_DBG("Using GPS driver to input assistance data"); + } else { + LOG_DBG("Using GNSS API to input assistance data"); } } @@ -725,7 +725,7 @@ int nrf_cloud_agps_process(const char *buf, size_t buf_len, const int *socket) parsed_len += element_size; - LOG_DBG("Parsed_len: %d\n", parsed_len); + LOG_DBG("Parsed_len: %d", parsed_len); if (element.type == NRF_CLOUD_AGPS_GPS_TOWS) { memcpy(&sys_time.sv_tow[element.tow->sv_id - 1], diff --git a/subsys/net/lib/nrf_cloud/src/nrf_cloud_codec.c b/subsys/net/lib/nrf_cloud/src/nrf_cloud_codec.c index 9d989e723f8f..cee7c0c8b1b6 100644 --- a/subsys/net/lib/nrf_cloud/src/nrf_cloud_codec.c +++ b/subsys/net/lib/nrf_cloud/src/nrf_cloud_codec.c @@ -391,7 +391,7 @@ int nrf_cloud_encode_state(uint32_t reported_state, struct nrf_cloud_data *outpu /* Report keepalive value. */ if (cJSON_AddNumberToObjectCS(connection_obj, JSON_KEY_KEEPALIVE, - CONFIG_MQTT_KEEPALIVE) == NULL) { + CONFIG_NRF_CLOUD_MQTT_KEEPALIVE) == NULL) { ret = -ENOMEM; } diff --git a/subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps.c b/subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps.c index e024e9b7594a..4edbf76e0624 100644 --- a/subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps.c +++ b/subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps.c @@ -244,9 +244,11 @@ static int validate_prediction(const struct nrf_cloud_pgps_prediction *p, err = -EINVAL; } } +#if IS_ENABLED(CONFIG_NRF_CLOUD_LOG_LEVEL_DBG) if (!err) { print_time_details("prediction:", pred_sec, p->time.date_day, p->time.time_full_s); } +#endif return err; } @@ -283,7 +285,7 @@ static int validate_stored_predictions(uint16_t *first_bad_day, pred->time.time_full_s); } else if (index.predictions[pnum] == NULL) { index.predictions[pnum] = pred; - LOG_INF("Prediction num:%u stored at idx:%d", pnum, i); + LOG_DBG("Prediction num:%u stored at idx:%d", pnum, i); } else { LOG_WRN("Prediction num:%u stored more than once!", pnum); } @@ -319,7 +321,7 @@ static int validate_stored_predictions(uint16_t *first_bad_day, } i = npgps_pointer_to_block((uint8_t *)pred); - LOG_INF("Prediction num:%u, loc:%p, blk:%d", pnum, pred, i); + LOG_DBG("Prediction num:%u, loc:%p, blk:%d", pnum, pred, i); __ASSERT(i != -1, "unexpected pointer value %p", pred); npgps_mark_block_used(i, true); } diff --git a/subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps_utils.c b/subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps_utils.c index d7545025fc11..cc8f698bbff3 100644 --- a/subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps_utils.c +++ b/subsys/net/lib/nrf_cloud/src/nrf_cloud_pgps_utils.c @@ -351,7 +351,7 @@ void npgps_print_blocks(void) map[i] = pool.block_used[i] ? '1' : '0'; } map[i] = '\0'; - LOG_INF("map:%s", map); + LOG_INF("map:%s", log_strdup(map)); } diff --git a/subsys/net/lib/nrf_cloud/src/nrf_cloud_transport.c b/subsys/net/lib/nrf_cloud/src/nrf_cloud_transport.c index 0ab411437996..6794455efe7b 100644 --- a/subsys/net/lib/nrf_cloud/src/nrf_cloud_transport.c +++ b/subsys/net/lib/nrf_cloud/src/nrf_cloud_transport.c @@ -677,6 +677,7 @@ int nct_mqtt_connect(void) nct.client.protocol_version = MQTT_VERSION_3_1_1; nct.client.password = NULL; nct.client.user_name = NULL; + nct.client.keepalive = CONFIG_NRF_CLOUD_MQTT_KEEPALIVE; nct.client.clean_session = persistent_session ? 0U : 1U; LOG_DBG("MQTT clean session flag: %u", nct.client.clean_session); diff --git a/subsys/net/openthread/Kconfig b/subsys/net/openthread/Kconfig index 8d51e579ced1..b936ddab193e 100644 --- a/subsys/net/openthread/Kconfig +++ b/subsys/net/openthread/Kconfig @@ -63,9 +63,6 @@ config OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE default 796 if SOC_NRF5340_CPUAPP default 736 -config OPENTHREAD_CUSTOM_PARAMETERS - default "OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT=0 OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS=0" if NRF_802154_ENCRYPTION - endmenu endif diff --git a/subsys/nfc/ndef/uri_msg.c b/subsys/nfc/ndef/uri_msg.c index d32c85163f57..4c3ad2cf7c93 100644 --- a/subsys/nfc/ndef/uri_msg.c +++ b/subsys/nfc/ndef/uri_msg.c @@ -9,7 +9,7 @@ int nfc_ndef_uri_msg_encode(enum nfc_ndef_uri_rec_id uri_id_code, uint8_t const *const uri_data, - uint8_t uri_data_len, + uint16_t uri_data_len, uint8_t *buf, uint32_t *len) { diff --git a/subsys/nfc/t4t/CMakeLists.txt b/subsys/nfc/t4t/CMakeLists.txt index ae7a863ab2cc..7c6762faa8e0 100644 --- a/subsys/nfc/t4t/CMakeLists.txt +++ b/subsys/nfc/t4t/CMakeLists.txt @@ -10,4 +10,4 @@ zephyr_sources_ifdef(CONFIG_NFC_T4T_APDU apdu.c) zephyr_sources_ifdef(CONFIG_NFC_T4T_CC_FILE cc_file.c tlv_block.c) -zephyr_sources_ifdef(CONFIG_NFC_T4T_HL_PROCEDURE hl_procedure) +zephyr_sources_ifdef(CONFIG_NFC_T4T_HL_PROCEDURE hl_procedure.c) diff --git a/subsys/partition_manager/CMakeLists.txt b/subsys/partition_manager/CMakeLists.txt index c9a691c03a00..ce9879f76393 100644 --- a/subsys/partition_manager/CMakeLists.txt +++ b/subsys/partition_manager/CMakeLists.txt @@ -32,11 +32,11 @@ function(preprocess_pm_yml in_file out_file) if (DEFINED IMAGE_NAME) # Share location of original source file so that the parent image can add it # to the CMAKE_CONFIGURE_DEPENDS list. - share("list(APPEND ${IMAGE_NAME}PM_YML_DEP_FILES ${in_file})") + set_shared(IMAGE ${IMAGE_NAME} APPEND PROPERTY PM_YML_DEP_FILES ${in_file}) # Share location of preprocessed pm.yml file so that the parent image can # use it as source for partition manager configuration. - share("list(APPEND ${IMAGE_NAME}PM_YML_FILES ${out_file})") + set_shared(IMAGE ${IMAGE_NAME} APPEND PROPERTY PM_YML_FILES ${out_file}) endif() # Re-configure (Re-execute all CMakeLists.txt code) when original diff --git a/subsys/spm/CMakeLists.txt b/subsys/spm/CMakeLists.txt index eb71b00cfc60..48dca747e954 100644 --- a/subsys/spm/CMakeLists.txt +++ b/subsys/spm/CMakeLists.txt @@ -10,7 +10,7 @@ zephyr_sources_ifdef(CONFIG_SPM_SHARE_CONSOLE_UART spm_uart.c) zephyr_linker_sources(SECTIONS secure_services.ld) if(CONFIG_ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS) - share( - "list(APPEND ${IMAGE_NAME}BUILD_BYPRODUCTS - ${CMAKE_BINARY_DIR}/${CONFIG_ARM_ENTRY_VENEERS_LIB_NAME})") + set_shared(IMAGE ${IMAGE_NAME} APPEND PROPERTY BUILD_BYPRODUCTS + ${CMAKE_BINARY_DIR}/${CONFIG_ARM_ENTRY_VENEERS_LIB_NAME} + ) endif() diff --git a/subsys/zigbee/osif/zb_nrf_pwr_mgmt.c b/subsys/zigbee/osif/zb_nrf_pwr_mgmt.c index bf3e99191a05..78d5d3052d58 100644 --- a/subsys/zigbee/osif/zb_nrf_pwr_mgmt.c +++ b/subsys/zigbee/osif/zb_nrf_pwr_mgmt.c @@ -68,10 +68,11 @@ __weak zb_uint32_t zb_osif_sleep(zb_uint32_t sleep_tmo) time_slept_us = zigbee_event_poll(sleep_tmo * USEC_PER_MSEC); /* Calculate sleep duration in milliseconds. Round up the result - * to avoid possible errors in the event of - * another time unit conversion. + * using the basic time unit of ZBOSS API to avoid possible errors + * in the time unit conversion. */ - time_slept_ms = ceiling_fraction(time_slept_us, USEC_PER_MSEC); + time_slept_ms = ZB_TIME_BEACON_INTERVAL_TO_MSEC( + ceiling_fraction(time_slept_us, ZB_BEACON_INTERVAL_USEC)); /* Unlock timer value updates. */ ZVUNUSED(atomic_set((atomic_t *)&is_sleeping, 0)); diff --git a/subsys/zigbee/osif/zb_nrf_transceiver.c b/subsys/zigbee/osif/zb_nrf_transceiver.c index 9f1833b82f90..f7a97ac69d1a 100644 --- a/subsys/zigbee/osif/zb_nrf_transceiver.c +++ b/subsys/zigbee/osif/zb_nrf_transceiver.c @@ -275,6 +275,7 @@ zb_bool_t zb_trans_is_active(void) zb_bool_t zb_trans_transmit(zb_uint8_t wait_type, zb_time_t tx_at, zb_uint8_t *tx_buf, zb_uint8_t current_channel) { + struct net_pkt *pkt = NULL; struct net_buf frag = { .frags = NULL, .b = { @@ -293,6 +294,12 @@ zb_bool_t zb_trans_transmit(zb_uint8_t wait_type, zb_time_t tx_at, ARG_UNUSED(current_channel); #endif + pkt = net_pkt_alloc(K_NO_WAIT); + if (!pkt) { + ZB_ASSERT(0); + return ZB_FALSE; + } + ack_frame = NULL; switch (wait_type) { @@ -306,22 +313,15 @@ zb_bool_t zb_trans_transmit(zb_uint8_t wait_type, zb_time_t tx_at, mode = IEEE802154_TX_MODE_CCA; } - err = radio_api->tx(radio_dev, mode, NULL, &frag); + err = radio_api->tx(radio_dev, mode, pkt, &frag); break; } #ifdef ZB_ENABLE_ZGP_DIRECT case ZB_MAC_TX_WAIT_ZGP: { - struct net_pkt *pkt = NULL; - if (!(radio_api->get_capabilities(radio_dev) & IEEE802154_HW_TXTIME)) { - return ZB_FALSE; - } - - pkt = net_pkt_alloc(K_NO_WAIT); - if (!pkt) { - ZB_ASSERT(0); + net_pkt_unref(pkt); return ZB_FALSE; } @@ -331,7 +331,6 @@ zb_bool_t zb_trans_transmit(zb_uint8_t wait_type, zb_time_t tx_at, IEEE802154_TX_MODE_TXTIME, pkt, &frag); - net_pkt_unref(pkt); break; } #endif @@ -340,15 +339,17 @@ zb_bool_t zb_trans_transmit(zb_uint8_t wait_type, zb_time_t tx_at, state_cache.radio_state = RADIO_802154_STATE_TRANSMIT; err = radio_api->tx(radio_dev, IEEE802154_TX_MODE_DIRECT, - NULL, + pkt, &frag); break; default: LOG_DBG("Illegal wait_type parameter: %d", wait_type); ZB_ASSERT(0); + net_pkt_unref(pkt); return ZB_FALSE; } + net_pkt_unref(pkt); state_cache.radio_state = RADIO_802154_STATE_RECEIVE; switch (err) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eec7dc32652d..aa1cc62b62d6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,16 +13,20 @@ if (CONFIG_ZTEST AND "${ZEPHYR_NRF_MODULE_DIR}/subsys/bootloader/image/secure_boot.conf" ) - # Add a child image in the network core. - # Since we have enabled MCUBoot in the app core, the B0N bootloader is - # automatically added. This can not be done from the test CMakeLists.txt - # since it will not be considered when running partition_manager.cmake. - add_child_image( - NAME hello_world - SOURCE_DIR ${ZEPHYR_BASE}/samples/hello_world - DOMAIN CPUNET - BOARD ${CONFIG_DOMAIN_CPUNET_BOARD}) + if(NOT DEFINED CPUNET_PM_DOMAIN_DYNAMIC_PARTITION + OR "${CPUNET_PM_DOMAIN_DYNAMIC_PARTITION}" STREQUAL hello_world + ) + # Add a child image in the network core if there is not an image already. + # Since we have enabled MCUBoot in the app core, the B0N bootloader is + # automatically added. This can not be done from the test CMakeLists.txt + # since it will not be considered when running partition_manager.cmake. + add_child_image( + NAME hello_world + SOURCE_DIR ${ZEPHYR_BASE}/samples/hello_world + DOMAIN CPUNET + BOARD ${CONFIG_DOMAIN_CPUNET_BOARD}) + endif() endif() diff --git a/tests/bluetooth/tester/src/bttester.h b/tests/bluetooth/tester/src/bttester.h index aef564dec5a4..e8cb63e7d4b4 100644 --- a/tests/bluetooth/tester/src/bttester.h +++ b/tests/bluetooth/tester/src/bttester.h @@ -621,7 +621,7 @@ struct mesh_scheduler_action_set { uint8_t ack; uint8_t index; uint8_t year; - uint8_t month; + uint16_t month; uint8_t day; uint8_t hour; uint8_t minute; diff --git a/tests/bluetooth/tester/src/mmdl.c b/tests/bluetooth/tester/src/mmdl.c index 10e9e929d985..9962ef1ee467 100644 --- a/tests/bluetooth/tester/src/mmdl.c +++ b/tests/bluetooth/tester/src/mmdl.c @@ -5159,7 +5159,7 @@ static void scheduler_action_set(uint8_t *data, uint16_t len) if (cmd->ack) { net_buf_simple_init(buf, 0); net_buf_simple_add_u8(buf, status.year); - net_buf_simple_add_u8(buf, status.month); + net_buf_simple_add_le16(buf, status.month); net_buf_simple_add_u8(buf, status.day); net_buf_simple_add_u8(buf, status.hour); net_buf_simple_add_u8(buf, status.minute); diff --git a/tests/bluetooth/tester/src/model_handler.c b/tests/bluetooth/tester/src/model_handler.c index dea540743c5f..41f1ab897ecb 100644 --- a/tests/bluetooth/tester/src/model_handler.c +++ b/tests/bluetooth/tester/src/model_handler.c @@ -695,6 +695,22 @@ struct light_hsl_ctx { struct bt_mesh_light_hsl_srv srv; struct light_hue_ctx light_hue_ctx; struct light_sat_ctx light_sat_ctx; + struct lightness_ctx *lightness_ctx; +}; + +struct light_xy_ctx { + struct bt_mesh_light_xyl_srv srv; + struct k_work_delayable work; + uint32_t remaining; + uint32_t period; + struct bt_mesh_light_xy current; + struct bt_mesh_light_xy target; + struct lightness_ctx *lightness_ctx; +}; + +struct light_xyl_hsl_ctx { + struct light_xy_ctx xyl_ctx; + struct light_hsl_ctx hsl_ctx; struct lightness_ctx lightness_ctx; }; @@ -703,8 +719,8 @@ static void light_hsl_status(struct light_hsl_ctx *ctx, { rsp->params.hue = ctx->light_hue_ctx.current; rsp->params.saturation = ctx->light_sat_ctx.current; - rsp->params.lightness = ctx->lightness_ctx.current; - rsp->remaining_time = MAX(MAX(ctx->lightness_ctx.remaining, + rsp->params.lightness = ctx->lightness_ctx->current; + rsp->remaining_time = MAX(MAX(ctx->lightness_ctx->remaining, ctx->light_hue_ctx.remaining), ctx->light_sat_ctx.remaining); } @@ -733,7 +749,7 @@ static void periodic_light_hue_work(struct k_work *work) struct light_hsl_ctx *hsl_ctx = CONTAINER_OF(ctx, struct light_hsl_ctx, light_hue_ctx); struct light_sat_ctx *sat_ctx = &hsl_ctx->light_sat_ctx; - struct lightness_ctx *lightness_ctx = &hsl_ctx->lightness_ctx; + struct lightness_ctx *lightness_ctx = hsl_ctx->lightness_ctx; ctx->remaining -= ctx->period; @@ -832,7 +848,7 @@ static void periodic_light_sat_work(struct k_work *work) struct light_hsl_ctx *hsl_ctx = CONTAINER_OF(ctx, struct light_hsl_ctx, light_sat_ctx); struct light_hue_ctx *hue_ctx = &hsl_ctx->light_hue_ctx; - struct lightness_ctx *lightness_ctx = &hsl_ctx->lightness_ctx; + struct lightness_ctx *lightness_ctx = hsl_ctx->lightness_ctx; ctx->remaining -= ctx->period; @@ -907,111 +923,6 @@ static const struct bt_mesh_light_sat_srv_handlers sat_cb = { .get = light_sat_get, }; -static void periodic_light_hsl_lightness_work(struct k_work *work) -{ - struct lightness_ctx *ctx = - CONTAINER_OF(work, struct lightness_ctx, work); - struct light_hsl_ctx *hsl_ctx = - CONTAINER_OF(ctx, struct light_hsl_ctx, lightness_ctx); - struct light_hue_ctx *hue_ctx = &hsl_ctx->light_hue_ctx; - struct light_sat_ctx *sat_ctx = &hsl_ctx->light_sat_ctx; - - ctx->remaining -= ctx->period; - - if ((ctx->remaining <= ctx->period) || - (abs(ctx->target - ctx->current) <= PWM_SIZE_STEP)) { - ctx->current = ctx->target; - ctx->remaining = 0; - /* Publish the new value at the end of the transition */ - struct bt_mesh_lightness_status status; - - lightness_status(ctx, &status); - bt_mesh_lightness_srv_pub(&hsl_ctx->srv.lightness, NULL, - &status); - - if (hue_ctx->remaining == 0 && sat_ctx->remaining == 0) { - struct bt_mesh_light_hsl_status hsl_status; - - light_hsl_status(hsl_ctx, &hsl_status); - bt_mesh_light_hsl_srv_pub(&hsl_ctx->srv, NULL, &hsl_status); - } - return; - } else if (ctx->target > ctx->current) { - ctx->current += PWM_SIZE_STEP; - } else { - ctx->current -= PWM_SIZE_STEP; - } - - k_work_reschedule(&ctx->work, K_MSEC(ctx->period)); -} - -static void light_hsl_lightness_set(struct bt_mesh_lightness_srv *srv, - struct bt_mesh_msg_ctx *ctx, - const struct bt_mesh_lightness_set *set, - struct bt_mesh_lightness_status *rsp) -{ - struct bt_mesh_light_hsl_srv *hsl_srv = - CONTAINER_OF(srv, struct bt_mesh_light_hsl_srv, lightness); - struct light_hsl_ctx *hsl_ctx = - CONTAINER_OF(hsl_srv, struct light_hsl_ctx, srv); - struct lightness_ctx *l_ctx = &hsl_ctx->lightness_ctx; - uint32_t step_cnt; - - l_ctx->target = set->lvl; - if (set->transition) { - l_ctx->remaining = set->transition->time + set->transition->delay; - } else { - l_ctx->remaining = 0; - } - - if (l_ctx->remaining) { - step_cnt = abs(l_ctx->target - l_ctx->current) / PWM_SIZE_STEP; - start_new_lightness_trans(step_cnt, set->transition, l_ctx); - } else { - l_ctx->current = l_ctx->target; - } - - lightness_status(l_ctx, rsp); - - struct bt_mesh_light_hsl_status hsl_status; - - light_hsl_status(hsl_ctx, &hsl_status); - bt_mesh_light_hsl_srv_pub(&hsl_ctx->srv, NULL, &hsl_status); -} - -static void light_hsl_lightness_get(struct bt_mesh_lightness_srv *srv, - struct bt_mesh_msg_ctx *ctx, - struct bt_mesh_lightness_status *rsp) -{ - struct bt_mesh_light_hsl_srv *hsl_srv = - CONTAINER_OF(srv, struct bt_mesh_light_hsl_srv, lightness); - struct light_hsl_ctx *hsl_ctx = - CONTAINER_OF(hsl_srv, struct light_hsl_ctx, srv); - struct lightness_ctx *l_ctx = &hsl_ctx->lightness_ctx; - - lightness_status(l_ctx, rsp); -} - -static const struct bt_mesh_lightness_srv_handlers hsl_lightness_srv_handlers = { - .light_set = light_hsl_lightness_set, - .light_get = light_hsl_lightness_get, -}; - -static struct light_hsl_ctx light_hsl_ctx = { - .srv = BT_MESH_LIGHT_HSL_SRV_INIT(&hue_cb, &sat_cb, - &hsl_lightness_srv_handlers), -}; - -struct light_xy_ctx { - struct bt_mesh_light_xyl_srv srv; - struct k_work_delayable work; - uint32_t remaining; - uint32_t period; - struct bt_mesh_light_xy current; - struct bt_mesh_light_xy target; - struct lightness_ctx xyl_lightness_ctx; -}; - static void start_new_light_xy_trans(uint32_t step_cnt, const struct bt_mesh_model_transition *transition, @@ -1036,7 +947,7 @@ static void xyl_get(struct bt_mesh_light_xyl_srv *srv, struct bt_mesh_lightness_status lightness = { 0 }; struct bt_mesh_light_xy_status xy = { 0 }; - srv->lightness_srv.handlers->light_get(&srv->lightness_srv, ctx, + srv->lightness_srv->handlers->light_get(srv->lightness_srv, ctx, &lightness); srv->handlers->xy_get(srv, ctx, &xy); @@ -1050,6 +961,8 @@ static void periodic_light_xy_work(struct k_work *work) { struct light_xy_ctx *ctx = CONTAINER_OF(work, struct light_xy_ctx, work); + struct light_xyl_hsl_ctx *xyl_hsl_ctx = + CONTAINER_OF(ctx, struct light_xyl_hsl_ctx, xyl_ctx); ctx->remaining -= ctx->period; @@ -1060,10 +973,15 @@ static void periodic_light_xy_work(struct k_work *work) ctx->current.y = ctx->target.y; ctx->remaining = 0; /* Publish the new value at the end of the transition */ - struct bt_mesh_light_xyl_status status; + struct bt_mesh_light_xyl_status xyl_status; + struct bt_mesh_light_hsl_status hsl_status; + + xyl_get(&ctx->srv, NULL, &xyl_status); + bt_mesh_light_xyl_srv_pub(&ctx->srv, NULL, &xyl_status); + + light_hsl_status(&xyl_hsl_ctx->hsl_ctx, &hsl_status); + bt_mesh_light_hsl_srv_pub(&xyl_hsl_ctx->hsl_ctx.srv, NULL, &hsl_status); - xyl_get(&ctx->srv, NULL, &status); - bt_mesh_light_xyl_srv_pub(&ctx->srv, NULL, &status); return; } else if ((ctx->target.x > ctx->current.x) && (ctx->target.y > ctx->current.y)) { @@ -1084,6 +1002,9 @@ static void light_xy_set(struct bt_mesh_light_xyl_srv *srv, { struct light_xy_ctx *l_ctx = CONTAINER_OF(srv, struct light_xy_ctx, srv); + struct light_xyl_hsl_ctx *xyl_hsl_ctx = + CONTAINER_OF(l_ctx, struct light_xyl_hsl_ctx, xyl_ctx); + struct bt_mesh_light_hsl_status hsl_status; uint32_t step_cnt; l_ctx->target.x = set->params.x; @@ -1105,6 +1026,9 @@ static void light_xy_set(struct bt_mesh_light_xyl_srv *srv, l_ctx->current.y = l_ctx->target.y; } light_xy_status(l_ctx, rsp); + + light_hsl_status(&xyl_hsl_ctx->hsl_ctx, &hsl_status); + bt_mesh_light_hsl_srv_pub(&xyl_hsl_ctx->hsl_ctx.srv, NULL, &hsl_status); } static void light_xy_get(struct bt_mesh_light_xyl_srv *srv, struct bt_mesh_msg_ctx *ctx, @@ -1121,12 +1045,14 @@ static const struct bt_mesh_light_xyl_srv_handlers light_xyl_handlers = { .xy_get = light_xy_get, }; -static void periodic_light_xyl_lightness_work(struct k_work *work) +static void periodic_light_xyl_hsl_lightness_work(struct k_work *work) { struct lightness_ctx *ctx = CONTAINER_OF(work, struct lightness_ctx, work); - struct light_xy_ctx *xyl_ctx = - CONTAINER_OF(ctx, struct light_xy_ctx, xyl_lightness_ctx); + struct light_xyl_hsl_ctx *xyl_hsl_ctx = + CONTAINER_OF(ctx, struct light_xyl_hsl_ctx, lightness_ctx); + struct light_hue_ctx *hue_ctx = &xyl_hsl_ctx->hsl_ctx.light_hue_ctx; + struct light_sat_ctx *sat_ctx = &xyl_hsl_ctx->hsl_ctx.light_sat_ctx; ctx->remaining -= ctx->period; @@ -1138,8 +1064,14 @@ static void periodic_light_xyl_lightness_work(struct k_work *work) struct bt_mesh_lightness_status status; lightness_status(ctx, &status); - bt_mesh_lightness_srv_pub(&xyl_ctx->srv.lightness_srv, NULL, - &status); + bt_mesh_lightness_srv_pub(&xyl_hsl_ctx->lightness_ctx.srv, NULL, &status); + + if (hue_ctx->remaining == 0 && sat_ctx->remaining == 0) { + struct bt_mesh_light_hsl_status hsl_status; + + light_hsl_status(&xyl_hsl_ctx->hsl_ctx, &hsl_status); + bt_mesh_light_hsl_srv_pub(&xyl_hsl_ctx->hsl_ctx.srv, NULL, &hsl_status); + } return; } else if (ctx->target > ctx->current) { ctx->current += PWM_SIZE_STEP; @@ -1150,16 +1082,16 @@ static void periodic_light_xyl_lightness_work(struct k_work *work) k_work_reschedule(&ctx->work, K_MSEC(ctx->period)); } -static void light_xyl_lightness_set(struct bt_mesh_lightness_srv *srv, +static void light_xyl_hsl_lightness_set(struct bt_mesh_lightness_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_lightness_set *set, struct bt_mesh_lightness_status *rsp) { - struct bt_mesh_light_xyl_srv *xyl_srv = - CONTAINER_OF(srv, struct bt_mesh_light_xyl_srv, lightness_srv); - struct light_xy_ctx *xyl_ctx = - CONTAINER_OF(xyl_srv, struct light_xy_ctx, srv); - struct lightness_ctx *l_ctx = &xyl_ctx->xyl_lightness_ctx; + struct lightness_ctx *l_ctx = CONTAINER_OF(srv, struct lightness_ctx, srv); + struct light_xyl_hsl_ctx *xyl_hsl_ctx = + CONTAINER_OF(l_ctx, struct light_xyl_hsl_ctx, lightness_ctx); + struct bt_mesh_light_xyl_status xyl_status; + struct bt_mesh_light_hsl_status hsl_status; uint32_t step_cnt; l_ctx->target = set->lvl; @@ -1177,29 +1109,39 @@ static void light_xyl_lightness_set(struct bt_mesh_lightness_srv *srv, } lightness_status(l_ctx, rsp); + + xyl_get(&xyl_hsl_ctx->xyl_ctx.srv, NULL, &xyl_status); + bt_mesh_light_xyl_srv_pub(&xyl_hsl_ctx->xyl_ctx.srv, NULL, &xyl_status); + + light_hsl_status(&xyl_hsl_ctx->hsl_ctx, &hsl_status); + bt_mesh_light_hsl_srv_pub(&xyl_hsl_ctx->hsl_ctx.srv, NULL, &hsl_status); } -static void light_xyl_lightness_get(struct bt_mesh_lightness_srv *srv, +static void light_xyl_hsl_lightness_get(struct bt_mesh_lightness_srv *srv, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_lightness_status *rsp) { - struct bt_mesh_light_xyl_srv *xyl_srv = - CONTAINER_OF(srv, struct bt_mesh_light_xyl_srv, lightness_srv); - struct light_xy_ctx *xyl_ctx = - CONTAINER_OF(xyl_srv, struct light_xy_ctx, srv); - struct lightness_ctx *l_ctx = &xyl_ctx->xyl_lightness_ctx; + struct lightness_ctx *l_ctx = CONTAINER_OF(srv, struct lightness_ctx, srv); lightness_status(l_ctx, rsp); } -static const struct bt_mesh_lightness_srv_handlers xyl_lightness_srv_handlers = { - .light_set = light_xyl_lightness_set, - .light_get = light_xyl_lightness_get, +static const struct bt_mesh_lightness_srv_handlers xyl_hsl_lightness_srv_handlers = { + .light_set = light_xyl_hsl_lightness_set, + .light_get = light_xyl_hsl_lightness_get, }; -static struct light_xy_ctx light_xy_ctx = { - .srv = BT_MESH_LIGHT_XYL_SRV_INIT(&xyl_lightness_srv_handlers, - &light_xyl_handlers), +static struct light_xyl_hsl_ctx xyl_hsl_ctx = { + .lightness_ctx.srv = BT_MESH_LIGHTNESS_SRV_INIT(&xyl_hsl_lightness_srv_handlers), + .xyl_ctx = { + .srv = BT_MESH_LIGHT_XYL_SRV_INIT(&xyl_hsl_ctx.lightness_ctx.srv, + &light_xyl_handlers), + .lightness_ctx = &xyl_hsl_ctx.lightness_ctx, + }, + .hsl_ctx = { + .srv = BT_MESH_LIGHT_HSL_SRV_INIT(&xyl_hsl_ctx.lightness_ctx.srv, &hue_cb, &sat_cb), + .lightness_ctx = &xyl_hsl_ctx.lightness_ctx, + } }; static void get_faults(uint8_t *faults, uint8_t faults_size, uint8_t *dst, @@ -1357,29 +1299,27 @@ static struct bt_mesh_elem elements[] = { BT_MESH_MODEL_NONE), BT_MESH_ELEM(50, BT_MESH_MODEL_LIST( - BT_MESH_MODEL_LIGHT_HSL_SRV(&light_hsl_ctx.srv)), + BT_MESH_MODEL_LIGHTNESS_SRV(&xyl_hsl_ctx.lightness_ctx.srv), + BT_MESH_MODEL_LIGHT_XYL_SRV(&xyl_hsl_ctx.xyl_ctx.srv), + BT_MESH_MODEL_LIGHT_HSL_SRV(&xyl_hsl_ctx.hsl_ctx.srv)), BT_MESH_MODEL_NONE), BT_MESH_ELEM(51, BT_MESH_MODEL_LIST( - BT_MESH_MODEL_LIGHT_HUE_SRV(&light_hsl_ctx.srv.hue)), + BT_MESH_MODEL_LIGHT_HUE_SRV(&xyl_hsl_ctx.hsl_ctx.srv.hue)), BT_MESH_MODEL_NONE), BT_MESH_ELEM(52, BT_MESH_MODEL_LIST( - BT_MESH_MODEL_LIGHT_SAT_SRV(&light_hsl_ctx.srv.sat)), + BT_MESH_MODEL_LIGHT_SAT_SRV(&xyl_hsl_ctx.hsl_ctx.srv.sat)), BT_MESH_MODEL_NONE), BT_MESH_ELEM(60, - BT_MESH_MODEL_LIST( - BT_MESH_MODEL_LIGHT_XYL_SRV(&light_xy_ctx.srv)), - BT_MESH_MODEL_NONE), - BT_MESH_ELEM(70, BT_MESH_MODEL_LIST( BT_MESH_MODEL_LIGHT_CTL_SRV(&light_ctl_ctx.srv)), BT_MESH_MODEL_NONE), - BT_MESH_ELEM(71, + BT_MESH_ELEM(61, BT_MESH_MODEL_LIST( BT_MESH_MODEL_LIGHT_TEMP_SRV(&light_ctl_ctx.srv.temp_srv)), BT_MESH_MODEL_NONE), - BT_MESH_ELEM(80, + BT_MESH_ELEM(70, BT_MESH_MODEL_LIST( BT_MESH_MODEL_ONOFF_CLI(&onoff_cli), BT_MESH_MODEL_LVL_CLI(&lvl_cli), @@ -1411,18 +1351,16 @@ const struct bt_mesh_comp *model_handler_init(void) { k_work_init_delayable(&lvl_ctx.work, periodic_led_work); k_work_init_delayable(&lightness_ctx.work, periodic_led_lightness_work); - k_work_init_delayable(&light_xy_ctx.work, periodic_light_xy_work); - k_work_init_delayable(&light_xy_ctx.xyl_lightness_ctx.work, - periodic_light_xyl_lightness_work); + k_work_init_delayable(&xyl_hsl_ctx.xyl_ctx.work, periodic_light_xy_work); + k_work_init_delayable(&xyl_hsl_ctx.lightness_ctx.work, + periodic_light_xyl_hsl_lightness_work); + k_work_init_delayable(&xyl_hsl_ctx.hsl_ctx.light_hue_ctx.work, + periodic_light_hue_work); + k_work_init_delayable(&xyl_hsl_ctx.hsl_ctx.light_sat_ctx.work, + periodic_light_sat_work); k_work_init_delayable(&light_ctl_ctx.ctl_lightness_ctx.work, periodic_light_ctl_lightness_work); k_work_init_delayable(&light_ctl_ctx.light_temp_ctx.work, periodic_light_temp_work); - k_work_init_delayable(&light_hsl_ctx.light_hue_ctx.work, - periodic_light_hue_work); - k_work_init_delayable(&light_hsl_ctx.light_sat_ctx.work, - periodic_light_sat_work); - k_work_init_delayable(&light_hsl_ctx.lightness_ctx.work, - periodic_light_hsl_lightness_work); return ∁ } diff --git a/tests/crypto/README.rst b/tests/crypto/README.rst index 7812195a1c29..0978bd93dd85 100644 --- a/tests/crypto/README.rst +++ b/tests/crypto/README.rst @@ -19,7 +19,7 @@ See :ref:`crypto_test_ztest_custom` for details. The tests are executed if the cryptographic functionality is enabled in Kconfig. Make sure to configure :ref:`nrfxlib:nrf_security` and all available hardware or software backends to enable the tests. -See :option:`CONFIG_NORDIC_SECURITY_BACKEND`. +See :kconfig:`CONFIG_NORDIC_SECURITY_BACKEND`. +--------------------+-------------+----------------------------------------------------------------------------+----------------------------------------------------------------------------+ | Cryptographic mode | Sub-mode | Link to standard | Test Vector Source | @@ -129,7 +129,7 @@ The tests support the following development kits: .. table-from-rows:: /includes/sample_board_rows.txt :header: heading - :rows: nrf9160dk_nrf9160ns, nrf52840dk_nrf52840 + :rows: nrf9160dk_nrf9160_ns, nrf52840dk_nrf52840 .. note:: Nordic devices such as nRF51, nRF52810, or nRF52811 cannot run the full test suite because of limited flash capacity. @@ -158,9 +158,9 @@ Ztest custom log formatting =========================== Cryptography tests replace the standard Ztest formatting to assure more efficient reporting of running tests and test results. -Set the configuration option :option:`CONFIG_ZTEST_TC_UTIL_USER_OVERRIDE` to replace the Ztest macros ``TC_START`` and ``Z_TC_END_RESULT`` with versions more suited for reporting results of cryptographic tests. +Set the configuration option :kconfig:`CONFIG_ZTEST_TC_UTIL_USER_OVERRIDE` to replace the Ztest macros ``TC_START`` and ``Z_TC_END_RESULT`` with versions more suited for reporting results of cryptographic tests. -:option:`CONFIG_ZTEST_TC_UTIL_USER_OVERRIDE` uses :file:`tests/crypto/include_override/tc_util_user_override.h` to define the custom formatting. +:kconfig:`CONFIG_ZTEST_TC_UTIL_USER_OVERRIDE` uses :file:`tests/crypto/include_override/tc_util_user_override.h` to define the custom formatting. .. _crypto_test_testing: diff --git a/tests/drivers/fprotect/negative/testcase.yaml b/tests/drivers/fprotect/negative/testcase.yaml index 78887a750f27..f0901646fb2a 100644 --- a/tests/drivers/fprotect/negative/testcase.yaml +++ b/tests/drivers/fprotect/negative/testcase.yaml @@ -1,5 +1,5 @@ tests: drivers.fprotect.negative: platform_allow: nrf9160dk_nrf9160 nrf52dk_nrf52832 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns nrf52840dk_nrf52840 nrf51dk_nrf51422 + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns nrf52840dk_nrf52840 nrf51dk_nrf51422 tags: b0 fprotect ignore_faults diff --git a/tests/drivers/fprotect/positive/prj.conf b/tests/drivers/fprotect/positive/prj.conf index 1ccbc79b0926..58a77c4dab45 100644 --- a/tests/drivers/fprotect/positive/prj.conf +++ b/tests/drivers/fprotect/positive/prj.conf @@ -12,4 +12,4 @@ CONFIG_STDOUT_CONSOLE=n CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_SECURE_BOOT=y CONFIG_FLASH=y -CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y +CONFIG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y diff --git a/tests/drivers/fprotect/positive/testcase.yaml b/tests/drivers/fprotect/positive/testcase.yaml index 197d10ac95e8..7f6497a854dd 100644 --- a/tests/drivers/fprotect/positive/testcase.yaml +++ b/tests/drivers/fprotect/positive/testcase.yaml @@ -1,5 +1,5 @@ tests: drivers.fprotect.positive: platform_allow: nrf9160dk_nrf9160 nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf51dk_nrf51422 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: b0 fprotect diff --git a/tests/lib/hw_unique_key_tfm/README.txt b/tests/lib/hw_unique_key_tfm/README.txt index 1e9914ae7fe0..5bd61f6f50d6 100644 --- a/tests/lib/hw_unique_key_tfm/README.txt +++ b/tests/lib/hw_unique_key_tfm/README.txt @@ -14,4 +14,4 @@ This means that the SEGGER id of the development kit must be passed both to west Here is an example of passing the id to the build: - west build -b nrf9160dk_nrf9160ns -- -DCONFIG_HUK_TEST_BOARD_SNR=\"901234567\" + west build -b nrf9160dk_nrf9160_ns -- -DCONFIG_HUK_TEST_BOARD_SNR=\"901234567\" diff --git a/tests/lib/hw_unique_key_tfm/testcase.yaml b/tests/lib/hw_unique_key_tfm/testcase.yaml index f75e5d33c7c7..6559ff5b4b73 100644 --- a/tests/lib/hw_unique_key_tfm/testcase.yaml +++ b/tests/lib/hw_unique_key_tfm/testcase.yaml @@ -1,5 +1,5 @@ tests: lib.hw_unique_key_tfm: - platform_allow: nrf9160dk_nrf9160ns nrf5340dk_nrf5340_cpuappns + platform_allow: nrf9160dk_nrf9160_ns nrf5340dk_nrf5340_cpuapp_ns tags: hw_unique_key build_only: true diff --git a/tests/lib/lte_lc/boards/nrf9160dk_nrf9160ns.conf b/tests/lib/lte_lc/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from tests/lib/lte_lc/boards/nrf9160dk_nrf9160ns.conf rename to tests/lib/lte_lc/boards/nrf9160dk_nrf9160_ns.conf diff --git a/tests/subsys/bootloader/bl_crypto/prj.conf b/tests/subsys/bootloader/bl_crypto/prj.conf index 55be3a221e06..1e374dee809a 100644 --- a/tests/subsys/bootloader/bl_crypto/prj.conf +++ b/tests/subsys/bootloader/bl_crypto/prj.conf @@ -17,4 +17,4 @@ CONFIG_SB_CRYPTO_CLIENT_ECDSA_SECP256R1=y CONFIG_BOOTLOADER_MCUBOOT=y # To test FW_INFO_PROVIDE_EXT_API. CONFIG_SB_MONOTONIC_COUNTER=n # To test that this config works properly. CONFIG_FW_INFO=y -CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y +CONFIG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y diff --git a/tests/subsys/bootloader/bl_crypto/testcase.yaml b/tests/subsys/bootloader/bl_crypto/testcase.yaml index ab3c427b65f7..2ad450b74c54 100644 --- a/tests/subsys/bootloader/bl_crypto/testcase.yaml +++ b/tests/subsys/bootloader/bl_crypto/testcase.yaml @@ -1,5 +1,5 @@ tests: bootloader.bl_crypto: platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf9160dk_nrf9160 nrf51dk_nrf51422 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: b0 diff --git a/tests/subsys/bootloader/bl_storage/testcase.yaml b/tests/subsys/bootloader/bl_storage/testcase.yaml index 10e75d5aa91f..4b95757e4d2f 100644 --- a/tests/subsys/bootloader/bl_storage/testcase.yaml +++ b/tests/subsys/bootloader/bl_storage/testcase.yaml @@ -1,7 +1,7 @@ tests: bootloader.bl_storage: platform_allow: nrf9160dk_nrf9160 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: b0 harness: console harness_config: diff --git a/tests/subsys/bootloader/bl_validation/prj.conf b/tests/subsys/bootloader/bl_validation/prj.conf index 302bfaefb9ba..08d659079f64 100644 --- a/tests/subsys/bootloader/bl_validation/prj.conf +++ b/tests/subsys/bootloader/bl_validation/prj.conf @@ -14,4 +14,4 @@ CONFIG_BL_VALIDATE_FW_EXT_API_REQUIRED=y CONFIG_SB_DEBUG_SIGNATURE_PUBLIC_KEY_LAST=y CONFIG_NRFX_NVMC=y CONFIG_MPU_ALLOW_FLASH_WRITE=y -CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y +CONFIG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y diff --git a/tests/subsys/bootloader/bl_validation/testcase.yaml b/tests/subsys/bootloader/bl_validation/testcase.yaml index 75b0e3277cef..6d8fc8285f6f 100644 --- a/tests/subsys/bootloader/bl_validation/testcase.yaml +++ b/tests/subsys/bootloader/bl_validation/testcase.yaml @@ -1,5 +1,5 @@ tests: bootloader.bl_validation: platform_allow: nrf9160dk_nrf9160 nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf51dk_nrf51422 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: b0 bl_validation diff --git a/tests/subsys/bootloader/bl_validation_neg/prj.conf b/tests/subsys/bootloader/bl_validation_neg/prj.conf index eb093ab56bb2..d2a436e090e2 100644 --- a/tests/subsys/bootloader/bl_validation_neg/prj.conf +++ b/tests/subsys/bootloader/bl_validation_neg/prj.conf @@ -13,4 +13,4 @@ CONFIG_NRFX_NVMC=y CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_REBOOT=y CONFIG_SECURE_BOOT_STORAGE=y -CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y +CONFIG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y diff --git a/tests/subsys/bootloader/bl_validation_neg/testcase.yaml b/tests/subsys/bootloader/bl_validation_neg/testcase.yaml index 244d8bae9ea3..6151ec8c2c30 100644 --- a/tests/subsys/bootloader/bl_validation_neg/testcase.yaml +++ b/tests/subsys/bootloader/bl_validation_neg/testcase.yaml @@ -1,7 +1,7 @@ tests: bootloader.bl_validation.negative: platform_allow: nrf9160dk_nrf9160 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: b0 bl_validation negative bl_validation_negative harness: console harness_config: diff --git a/tests/subsys/dfu/dfu_target_mcuboot/src/main.c b/tests/subsys/dfu/dfu_target_mcuboot/src/main.c index bdcdad29f2c4..a0e4d6923beb 100644 --- a/tests/subsys/dfu/dfu_target_mcuboot/src/main.c +++ b/tests/subsys/dfu/dfu_target_mcuboot/src/main.c @@ -17,7 +17,7 @@ */ char buf[1024]; -#define S0_S1 "s0 s1" +#define S0_S1 "s0+s1" #define NO_SPACE "s0s1" const char *flash_ptr = S0_S1; diff --git a/tests/subsys/dfu/dfu_target_stream/boards/nrf9160dk_nrf9160ns.conf b/tests/subsys/dfu/dfu_target_stream/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from tests/subsys/dfu/dfu_target_stream/boards/nrf9160dk_nrf9160ns.conf rename to tests/subsys/dfu/dfu_target_stream/boards/nrf9160dk_nrf9160_ns.conf diff --git a/tests/subsys/event_manager/testcase.yaml b/tests/subsys/event_manager/testcase.yaml index 8185b164ce7a..f5bb1bff9e86 100644 --- a/tests/subsys/event_manager/testcase.yaml +++ b/tests/subsys/event_manager/testcase.yaml @@ -5,5 +5,5 @@ tests: - nrf51dk_nrf51422 - nrf52dk_nrf52832 - nrf52840dk_nrf52840 - - nrf9160dk_nrf9160ns + - nrf9160dk_nrf9160_ns tags: event_manager diff --git a/tests/subsys/fw_info/testcase.yaml b/tests/subsys/fw_info/testcase.yaml index 88da38d041b1..4e9eb77ca42f 100644 --- a/tests/subsys/fw_info/testcase.yaml +++ b/tests/subsys/fw_info/testcase.yaml @@ -1,5 +1,5 @@ tests: fw_info.core: platform_allow: nrf9160dk_nrf9160 nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf51dk_nrf51422 - nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuappns + nrf5340dk_nrf5340_cpuapp nrf5340dk_nrf5340_cpuapp_ns tags: b0 fw_info diff --git a/tests/subsys/net/lib/fota_download/boards/nrf9160dk_nrf9160ns.conf b/tests/subsys/net/lib/fota_download/boards/nrf9160dk_nrf9160_ns.conf similarity index 100% rename from tests/subsys/net/lib/fota_download/boards/nrf9160dk_nrf9160ns.conf rename to tests/subsys/net/lib/fota_download/boards/nrf9160dk_nrf9160_ns.conf diff --git a/tests/subsys/net/lib/fota_download/testcase.yaml b/tests/subsys/net/lib/fota_download/testcase.yaml index 2b11885e2feb..06ddffbc5712 100644 --- a/tests/subsys/net/lib/fota_download/testcase.yaml +++ b/tests/subsys/net/lib/fota_download/testcase.yaml @@ -1,4 +1,4 @@ tests: net.lib.fota_download: tags: aws fota - platform_allow: nrf9160dk_nrf9160 nrf9160dk_nrf9160ns + platform_allow: nrf9160dk_nrf9160 nrf9160dk_nrf9160_ns diff --git a/tests/subsys/spm/secure_services/testcase.yaml b/tests/subsys/spm/secure_services/testcase.yaml index 47f7fb113fe7..02e8a15fdbea 100644 --- a/tests/subsys/spm/secure_services/testcase.yaml +++ b/tests/subsys/spm/secure_services/testcase.yaml @@ -1,4 +1,4 @@ tests: spm.secure_services: - platform_allow: nrf9160dk_nrf9160ns nrf5340dk_nrf5340_cpuappns + platform_allow: nrf9160dk_nrf9160_ns nrf5340dk_nrf5340_cpuapp_ns tags: spm secure_services diff --git a/tests/subsys/spm/thread_swap/testcase.yaml b/tests/subsys/spm/thread_swap/testcase.yaml index 1324dcae22d2..dbb6fbd64ce4 100644 --- a/tests/subsys/spm/thread_swap/testcase.yaml +++ b/tests/subsys/spm/thread_swap/testcase.yaml @@ -1,4 +1,4 @@ tests: spm.secure_services.thread_swap: - platform_allow: nrf9160dk_nrf9160ns nrf5340dk_nrf5340_cpuappns + platform_allow: nrf9160dk_nrf9160_ns nrf5340dk_nrf5340_cpuapp_ns tags: spm secure_services thread_swap diff --git a/west.yml b/west.yml index 6d933afc1489..ba3a98fb3d48 100644 --- a/west.yml +++ b/west.yml @@ -27,8 +27,6 @@ manifest: url-base: https://github.com/ThrowTheSwitch - name: armmbed url-base: https://github.com/ARMmbed - - name: nanopb - url-base: https://github.com/nanopb - name: alexa url-base: https://github.com/alexa - name: nordicsemi @@ -56,7 +54,7 @@ manifest: # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html - name: zephyr repo-path: sdk-zephyr - revision: 0944459b5b622048a08ad1f8cf8a044c135fd0d3 + revision: 01a38e7fa55913350c647df1f51715fea5d80daa import: # In addition to the zephyr repository itself, NCS also # imports the contents of zephyr/west.yml at the above @@ -70,9 +68,10 @@ manifest: # # Please keep this list sorted alphabetically. name-allowlist: + - TraceRecorderSource - canopennode - - cmsis - civetweb + - cmsis - edtt - fatfs - hal_nordic @@ -81,9 +80,11 @@ manifest: - littlefs - loramac-node - lvgl + - lz4 - mbedtls - mcumgr - mipi-sys-t + - nanopb - net-tools - nrf_hw_models - open-amp @@ -91,7 +92,6 @@ manifest: - segger - tinycbor - tinycrypt - - TraceRecorderSource # NCS repositories. # @@ -99,16 +99,16 @@ manifest: # changes. - name: mcuboot repo-path: sdk-mcuboot - revision: 5a6bf2fa11503ea0a3ef2b42a8afeed43053b6b9 + revision: 274ff833dabea621483cafa3e5aede9a9bf11b9e path: bootloader/mcuboot - name: nrfxlib repo-path: sdk-nrfxlib path: nrfxlib - revision: aa5661dbe16ab55b5f0665220660b051277eac25 + revision: 1c0ba974a1db404110f36976ac942645fedc4a36 - name: trusted-firmware-m repo-path: sdk-trusted-firmware-m path: modules/tee/tfm - revision: v1.3.99-ncs1 + revision: 52a2fbefe02da485f4c6103d40a86b3a529cbd8e - name: tfm-mcuboot # This is used by the trusted-firmware-m module. repo-path: sdk-mcuboot path: modules/tee/tfm-mcuboot @@ -116,7 +116,7 @@ manifest: - name: matter repo-path: sdk-connectedhomeip path: modules/lib/matter - revision: 5b90f5789e317812a49e981071de20b29a5fd343 + revision: 27bce6d82a1227b1f9fb442c16ea74e4930acd6c submodules: - name: nlio path: third_party/nlio/repo @@ -148,10 +148,6 @@ manifest: repo-path: mbedtls revision: mbedtls-2.26.0 remote: armmbed - - name: nanopb - path: modules/lib/nanopb - revision: nanopb-0.4.2 - remote: nanopb - name: Alexa-Gadgets-Embedded-Sample-Code path: modules/alexa-embedded revision: face92d8c62184832793f518bb1f19379538c5c1 @@ -166,17 +162,17 @@ manifest: path: modules/lib/cddl-gen - name: homekit repo-path: sdk-homekit - revision: c01ec0692c959790b0f73f036c8485da6ade562a + revision: 8014b7f5d3e20164d1e305cf1188ec72fab330f4 groups: - homekit - name: find-my repo-path: sdk-find-my - revision: v1.6.0 + revision: 454c7c39037dafe9be1fb793c492b22b4eacacd1 groups: - find-my - name: memfault-firmware-sdk path: modules/lib/memfault-firmware-sdk - revision: 0.21.1 + revision: 0.24.1 remote: memfault # West-related configuration for the nrf repository.