10.2.1.4 CoAP Demo Application
This demo requires two WBZ451 Curiosity boards and a Serial terminal software (eg. Tera Term). Hex files for the demo are available as part of the Apps repository.
Users can also generate hex files by building the demo applications. Before building the SED
client and server applications, user need to modify app_thread.c
file by following the step 17 mentioned in topic ‘Project Generation with Thread CoAP MCC
Component’. Applications are located in the Apps repository at the following path:
wireless_apps_pic32cxbz2_wbz45\apps\thread\advanced_applications\CoAP
.
To generate the demo applications and the hex files from scratch, please follow the steps outlined in the topic ‘Project Generation with Thread CoAP MCC Component’. Additionally, include or replace the following files from their respective project source folders in the specified path of the Apps repository: wireless_apps_pic32cxbz2_wbz45\apps\thread\advanced_applications\CoAP
- app_coap.c
- app_thread.c
- app_thread.h
- app_timer.c
- app_timer.h
- app_error_defs.h
- app_led.c
- app_led.h
- app.c
- app.h
For coap_ftd_client, user have to include following files additionally.
- app_key.c
- app_key.h
Follow the steps below to run the demo applications.
Demonstration for FTD Server and SED Client:
This demo demonstrates the usage of the CoAP SED client. The client wakes up periodically through RTC or via button press, sending CoAP requests to the CoAP FTD server to control LED resource.
Flow of transactions between an SED client and an FTD server on Button wake up
Flow of transactions between an SED client and an FTD server on Auto wake up
-
Hex File Download: Download the FTD server hex file and the SED client hex file onto two separate boards. Hex files can be found in the following path within Apps repository
wireless_apps_pic32cxbz2_wbz45\apps\thread\advanced_applications\CoAP\coap_ftd_server\hex
for FTD server andwireless_apps_pic32cxbz2_wbz45\apps\thread\advanced_applications\CoAP\coap_sed_client\hex
for SED client . -
Thread Network Formation: Wait until the blue LED stops flashing to establish a thread network. The FTD board becomes the leader, and the SED board becomes the child in the network.
-
PUT Request on Button Wake-Up: With button wake-up, the SED board automatically sends a PUT request.
-
Request Reception and LED Indicators: The FTD board receives the PUT request, causing its Green RGB LED to toggle. Subsequently, the FTD board sends an acknowledgment (ACK) to the SED board.
-
GET Request: After receiving the ACK, the SED board initiates a GET request. Additionally, the active timer resets during this stage to 4 seconds.
-
Response Transmission: The FTD board responds to the GET request by sending the required data.
-
Transaction Completion Indicator: Upon receiving the response, the SED board's Green RGB LED turns on. The LED turns off when the SED board enters sleep mode when the active timer times out.
-
PUT Request on Auto Wake-Up: With Auto wake-up, the SED board automatically sends a PUT request periodically.
-
Request Reception and LED Indicators: The FTD board receives the PUT request, causing its Green RGB LED to toggle. Subsequently, the FTD board sends an acknowledgment (ACK) to the SED board.
-
Transaction Completion: The SED receives the ACK. The SED board enters sleep mode when the active timer times out.
Note:
- The SED board follows a sleep period of 10 seconds and remains active for 4 to 8 seconds after waking up.
- The active timer resets in step 5, providing the necessary time for the completion of the GET request packet transaction.
SED client console (UART baud settings: 115200 8-N-1 without flow control):
FTD server console(UART baud settings: 115200 8-N-1 without flow control):
Demonstration for FTD Client and SED Server:
This demo demonstrates the usage of the CoAP SED server. The server periodically wakes up through RTC and receives CoAP requests from the CoAP FTD client to control LED resource.
Flow of transactions between an FTD client and an SED server.
-
Download Hex Files: Download the FTD client hex file and the SED server hex file onto two separate boards. Hex files can be found in the following path within Apps repository
wireless_apps_pic32cxbz2_wbz45\apps\thread\advanced_applications\CoAP\coap_ftd_client\hex
for FTD client andwireless_apps_pic32cxbz2_wbz45\apps\thread\advanced_applications\CoAP\coap_sed_server\hex
for SED server . -
Thread Network Formation: Wait for the blue LED to stop flashing, indicating the establishment of a thread network. The FTD board becomes the leader, and the SED board becomes the child in this network.
-
PUT Request: Short press the FTD User button to initiate a PUT request.
-
Request Reception and LED Indicators: The SED board receives the request when it wakes up. The Green RGB LED on the SED board turns on, and it sends an acknowledgment (ACK) to the FTD board. Additionally, the active timer resets during this stage to 3 seconds.
-
GET Request: Upon receiving the ACK, the FTD board sends a GET request.
-
Response Transmission: The SED board sends a response to the GET request.
-
Transaction Completion Indicator: The FTD board's Green RGB LED blinks three times upon receiving the response. The LED turns off when the SED board goes back to sleep when the active timer times out.
Note:
- The SED board sleeps for 5 seconds and remains active for 3 to 6 seconds after waking up. If no request is received, the SED goes to sleep for 3 seconds. If any request is received, it will remain active for 3 seconds to complete transactions.
- The active timer resets in step 4, providing the necessary time for the completion of the GET request packet transaction, also users can observe the LED remaining active for 3-second duration.
SED server console(UART baud settings: 115200 8-N-1 without flow control):
FTD client console(UART baud settings: 115200 8-N-1 without flow control):