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 4:0f845ba8adff, committed 2013-10-10
- Comitter:
- screamer
- Date:
- Thu Oct 10 11:39:55 2013 +0000
- Parent:
- 3:d8cb1afd7285
- Child:
- 6:1caf76131c9a
- Commit message:
- Even more doxygen markup #4
Changed in this revision
| sn_nsdl.h | Show annotated file Show diff for this revision Revisions of this file |
| sn_nsdl_lib.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/sn_nsdl.h Thu Oct 10 10:24:59 2013 +0000
+++ b/sn_nsdl.h Thu Oct 10 11:39:55 2013 +0000
@@ -43,18 +43,24 @@
/* * * * * * * * * * * * * * */
+/**
+ * \brief Used protocol
+ */
typedef enum sn_nsdl_capab_
{
- SN_NSDL_PROTOCOL_HTTP = 0x01,
- SN_NSDL_PROTOCOL_HTTPS = 0x02,
- SN_NSDL_PROTOCOL_COAP = 0x04
+ SN_NSDL_PROTOCOL_HTTP = 0x01, /**< Unsupported */
+ SN_NSDL_PROTOCOL_HTTPS = 0x02, /**< Unsupported */
+ SN_NSDL_PROTOCOL_COAP = 0x04 /**< Supported */
} sn_nsdl_capab_e;
+/**
+ * \brief Address type of given address
+ */
typedef enum sn_nsdl_addr_type_
{
- SN_NSDL_ADDRESS_TYPE_IPV6 = 0x01,
- SN_NSDL_ADDRESS_TYPE_IPV4 = 0x02,
- SN_NSDL_ADDRESS_TYPE_HOSTNAME = 0x03,
+ SN_NSDL_ADDRESS_TYPE_IPV6 = 0x01, /**< Supported */
+ SN_NSDL_ADDRESS_TYPE_IPV4 = 0x02, /**< Supported */
+ SN_NSDL_ADDRESS_TYPE_HOSTNAME = 0x03, /**< Unsupported */
SN_NSDL_ADDRESS_TYPE_NONE = 0xFF
} sn_nsdl_addr_type_e;
@@ -111,7 +117,7 @@
uint8_t *links_ptr; /**< Resource registration string */
uint16_t links_len;
-}registration_info_t;
+} registration_info_t;
#endif /* SN_NSDL_H_ */
--- a/sn_nsdl_lib.h Thu Oct 10 10:24:59 2013 +0000
+++ b/sn_nsdl_lib.h Thu Oct 10 11:39:55 2013 +0000
@@ -80,24 +80,36 @@
} sn_nsdl_ep_parameters_s;
+/**
+ * \brief For internal use
+ */
typedef struct sn_nsdl_sent_messages_
{
uint16_t msg_id_number;
uint8_t message_type;
} sn_nsdl_sent_messages_s;
+/**
+ * \brief Function pointers used for memory allocation and freeing
+ */
typedef struct sn_nsdl_mem_
{
void *(*sn_nsdl_alloc)(uint16_t);
void (*sn_nsdl_free)(void *);
} sn_nsdl_mem_s;
+/**
+ * \brief Includes resource path
+ */
typedef struct sn_grs_resource_
{
uint8_t pathlen;
uint8_t *path;
} sn_grs_resource_s;
+/**
+ * \brief Table of created resources
+ */
typedef struct sn_grs_resource_list_
{
uint8_t res_count; /**< Number of resources */
@@ -115,9 +127,12 @@
SN_GRS_DELETE_ALLOWED = 0x08
} sn_grs_resource_acl_e;
+/**
+ * \brief Used protocol
+ */
typedef struct sn_proto_info_
{
- sn_nsdl_capab_e proto;
+ sn_nsdl_capab_e proto; /**< Only COAP is supported */
} sn_proto_info_s;
/**
@@ -125,9 +140,9 @@
*/
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_GRS_STATIC, /**< Static resources have some value that doesn't 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;
/**
@@ -186,10 +201,10 @@
*
* \param *sn_memory Memory structure which includes function pointers to the allocation and free functions.
*
- * \return Success = 0
- * \return Failed = -1
+ * \return 0 Success
+ * \return -1 Failure
*/
-int8_t sn_nsdl_init (uint8_t (*sn_nsdl_tx_cb)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *),
+int8_t sn_nsdl_init(uint8_t (*sn_nsdl_tx_cb)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *),
uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *),
sn_nsdl_mem_s *sn_memory);
@@ -200,8 +215,8 @@
*
* \param *endpoint_info_ptr Contains endpoint information.
*
- * \return Success = 0
- * \return Failed = -1
+ * \return 0 Success
+ * \return -1 Failure
*/
int8_t sn_nsdl_register_endpoint(sn_nsdl_ep_parameters_s *endpoint_info_ptr);
@@ -210,104 +225,240 @@
*
* \brief Sends unregister-message to NSP server.
*
- * \return Success = 0
- * \return Failed = -1
+ * \return 0 Success
+ * \return -1 Failure
*/
int8_t sn_nsdl_unregister_endpoint(void);
/**
- * Update the registration with NSP.
+ * \fn int8_t sn_nsdl_update_registration(sn_nsdl_ep_parameters_s *endpoint_parameters_ptr);
+ *
+ * \brief Update the registration with NSP.
+ *
+ * \param *endpoint_info_ptr Contains endpoint information.
+ *
+ * \return 0 Success
+ * \return -1 Failure
*/
-int8_t sn_nsdl_update_registration (sn_nsdl_ep_parameters_s *endpoint_parameters_ptr);
-
-/**
- *
- */
-int8_t sn_nsdl_send_eventing_message (uint8_t *event_name_ptr, uint16_t event_name_len, uint8_t *message_body_ptr, uint16_t message_body_len);
+int8_t sn_nsdl_update_registration(sn_nsdl_ep_parameters_s *endpoint_parameters_ptr);
/**
* \fn extern int8_t sn_nsdl_is_ep_registered(void)
*
* \brief Checks if endpoint is registered.
*
- * \return 1 if endpointi registration is done successfully
- * \return 0 if endpoint is not registered
+ * \return 1 Endpoint registration is done successfully
+ * \return 0 Endpoint is not registered
*/
int8_t sn_nsdl_is_ep_registered(void);
/**
* \fn void sn_nsdl_nsp_lost(void);
*
- * \brief A function to inform NSDL-C library if application detects a fault in NSP registration. After calling this function
- * , sn_nsdl_is_ep_registered() will return "not registered".
+ * \brief A function to inform NSDL-C library if application detects a fault in NSP registration.
+ *
+ * After calling this function sn_nsdl_is_ep_registered() will return "not registered".
*/
void sn_nsdl_nsp_lost(void);
/**
- * \fn extern int8_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len,
- * uint8_t *payload_ptr, uint16_t payload_len,
- * uint8_t *observe_ptr, uint8_t observe_len)
+ * \fn extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len,
+ * uint8_t *payload_ptr, uint16_t payload_len,
+ * uint8_t *observe_ptr, uint8_t observe_len,
+ * sn_coap_msg_type_e message_type, uint8_t content_type)
*
*
* \brief Sends observation message to NSP server
*
- * \param *token_ptr Pointer to token to be used
- * \param token_len Token length
- * \param *payload_ptr Pointer to payload to be sent
- * \param payload_len Payload length
- * \param *observe_ptr Pointer to observe number to be sent
- * \param observe_len Observe number len
+ * \param *token_ptr Pointer to token to be used
+ * \param token_len Token length
+ * \param *payload_ptr Pointer to payload to be sent
+ * \param payload_len Payload length
+ * \param *observe_ptr Pointer to observe number to be sent
+ * \param observe_len Observe number len
+ * \param message_type Observation message type (confirmable or non-confirmable)
+ * \param contetnt_type Observation message payload contetnt type
+ *
+ * \return !0 Success, observation messages message ID
+ * \return 0 Failure
+ */
+extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len,
+ uint8_t *payload_ptr, uint16_t payload_len,
+ uint8_t *observe_ptr, uint8_t observe_len,
+ sn_coap_msg_type_e message_type, uint8_t content_type);
+
+/**
+ * \fn extern int16_t sn_nsdl_get_capability(void)
+ *
+ * \brief Capability query function.
+ *
+ * Used to retrieve the list of supported protocols from the NSDL module.
*
- * \return Success = 0
- * \return Failed = -1
+ * \return >0 Success, supported capabilities reported using bitmask with definitions from sn_nsdl_capab_t
+ * \return 0 Success, no supported capabilities
*/
-extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len, uint8_t *payload_ptr, uint16_t payload_len, uint8_t *observe_ptr, uint8_t observe_len, sn_coap_msg_type_e message_type, uint8_t content_type);
+int16_t sn_nsdl_get_capability(void);
-int16_t sn_nsdl_get_capability(void);
+/**
+ * \fn extern uint32_t sn_nsdl_get_version(void)
+ *
+ * \brief Version query function.
+ *
+ * Used to retrieve the version information structure from the NSDL library.
+ *
+ * \return !0 MSB 2 bytes major version, LSB 2 bytes minor version.
+ * \return 0 Failure
+*/
uint32_t sn_nsdl_get_version(void);
+
+/**
+ * \fn extern int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src)
+ *
+ * \brief Currently HTTP is not supported
+ *
+ * \return -1 Failure
+ */
int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src);
/**
- * \brief Process an incoming CoAP message.
+ * \fn extern int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src)
+ *
+ * \brief To push CoAP packet to NSDL library
+ *
+ * Used to push an CoAP packet to NSDL library for processing.
+ *
+ * \param *packet Pointer to a uint8_t array containing the packet (including the CoAP headers).
+ * After successful execution this array may contain the response packet.
+ *
+ * \param *packet_len Pointer to length of the packet. After successful execution this array may contain the length
+ * of the response packet.
+ *
+ * \param *src Pointer to packet source address information. After successful execution this array may contain
+ * the destination address of the response packet.
+ *
+ * \return 0 Success
+ * \return -1 Failure
*/
int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src);
/**
- * \brief Must be called periodically for the library to update retransmissions.
+ * \fn extern int8_t sn_nsdl_exec(uint32_t time);
+ *
+ * \brief CoAP retransmission function.
+ *
+ * Used to give execution time for the NSDL (CoAP) library for retransmissions. The NSDL library
+ * will call the exec functions of all enabled protocol modules.
+ *
+ * \param time Time in seconds.
+ *
+ * \return 0 Success
+ * \return -1 Failure
*/
int8_t sn_nsdl_exec(uint32_t time);
/**
- * \brief Adds a resource to the server.
+ * \fn extern int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res)
+ *
+ * \brief Resource creating function.
+ *
+ * Used to create a static or dynamic HTTP(S) or CoAP resource.
+ *
+ * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information
+ * about the resource.
+ *
+ * \return 0 Success
+ * \return -1 Failure
+ * \return -2 Resource already exists
+ * \return -3 Invalid path
+ * \return -4 List adding failure
*/
int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res);
/**
- * \brief Updates a resource on the server.
+ * \fn extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res)
+ *
+ * \brief Resource updating function.
+ *
+ * Used to update the direct value of a static resource, the callback function pointer of a dynamic resource
+ * and access rights of the recource.
+ *
+ * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information
+ * about the resource. Only the pathlen and path elements are evaluated along with
+ * either resourcelen and resource or the function pointer.
+ *
+ * \return 0 Success
+ * \return -1 Failure
*/
int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res);
/**
- * \brief Removes a resource from the resource server.
+ * \fn extern int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path)
+ *
+ * \brief Resource delete function.
+ *
+ * Used to delete a resource. If resource has a subresources, these all must also be removed.
+ *
+ * \param pathlen Contains the length of the path that is to be deleted (excluding possible trailing "\0").
+ *
+ * \param *path_ptr A pointer to an array containing the path.
+ *
+ * \return 0 Success
+ * \return -1 Failure (No such resource)
*/
int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path);
+/**
+ * \fn extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint8_t pathlen, uint8_t *path)
+ *
+ * \brief Resource get function.
+ *
+ * Used to get a resource.
+ *
+ * \param pathlen Contains the length of the path that is to be returned (excluding possible trailing '\0').
+ *
+ * \param *path A pointer to an array containing the path.
+ *
+ * \return !NULL Success, pointer to a sn_nsdl_resource_info_s that contains the resource information\n
+ * \return NULL Failure
+ */
+sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint8_t pathlen, uint8_t *path);
-sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint8_t pathlen, uint8_t *path);
+/**
+ * \fn extern sn_grs_resource_list_s *sn_nsdl_list_resource(uint8_t pathlen, uint8_t *path)
+ *
+ * \brief Resource list function.
+ *
+ * \param pathlen Contains the length of the target path (excluding possible trailing '\0').
+ * The length value is not examined if the path itself is a NULL pointer.
+ *
+ * \param *path A pointer to an array containing the path or a NULL pointer.
+ *
+ * \return !NULL A pointer to a sn_grs_resource_list_s structure containing the resource listing.
+ * \return NULL Failure with an unspecified error
+ */
sn_grs_resource_list_s *sn_nsdl_list_resource(uint8_t pathlen, uint8_t *path);
/**
+ * \fn extern int8_t sn_nsdl_send_coap_message(sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr);
+ *
* \brief Send an outgoing CoAP request.
+ *
+ * \param *address_ptr Pointer to source address struct
+ *
+ * \param *coap_hdr_ptr Pointer to CoAP message to be sent
+ *
+ * \return 0 Success
+ * \return -1 Failure
*/
int8_t sn_nsdl_send_coap_message(sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr);
/**
- * \fn int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type);
+ * \fn extern int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type);
*
* \brief This function is used to set the NSP address given by an application.
*
- * \return 0 on success,
- * \return -1 on false to indicate that NSDL internal address pointer is not allocated (call nsdl_init() first).
+ * \return 0 Success
+ * \return -1 Failed to indicate that NSDL internal address pointer is not allocated (call nsdl_init() first).
*/
int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type);
