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
Revision 3:d8cb1afd7285, committed 2013-10-10
- Comitter:
- screamer
- Date:
- Thu Oct 10 10:24:59 2013 +0000
- Parent:
- 2:ab50a2ab6ec9
- Child:
- 4:0f845ba8adff
- Commit message:
- More doxygen markup #3
Changed in this revision
--- a/sn_coap_header.h Wed Oct 09 14:57:33 2013 +0000
+++ b/sn_coap_header.h Thu Oct 10 10:24:59 2013 +0000
@@ -25,7 +25,7 @@
/* * * * * * * * * * * * * * */
/**
- * Enumeration for CoAP Version
+ * \brief Enumeration for CoAP Version
*/
typedef enum coap_version_
{
@@ -34,18 +34,18 @@
} coap_version_e;
/**
- * Enumeration for CoAP Message type, used in CoAP Header
+ * \brief 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, /**< Reliable Request messages */
+ COAP_MSG_TYPE_NON_CONFIRMABLE = 0x10, /**< Non-reliable Request and Response messages */
+ COAP_MSG_TYPE_ACKNOWLEDGEMENT = 0x20, /**< Response to a Confirmable Request */
+ COAP_MSG_TYPE_RESET = 0x30 /**< Answer a Bad Request */
} sn_coap_msg_type_e;
/**
- * Enumeration for CoAP Message code, used in CoAP Header
+ * \brief Enumeration for CoAP Message code, used in CoAP Header
*/
typedef enum sn_coap_msg_code_
{
@@ -80,7 +80,7 @@
} sn_coap_msg_code_e;
/**
- * Enumeration for CoAP Option number, used in CoAP Header
+ * \brief Enumeration for CoAP Option number, used in CoAP Header
*/
typedef enum sn_coap_option_numbers_
{
@@ -108,7 +108,7 @@
} sn_coap_option_numbers_e;
/**
- * Enumeration for CoAP Content Format codes
+ * \brief Enumeration for CoAP Content Format codes
*/
typedef enum sn_coap_content_format_
{
@@ -122,7 +122,7 @@
} sn_coap_content_format_e;
/**
- * Enumeration for CoAP status, used in CoAP Header
+ * \brief Enumeration for CoAP status, used in CoAP Header
*/
typedef enum sn_coap_status_
{
@@ -143,7 +143,7 @@
/* * * * * * * * * * * * * */
/**
- * Structure for CoAP Options
+ * \brief Structure for CoAP Options
*/
typedef struct sn_coap_options_list_
{
@@ -197,7 +197,7 @@
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/**
- * Main CoAP message struct
+ * \brief Main CoAP message struct
*/
typedef struct sn_coap_hdr_
{
@@ -243,42 +243,42 @@
/* * * * * * * * * * * * * * * * * * * * * * */
/**
- * This function sets the memory allocation and deallocation functions the library will use, and must be called first.
+ * \brief Sets the memory allocation and deallocation functions the library will use, and must be called first.
*/
extern void sn_coap_builder_and_parser_init(void* (*used_malloc_func_ptr)(uint16_t), void (*used_free_func_ptr)(void*));
/**
- * Use to parse an incoming message buffer to a CoAP header structure.
+ * \brief Parses an incoming message buffer to a CoAP header structure.
*/
extern sn_coap_hdr_s *sn_coap_parser(uint16_t packet_data_len, uint8_t *packet_data_ptr, coap_version_e *coap_version_ptr);
/**
- * This function releases any memory allocated by a CoAP message structure.
+ * \brief Releases any memory allocated by a CoAP message structure.
*/
extern void sn_coap_parser_release_allocated_coap_msg_mem(sn_coap_hdr_s *freed_coap_msg_ptr);
/**
- * Use to build an outgoing message buffer from a CoAP header structure.
+ * \brief Builds an outgoing message buffer from a CoAP header structure.
*/
extern int16_t sn_coap_builder(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr);
/**
- * Use to calculate the needed message buffer size from a CoAP message structure.
+ * \brief Calculates the needed message buffer size from a CoAP message structure.
*/
extern uint16_t sn_coap_builder_calc_needed_packet_data_size(sn_coap_hdr_s *src_coap_msg_ptr);
/**
- * This function releases any memory allocated in sn_nsdl_transmit_s
+ * \brief Releases any memory allocated in sn_nsdl_transmit_s
*/
extern void sn_coap_builder_release_allocated_send_msg_mem(sn_nsdl_transmit_s *freed_send_msg_ptr);
/**
- * Use to automate the building of a response to an incoming request.
+ * \brief Automates the building of a response to an incoming request.
*/
extern sn_coap_hdr_s *sn_coap_build_response(sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code);
/**
- * CoAP packet debugging.
+ * \brief CoAP packet debugging.
*/
extern void sn_coap_packet_debug(sn_coap_hdr_s *coap_packet_ptr);
--- a/sn_coap_protocol.h Wed Oct 09 14:57:33 2013 +0000 +++ b/sn_coap_protocol.h Thu Oct 10 10:24:59 2013 +0000 @@ -70,59 +70,60 @@ /* * * * * * * * * * * * * * * * * * * * * * */ /** - * This function sets the memory allocation and deallocation functions the library will use, and must be called first. + * \brief This function sets the memory allocation and deallocation functions the library will use, and must be called first. */ extern int8_t sn_coap_protocol_init(void* (*used_malloc_func_ptr)(uint16_t), void (*used_free_func_ptr)(void*), uint8_t (*used_tx_callback_ptr)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *)); /** - * Frees all allocated memory in libCoap protocol part. + * \brief Frees all allocated memory in libCoap protocol part. */ extern int8_t sn_coap_protocol_destroy(void); /** - * Use to build an outgoing message buffer from a CoAP header structure. + * \brief Use to build an outgoing message buffer from a CoAP header structure. */ extern int16_t sn_coap_protocol_build(sn_nsdl_addr_s *dst_addr_ptr, uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr); /** - * Use to parse an incoming message buffer to a CoAP header structure. + * \brief Use to parse an incoming message buffer to a CoAP header structure. */ extern sn_coap_hdr_s *sn_coap_protocol_parse(sn_nsdl_addr_s *src_addr_ptr, uint16_t packet_data_len, uint8_t *packet_data_ptr); /** - * Called periodically to allow the protocol to update retransmission timers and destroy unneeded data. + * \brief Called periodically to allow the protocol to update retransmission timers and destroy unneeded data. */ extern int8_t sn_coap_protocol_exec(uint32_t current_time); /** - * If block transfer is enabled, this function changes the block size. + * \brief If block transfer is enabled, this function changes the block size. */ extern int8_t sn_coap_protocol_set_block_size(uint16_t block_size); /** - * If dublicate message detection is enabled, this function changes buffer size. + * \brief If dublicate message detection is enabled, this function changes buffer size. */ extern int8_t sn_coap_protocol_set_duplicate_buffer_size(uint8_t message_count); /** - * If re-transmissions are enabled, this function changes resending count and buffer size. + * \brief If re-transmissions are enabled, this function changes resending count and buffer size. */ extern int8_t sn_coap_protocol_set_retransmission(uint8_t resending_count, uint8_t buffer_size); /* NSP registration functions */ + /** - * Create an NSP registration message. + * \brief Create an NSP registration message. */ extern int8_t sn_coap_register(sn_coap_hdr_s *coap_hdr_ptr, registration_info_t *endpoint_info_ptr); /** - * Create an NSP update message. + * \brief Create an NSP update message. */ extern int8_t sn_coap_register_update(sn_coap_hdr_s *coap_hdr_ptr, uint8_t *location, uint8_t length); /** - * Create an NSP de-registration message. + * \brief Create an NSP de-registration message. */ extern int8_t sn_coap_deregister(sn_coap_hdr_s *coap_hdr_ptr, uint8_t *location, uint8_t length);
--- a/sn_nsdl.h Wed Oct 09 14:57:33 2013 +0000
+++ b/sn_nsdl.h Thu Oct 10 10:24:59 2013 +0000
@@ -69,7 +69,7 @@
/* * * * * * * * * * * * * */
/**
- * Address structure of Packet data
+ * \brief Address structure of Packet data
*/
typedef struct sn_nsdl_addr_
{
@@ -85,7 +85,7 @@
} sn_nsdl_addr_s;
/**
- * This structure is returned by sn_coap_exec() for sending
+ * \brief This structure is returned by sn_coap_exec() for sending
*/
typedef struct sn_nsdl_transmit_
{
@@ -97,15 +97,18 @@
uint8_t *packet_ptr;
} sn_nsdl_transmit_s;
+/**
+ * \brief Used for creating manually nsdl registration message with sn_coap_register()
+ */
typedef struct registration_info_
{
- uint8_t *endpoint_ptr;
+ uint8_t *endpoint_ptr; /**< Endpoint name */
uint8_t endpoint_len;
- uint8_t *endpoint_type_ptr;
+ uint8_t *endpoint_type_ptr; /**< Endpoint type */
uint8_t endpoint_type_len;
- uint8_t *links_ptr;
+ uint8_t *links_ptr; /**< Resource registration string */
uint16_t links_len;
}registration_info_t;
--- a/sn_nsdl_lib.h Wed Oct 09 14:57:33 2013 +0000
+++ b/sn_nsdl_lib.h Thu Oct 10 10:24:59 2013 +0000
@@ -58,21 +58,24 @@
#define SN_NSDL_ENDPOINT_NOT_REGISTERED 0
#define SN_NSDL_ENDPOINT_IS_REGISTERED 1
+/**
+ * \brief Endpoint registration parameters
+ */
typedef struct sn_nsdl_ep_parameters_
{
- uint8_t *endpoint_name_ptr;
+ uint8_t *endpoint_name_ptr; /**< Endpoint name */
uint8_t endpoint_name_len;
- uint8_t *domain_name_ptr;
+ uint8_t *domain_name_ptr; /**< Domain to register. If null, NSP uses default domain */
uint8_t domain_name_len;
- uint8_t *type_ptr;
+ uint8_t *type_ptr; /**< Endpoint type */
uint8_t type_len;
uint8_t *contex_ptr;
uint8_t contex_len;
- uint8_t *lifetime_ptr;
+ uint8_t *lifetime_ptr; /**< Endpoint lifetime in seconds. eg. "1200" = 1200 seconds */
uint8_t lifetime_len;
} sn_nsdl_ep_parameters_s;
@@ -81,54 +84,55 @@
{
uint16_t msg_id_number;
uint8_t message_type;
-}sn_nsdl_sent_messages_s;
+} sn_nsdl_sent_messages_s;
typedef struct sn_nsdl_mem_
{
void *(*sn_nsdl_alloc)(uint16_t);
void (*sn_nsdl_free)(void *);
-}sn_nsdl_mem_s;
+} sn_nsdl_mem_s;
typedef struct sn_grs_resource_
{
uint8_t pathlen;
uint8_t *path;
-}sn_grs_resource_s;
+} sn_grs_resource_s;
typedef struct sn_grs_resource_list_
{
- uint8_t res_count; /**< Number of resources */
+ uint8_t res_count; /**< Number of resources */
sn_grs_resource_s *res;
-}sn_grs_resource_list_s;
+} sn_grs_resource_list_s;
-typedef enum sn_nsdl_resource_mode_
-{
- SN_GRS_STATIC,
- SN_GRS_DYNAMIC,
- SN_GRS_DIRECTORY
-}sn_nsdl_resource_mode_e;
-
-typedef enum sn_grs_resource_mutable_
-{
- SN_GRS_GET = 0x01,
- SN_GRS_POST = 0x02,
- SN_GRS_PUT = 0x04,
- SN_GRS_DELETE = 0x08
-}sn_grs_resource_mutable_e;
-
+/**
+ * \brief Resource access rights
+ */
typedef enum sn_grs_resource_acl_
{
SN_GRS_GET_ALLOWED = 0x01 ,
SN_GRS_PUT_ALLOWED = 0x02,
SN_GRS_POST_ALLOWED = 0x04,
SN_GRS_DELETE_ALLOWED = 0x08
-}sn_grs_resource_acl_e;
+} sn_grs_resource_acl_e;
typedef struct sn_proto_info_
{
sn_nsdl_capab_e proto;
-}sn_proto_info_s;
+} sn_proto_info_s;
+/**
+ * \brief Defines the resource mode
+ */
+typedef enum sn_nsdl_resource_mode_
+{
+ SN_GRS_STATIC, /**< Static resources have some value that does not change. */
+ SN_GRS_DYNAMIC, /**< Dynamic resources are handled in application. Therefore one must give function callback pointer to them. */
+ SN_GRS_DIRECTORY /**< Directory resources are unused and unsupported. */
+} sn_nsdl_resource_mode_e;
+
+/**
+ * \brief Resource registration parameters
+ */
typedef struct sn_nsdl_resource_parameters_
{
uint8_t *resource_type_ptr;
@@ -147,17 +151,20 @@
}sn_nsdl_resource_parameters_s;
+/**
+ * \brief Defines parameters for the resource.
+ */
typedef struct sn_nsdl_resource_info_
{
sn_nsdl_resource_parameters_s *resource_parameters_ptr;
- sn_nsdl_resource_mode_e mode; //< STATIC etc..
+ sn_nsdl_resource_mode_e mode; /**< STATIC etc.. */
- uint16_t pathlen; //< Address
+ uint16_t pathlen; /**< Address */
uint8_t *path;
- uint16_t resourcelen; //< 0 if dynamic resource, resource information in static resource
- uint8_t *resource; //< NULL if dynamic resource
+ uint16_t resourcelen; /**< 0 if dynamic resource, resource information in static resource */
+ uint8_t *resource; /**< NULL if dynamic resource */
sn_grs_resource_acl_e access;
@@ -261,27 +268,27 @@
int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src);
/**
- * Process an incoming CoAP message.
+ * \brief Process an incoming CoAP message.
*/
int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src);
/**
- * Must be called periodically for the library to update retransmissions.
+ * \brief Must be called periodically for the library to update retransmissions.
*/
int8_t sn_nsdl_exec(uint32_t time);
/**
- * Adds a resource to the server.
+ * \brief Adds a resource to the server.
*/
int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res);
/**
- * Updates a resource on the server.
+ * \brief Updates a resource on the server.
*/
int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res);
/**
- * Removes a resource from the resource server.
+ * \brief Removes a resource from the resource server.
*/
int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path);
@@ -290,7 +297,7 @@
sn_grs_resource_list_s *sn_nsdl_list_resource(uint8_t pathlen, uint8_t *path);
/**
- * Send an outgoing CoAP request.
+ * \brief Send an outgoing CoAP request.
*/
int8_t sn_nsdl_send_coap_message(sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr);
