This is an old revision of the document!
The following scenario will show you how to create a CoAP server on the IoT end node device.
A CoAP service is an endpoint that provides information. It is UDP-based, and the protocol configuration (confirmable and non-confirmable messages) requires more than one handler to be implemented in complex and fully implemented scenarios.
To implement this scenario, it is necessary to get familiar with at least one of the following scenarios first:
and obligatory:
There are many implementations of the CoAP protocol, but we will use the following library:
lib_deps = hirotakaster/CoAP simple library
Note—this scenario can be used in tandem with IOT6: Connecting to the CoAP service to build a client-server solution using two devices (CoAP server and CoAP client). You need to book two devices then and develop them in parallel. We suggest connecting them over the AP rather than setting up an access point on the ESP32 device.
Connect to the “internal IoT” WiFI access point as presented in the scenario IOT2: Reading IP address of the WiFi—present connection status on display. Then, set up a CoAP server, sending on its endpoint a “Hello World” message or any customized message of your choice; note to keep it short in case you visualise it on another node's display with limited capabilities. Another endpoint should present any data of the selected sensor (e.g. temperature, humidity, as in the EMBx scenarios) or control any actuator as we present in this scenario. This example uses an RGB LED to switch it on and off (as presented in the scenario EMB9A: Use of RGB LEDs).
The following endpoints should be implemented:
coap://ip_address_of_the_node/helloworld
coap://ip_address_of_the_node/light
:
[pczekalski]Skończyć