This is an old revision of the document!


IOT5: Setting up a CoAP service

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.

Prerequisites

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

Suggested Readings and Knowledge Resources

Hands-on Lab Scenario

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.

Task to be implemented

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:

  • endpoint 1
    coap://ip_address_of_the_node/helloworld
    • method GET - should return a “Hello World” or other string of our choice,
  • endpoint 2
    coap://ip_address_of_the_node/light

    :

    • method GET - should return current status of the LED light (“ON” or “OFF”),
    • method PUT - should set the LED on and off, with the expected payload being “1” for on and “0” for off.

[pczekalski]Skończyć

en/iot-open/practical/hardware/sut/esp32/iot_5.1714323794.txt.gz · Last modified: 2024/04/28 17:03 by pczekalski
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0