NSDL C library
Dependents: NSDL_HelloWorld_WiFi UbloxModemNanoServiceClient IOT-NSDL_HelloWorld LWM2M_NanoService_Ethernet ... more
Fork of nsdl_lib by
Note that use of this software requires acceptance of the Sensinode EULA: http://mbed.org/teams/Sensinode/code/nsdl_lib/wiki/EULA
Diff: sn_coap_header.h
- Revision:
- 1:01d723824294
- Parent:
- 0:58c4f13c4b9a
- Child:
- 2:ab50a2ab6ec9
diff -r 58c4f13c4b9a -r 01d723824294 sn_coap_header.h --- a/sn_coap_header.h Wed Oct 09 09:20:29 2013 +0000 +++ b/sn_coap_header.h Wed Oct 09 14:18:21 2013 +0000 @@ -24,23 +24,29 @@ /* * * * ENUMERATIONS * * * */ /* * * * * * * * * * * * * * */ -/* Enumeration for CoAP Version */ +/** + * Enumeration for CoAP Version + */ typedef enum coap_version_ { COAP_VERSION_1 = 0x40, COAP_VERSION_UNKNOWN = 0xFF } coap_version_e; -/* Enumeration for CoAP Message type, used in CoAP Header */ +/** + * Enumeration for CoAP Message type, used in CoAP Header + */ typedef enum sn_coap_msg_type_ { - COAP_MSG_TYPE_CONFIRMABLE = 0x00, /* User uses this for Reliable Request messages */ - COAP_MSG_TYPE_NON_CONFIRMABLE = 0x10, /* User uses this for Non-reliable Request and Response messages */ - COAP_MSG_TYPE_ACKNOWLEDGEMENT = 0x20, /* User uses this for Response to a Confirmable Request */ - COAP_MSG_TYPE_RESET = 0x30 /* User uses this to answer a Bad Request */ + COAP_MSG_TYPE_CONFIRMABLE = 0x00, /**< User uses this for Reliable Request messages */ + COAP_MSG_TYPE_NON_CONFIRMABLE = 0x10, /**< User uses this for Non-reliable Request and Response messages */ + COAP_MSG_TYPE_ACKNOWLEDGEMENT = 0x20, /**< User uses this for Response to a Confirmable Request */ + COAP_MSG_TYPE_RESET = 0x30 /**< User uses this to answer a Bad Request */ } sn_coap_msg_type_e; -/* Enumeration for CoAP Message code, used in CoAP Header */ +/** + * Enumeration for CoAP Message code, used in CoAP Header + */ typedef enum sn_coap_msg_code_ { COAP_MSG_CODE_EMPTY = 0, @@ -73,7 +79,9 @@ COAP_MSG_CODE_RESPONSE_PROXYING_NOT_SUPPORTED = 165 } sn_coap_msg_code_e; -/* Enumeration for CoAP Option number, used in CoAP Header */ +/** + * Enumeration for CoAP Option number, used in CoAP Header + */ typedef enum sn_coap_option_numbers_ { COAP_OPTION_IF_MATCH = 1, @@ -99,7 +107,9 @@ // 136 = (Reserved) } sn_coap_option_numbers_e; -/* Enumeration for CoAP Content Format codes */ +/** + * Enumeration for CoAP Content Format codes + */ typedef enum sn_coap_content_format_ { COAP_CT_NONE = -1, @@ -111,18 +121,20 @@ COAP_CT_JSON = 50, } sn_coap_content_format_e; -/* Enumeration for CoAP status, used in CoAP Header */ +/** + * Enumeration for CoAP status, used in CoAP Header + */ typedef enum sn_coap_status_ { - COAP_STATUS_OK = 0, /* Default value is OK */ - COAP_STATUS_PARSER_ERROR_IN_HEADER = 1, /* CoAP will send Reset message to invalid message sender */ - COAP_STATUS_PARSER_DUPLICATED_MSG = 2, /* CoAP will send Acknowledgement message to duplicated message sender */ - COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVING = 3, /* User will get whole message after all message blocks received. - User must release messages with this status. */ - COAP_STATUS_PARSER_BLOCKWISE_ACK = 4, /* Acknowledgement for sent Blockwise message received */ - COAP_STATUS_PARSER_BLOCKWISE_MSG_REJECTED = 5, /* Blockwise message received but not supported by compiling switch */ - COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED = 6 /* Blockwise message fully received and returned to app. */ - /* User must take care of releasing whole payload of the blockwise messages */ + COAP_STATUS_OK = 0, /**< Default value is OK */ + COAP_STATUS_PARSER_ERROR_IN_HEADER = 1, /**< CoAP will send Reset message to invalid message sender */ + COAP_STATUS_PARSER_DUPLICATED_MSG = 2, /**< CoAP will send Acknowledgement message to duplicated message sender */ + COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVING = 3, /**< User will get whole message after all message blocks received. + User must release messages with this status. */ + COAP_STATUS_PARSER_BLOCKWISE_ACK = 4, /**< Acknowledgement for sent Blockwise message received */ + COAP_STATUS_PARSER_BLOCKWISE_MSG_REJECTED = 5, /**< Blockwise message received but not supported by compiling switch */ + COAP_STATUS_PARSER_BLOCKWISE_MSG_RECEIVED = 6 /**< Blockwise message fully received and returned to app. + User must take care of releasing whole payload of the blockwise messages */ } sn_coap_status_e; @@ -130,7 +142,9 @@ /* * * * STRUCTURES * * * */ /* * * * * * * * * * * * * */ -/* Structure for CoAP Options */ +/** + * Structure for CoAP Options + */ typedef struct sn_coap_options_list_ { @@ -139,58 +153,63 @@ /* Size */ /* Proxy-Scheme */ - uint8_t max_age_len; /* 0-4 bytes. */ - uint8_t *max_age_ptr; /* Must be set to NULL if not used */ + uint8_t max_age_len; /**< 0-4 bytes. */ + uint8_t *max_age_ptr; /**< Must be set to NULL if not used */ - uint16_t proxy_uri_len; /* 1-1034 bytes. */ - uint8_t *proxy_uri_ptr; /* Must be set to NULL if not used */ + uint16_t proxy_uri_len; /**< 1-1034 bytes. */ + uint8_t *proxy_uri_ptr; /**< Must be set to NULL if not used */ - uint8_t etag_len; /* 1-8 bytes. Repeatable */ - uint8_t *etag_ptr; /* Must be set to NULL if not used */ + uint8_t etag_len; /**< 1-8 bytes. Repeatable */ + uint8_t *etag_ptr; /**< Must be set to NULL if not used */ - uint16_t uri_host_len; /* 1-255 bytes. */ - uint8_t *uri_host_ptr; /* Must be set to NULL if not used */ + uint16_t uri_host_len; /**< 1-255 bytes. */ + uint8_t *uri_host_ptr; /**< Must be set to NULL if not used */ - uint16_t location_path_len; /* 0-255 bytes. Repeatable */ - uint8_t *location_path_ptr; /* Must be set to NULL if not used */ + uint16_t location_path_len; /**< 0-255 bytes. Repeatable */ + uint8_t *location_path_ptr; /**< Must be set to NULL if not used */ - uint8_t uri_port_len; /* 0-2 bytes. */ - uint8_t *uri_port_ptr; /* Must be set to NULL if not used */ + uint8_t uri_port_len; /**< 0-2 bytes. */ + uint8_t *uri_port_ptr; /**< Must be set to NULL if not used */ - uint16_t location_query_len; /* 0-255 bytes. Repeatable */ - uint8_t *location_query_ptr; /* Must be set to NULL if not used */ + uint16_t location_query_len; /**< 0-255 bytes. Repeatable */ + uint8_t *location_query_ptr; /**< Must be set to NULL if not used */ uint8_t observe; - uint8_t observe_len; /* 0-2 bytes. */ - uint8_t *observe_ptr; /* Must be set to NULL if not used */ + uint8_t observe_len; /**< 0-2 bytes. */ + uint8_t *observe_ptr; /**< Must be set to NULL if not used */ - uint8_t accept_len; /* 0-2 bytes. Repeatable */ - uint8_t *accept_ptr; /* Must be set to NULL if not used */ + uint8_t accept_len; /**< 0-2 bytes. Repeatable */ + uint8_t *accept_ptr; /**< Must be set to NULL if not used */ - uint16_t uri_query_len; /* 1-255 bytes. Repeatable */ - uint8_t *uri_query_ptr; /* Must be set to NULL if not used */ + uint16_t uri_query_len; /**< 1-255 bytes. Repeatable */ + uint8_t *uri_query_ptr; /**< Must be set to NULL if not used */ - uint8_t block1_len; /* 0-3 bytes. */ - uint8_t *block1_ptr; /* Not for User */ + uint8_t block1_len; /**< 0-3 bytes. */ + uint8_t *block1_ptr; /**< Not for User */ - uint8_t block2_len; /* 0-3 bytes. */ - uint8_t *block2_ptr; /* Not for User */ + uint8_t block2_len; /**< 0-3 bytes. */ + uint8_t *block2_ptr; /**< Not for User */ } sn_coap_options_list_s; + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ /* !!! Main CoAP message struct !!! */ /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +/** + * Main CoAP message struct + */ typedef struct sn_coap_hdr_ { - sn_coap_status_e coap_status; /* Used for telling to User special cases when parsing message */ + sn_coap_status_e coap_status; /**< Used for telling to User special cases when parsing message */ /* * * * * * * * * * * */ /* * * * Header * * * */ /* * * * * * * * * * * */ - sn_coap_msg_type_e msg_type; /* Confirmable, Non-Confirmable, Acknowledgement or Reset */ - sn_coap_msg_code_e msg_code; /* Empty: 0; Requests: 1-31; Responses: 64-191 */ - uint16_t msg_id; /* Message ID. Parser sets parsed message ID, builder sets message ID of built coap message */ + sn_coap_msg_type_e msg_type; /**< Confirmable, Non-Confirmable, Acknowledgement or Reset */ + sn_coap_msg_code_e msg_code; /**< Empty: 0; Requests: 1-31; Responses: 64-191 */ + uint16_t msg_id; /**< Message ID. Parser sets parsed message ID, builder sets message ID of built coap message */ /* * * * * * * * * * * */ /* * * * Options * * * */ @@ -198,25 +217,25 @@ /* Here are most often used Options */ - uint16_t uri_path_len; /* 0-255 bytes. Repeatable. */ - uint8_t *uri_path_ptr; /* Must be set to NULL if not used. E.g: temp1/temp2 */ + uint16_t uri_path_len; /**< 0-255 bytes. Repeatable. */ + uint8_t *uri_path_ptr; /**< Must be set to NULL if not used. E.g: temp1/temp2 */ - uint8_t token_len; /* 1-8 bytes. */ - uint8_t *token_ptr; /* Must be set to NULL if not used */ + uint8_t token_len; /**< 1-8 bytes. */ + uint8_t *token_ptr; /**< Must be set to NULL if not used */ /* todo: COAP12 - content type ptr as a content_type_e */ - uint8_t content_type_len; /* 0-2 bytes. */ - uint8_t *content_type_ptr; /* Must be set to NULL if not used */ + uint8_t content_type_len; /**< 0-2 bytes. */ + uint8_t *content_type_ptr; /**< Must be set to NULL if not used */ /* Here are not so often used Options */ - sn_coap_options_list_s *options_list_ptr; /* Must be set to NULL if not used */ + sn_coap_options_list_s *options_list_ptr; /**< Must be set to NULL if not used */ /* * * * * * * * * * * */ /* * * * Payload * * * */ /* * * * * * * * * * * */ - uint16_t payload_len; /* Must be set to zero if not used */ - uint8_t *payload_ptr; /* Must be set to NULL if not used */ + uint16_t payload_len; /**< Must be set to zero if not used */ + uint8_t *payload_ptr; /**< Must be set to NULL if not used */ } sn_coap_hdr_s; /* * * * * * * * * * * * * * * * * * * * * * */