OpenWSN Firmware
OpenCoap

Data Structures

struct  coap_header_iht
 
struct  coap_option_iht
 
struct  coap_resource_desc_t
 
struct  opencoap_vars_t
 

Macros

#define MAX_COAP_OPTIONS   10
 the maximum number of options in a RX'ed CoAP message More...
 
#define COAP_MAX_TKL   8
 
#define COAP_PAYLOAD_MARKER   0xFF
 
#define COAP_VERSION   1
 

Typedefs

typedef owerror_t(* callbackRx_cbt )(OpenQueueEntry_t *msg, coap_header_iht *coap_header, coap_option_iht *coap_options)
 
typedef void(* callbackSendDone_cbt )(OpenQueueEntry_t *msg, owerror_t error)
 
typedef struct coap_resource_desc_t coap_resource_desc_t
 

Enumerations

enum  coap_type_t { COAP_TYPE_CON = 0, COAP_TYPE_NON = 1, COAP_TYPE_ACK = 2, COAP_TYPE_RES = 3 }
 
enum  coap_code_t {
  COAP_CODE_EMPTY = 0, COAP_CODE_REQ_GET = 1, COAP_CODE_REQ_POST = 2, COAP_CODE_REQ_PUT = 3,
  COAP_CODE_REQ_DELETE = 4, COAP_CODE_RESP_CREATED = 65, COAP_CODE_RESP_DELETED = 66, COAP_CODE_RESP_VALID = 67,
  COAP_CODE_RESP_CHANGED = 68, COAP_CODE_RESP_CONTENT = 69, COAP_CODE_RESP_BADREQ = 128, COAP_CODE_RESP_UNAUTHORIZED = 129,
  COAP_CODE_RESP_BADOPTION = 130, COAP_CODE_RESP_FORBIDDEN = 131, COAP_CODE_RESP_NOTFOUND = 132, COAP_CODE_RESP_METHODNOTALLOWED = 133,
  COAP_CODE_RESP_PRECONDFAILED = 140, COAP_CODE_RESP_REQTOOLARGE = 141, COAP_CODE_RESP_UNSUPPMEDIATYPE = 143, COAP_CODE_RESP_SERVERERROR = 160,
  COAP_CODE_RESP_NOTIMPLEMENTED = 161, COAP_CODE_RESP_BADGATEWAY = 162, COAP_CODE_RESP_UNAVAILABLE = 163, COAP_CODE_RESP_GWTIMEOUT = 164,
  COAP_CODE_RESP_PROXYINGNOTSUPP = 165
}
 
enum  coap_option_t {
  COAP_OPTION_NONE = 0, COAP_OPTION_NUM_IFMATCH = 1, COAP_OPTION_NUM_URIHOST = 3, COAP_OPTION_NUM_ETAG = 4,
  COAP_OPTION_NUM_IFNONEMATCH = 5, COAP_OPTION_NUM_URIPORT = 7, COAP_OPTION_NUM_LOCATIONPATH = 8, COAP_OPTION_NUM_URIPATH = 11,
  COAP_OPTION_NUM_CONTENTFORMAT = 12, COAP_OPTION_NUM_MAXAGE = 14, COAP_OPTION_NUM_URIQUERY = 15, COAP_OPTION_NUM_ACCEPT = 16,
  COAP_OPTION_NUM_LOCATIONQUERY = 20, COAP_OPTION_NUM_PROXYURI = 35, COAP_OPTION_NUM_PROXYSCHEME = 39
}
 
enum  coap_media_type_t {
  COAP_MEDTYPE_TEXTPLAIN = 0, COAP_MEDTYPE_APPLINKFORMAT = 40, COAP_MEDTYPE_APPXML = 41, COAP_MEDTYPE_APPOCTETSTREAM = 42,
  COAP_MEDTYPE_APPEXI = 47, COAP_MEDTYPE_APPJSON = 50
}
 

Functions

void opencoap_init (void)
 Initialize this module. More...
 
void opencoap_receive (OpenQueueEntry_t *msg)
 Indicate a CoAP messages was received. More...
 
void opencoap_sendDone (OpenQueueEntry_t *msg, owerror_t error)
 Indicates that the CoAP response has been sent. More...
 
void opencoap_writeLinks (OpenQueueEntry_t *msg)
 Writes the links to all the resources on this mote into the message. More...
 
void opencoap_register (coap_resource_desc_t *desc)
 Register a new CoAP resource. More...
 
owerror_t opencoap_send (OpenQueueEntry_t *msg, coap_type_t type, coap_code_t code, uint8_t numOptions, coap_resource_desc_t *descSender)
 Send a CoAP request. More...
 

Detailed Description

Macro Definition Documentation

#define COAP_MAX_TKL   8
#define COAP_PAYLOAD_MARKER   0xFF
#define COAP_VERSION   1
#define MAX_COAP_OPTIONS   10

