### Sample Output Log Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/wifi/promiscuous/README.rst Example console output showing the initialization of the network, DHCP connection, and the start of the Wi-Fi promiscuous mode RX thread. ```text [00:00:00.433,898] usb_net: netusb initialized *** Booting nRF Connect SDK v2.6.99-22ce705894ad *** *** Using Zephyr OS v3.6.99-688107b4a1a2 *** [00:00:00.516,448] net_config: Initializing network [00:00:00.516,448] net_config: Waiting interface 1 (0x20001020) to be up... [00:00:00.516,601] net_config: IPv4 address: 192.168.1.99 [00:00:00.516,662] net_config: Running dhcpv4 client... [00:00:00.519,897] promiscuous: Promiscuous mode enabled [00:00:07.712,585] wifi_connect: Connected [00:00:07.844,177] promiscuous: Wi-Fi promiscuous mode RX thread started [00:00:12.869,476] promiscuous: Management Frames: [00:00:12.869,506] promiscuous: Beacon Count: 48 [00:00:12.869,506] promiscuous: Probe Request Count: 0 [00:00:12.869,506] promiscuous: Probe Response Count: 190 ``` -------------------------------- ### Console Boot Output Example Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/cellular/modem_shell/README.rst Example of the initial console output when the application starts on the development kit. It shows the Zephyr OS and MoSh versions, modem initialization status, and network registration. ```console *** Booting Zephyr OS build v2.4.99-ncs1-3525-g4d068de3f50f *** MOSH version: v1.5.0-649-g7e657c2fab02 MOSH build id: 152 MOSH build variant: normal Initializing modemlib... Initialized modemlib Network registration status: searching Network registration status: Connected - home network mosh:~$ ``` -------------------------------- ### SoftAP Wi-Fi Provision Library Usage Example (C) Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/libraries/networking/softap_wifi_provision.rst Demonstrates the initialization and usage of the SoftAP Wi-Fi provision library. It includes setting up an event handler, bringing up the network interface, and starting the provisioning process. The handler manages various provisioning events like started, client connected/disconnected, credentials received, completion, and errors. ```c #include static void softap_wifi_provision_handler(const struct softap_wifi_provision_evt *evt) { int ret; switch (evt->type) { case SOFTAP_WIFI_PROVISION_EVT_STARTED: LOG_INF("Provisioning started"); break; case SOFTAP_WIFI_PROVISION_EVT_CLIENT_CONNECTED: LOG_INF("Client connected"); break; case SOFTAP_WIFI_PROVISION_EVT_CLIENT_DISCONNECTED: LOG_INF("Client disconnected"); break; case SOFTAP_WIFI_PROVISION_EVT_CREDENTIALS_RECEIVED: LOG_INF("Wi-Fi credentials received"); break; case SOFTAP_WIFI_PROVISION_EVT_COMPLETED: LOG_INF("Provisioning completed"); break; case SOFTAP_WIFI_PROVISION_EVT_UNPROVISIONED_REBOOT_NEEDED: LOG_INF("Reboot request notified, rebooting..."); sys_reboot(0); break; case SOFTAP_WIFI_PROVISION_EVT_FATAL_ERROR: LOG_ERR("Provisioning failed, fatal error!"); break; default: /* Don't care */ return; } } int main(void) { int ret; ret = softap_wifi_provision_init(softap_wifi_provision_handler); if (ret) { LOG_ERR("softap_wifi_provision_init, error: %d", ret); return ret; } ret = conn_mgr_all_if_up(true); if (ret) { LOG_ERR("conn_mgr_all_if_up, error: %d", ret); return ret; } LOG_INF("Network interface brought up"); /* Start provisioning, this function blocks. */ ret = softap_wifi_provision_start(); if (ret == -EALREADY) { LOG_INF("Wi-Fi credentials found, skipping provisioning"); return ret; } else if (ret) { LOG_ERR("softap_wifi_provision_start, error: %d", ret); return ret; } } ``` -------------------------------- ### Sample Output: Unclaimed Device Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/cellular/nrf_device_provisioning/README.rst Example output from the nRF Device Provisioning sample when the device has not yet been claimed. It shows the boot process, network connection, and the start of the provisioning process. ```console *** Booting nRF Connect SDK v3.0.99-ab6a14880c0a *** *** Using Zephyr OS v4.1.99-7f1481559760 *** nrf_provisioning_sample: nRF Device Provisioning Sample nrf_provisioning_sample: Bringing network interface up and connecting to the network nrf_provisioning_sample: Provisioning scheduled, next attempt in 3 seconds nrf_provisioning_sample: Network connectivity established nrf_provisioning_sample: IPv4 connectivity established nrf_provisioning_sample: IPv6 connectivity established ``` -------------------------------- ### Install Latest NCS Release Example Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/installation/install_ncs.rst An example command to install the latest nRF Connect SDK release and its toolchain. This is useful for getting started quickly or when a specific branch is not required initially. ```console nrfutil sdk-manager install |release| ``` -------------------------------- ### Flash and Test Wi-Fi Provisioning Sample Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/wifi/provisioning/internal/README.rst Instructions for flashing the built sample to the device and connecting to the console to test basic Wi-Fi provisioning commands. Includes commands for checking info, status, and sending raw data. ```bash west flash screen /dev/ttyACM0 115200 # Test commands uart:~$ wifi_prov info uart:~$ wifi_prov get_status uart:~$ wifi_prov raw 0801 ``` -------------------------------- ### Install MCUmgr CLI Tool Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/app_dev/bootloaders_dfu/dfu_tools_mcumgr_cli.rst Installs the MCUmgr command-line tool. The installation command varies based on the Go version. For Go versions prior to 1.18, 'go get' is used. For Go versions 1.18 and later, 'go install' is recommended. ```bash go get github.com/apache/mynewt-mcumgr-cli/mcumgr ``` ```bash go install github.com/apache/mynewt-mcumgr-cli/mcumgr@latest ``` -------------------------------- ### QoS Library Initialization and Usage Example Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/libraries/others/qos.rst This example demonstrates how to initialize the QoS library, set an event handler, and add a message with required acknowledgment. ```APIDOC ## QoS Library Initialization and Usage Example ### Description This example demonstrates the initialization of the QoS library and the process of adding a message that requires acknowledgment. It also shows how to handle events from the library. ### Method N/A (C code example) ### Endpoint N/A (C code example) ### Parameters N/A ### Request Example ```c /* Define message types that can be used to route data. */ enum { SENSOR_DATA, DIAGNOSTIC_DATA }; /* Event handler used to receive notifications from the library. */ static void qos_event_handler(const struct qos_evt *evt) { switch (evt->type) { case QOS_EVT_MESSAGE_NEW: case QOS_EVT_MESSAGE_TIMER_EXPIRED: /* Check evt->message.type and route message based on type. */ break; case QOS_EVT_MESSAGE_REMOVED_FROM_LIST: /* Free payload if (evt->message.heap_allocated == true) */ break; default: break; } } /* QoS library message data structure. */ struct qos_data message = { .heap_allocated = true, .data.buf = pointer_to_payload, .data.len = size_of_payload, .id = qos_message_id_get_next(), .type = SENSOR_DATA, .flags = QOS_FLAG_RELIABILITY_ACK_REQUIRED }; /* Initialize the QoS library and set the library event handler. */ err = qos_init(qos_event_handler); if (err) { LOG_ERR("qos_init, err", err); return err; } /* Add a single message. */ err = qos_message_add(&message); if (err) { LOG_ERR("qos_message_add, error: %d", err); return err; } ``` ### Response N/A (C code example) ### Response Example N/A (C code example) ``` -------------------------------- ### GET /location/request Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/releases_and_maturity/releases/release-notes-2.6.0.rst Initiates a location request and handles location events including fallback and start notifications. ```APIDOC ## GET /location/request ### Description Requests a location update. The system may trigger LOCATION_EVT_STARTED or LOCATION_EVT_FALLBACK events based on configuration. ### Method GET ### Endpoint /location/request ### Parameters #### Query Parameters - **method** (string) - Required - Location method to use (e.g., GNSS, CELLULAR) ### Request Example { "method": "GNSS" } ### Response #### Success Response (200) - **event** (string) - The type of location event triggered - **details** (object) - Detailed location data if available #### Response Example { "event": "LOCATION_EVT_STARTED", "details": {} } ``` -------------------------------- ### Build and Flash Multicore Sample Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/app_dev/device_guides/nrf54h/ug_nrf54h20_gs.rst Uses West to build the sysbuild hello_world sample for the nRF54H20 DK and flash it to the device. The build command targets both the application and radio cores. ```bash west build -p -b nrf54h20dk/nrf54h20/cpuapp -T sample.sysbuild.hello_world.nrf54h20dk_cpuapp_cpurad . west flash ``` -------------------------------- ### Start Traffic Generator Server (Python) Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/wifi/twt/README.rst This command starts the Python 3 based traffic generator server required for the TWT sample. Ensure Python 3 is installed and the server is accessible from the development kit. ```console python3 traffic_gen_server.py ``` -------------------------------- ### Test Case Setup with ITEM_GET and Unhexification (C) Source: https://github.com/nrfconnect/sdk-nrf/blob/main/tests/crypto/README.rst Illustrates the setup procedure for a cryptographic test case. It includes clearing buffers, fetching the next test vector using ITEM_GET, and unhexifying the hexadecimal string data into binary format for processing. This setup is crucial before executing the test case. ```c void hmac_setup(void) { hmac_clear_buffers(); p_test_vector = ITEM_GET(test_vector_hmac_data, test_vector_hmac_t, hmac_vector_n); unhexify_hmac(); } ``` -------------------------------- ### Enable Global Watchdog Module Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/protocols/matter/end_product/watchdog.rst Enable the global watchdog module. This function returns false if no watchdog sources are installed or if there's an issue starting the watchdog timer. Successful enablement requires all installed sources to be fed periodically. ```c++ if(!Nrf::Watchdog::Enable()) { return false; } ``` -------------------------------- ### Define Boolean Kconfig Symbol Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/dev_model_and_contributions/documentation/styleguide.rst Example of a boolean configuration option, requiring an imperative verb at the start of the help text. ```kconfig config MY_FEATURE bool "My feature" depends on MY_DEPENDENCY help Enable support for my feature. This feature provides... ``` -------------------------------- ### Build and Configure Wi-Fi Provisioning Sample Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/wifi/provisioning/internal/README.rst Commands to build the Wi-Fi provisioning sample with custom SSID and passphrase using west build and Kconfig options. This allows for pre-configuration of Wi-Fi credentials before flashing. ```bash west build -b nrf7002dk/nrf5340/cpuapp samples/wifi/provisioning/internal \ -- -DCONFIG_WIFI_PROV_SSID="MyNetwork" \ -DCONFIG_WIFI_PROV_PASSPHRASE="mypassword" ``` -------------------------------- ### Build and Flash PPR Core (Minimal Sample) Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/app_dev/device_guides/nrf54h/ug_nrf54h20_ppr.rst This command builds and flashes the nRF54H20DK with the PPR core using the minimal sample for VPR bootstrapping. It assumes a pristine build environment. ```console west build -p -b nrf54h20dk/nrf54h20/cpuppr west flash ``` -------------------------------- ### Wi-Fi Provisioning Protocol Testing Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/wifi/provisioning/internal/README.rst Demonstrates how to test Wi-Fi provisioning protocols by sending commands like 'start_scan' and observing the automatically logged protobuf messages. This includes sample output for scan results. ```text uart:~$ wifi_prov start_scan Starting Wi-Fi scan... === Wi-Fi Provisioning Request === Type: START_SCAN =============================== Wi-Fi scan started successfully # Response will be logged automatically: === Wi-Fi Provisioning Response === Scan Result: Status: 0 Networks found: 3 Network 1: SSID: MyWi-FiNetwork BSSID: 11:22:33:44:55:66 RSSI: -45 Channel: 6 Auth mode: 3 ``` -------------------------------- ### Deploy OTBR using Docker Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/protocols/thread/tools.rst Commands to install Docker, create an IPv6 network, pull the OTBR image, and start the container with necessary privileges and sysctl settings. ```console sudo apt update && sudo apt install docker.io sudo systemctl start docker sudo docker network create --ipv6 --subnet fd11:db8:1::/64 -o com.docker.network.bridge.name=otbr0 otbr docker pull nrfconnect/otbr:fbde28a sudo modprobe ip6table_filter sudo docker run -it --rm --privileged --name otbr --network otbr -p 8080:80 --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" nrfconnect/otbr:fbde28a ``` -------------------------------- ### Initial Secure Boot Verification Log Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/app_dev/bootloaders_dfu/mcuboot_nsib/bootloader_signature_keys.rst Example console output demonstrating the initial secure boot process, where the firmware signature is verified against the first available public key. ```text *** Booting Zephyr OS build ... *** Attempting to boot slot 0. Attempting to boot from address 0x9000. Verifying signature against key 0. Hash: 0xda...4f Firmware signature verified. Firmware version 1 *** Booting Zephyr OS build ... *** ... ``` -------------------------------- ### Static Partition Configuration Example Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/security/tfm/tfm_services.rst Example configuration for static partitions on nRF9151, demonstrating how to group storage partitions to optimize flash usage. ```yaml EMPTY_0: address: 0xfc000 end_address: 0x100000 placement: after: - tfm_ps region: flash_primary size: 0x4000 EMPTY_1: address: 0xf2000 end_address: 0xf8000 placement: after: - tfm_otp_nv_counters region: flash_primary size: 0x6000 EMPTY_2: address: 0xea000 end_address: 0xf0000 placement: after: - tfm_its region: flash_primary size: 0x6000 app: address: 0x40000 end_address: 0xe8000 region: flash_primary size: 0xa8000 tfm_nonsecure: address: 0x40000 end_address: 0xe8000 orig_span: &id004 - app region: flash_primary size: 0xa8000 span: *id004 tfm_its: address: 0xe8000 end_address: 0xea000 inside: - tfm_storage placement: align: start: 0x8000 before: - tfm_otp_nv_counters region: flash_primary size: 0x2000 tfm_otp_nv_counters: address: 0xf0000 end_address: 0xf2000 inside: - tfm_storage placement: align: start: 0x8000 before: - tfm_ps region: flash_primary size: 0x2000 tfm_ps: address: 0xf8000 end_address: 0xfc000 ``` -------------------------------- ### Commissionable Data Provider Interface (C++) Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/protocols/matter/end_product/factory_provisioning.rst Defines the interface for managing commissionable data, including setup discriminators, iteration counts, salts, verifiers, and passcodes. Supports both getting and setting these values. ```cpp // ===== Members functions that implement the CommissionableDataProvider CHIP_ERROR GetSetupDiscriminator(uint16_t & setupDiscriminator) override; CHIP_ERROR SetSetupDiscriminator(uint16_t setupDiscriminator) override; CHIP_ERROR GetSpake2pIterationCount(uint32_t & iterationCount) override; CHIP_ERROR GetSpake2pSalt(MutableByteSpan & saltBuf) override; CHIP_ERROR GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) override; CHIP_ERROR GetSetupPasscode(uint32_t & setupPasscode) override; CHIP_ERROR SetSetupPasscode(uint32_t setupPasscode) override; ``` -------------------------------- ### Initialize and Compose Light HSL Server in C Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/libraries/bluetooth/mesh/light_hsl_srv.rst Demonstrates the initialization of the Lightness and HSL server structures and their inclusion in the Bluetooth Mesh element composition array. This setup ensures the HSL server correctly references the underlying lightness, hue, and saturation models. ```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(&lightness_srv, &hue_cb, &sat_cb); static struct bt_mesh_elem elements[] = { BT_MESH_ELEM( 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)), BT_MESH_MODEL_NONE), BT_MESH_ELEM( 3, BT_MESH_MODEL_LIST(BT_MESH_MODEL_LIGHT_SAT_SRV(&hsl_srv.sat)), BT_MESH_MODEL_NONE), }; ``` -------------------------------- ### Interact with HTTP Server via HTTPie Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/net/http_server/README.rst Demonstrates how to perform PUT and GET requests to the HTTP server to control and query LED states. Requires the HTTPie command-line tool installed on the host machine. ```console http PUT http://httpserver.local:80/led/1 --raw="1" http GET http://httpserver.local:80/led/1 ``` -------------------------------- ### Get NCS Specific Zephyr Commits Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/releases_and_maturity/releases/release-notes-1.6.0.rst This command lists one-line commit messages for NCS-specific changes in the Zephyr repository, starting from the manifest revision and excluding a specific upstream tag. This helps identify custom modifications. ```none git log --oneline manifest-rev ^v2.6.0-rc1 ``` -------------------------------- ### Build and Configure Wi-Fi Raw TX Sample Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/wifi/offloaded_raw_tx/README.rst Commands to build the offloaded raw TX sample for nRF7002 DK, including specific configurations for beacon generation and transmission intervals. ```console west build -p -b nrf7002dk/nrf5340/cpuapp west build -p -b nrf7002dk/nrf5340/cpuapp -- -DCONFIG_GENERATE_MAC_ADDRESS=y -DCONFIG_ENTROPY_GENERATOR=y west build -p -b nrf7002dk/nrf5340/cpuapp -- -DCONFIG_BEACON_INTERVAL=200 west build -p -b nrf5340dk/nrf5340/cpuapp -- -DSHIELD=nrf7002ek ``` -------------------------------- ### Downloader Initialization and Configuration Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/libraries/networking/downloader.rst Demonstrates the initialization of the downloader library, setting up HTTP transport configuration, and host configuration. ```APIDOC ## Downloader Initialization and Configuration ### Description Initializes the downloader library, configures HTTP transport parameters, and sets up host-specific configurations for downloads. ### Method N/A (Illustrative C code) ### Endpoint N/A ### Parameters #### Request Body - **dl_buf** (char[2048]) - Buffer for downloader data. - **dl_cfg** (struct downloader_cfg) - Downloader configuration, including callback and buffer. - **dl_host_cfg** (struct downloader_host_cfg) - Host configuration, including security tags. - **dl_transport_http_cfg** (struct downloader_transport_http_cfg) - HTTP transport configuration, including receive timeout. ### Request Example ```c char dl_buf[2048]; struct downloader dl; struct downloader_cfg dl_cfg = { .callback = dl_callback, .buf = dl_buf, .buf_size = sizeof(dl_buf), }; int sec_tags[] = {1, 2, 3}; struct downloader_host_cfg dl_host_cfg = { .sec_tag_list = sec_tags, .sec_tag_count = ARRAY_SIZE(sec_tags), .keep_connection = false, }; struct downloader_transport_http_cfg dl_transport_http_cfg = { .sock_recv_timeo_ms = 60 * MSEC_PER_SEC, }; err = downloader_init(&dl, &dl_cfg); // ... error handling ... err = downloader_transport_http_set_config(&dl, &dl_transport_http_cfg); // ... error handling ... ``` ### Response #### Success Response (0) - **err** (int) - 0 indicates success. #### Response Example ```c // Success is indicated by err == 0 ``` ``` -------------------------------- ### Add Sensor Setting - C Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/libraries/bluetooth/mesh/sensor.rst Example demonstrating how to add a sensor setting to a Bluetooth Mesh sensor. It includes the mandatory 'get' callback and an optional 'set' callback for handling sensor value updates. The 'set' callback can return an error code to reject changes. ```c static void motion_threshold_get(struct bt_mesh_sensor_srv *srv, struct bt_mesh_sensor *sensor, const struct bt_mesh_sensor_setting *setting, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_sensor_value *rsp) { /** Get the current threshold in an application defined way and * store it in rsp. */ get_threshold(rsp); } static int motion_threshold_set(struct bt_mesh_sensor_srv *srv, struct bt_mesh_sensor *sensor, const struct bt_mesh_sensor_setting *setting, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_sensor_value *value) { /** Store incoming threshold in application-defined way. * Return error code to reject set. */ return set_threshold(value); } static const struct bt_mesh_sensor_setting settings[] = { { .type = &bt_mesh_sensor_motion_threshold, .get = motion_threshold_get, .set = motion_threshold_set, } }; static struct bt_mesh_sensor motion_sensor = { .type = &bt_mesh_sensor_motion_sensed, .get = get_motion, .settings = { .list = settings, .count = ARRAY_SIZE(settings) } }; ``` -------------------------------- ### Initialize and Configure Downloader Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/libraries/networking/downloader.rst Initializes the downloader with a callback function and buffer, then sets up HTTP transport parameters. This prepares the downloader for fetching data. ```c char dl_buf[2048]; struct downloader dl; struct downloader_cfg dl_cfg = { .callback = dl_callback, .buf = dl_buf, .buf_size, }; struct downloader_transport_http_cfg dl_transport_http_cfg = { .sock_recv_timeo_ms = 60 * MSEC_PER_SEC, }; err = downloader_init(&dl, &dl_cfg); if (err) { printk("downloader init failed, err %d\n", err); } err = downloader_transport_http_set_config(&dl, &dl_transport_http_cfg); if (err) { printk("failed to set http transport params failed, err %d\n", err); } ``` -------------------------------- ### Testing HTTP Server with REST Calls (Cellular) Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/net/http_server/README.rst Demonstrates how to interact with the HTTP server sample using REST calls over a cellular connection. It covers unsecure, TLS with server authentication, and TLS with server and client authentication scenarios. Examples include setting and getting LED states. ```console http PUT http://:80/led/1 --raw="1" http GET http://:80/led/1 ``` ```console https PUT https://:443/led/1 --raw="1" --verify server_certificate.pem https GET https://:443/led/1 --verify server_certificate.pem ``` ```console https PUT https://:443/led/1 --raw="1" --verify server_certificate.pem --cert client.crt --cert-key client.key https GET https://:443/led/1 --verify server_certificate.pem --cert client.crt --cert-key client.key ``` -------------------------------- ### Initialize Light xyL Server with Light Lightness Server (C) Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/libraries/bluetooth/mesh/light_xyl_srv.rst Demonstrates the initialization of the Light xyL Server and the required Light Lightness Server in application code. The Light Lightness Server must be defined and initialized separately, and its pointer passed to the Light xyL Server initialization macro. This setup is for a single element node. ```c static struct bt_mesh_lightness_srv lightess_srv = BT_MESH_LIGHTNESS_SRV_INIT(&lightness_cb); static struct bt_mesh_light_xyl_srv xyl_srv = BT_MESH_LIGHT_XYL_SRV_INIT(&lightness_srv, &xyl_handlers); static struct bt_mesh_elem elements[] = { BT_MESH_ELEM( 1, BT_MESH_MODEL_LIST( BT_MESH_MODEL_LIGHTNESS_SRV(&lightness_srv), BT_MESH_MODEL_LIGHT_XYL_SRV(&xyl_srv)), BT_MESH_MODEL_NONE), }; ``` -------------------------------- ### Testing HTTP Server with REST Calls (Wi-Fi) Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/net/http_server/README.rst Demonstrates how to interact with the HTTP server sample using REST calls over a Wi-Fi connection. It covers unsecure, TLS with server authentication, and TLS with server and client authentication scenarios. Examples include setting and getting LED states. ```console http PUT http://httpserver.local:80/led/1 --raw="1" http GET http://httpserver.local:80/led/1 ``` ```console https PUT https://httpserver.local:443/led/1 --raw="1" --verify server_certificate.pem https GET https://httpserver.local:443/led/1 --verify server_certificate.pem ``` ```console https PUT https://httpserver.local:443/led/1 --raw="1" --verify server_certificate.pem --cert client.crt --cert-key client.key https GET https://httpserver.local:443/led/1 --verify server_certificate.pem --cert client.crt --cert-key client.key ``` ```console http PUT 'http://[2001:8c0:5140:895:f7ce:37ff:fe00:1971]:81/led/1' --raw="1" ``` -------------------------------- ### Execute HMAC Test Case - C Source: https://github.com/nrfconnect/sdk-nrf/blob/main/tests/crypto/README.rst This C function, exec_test_case_hmac, demonstrates the initialization, setup, and execution of HMAC operations using the mbedtls library. It includes steps for starting the HMAC computation, updating it with input data, finalizing the process, and verifying the output against expected results. Error handling and time measurement are also incorporated. ```c void exec_test_case_hmac(void) { int err_code = -1; /* Initialize the HMAC module. */ mbedtls_md_init(&md_context); const mbedtls_md_info_t *p_md_info = mbedtls_md_info_from_type(p_test_vector->digest_type); err_code = mbedtls_md_setup(&md_context, p_md_info, 1); if (err_code != 0) { LOG_WRN("mb setup ec: -0x%02X", -err_code); } TEST_VECTOR_ASSERT_EQUAL(err_code, 0); start_time_measurement(); err_code = mbedtls_md_hmac_starts(&md_context, m_hmac_key_buf, key_len); TEST_VECTOR_ASSERT_EQUAL(err_code, 0); err_code = mbedtls_md_hmac_update(&md_context, m_hmac_input_buf, in_len); TEST_VECTOR_ASSERT_EQUAL(err_code, 0); /* Finalize the HMAC computation. */ err_code = mbedtls_md_hmac_finish(&md_context, m_hmac_output_buf); stop_time_measurement(); TEST_VECTOR_ASSERT_EQUAL(p_test_vector->expected_err_code, err_code); /* Verify the generated HMAC. */ TEST_VECTOR_ASSERT_EQUAL(expected_hmac_len, hmac_len); TEST_VECTOR_MEMCMP_ASSERT(m_hmac_output_buf, m_hmac_expected_output_buf, expected_hmac_len, p_test_vector->expected_result, "Incorrect hmac"); mbedtls_md_free(&md_context); } ``` -------------------------------- ### Initialize Light xyL Server with Light HSL Server (C) Source: https://github.com/nrfconnect/sdk-nrf/blob/main/doc/nrf/libraries/bluetooth/mesh/light_xyl_srv.rst Illustrates the initialization of Light xyL Server, Light HSL Server, and their associated models (Light Lightness, Light Hue, Light Saturation) across multiple elements. This configuration allows independent control of hue and saturation while sharing a single Light Lightness Server instance. ```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(&lightness_srv, &hue_cb, &sat_cb); static struct bt_mesh_light_xyl_srv xyl_srv = BT_MESH_LIGHT_XYL_SRV_INIT(&lightness_srv, &xyl_handlers); static struct bt_mesh_elem elements[] = { BT_MESH_ELEM( 1, BT_MESH_MODEL_LIST( BT_MESH_MODEL_LIGHTNESS_SRV(&lightness_srv), BT_MESH_MODEL_LIGHT_HSL_SRV(&hsl_srv), BT_MESH_MODEL_LIGHT_XYL_SRV(&xyl_srv)), BT_MESH_MODEL_NONE), BT_MESH_ELEM( 2, BT_MESH_MODEL_LIST(BT_MESH_MODEL_LIGHT_HUE_SRV(&hsl_srv.hue)), BT_MESH_MODEL_NONE), BT_MESH_ELEM( 3, BT_MESH_MODEL_LIST(BT_MESH_MODEL_LIGHT_SAT_SRV(&hsl_srv.sat)), BT_MESH_MODEL_NONE), }; ``` -------------------------------- ### CMake: Install Test Directory for nRF9161dk Source: https://github.com/nrfconnect/sdk-nrf/blob/main/modules/trusted-firmware-m/tfm_boards/nrf9120/CMakeLists.txt Installs the 'tests' directory from the nRF9161dk platform into the installation path. This makes the test suite for this specific development kit available after installation. ```cmake install(DIRECTORY ${Trusted\ Firmware\ M_SOURCE_DIR}/platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/tests DESTINATION ${INSTALL_PLATFORM_NS_DIR} ) ``` -------------------------------- ### Build SMP Server Sample with Configuration Source: https://github.com/nrfconnect/sdk-nrf/blob/main/samples/dfu/smp_svr/README.rst Builds the SMP server sample using a specified configuration from the sample.yaml file. This command allows for flexible build targets and configurations. ```console west build -b -T ./ ```