Device Under Test (DUT)

This sample demonstrates how to use Sidewalk Device Under Test for the testing and evaluation purposes.

Configuration options

Before building the Device Under Test application variant of the Sidewalk end device, ensure you have enabled the OVERLAY_CONFIG="overlay-dut.conf" configuration.

  • CONFIG_SIDEWALK – Enables support for the Sidewalk protocol and its dependencies.

  • CONFIG_SIDEWALK_SUBGHZ_SUPPORT – Enables using Sidewalk libraries with Bluetooth LE, LoRa and FSK support. Disabling this option results in using Sidewalk libraries with only Bluetooth LE support. While this results in a smaller memory footprint for the application, it also limits its functionality, as connectivity over LoRa or FSK is not available.

  • CONFIG_SIDEWALK_DFU – Enables the nRF Connect SDK bootloader and DFU service over Bluetooth LE.

  • Application variant is selected by the SID_END_DEVICE Kconfig choice (mutually exclusive options below).

    • CONFIG_SID_END_DEVICE_HELLO – Enables the Hello Sidewalk application. This is the default option. For more details, see the Hello Sidewalk page.

    • CONFIG_SID_END_DEVICE_SENSOR_MONITORING – Enables the Sidewalk Sensor monitoring application. For more details, see the Sensor monitoring page.

    • CONFIG_SID_END_DEVICE_DUT – Enables the Sidewalk device under test application. For more details, see the Device Under Test (DUT) page.

  • CONFIG_SID_END_DEVICE_CLI – Enables Sidewalk CLI. To see the list of available commands, flash the sample and type sid help.

  • CONFIG_SIDEWALK_ON_DEV_CERT – Enables the on-device certification Shell.

  • CONFIG_SIDEWALK_CRYPTO_PSA_KEY_STORAGE - Enables secure storage for persistent Sidewalk keys.

  • CONFIG_SIDEWALK_MFG_STORAGE_SUPPORT_HEX_v7 - Enables support for Sidewalk manufacturing HEX in version 7 and below.

  • CONFIG_SID_END_DEVICE_AUTO_START – Enables an automatic Sidewalk initialization and start.

  • CONFIG_SID_END_DEVICE_AUTO_CONN_REQ – Enables an automatic connection request before sending a message. If needed, the Bluetooth LE connection request is sent automatically.

  • CONFIG_SID_END_DEVICE_PERSISTENT_LINK_MASK - Enables persistent link mask.

  • CONFIG_SID_END_DEVICE_LINK_MASK - Choose the default physical link type for Sidewalk connection to start with

    • CONFIG_SID_END_DEVICE_LINK_MASK_BLE – Choose Bluetooth Low Energy link.

    • CONFIG_SID_END_DEVICE_LINK_MASK_FSK – Choose Sub-GHz link for FSK.

    • CONFIG_SID_END_DEVICE_LINK_MASK_LORA – Choose Sub-GHz link for LORA.

    • CONFIG_SIDEWALK_LINK_MASK_LORA – Choose Sub-GHz link for LORA.

Building and running

This sample can be found under samples/sid_end_device.

Note

Before you flash your Sidewalk sample, make sure you have completed the following:

This step needs to be completed only once. You do not have to repeat it for every sample rebuild.

For general instructions on building the sample, follow the steps in the Building and programming an application documentation.

You can also build the sample with specific configurations:

  • For Bluetooth LE only operation, use the default build commands.

     west build -b board_target
  • For sub-GHz (LoRa and FSK) operation, use the --shield option with west build. This configures the correct device tree overlays and pin mappings for the Semtech radio shield, and enables the correct Sidewalk radio configuration.

    west build -b nrf54l15dk/nrf54l15/cpuapp --shield nrf54l15dk_arduino_adapter --shield semtech_sx1262mb2cas
    
  • For sub-GHz (LoRa and FSK) operation and location scanning over WiFi and GNSS, use the lr1110mb1lcks shield.

    west build -b nrf54l15dk/nrf54l15/cpuapp --shield simple_arduino_adapter --shield semtech_lr1110mb1xxs
    