the maximum number of options in a RX'ed CoAP message

Typedef Documentation

typedef owerror_t(* callbackRx_cbt)(OpenQueueEntry_t *msg, coap_header_iht *coap_header, coap_option_iht *coap_options)
typedef void(* callbackSendDone_cbt)(OpenQueueEntry_t *msg, owerror_t error)

Enumeration Type Documentation

Enumerator
COAP_CODE_EMPTY 
COAP_CODE_REQ_GET 
COAP_CODE_REQ_POST 
COAP_CODE_REQ_PUT 
COAP_CODE_REQ_DELETE 
COAP_CODE_RESP_CREATED 
COAP_CODE_RESP_DELETED 
COAP_CODE_RESP_VALID 
COAP_CODE_RESP_CHANGED 
COAP_CODE_RESP_CONTENT 
COAP_CODE_RESP_BADREQ 
COAP_CODE_RESP_UNAUTHORIZED 
COAP_CODE_RESP_BADOPTION 
COAP_CODE_RESP_FORBIDDEN 
COAP_CODE_RESP_NOTFOUND 
COAP_CODE_RESP_METHODNOTALLOWED 
COAP_CODE_RESP_PRECONDFAILED 
COAP_CODE_RESP_REQTOOLARGE 
COAP_CODE_RESP_UNSUPPMEDIATYPE 
COAP_CODE_RESP_SERVERERROR 
COAP_CODE_RESP_NOTIMPLEMENTED 
COAP_CODE_RESP_BADGATEWAY 
COAP_CODE_RESP_UNAVAILABLE 
COAP_CODE_RESP_GWTIMEOUT 
COAP_CODE_RESP_PROXYINGNOTSUPP 
Enumerator
COAP_MEDTYPE_TEXTPLAIN 
COAP_MEDTYPE_APPLINKFORMAT 
COAP_MEDTYPE_APPXML 
COAP_MEDTYPE_APPOCTETSTREAM 
COAP_MEDTYPE_APPEXI 
COAP_MEDTYPE_APPJSON 
Enumerator
COAP_OPTION_NONE 
COAP_OPTION_NUM_IFMATCH 
COAP_OPTION_NUM_URIHOST 
COAP_OPTION_NUM_ETAG 
COAP_OPTION_NUM_IFNONEMATCH 
COAP_OPTION_NUM_URIPORT 
COAP_OPTION_NUM_LOCATIONPATH 
COAP_OPTION_NUM_URIPATH 
COAP_OPTION_NUM_CONTENTFORMAT 
COAP_OPTION_NUM_MAXAGE 
COAP_OPTION_NUM_URIQUERY 
COAP_OPTION_NUM_ACCEPT 
COAP_OPTION_NUM_LOCATIONQUERY 
COAP_OPTION_NUM_PROXYURI 
COAP_OPTION_NUM_PROXYSCHEME 
Enumerator
COAP_TYPE_CON 
COAP_TYPE_NON 
COAP_TYPE_ACK 
COAP_TYPE_RES 

Function Documentation

void opencoap_init ( void  )

Initialize this module.

void opencoap_receive ( OpenQueueEntry_t msg)

Indicate a CoAP messages was received.

A "CoAP message" is simply a UDP datagram received on the CoAP UDP port.

This function will call the appropriate resource, and send back its answer. The received packetbuffer is reused to contain the response (or error code).

Parameters
[in]msgThe received CoAP message.
void opencoap_register ( coap_resource_desc_t desc)

Register a new CoAP resource.

This function is called by a CoAP resource when it starts, allowing it to receive data sent to that resource.

Registration consists in adding a new resource at the end of the linked list of resources.

Parameters
[in]descThe description of the CoAP resource.
owerror_t opencoap_send ( OpenQueueEntry_t msg,
coap_type_t  type,
coap_code_t  code,
uint8_t  TKL,
coap_resource_desc_t descSender 
)

Send a CoAP request.

This function is called by a CoAP resource when it wants to send some data. This function is NOT called for a response.

Parameters
[in]msgThe message to be sent. This messages should not contain the CoAP header.
[in]typeThe CoAP type of the message.
[in]codeThe CoAP code of the message.
[in]TKLThe Token Length of the message.
[out]descSenderA pointer to the description of the calling CoAP resource.
Postcondition
After returning, this function will have written the messageID and TOKEN used in the descSender parameter.
Returns
The outcome of sending the packet.
void opencoap_sendDone ( OpenQueueEntry_t msg,
owerror_t  error 
)

Indicates that the CoAP response has been sent.

Parameters
[in]msgA pointer to the message which was sent.
[in]errorThe outcome of the send function.
void opencoap_writeLinks ( OpenQueueEntry_t msg)

Writes the links to all the resources on this mote into the message.

Parameters
[out]msgThe messge to write the links to.
Postcondition
After this function returns, the msg contains