-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
samples: 802154_sniffer: Add 802154_sniffer sample
The sniffer sample allows the user to capture IEEE 802.15.4 packets in real time using the Wireshark protocol analyzer. The sample integrates with the nRF Sniffer for 802.15.4 extcap tool available on NordicSemiconductor GitHub respository. https://github.com/NordicSemiconductor/nRF-Sniffer-for-802.15.4 Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
- Loading branch information
Showing
11 changed files
with
439 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# Copyright (c) 2023 Nordic Semiconductor | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(802154_sniffer) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
.. _802154_sniffer: | ||
|
||
IEEE 802.15.4 Sniffer | ||
##################### | ||
|
||
.. contents:: | ||
:local: | ||
:depth: 2 | ||
|
||
The IEEE 802.15.4 Sniffer listens to a selected IEEE 802.15.4 channel (2.4GHz O-QPSK with DSSS) and integrates with the nRF 802.15.4 sniffer extcap for Wireshark. | ||
|
||
Requirements | ||
************ | ||
|
||
The sample supports the following development kits: | ||
|
||
.. table-from-sample-yaml:: | ||
|
||
The application can be used with the `nRF Sniffer for 802.15.4`_ extcap utility for the `Wireshark`_ network protocol analyzer. | ||
|
||
Overview | ||
******** | ||
|
||
The application presents the user with a command-line interface. | ||
|
||
See the :ref:`802154_sniffer_commands` for the list of the available commands. | ||
|
||
LED 1: | ||
When the capture is stopped the LED blinks with a period of 2 seconds with 50% duty cycle. | ||
When the capture is ongoing the LED blinks with a period of 0.5 seconds with 50% duty cycle. | ||
|
||
LED 4: | ||
When the sniffer captures a packet the LED is toggled on and off. | ||
|
||
.. _802154_sniffer_commands: | ||
|
||
Serial commands list | ||
******************** | ||
|
||
This section lists the serial commands that are supported by the sample. | ||
|
||
channel - Change the radio channel | ||
================================== | ||
|
||
The command changes the IEEE 802.15.4 radio channel to listen on. | ||
|
||
.. parsed-literal:: | ||
:class: highlight | ||
channel *<channel>* | ||
The ``<channel>`` argument is an integer in the range between 11 and 26. | ||
|
||
For example: | ||
|
||
.. parsed-literal:: | ||
:class: highlight | ||
channel *23* | ||
receive - start capturing packets | ||
================================= | ||
|
||
The ``receive`` command makes the sniffer enter the RX state and start capturing packets. | ||
|
||
.. parsed-literal:: | ||
:class: highlight | ||
receive | ||
The received packets will be printed to the command-line with the following format: | ||
|
||
.. parsed-literal:: | ||
:class: highlight | ||
received: *<data>* power: *<power>* lqi: *<lqi>* time: *<timestamp>* | ||
* The ``<data>`` is a hexidecimal string representation of the received packet. | ||
* The ``<power>`` value is the signal power in dBm. | ||
* The ``<lqi>`` value is the IEEE 802.15.4 Link Quality Indicator. | ||
* The ``<timestamp>`` value is the absolute time of the received packet since the sniffer booted. | ||
|
||
sleep - stop capturing packets | ||
============================== | ||
|
||
The ``sleep`` command disables the radio and ends the receive process. | ||
|
||
.. parsed-literal:: | ||
:class: highlight | ||
sleep | ||
Configuration | ||
************* | ||
|
||
|config| | ||
|
||
Building and running | ||
******************** | ||
|
||
.. |sample path| replace:: :file:`samples/peripheral/802154_sniffer` | ||
|
||
.. include:: /includes/build_and_run.txt | ||
|
||
.. _802154_sniffer_testing: | ||
|
||
Testing the sample | ||
================== | ||
|
||
After programming the sample to your development kit, complete the following steps to test it: | ||
|
||
1. Connect the development kit to the computer using a USB cable. | ||
Use the development kit's nRF USB port (**J3**). | ||
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| | ||
#. Switch to a radio channel with an ongoing radio traffic: | ||
|
||
.. parsed-literal:: | ||
:class: highlight | ||
channel *23* | ||
#. Start the capture process: | ||
|
||
.. parsed-literal:: | ||
:class: highlight | ||
receive | ||
The **LED 1** will start blinking with shorter intervals. | ||
|
||
#. If there is radio traffic on the selected channel, the sniffer should print the captured packets: | ||
|
||
.. parsed-literal:: | ||
:class: highlight | ||
received: 49a85d41a5fffff4110f10270000369756e65619d09428a04b301951821db234460aa5ec4ff506631ef8adb22674683700 power: -39 lqi: 220 time: 15822687 | ||
The **LED 4** will toggle its state when a frame is received. | ||
|
||
#. Disable the capture: | ||
|
||
.. parsed-literal:: | ||
:class: highlight | ||
sleep | ||
The **LED 1** will start blinking with longer intervals. | ||
|
||
Dependencies | ||
************ | ||
|
||
This sample uses the following `sdk-nrfxlib`_ libraries: | ||
|
||
* :ref:`nrfxlib:mpsl` | ||
* :ref:`nrfxlib:nrf_802154` | ||
|
||
This sample uses the following |NCS| libraries: | ||
|
||
* :ref:`dk_buttons_and_leds_readme` | ||
|
||
This sample uses the following Zephyr libraries: | ||
|
||
* :ref:`zephyr:kernel_api`: | ||
|
||
* :file:`include/zephyr/kernel.h` | ||
* :file:`include/zephyr/sys/util.h` | ||
|
||
* :ref:`zephyr:ieee802154_interface`: | ||
|
||
* :file:`include/zephyr/net/ieee802154_radio.h` | ||
|
||
* :ref:`zephyr:shell_api`: | ||
|
||
* :file:`include/zephyr/shell/shell.h` | ||
* :file:`include/zephyr/shell/shell_uart.h` |
17 changes: 17 additions & 0 deletions
17
samples/peripheral/802154_sniffer/boards/nrf52840dk_nrf52840.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/ { | ||
chosen { | ||
zephyr,shell-uart = &cdc_acm_uart0; | ||
}; | ||
}; | ||
|
||
&zephyr_udc0 { | ||
cdc_acm_uart0: cdc_acm_uart0 { | ||
compatible = "zephyr,cdc-acm-uart"; | ||
}; | ||
}; |
17 changes: 17 additions & 0 deletions
17
samples/peripheral/802154_sniffer/boards/nrf52840dongle_nrf52840.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/ { | ||
chosen { | ||
zephyr,shell-uart = &cdc_acm_uart0; | ||
}; | ||
}; | ||
|
||
&zephyr_udc0 { | ||
cdc_acm_uart0: cdc_acm_uart0 { | ||
compatible = "zephyr,cdc-acm-uart"; | ||
}; | ||
}; |
17 changes: 17 additions & 0 deletions
17
samples/peripheral/802154_sniffer/boards/nrf5340dk_nrf5340_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/ { | ||
chosen { | ||
zephyr,shell-uart = &cdc_acm_uart0; | ||
}; | ||
}; | ||
|
||
&zephyr_udc0 { | ||
cdc_acm_uart0: cdc_acm_uart0 { | ||
compatible = "zephyr,cdc-acm-uart"; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Enabling radio driver | ||
CONFIG_NETWORKING=y | ||
CONFIG_IEEE802154=y | ||
CONFIG_IEEE802154_RAW_MODE=y | ||
CONFIG_NET_PKT_TIMESTAMP=y | ||
|
||
# Allow sharing the RTC between IEEE 802.15.4 and Zephyr | ||
CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=3 | ||
|
||
# Shell configuration | ||
CONFIG_SHELL=y | ||
CONFIG_SHELL_PROMPT_UART="" | ||
CONFIG_SHELL_VT100_COLORS=n | ||
|
||
# LED indication | ||
CONFIG_DK_LIBRARY=y | ||
|
||
# USB configuration | ||
CONFIG_USB_DEVICE_STACK=y | ||
CONFIG_USB_DEVICE_MANUFACTURER="Nordic Semiconductor ASA" | ||
CONFIG_USB_DEVICE_PRODUCT="nRF 802154 Sniffer" | ||
CONFIG_USB_DEVICE_VID=0x1915 | ||
CONFIG_USB_DEVICE_PID=0x154b | ||
CONFIG_SHELL_BACKEND_SERIAL_CHECK_DTR=y | ||
CONFIG_UART_LINE_CTRL=y | ||
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51 | ||
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
sample: | ||
description: IEEE 802.15.4 Sniffer sample | ||
name: IEEE 802.15.4 Sniffer | ||
tests: | ||
sample.peripheral.802154_sniffer: | ||
build_only: true | ||
integration_platforms: | ||
- nrf52840dk_nrf52840 | ||
- nrf52840dongle_nrf52840 | ||
- nrf5340dk_nrf5340_cpuapp | ||
platform_allow: nrf52840dk_nrf52840 nrf52840dongle_nrf52840 nrf5340dk_nrf5340_cpuapp | ||
tags: ci_build |
Oops, something went wrong.