Testing

  1. After successfully building and flashing, the sample is ready to use. You should see the command-line prompt uart:~$. Rub sid help to get the list of supported Sidewalk commands.

    uart:~$ sid help
    
  2. Initialize Sidewalk in the desired transport mode:

    Note

    To use sub-GHz radio, you need to connect radio over SPI, and build the Sidewalk application with LoRa and FSK library variant.

    1. For Bluetooth LE only mode, run:

      uart:~$ sid init 1
      
    2. For sub-GHz radio, run:

      uart:~$ sid init 7
      

      Use 2 for FSK, 4 for Bluetooth LE and LoRa, and 7 for all transports. For more available options see sid help.

  3. Start the Sidewalk stack

    uart:~$ sid start
    
  4. Wait for Sidewalk to be ready

    <inf> app: Status changed: ready
    
  5. Send message to cloud.

    You can use AWS IoT MQTT client to view the received and republished messages from the device.

    1. Enter # and click Subscribe to topic. You are now subscribed to the republished device messages.

    2. To see the data republished into the subscribed MQTT topic, use the send command:

      uart:~$ sid send test_message
      <inf> app: Message send success
      

    You should see the message data in the base64 format:

    {
       "MessageId": "4c5dadb3-2762-40fa-9763-8a432c023eb5",
       "WirelessDeviceId": "5153dd3a-c78f-4e9e-9d8c-3d84fabb8911",
       "PayloadData": "MDA=",
       "WirelessMetadata": {
          "Sidewalk": {
             "CmdExStatus": "COMMAND_EXEC_STATUS_UNSPECIFIED",
             "MessageType": "CUSTOM_COMMAND_ID_NOTIFY",
             "NackExStatus": [],
             "Seq": 2,
             "SidewalkId": "BFFFFFFFFF"
          }
       }
    }
    

    You can use last_status to check if your device is connected to the cloud. At least one Link status must be Up.

    uart:~$ sid last_status
    <inf> sid_cli: Device Is registered, Time Sync Success, Link status: {BLE: Up, FSK: Down, LoRa: Down}
    <inf> sid_cli: Link mode on BLE = {Cloud: True, Mobile: False}
    
    1. When operating in Bluetooth LE mode, if Sidewalk is not ready, initiate a Bluetooth LE connection every time you need to send a message.

      <inf> app: Status changed: not ready
      <inf> app: Device Is registered, Time Sync Success, Link status: {BLE: Down, FSK: Down, LoRa: Down}
      uart:~$ sid conn_req 1
      <inf> sid_cli: sid_conn_request returned 0 (SID_ERROR_NONE)
      <inf> sid_ble_conn: BT Connected
      <inf> app: Status changed: ready
      <inf> app: Device Is registered, Time Sync Success, Link status: {BLE: Up, FSK: Down, LoRa: Down}
      uart:~$ sid send test_message
      <inf> app: Message send success
      
  6. Receive message from cloud.

Receiving message from AWS MQTT

  1. To be able to use AWS CLI, you must first complete Installing or updating the latest version of the AWS CLI.

  2. Run the following command to send a message to your Sidewalk Endpoint:

    aws iotwireless send-data-to-wireless-device --id=<wireless-device-id> --transmit-mode 0 --payload-data="<payload-data>" --wireless-metadata "Sidewalk={Seq=<sequence-number>}"
    
    • <wireless-device-id> is the Wireless Device ID of your Sidewalk Device.

      You can find it in the WirelessDevice.json file, generated with the Nordic_MFG.hex file during Setting up your Sidewalk prototype. If you have sent a message before, you can also find your Wireless Device ID in the messages sent from your device to AWS.

    • <payload-data> is base64 encoded.

    • <sequence-number> is an integer and should be different for each subsequent request.

  3. Prepare a message payload in the base64 format by running the following command:

    python -c "import sys,base64;print(base64.b64encode(sys.argv[1].encode('utf-8')).decode('utf-8'))" "Hello Sidewalk!"
    SGVsbG8gU2lkZXdhbGsh
    
  4. Increase a sequence number on every message. The device will not receive a message with lower or equal sequence number.

    Once you have populated the command with data, it should look similar to the following:

    aws iotwireless send-data-to-wireless-device --id=5153dd3a-c78f-4e9e-9d8c-3d84fabb8911 --transmit-mode 0 --payload-data="SGVsbG8gU2lkZXdhbGsh" --wireless-metadata "Sidewalk={Seq=1}"
    

    Successfully sent response should look as follows:

    {
        "MessageId": "eabea2c7-a818-4680-8421-7a5fa322460e"
    }
    

    In case you receive the following error, make sure your IAM user or role has permissions to send data to your wireless device:

    {
       "Message": "User: arn:aws:iam::[AWS Account ID]:user/console_user is not authorized to perform:
       iotwireless:SendDataToWirelessDevice on resource: arn:aws:iotwireless:us-east-1:[AWS Account ID]:
       WirelessDevice/[Wireless Device ID]"
    }
    

    Data will be received in Sidewalk logs:

    [00:06:56.338,134] <inf> sid_thread: Message data:
                                  48 65 6c 6c 6f 20 20 20  53 69 64 65 77 61 6c 6b |Hello    Sidewalk
                                  21                                               |!
    

