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

#Demo Applications ##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 see demo_coap_cli.c
Table 4.1: CoAP client demo

###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.

//signatures of handler functions
typedef void (*restful_handl e r)(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, uint32_t *offset);

Listing 4.1: Resource handler function signature

Table 4.2 describes the resources available in the demo and the function of each CoAP handler.

Recource name Handler decription
GET POST PUT DELETE
res-led_toggle Returns informational message Toggles an LED on the board (if available) - -
res-push Returns a counter value of this periodic resource - - -
res-rf_info Returns RSSI, Power, and Sensitivity value in dB - - -
res-temp Returns a dummy temperature value - - -
res-toggle Returns informational message Switches ON an LED on the board (if available) Switches OFF an LED on the board (if available) -
Table 4.2: CoAP server demo resources

##UDP Sockets The User Datagram Protocol (UDP) demo applications show the use of standard UDP sockets. The client and server demo application work together to exchange message back-and-forth.

###UDP Client The UDP client periodically sends a sequence number that is incremented on the next use. The frequency of sending and the destination server address and port can be easily configured on the demo application (cf. Table 4.3). The _demo_udp_callback() function is called periodically to send message. This function also handles the receiving of messages from lower layers, i.e. UDP .

Parameter Configuration mechanism Decription
Destination Server address SERVER_IP_ADDR macro Composed of NET-WORK_PREFIX and SERVER_IP_ADDR_8_0 macros. See demo_udp_cli.c
Destination Server port __SERVER_PORT macro See demo_udp_cli.c
Client UDP port __CLIENT_PORT macro See demo_udp_cli.c
Sending period SEND_INTERVAL macro See demo_udp_cli.c
Table 4.3: UDP client demo

###UDP Server The UDP server demo always waits for a data to receive. This demo works together with a UDP client demo application which is already included in this software release (cf. ch. 4.3.1). When the UDP server receives a random sequence number it increments the received value by one and sends it back to the client. Configurable parameters are described in Table 4.4.

Parameter Configuration mechanism Decription
UDP Server port __SERVER_PORT macro See demo_udp_srv.c
Client UDP port __CLIENT_PORT macro See demo_udp_srv.c
Table 4.4: UDP server demo

##UDP Keep Alive This demo application provides DODAG visualization on a CETIC 6LBR router. The application sends UDP keep alive messages to the 6LBR border router. Sending of the keep alive messages is done peri- odically based on the time value configured in the SEND_INTERVAL macro. The SEND_INTERVAL can be found in the demo_udp_alive.c file.