Skip to content
edschmitt edited this page Oct 13, 2015 · 10 revisions

##Introduction to Demos The demos included in this software release show the basic usage of the components of the emb6 stack.

##CoAP Applications CoAP is an application protocol suitable for exchanging messages on constrained nodes. It allows a client/server interaction model between endpoints. Two demo applications, showing a client and server role, are included in the emb6 stack.

###CoAP Client A CoAP client sends requests to a CoAP server whenever necessary. The CoAP client application sends periodic POST requests to a remote CoAP server. The address of the server can be configured in the demo_coap_cli.c file, using the SERVER_NODE(ipaddr) macro. The CoAP port of the server is configured by the REMOTE_PORT macro. The aim of periodically sending POST requests is to toggle an LED resource located on a server. This LED toggle resource is included in the CoAP server demo(cf. ch. 4.2.2). The toggle interval in configured with the TOGGLE_INTERVAL macro. Table 4.1 summarizes useful attributes to configure the CoAP client demo as required.

Parameter Configuration mechanism Decription
Server address SERVER_NODE() macro see demo_coap_cli.c
Server port REMOTE_PORT macro see demo_coap_cli.c
Resource URI on the destination server service_urls[] char array see demo_coap_cli.c
Request period TOGGLE_INTERVAL macro Found in demo_coap_cli.c

###CoAP Server A CoAP server hosts resources which can be accessed through specified methods. When the server receives a request to a specific resource, the CoAP resource engine calls the associated method handler, if available. Multiple resources are included in the CoAP server demo. The resource shall provide handlers for CoAP methods, i.e GET, POST, PUT, and DELETE. The signature of the handlers is as shown in Listing 4.1. Each resource is created in a separate file and is initialized in the CoAP resource engine when the application starts. This initialization is done using the RESOURCE(name, attributes, get_handler, post_handler, put_handler, delete_handler) macro.