Testing Location Services

  1. Initialize and start a Sidewalk stack (for example, for Bluetooth LE and LoRa support):

    uart:~$ sid init 4
    uart:~$ sid start
    
  2. Initialize location services:

    uart:~$ location init
    <inf> location_shell_events: location_event_init returned 0
    <inf> location_shell_events: loc send result: 0
    <inf> location_shell_events: loc effort mode: 0
    <inf> location_shell_events: loc link type: 0
    

    You should see a log message with a success status. It may take a few seconds to get location stats (effort mode, link type).

  3. Send the location depending on the protocol used:

    1. For the Bluetooth LE location, check its Link status. Send conn_req if Bluetooth LE link is not Up.

      uart:~$ sid last_status
      <inf> sid_cli: Device Is registered, Time Sync Success, Link status: {BLE: Down, FSK: Down, LoRa: Down}
      uart:~$ sid conn_req 1
      <inf> sid_cli: sid_conn_request returned 0 (SID_ERROR_NONE)
      <inf> sid_ble_conn: BT Connected
      <inf> app: Status changed: ready
      <inf> app: Device Is registered, Time Sync Success, Link status: {BLE: Up, FSK: Down, LoRa: Down}
      

      Send location to cloud based on the current Bluetooth LE connection.

      uart:~$ location send 1
      <inf> location_shell_events: loc send result: 0
      <inf> location_shell_events: loc effort mode: 1
      <inf> location_shell_events: loc link type: 1
      <inf> location_shell_events: location_event_send mode: 1, returned 0
      
    2. For Wi-Fi and GNSS location, ensure that the required LR1110 radio hardware is connected.

      Note

      To perform a Wi-Fi or GNSS scan, more time is required. It may take up to a few minutes to send location data depending on the signal strength.

      Use 3 for Wi-Fi and 4 for GNSS.

      uart:~$ location send 3
      <inf> sidewalk: mw_wifi_scan_add_task: add task in supervisor at 2393 + 0 s
      <inf> sidewalk: mw_wifi_scan_service_on_launch
      <inf> sidewalk: RP: Task #3 enqueue with #11 priority
      <inf> sidewalk: Enqueued RP task for Wi-Fi scan (hook_id #3)
      <inf> sidewalk: mw_wifi_scan_service_on_update
      <inf> location_shell_events: location_event_send mode: 3, returned 0
      <inf> sidewalk: sid_pal_hold
      <inf> sidewalk: INFO: Wi-Fi task launch at 2394270
      <inf> sidewalk:
      <inf> sidewalk: INFO: wifi_rp_task_done at 2396937 (duration:2667 ms)
      <inf> sidewalk:
      <inf> sidewalk: Filter and Sort Wi-Fi results:
      <inf> sidewalk: Raw data:
      <inf> sidewalk: 1A 2B 3C 4D 5E 6F  -- Channel: 1 -- Type: 1 -- RSSI: -86 -- Origin: FIXED
      <inf> sidewalk: AA BB CC 00 11 22  -- Channel: 1 -- Type: 1 -- RSSI: -92 -- Origin: FIXED
      <inf> sidewalk: 01 23 45 67 89 AB  -- Channel: 6 -- Type: 1 -- RSSI: -90 -- Origin: FIXED
      <inf> sidewalk: AA BB CC 00 11 22  -- Channel: 6 -- Type: 1 -- RSSI: -82 -- Origin: UNKNOWN
      <inf> sidewalk: A0 B1 C2 D3 E3 F4  -- Channel: 9 -- Type: 1 -- RSSI: -93 -- Origin: FIXED
      <inf> sidewalk: 11 AA 22 BB 33 DD  -- Channel: 9 -- Type: 1 -- RSSI: -84 -- Origin: FIXED
      <inf> sidewalk: AB 00 CD 11 EF 22  -- Channel: 9 -- Type: 1 -- RSSI: -86 -- Origin: FIXED
      <inf> sidewalk: A0 B0 C0 D0 E0 F0  -- Channel: 2 -- Type: 2 -- RSSI: -80 -- Origin: UNKNOWN
      <inf> sidewalk:
      <inf> sidewalk: filtered data:
      <inf> sidewalk: 1A 2B 3C 4D 5E 6F  -- Channel: 1 -- Type: 1 -- RSSI: -86 -- Origin: FIXED
      <inf> sidewalk: AA BB CC 00 11 22  -- Channel: 1 -- Type: 1 -- RSSI: -92 -- Origin: FIXED
      <inf> sidewalk: 01 23 45 67 89 AB  -- Channel: 6 -- Type: 1 -- RSSI: -90 -- Origin: FIXED
      <inf> sidewalk: A0 B1 C2 D3 E3 F4  -- Channel: 9 -- Type: 1 -- RSSI: -93 -- Origin: FIXED
      <inf> sidewalk: 11 AA 22 BB 33 DD  -- Channel: 9 -- Type: 1 -- RSSI: -84 -- Origin: FIXED
      <inf> sidewalk: AB 00 CD 11 EF 22  -- Channel: 9 -- Type: 1 -- RSSI: -86 -- Origin: FIXED
      <inf> sidewalk:
      <inf> sidewalk: Sorted data:
      <inf> sidewalk: 11 AA 22 BB 33 DD  -- Channel: 9 -- Type: 1 -- RSSI: -84 -- Origin: FIXED
      <inf> sidewalk: 1A 2B 3C 4D 5E 6F  -- Channel: 1 -- Type: 1 -- RSSI: -86 -- Origin: FIXED
      <inf> sidewalk: AB 00 CD 11 EF 22  -- Channel: 9 -- Type: 1 -- RSSI: -86 -- Origin: FIXED
      <inf> sidewalk: 01 23 45 67 89 AB  -- Channel: 6 -- Type: 1 -- RSSI: -90 -- Origin: FIXED
      <inf> sidewalk: AA BB CC 00 11 22  -- Channel: 1 -- Type: 1 -- RSSI: -92 -- Origin: FIXED
      <inf> sidewalk:
      <inf> sidewalk: Event Received: SMTC_MODEM_EVENT_WIFI_SCAN_DONE
      <inf> sidewalk: SCAN_DONE info:
      <inf> sidewalk: -- number of results: 5
      <inf> sidewalk: -- power consumption: 8194 nah
      <inf> sidewalk: -- scan duration: 2905 ms
      <inf> sidewalk: 11 AA 22 BB 33 DD  -- Channel: 9 -- Type: 1 -- RSSI: -84 -- Origin: FIXED
      <inf> sidewalk: 1A 2B 3C 4D 5E 6F  -- Channel: 1 -- Type: 1 -- RSSI: -86 -- Origin: FIXED
      <inf> sidewalk: AB 00 CD 11 EF 22  -- Channel: 9 -- Type: 1 -- RSSI: -86 -- Origin: FIXED
      <inf> sidewalk: 01 23 45 67 89 AB  -- Channel: 6 -- Type: 1 -- RSSI: -90 -- Origin: FIXED
      <inf> sidewalk: AA BB CC 00 11 22  -- Channel: 1 -- Type: 1 -- RSSI: -92 -- Origin: FIXED
      <inf> sidewalk:
      <inf> sidewalk: Event Received: SMTC_MODEM_EVENT_WIFI_SCAN_DONE
      <inf> sidewalk: SCAN_DONE info:
      <inf> sidewalk: -- number of results: 5
      <inf> sidewalk: -- power consumption: 8353 nah
      <inf> sidewalk: -- scan duration: 2667 ms
      <inf> sidewalk:
      <inf> sidewalk: mw_wifi_send_add_task: add task in supervisor
      <inf> sidewalk: mw_wifi_send_add_task: no scan to be sent
      <inf> sidewalk: Event Received: SMTC_MODEM_EVENT_WIFI_TERMINATED
      <inf> sidewalk: Calling _app_event_lbm_wifi
      <inf> location_shell_events: loc send result: 0
      <inf> location_shell_events: loc effort mode: 3
      <inf> location_shell_events: loc link type: 1
      <inf> location_shell_events: loc payload:
      <inf> location_shell_events: loc payload
                        da 11 aa 22 bb 33 dd be  a0 b0 c0 d0 e0 f0 af ab
                        00 cd 11 ef 22 01 23 45  67 89 ab 63 a5 aa bb cc
                        00 11 22
      <inf> sidewalk: _app_event_lbm_wifi completed
      <inf> sidewalk: rp_hook_callback task WIFI state RP_TASK_STATE_FINISHED
      <inf> sidewalk: sid_pal_release
      

      If you only need to perform a scan without sending your location to the cloud, you can test your location using the scan command:

      uart:~$ location scan 3
      

    Check the MQTT topic used as Location Destination in AWS IoT MQTT client. You should see the location data in the following format:

    {
       "coordinates": [
          13.37607669,
          52.51823043,
          0
       ],
       "WirelessDeviceId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
       "type": "Point",
       "properties": {
          "verticalAccuracy": 0,
          "horizontalAccuracy": 100,
          "timestamp": "YYYY-MM-DDTHH:MM:SS.ZZZ"
       }
    }
    

    If you cannot see the coordinates message, refer to the Troubleshooting.