How to build Thread application based on Coap messages.
Connectivity, 802.15.4 protocol, Thread, COAP
This example runs on STM32WBA55xx devices.
This example has been tested with an STMicroelectronics STM32WBA55CGA_Nucleo board and can be easily tailored to any other supported device and development board.
In order to make the program work, you must do the following:
Note: when LED1, LED2 and LED3 are toggling it is indicating an error has occurred on application.
If you want to control this application, you can directly send and retrieve Cli commands connecting an HyperTerminal with the FTDI cable as following :
In a Thread network, nodes are split into two forwarding roles: Router or End Device.
The Thread Leader is a Router that is responsible for managing the set of Routers in a Thread network.
An End Device (or child) communicates primarily with a single Router.
In our Application which uses two devices, one device will act as a Leader (Router) and the other one will act as an End Device(mode child).
After the reset of the 2 boards, one board will be in Leader mode (Green LED2 ON).
The other one will be in Child mode (Red LED3 ON).
Let’s name indifferently one board A and one board B.
Same COAP commands can be sent from board B to board A.
___________________________ ___________________________ | Device A | | Device B | |_________________________| |_________________________| | | | | | | | | | SW1 --> |======> COAP =========>| BLUE LED TOGGLE (ON/OFF)| | | Resource "light" | | | | Mode: Multicast | | | | Type: Non-Confirmable | | | | Code: Put | | | | | | | | | | | SW2 --> |=====> COAP ==========>|--------> | | | Resource "light" | | | | | Mode: Multicast | CoapRequestHandler() | | | Type: Confirmable | | | | | Code: Put | | | | | | v | | | | CoapSendDataResponse() | | | | | | | | | v | | CoapDataRespHandler()<--|<===== COAP <==========| <------- | | | | BLUE LED TOGGLE (ON/OFF)| | | | | --------------------------- --------------------------- | Role : Child | | Role : Leader | | | | | | LED : Red | | LED : Green | | | | | |_________________________| |_________________________|
To get the traces you need to connect your Board to the Hyperterminal (through the STLink Virtual COM Port).
The UART must be configured as follows:
BaudRate = 115200 baud Word Length = 8 Bits Stop Bit = 1 bit Parity = none Flow control = none Terminal “Go to the Line” : <LF>