Example Embedded Applications

Hello, World! CoAP Service

This example is a simple Hello, World! style Nabto Edge Embedded SDK application. It is located in examples/simple_coap in the SDK repo.

The point with this simple application is only to demonstrate the very basic plumbing so access control is omitted for simplicity.

The application is a simple CoAP service, that handles a GET request at the path /hello-world. It replies with a string payload that says “Hello, world!” back to the client.

Configuration

The unique device configuration values are hard coded in the simple_coap.c source file, change to use the values obtained from the Nabto Cloud Console as discussed in the intro.

The private key in simple_coap.c must be replaced with a freshly generated one, e.g. using:

openssl ecparam -genkey -name prime256v1 -out key.pem

Building and running

Follow the general build instructions on the Embedded SDK intro page to build the Hello, World CoAP service.

To run the application, execute the following in a terminal:

 _install/bin/simple_coap_device

Invoking CoAP service from a Nabto Edge client

You can use the corresponding simple CoAP commandline client:

$ ./simple_coap_get -H https://pr-vcizvpox.clients.nabto.net \
  -p <product id  (pr-...)> \
  -d <device id   (de-...)>\
  -s <server key  (sk-...)\
  -r '/hello-world'
connecting to pr-udnromc7.de-g9caq9qv
Created a new connection
Connected to device with fingerprint: 3b7144c34e4e1cd8821e641997110631
Sending CoAP GET request
Sending coap get-request:/hello-world
Received CoAP response data: Hello world
freed connection

Or you can try the iOS Hello World CoAP app