This information applies to the nRF52840 SoC only.
This example demonstrates the usage of the IEEE 802.15.4 MAC library.
You can use the Wireless UART example to transmit and receive data between two nodes in a simple point-point wireless network. Both nodes have addresses defined at compile-time and are referred to as first and second devices. There are 2 versions of this example:
- Secure: all RF communication is secured
- Raw: no security is used
Example overview
Both of these devices work in exactly the same way, but their short addresses are different.
The devices operate in event-driven manner and their finite state machines are specified in the fsm.c
. Operation of each device consists of two main parts:
- Initialization mode: During the initialization phase, the device makes necessary calls into the FullMAC stack in order to configure it. After it is configured, the device switches to working mode.
- Working mode: In this mode, the device starts to listen both to UART and to the radio, waiting for incoming packets.
Incoming packets - UART
When a byte from UART is received, the device creates a MAC Common Part Layer (MCPS) Data request to the other device and includes the received information as a MAC Service Data Unit (MSDU - data payload). Then, the device waits until a confirmation of this request is received. If the confirmation status field contains an error, the device retries the request until a successful status is received.
Incoming packets - radio
The incoming radio frames are stored in a queue. When this queue is filled or when the previous UART transmission is completed, the device pops the next frame from the queue and puts its MSDU payload into the UART output buffer.
Setup
You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\802_15_4\wireless_uart
LED assignments:
- LED 1 is turned on when initialization is completed.
- LED 2 is turned on when the device sends data through the radio and turns off after receiving a confirmation.
- LED 3 is turned on when the device sends data through UART and turns off after this action is completed.
- LED 4 is turned on when an error occurs.
Testing
- Build and program a development board with the Wireless UART application. You can find the relevant project file in one of the following folders, depending on if you want to use raw or secure communication:
<InstallFolder>\examples\802_15_4\wireless_uart\raw\first
or <InstallFolder>\examples\802_15_4\wireless_uart\secure\first
.
- Start a terminal emulator like PuTTY and configure it according to the following parameters:
- Serial port number - use the one that was assigned to the development board by the operating system. You can refer to board installation instructions for information on how to find this number.
- Baud rate - 38400
- Data bits - 8
- Parity - None
- Stop bits - 1
- Flow control - RTS/CTS
- Note
- The flow control setting is crucial for correct operation of the application. These hardware pins are used by the device to control data congestion and loss due to sporadic failures on the wireless link.
- Repeat steps 1 and 2 with another development board using the project file in one of the following folders (use the version corresponding to the one you used on the first board):
<InstallFolder>\examples\802_15_4\wireless_uart\raw\second
or <InstallFolder>\examples\802_15_4\wireless_uart\secure\second
.
- Initiate the transmission by typing some data in the terminal or by sending a small file over the wireless link.
- Note
- Besides the user payload, each wireless frame holds an 8-bit application layer counter. This allows the Wireless UART application to ensure that no data frames are lost during transmission.