NSDL C library

Dependents:   NSDL_HelloWorld_WiFi UbloxModemNanoServiceClient IOT-NSDL_HelloWorld LWM2M_NanoService_Ethernet ... more

Fork of nsdl_lib by Tero Heinonen

Note that use of this software requires acceptance of the Sensinode EULA: http://mbed.org/teams/Sensinode/code/nsdl_lib/wiki/EULA

Committer:
bogdanm
Date:
Tue Oct 15 12:43:59 2013 +0000
Revision:
7:050d0f54a0dc
Parent:
6:1caf76131c9a
Fixed guards in headers.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 2:ab50a2ab6ec9 1 /**
screamer 2:ab50a2ab6ec9 2 * \file sn_nsdl_lib.h
screamer 2:ab50a2ab6ec9 3 *
screamer 2:ab50a2ab6ec9 4 * \brief NanoService Devices Library header file
screamer 2:ab50a2ab6ec9 5 *
screamer 2:ab50a2ab6ec9 6 * Created on: Aug 23, 2011
screamer 2:ab50a2ab6ec9 7 * Author: tero
screamer 2:ab50a2ab6ec9 8 *
screamer 2:ab50a2ab6ec9 9 */
terohoo 5:da1db64e7fb9 10
bogdanm 7:050d0f54a0dc 11 #ifndef SN_NSDL_LIB_H_
bogdanm 7:050d0f54a0dc 12 #define SN_NSDL_LIB_H_
bogdanm 7:050d0f54a0dc 13
terohoo 0:58c4f13c4b9a 14 #ifdef __cplusplus
terohoo 0:58c4f13c4b9a 15 extern "C" {
terohoo 0:58c4f13c4b9a 16 #endif
terohoo 0:58c4f13c4b9a 17
terohoo 0:58c4f13c4b9a 18 #define SN_NSDL_CONST_MEMORY_ATTRIBUTE
terohoo 0:58c4f13c4b9a 19
terohoo 0:58c4f13c4b9a 20 #define SN_NSDL_ENDPOINT_NOT_REGISTERED 0
terohoo 0:58c4f13c4b9a 21 #define SN_NSDL_ENDPOINT_IS_REGISTERED 1
terohoo 0:58c4f13c4b9a 22
screamer 3:d8cb1afd7285 23 /**
screamer 3:d8cb1afd7285 24 * \brief Endpoint registration parameters
screamer 3:d8cb1afd7285 25 */
terohoo 0:58c4f13c4b9a 26 typedef struct sn_nsdl_ep_parameters_
terohoo 0:58c4f13c4b9a 27 {
screamer 3:d8cb1afd7285 28 uint8_t *endpoint_name_ptr; /**< Endpoint name */
terohoo 0:58c4f13c4b9a 29 uint8_t endpoint_name_len;
terohoo 0:58c4f13c4b9a 30
screamer 3:d8cb1afd7285 31 uint8_t *domain_name_ptr; /**< Domain to register. If null, NSP uses default domain */
terohoo 0:58c4f13c4b9a 32 uint8_t domain_name_len;
terohoo 0:58c4f13c4b9a 33
screamer 3:d8cb1afd7285 34 uint8_t *type_ptr; /**< Endpoint type */
terohoo 0:58c4f13c4b9a 35 uint8_t type_len;
terohoo 0:58c4f13c4b9a 36
screamer 3:d8cb1afd7285 37 uint8_t *lifetime_ptr; /**< Endpoint lifetime in seconds. eg. "1200" = 1200 seconds */
terohoo 0:58c4f13c4b9a 38 uint8_t lifetime_len;
terohoo 0:58c4f13c4b9a 39
terohoo 0:58c4f13c4b9a 40 } sn_nsdl_ep_parameters_s;
terohoo 0:58c4f13c4b9a 41
screamer 4:0f845ba8adff 42 /**
screamer 4:0f845ba8adff 43 * \brief For internal use
screamer 4:0f845ba8adff 44 */
terohoo 0:58c4f13c4b9a 45 typedef struct sn_nsdl_sent_messages_
terohoo 0:58c4f13c4b9a 46 {
terohoo 0:58c4f13c4b9a 47 uint16_t msg_id_number;
terohoo 0:58c4f13c4b9a 48 uint8_t message_type;
screamer 3:d8cb1afd7285 49 } sn_nsdl_sent_messages_s;
terohoo 0:58c4f13c4b9a 50
screamer 4:0f845ba8adff 51 /**
screamer 4:0f845ba8adff 52 * \brief Function pointers used for memory allocation and freeing
screamer 4:0f845ba8adff 53 */
terohoo 0:58c4f13c4b9a 54 typedef struct sn_nsdl_mem_
terohoo 0:58c4f13c4b9a 55 {
terohoo 0:58c4f13c4b9a 56 void *(*sn_nsdl_alloc)(uint16_t);
terohoo 0:58c4f13c4b9a 57 void (*sn_nsdl_free)(void *);
screamer 3:d8cb1afd7285 58 } sn_nsdl_mem_s;
terohoo 0:58c4f13c4b9a 59
screamer 4:0f845ba8adff 60 /**
screamer 4:0f845ba8adff 61 * \brief Includes resource path
screamer 4:0f845ba8adff 62 */
terohoo 0:58c4f13c4b9a 63 typedef struct sn_grs_resource_
terohoo 0:58c4f13c4b9a 64 {
terohoo 0:58c4f13c4b9a 65 uint8_t pathlen;
terohoo 0:58c4f13c4b9a 66 uint8_t *path;
screamer 3:d8cb1afd7285 67 } sn_grs_resource_s;
terohoo 0:58c4f13c4b9a 68
screamer 4:0f845ba8adff 69 /**
screamer 4:0f845ba8adff 70 * \brief Table of created resources
screamer 4:0f845ba8adff 71 */
terohoo 0:58c4f13c4b9a 72 typedef struct sn_grs_resource_list_
terohoo 0:58c4f13c4b9a 73 {
screamer 3:d8cb1afd7285 74 uint8_t res_count; /**< Number of resources */
terohoo 0:58c4f13c4b9a 75 sn_grs_resource_s *res;
screamer 3:d8cb1afd7285 76 } sn_grs_resource_list_s;
terohoo 0:58c4f13c4b9a 77
screamer 3:d8cb1afd7285 78 /**
screamer 3:d8cb1afd7285 79 * \brief Resource access rights
screamer 3:d8cb1afd7285 80 */
terohoo 0:58c4f13c4b9a 81 typedef enum sn_grs_resource_acl_
terohoo 0:58c4f13c4b9a 82 {
terohoo 0:58c4f13c4b9a 83 SN_GRS_GET_ALLOWED = 0x01 ,
terohoo 0:58c4f13c4b9a 84 SN_GRS_PUT_ALLOWED = 0x02,
terohoo 0:58c4f13c4b9a 85 SN_GRS_POST_ALLOWED = 0x04,
terohoo 0:58c4f13c4b9a 86 SN_GRS_DELETE_ALLOWED = 0x08
screamer 3:d8cb1afd7285 87 } sn_grs_resource_acl_e;
terohoo 0:58c4f13c4b9a 88
screamer 4:0f845ba8adff 89 /**
screamer 4:0f845ba8adff 90 * \brief Used protocol
screamer 4:0f845ba8adff 91 */
terohoo 0:58c4f13c4b9a 92 typedef struct sn_proto_info_
terohoo 0:58c4f13c4b9a 93 {
screamer 4:0f845ba8adff 94 sn_nsdl_capab_e proto; /**< Only COAP is supported */
screamer 3:d8cb1afd7285 95 } sn_proto_info_s;
terohoo 0:58c4f13c4b9a 96
screamer 3:d8cb1afd7285 97 /**
screamer 3:d8cb1afd7285 98 * \brief Defines the resource mode
screamer 3:d8cb1afd7285 99 */
screamer 3:d8cb1afd7285 100 typedef enum sn_nsdl_resource_mode_
screamer 3:d8cb1afd7285 101 {
screamer 4:0f845ba8adff 102 SN_GRS_STATIC, /**< Static resources have some value that doesn't change */
screamer 4:0f845ba8adff 103 SN_GRS_DYNAMIC, /**< Dynamic resources are handled in application. Therefore one must give function callback pointer to them */
screamer 4:0f845ba8adff 104 SN_GRS_DIRECTORY /**< Directory resources are unused and unsupported */
screamer 3:d8cb1afd7285 105 } sn_nsdl_resource_mode_e;
screamer 3:d8cb1afd7285 106
screamer 3:d8cb1afd7285 107 /**
screamer 3:d8cb1afd7285 108 * \brief Resource registration parameters
screamer 3:d8cb1afd7285 109 */
terohoo 0:58c4f13c4b9a 110 typedef struct sn_nsdl_resource_parameters_
terohoo 0:58c4f13c4b9a 111 {
terohoo 0:58c4f13c4b9a 112 uint8_t *resource_type_ptr;
terohoo 0:58c4f13c4b9a 113 uint16_t resource_type_len;
terohoo 0:58c4f13c4b9a 114
terohoo 0:58c4f13c4b9a 115 uint8_t *interface_description_ptr;
terohoo 0:58c4f13c4b9a 116 uint16_t interface_description_len;
terohoo 0:58c4f13c4b9a 117
terohoo 0:58c4f13c4b9a 118 uint8_t coap_content_type;
terohoo 0:58c4f13c4b9a 119
terohoo 0:58c4f13c4b9a 120 uint8_t mime_content_type;
terohoo 0:58c4f13c4b9a 121
terohoo 0:58c4f13c4b9a 122 uint8_t observable;
terohoo 0:58c4f13c4b9a 123
terohoo 0:58c4f13c4b9a 124 uint8_t registered;
terohoo 0:58c4f13c4b9a 125
terohoo 0:58c4f13c4b9a 126 }sn_nsdl_resource_parameters_s;
terohoo 0:58c4f13c4b9a 127
screamer 3:d8cb1afd7285 128 /**
screamer 3:d8cb1afd7285 129 * \brief Defines parameters for the resource.
screamer 3:d8cb1afd7285 130 */
terohoo 0:58c4f13c4b9a 131 typedef struct sn_nsdl_resource_info_
terohoo 0:58c4f13c4b9a 132 {
terohoo 0:58c4f13c4b9a 133 sn_nsdl_resource_parameters_s *resource_parameters_ptr;
terohoo 0:58c4f13c4b9a 134
screamer 3:d8cb1afd7285 135 sn_nsdl_resource_mode_e mode; /**< STATIC etc.. */
terohoo 0:58c4f13c4b9a 136
screamer 3:d8cb1afd7285 137 uint16_t pathlen; /**< Address */
terohoo 0:58c4f13c4b9a 138 uint8_t *path;
terohoo 0:58c4f13c4b9a 139
screamer 3:d8cb1afd7285 140 uint16_t resourcelen; /**< 0 if dynamic resource, resource information in static resource */
screamer 3:d8cb1afd7285 141 uint8_t *resource; /**< NULL if dynamic resource */
terohoo 0:58c4f13c4b9a 142
terohoo 0:58c4f13c4b9a 143 sn_grs_resource_acl_e access;
terohoo 0:58c4f13c4b9a 144
terohoo 0:58c4f13c4b9a 145 uint8_t (*sn_grs_dyn_res_callback)(sn_coap_hdr_s *, sn_nsdl_addr_s *, sn_proto_info_s *);
terohoo 0:58c4f13c4b9a 146
terohoo 0:58c4f13c4b9a 147 } sn_nsdl_resource_info_s;
terohoo 0:58c4f13c4b9a 148
terohoo 0:58c4f13c4b9a 149 /**
terohoo 0:58c4f13c4b9a 150 * \fn extern int8_t sn_nsdl_init (uint8_t (*sn_nsdl_tx_cb)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *),
terohoo 0:58c4f13c4b9a 151 * uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *),
terohoo 0:58c4f13c4b9a 152 * sn_nsdl_mem_s *sn_memory)
terohoo 0:58c4f13c4b9a 153 *
terohoo 0:58c4f13c4b9a 154 * \brief Initialization function for NSDL library. Initializes NSDL, GRS, HTTP and CoAP.
terohoo 0:58c4f13c4b9a 155 *
terohoo 0:58c4f13c4b9a 156 * \param *sn_nsdl_tx_callback A callback function for sending messages.
terohoo 0:58c4f13c4b9a 157 *
terohoo 0:58c4f13c4b9a 158 * \param *sn_nsdl_rx_callback A callback function for parsed messages. If received message is not CoAP protocol message (eg. ACK), message for GRS (GET, PUT, POST, DELETE) or
terohoo 0:58c4f13c4b9a 159 * reply for some NSDL message (register message etc.), rx callback will be called.
terohoo 0:58c4f13c4b9a 160 *
terohoo 0:58c4f13c4b9a 161 * \param *sn_memory Memory structure which includes function pointers to the allocation and free functions.
terohoo 0:58c4f13c4b9a 162 *
screamer 4:0f845ba8adff 163 * \return 0 Success
screamer 4:0f845ba8adff 164 * \return -1 Failure
terohoo 0:58c4f13c4b9a 165 */
terohoo 5:da1db64e7fb9 166 extern int8_t sn_nsdl_init(uint8_t (*sn_nsdl_tx_cb)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *),
terohoo 0:58c4f13c4b9a 167 uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *),
terohoo 0:58c4f13c4b9a 168 sn_nsdl_mem_s *sn_memory);
terohoo 0:58c4f13c4b9a 169
terohoo 0:58c4f13c4b9a 170 /**
terohoo 0:58c4f13c4b9a 171 * \fn extern uint8_t sn_nsdl_register_endpoint(sn_nsdl_ep_parameters_s *endpoint_info_ptr)
terohoo 0:58c4f13c4b9a 172 *
terohoo 0:58c4f13c4b9a 173 * \brief Registers endpoint to NSP server.
terohoo 0:58c4f13c4b9a 174 *
terohoo 0:58c4f13c4b9a 175 * \param *endpoint_info_ptr Contains endpoint information.
terohoo 0:58c4f13c4b9a 176 *
screamer 4:0f845ba8adff 177 * \return 0 Success
screamer 4:0f845ba8adff 178 * \return -1 Failure
terohoo 0:58c4f13c4b9a 179 */
terohoo 5:da1db64e7fb9 180 extern int8_t sn_nsdl_register_endpoint(sn_nsdl_ep_parameters_s *endpoint_info_ptr);
terohoo 0:58c4f13c4b9a 181
terohoo 0:58c4f13c4b9a 182 /**
terohoo 0:58c4f13c4b9a 183 * \fn extern int8_t sn_nsdl_unregister_endpoint(void)
terohoo 0:58c4f13c4b9a 184 *
terohoo 0:58c4f13c4b9a 185 * \brief Sends unregister-message to NSP server.
terohoo 0:58c4f13c4b9a 186 *
screamer 4:0f845ba8adff 187 * \return 0 Success
screamer 4:0f845ba8adff 188 * \return -1 Failure
terohoo 0:58c4f13c4b9a 189 */
terohoo 5:da1db64e7fb9 190 extern int8_t sn_nsdl_unregister_endpoint(void);
screamer 2:ab50a2ab6ec9 191
screamer 2:ab50a2ab6ec9 192 /**
terohoo 5:da1db64e7fb9 193 * \fn extern int8_t sn_nsdl_update_registration(sn_nsdl_ep_parameters_s *endpoint_parameters_ptr);
screamer 4:0f845ba8adff 194 *
screamer 4:0f845ba8adff 195 * \brief Update the registration with NSP.
screamer 4:0f845ba8adff 196 *
screamer 4:0f845ba8adff 197 * \param *endpoint_info_ptr Contains endpoint information.
screamer 4:0f845ba8adff 198 *
screamer 4:0f845ba8adff 199 * \return 0 Success
screamer 4:0f845ba8adff 200 * \return -1 Failure
screamer 2:ab50a2ab6ec9 201 */
terohoo 5:da1db64e7fb9 202 extern int8_t sn_nsdl_update_registration(sn_nsdl_ep_parameters_s *endpoint_parameters_ptr);
terohoo 0:58c4f13c4b9a 203
terohoo 0:58c4f13c4b9a 204 /**
terohoo 0:58c4f13c4b9a 205 * \fn extern int8_t sn_nsdl_is_ep_registered(void)
terohoo 0:58c4f13c4b9a 206 *
terohoo 0:58c4f13c4b9a 207 * \brief Checks if endpoint is registered.
terohoo 0:58c4f13c4b9a 208 *
screamer 4:0f845ba8adff 209 * \return 1 Endpoint registration is done successfully
screamer 4:0f845ba8adff 210 * \return 0 Endpoint is not registered
terohoo 0:58c4f13c4b9a 211 */
terohoo 5:da1db64e7fb9 212 extern int8_t sn_nsdl_is_ep_registered(void);
terohoo 0:58c4f13c4b9a 213
screamer 1:01d723824294 214 /**
terohoo 5:da1db64e7fb9 215 * \fn extern void sn_nsdl_nsp_lost(void);
screamer 2:ab50a2ab6ec9 216 *
screamer 4:0f845ba8adff 217 * \brief A function to inform NSDL-C library if application detects a fault in NSP registration.
screamer 4:0f845ba8adff 218 *
screamer 4:0f845ba8adff 219 * After calling this function sn_nsdl_is_ep_registered() will return "not registered".
terohoo 0:58c4f13c4b9a 220 */
terohoo 5:da1db64e7fb9 221 extern void sn_nsdl_nsp_lost(void);
screamer 2:ab50a2ab6ec9 222
terohoo 0:58c4f13c4b9a 223 /**
screamer 4:0f845ba8adff 224 * \fn extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len,
screamer 4:0f845ba8adff 225 * uint8_t *payload_ptr, uint16_t payload_len,
screamer 4:0f845ba8adff 226 * uint8_t *observe_ptr, uint8_t observe_len,
screamer 4:0f845ba8adff 227 * sn_coap_msg_type_e message_type, uint8_t content_type)
terohoo 0:58c4f13c4b9a 228 *
terohoo 0:58c4f13c4b9a 229 *
terohoo 0:58c4f13c4b9a 230 * \brief Sends observation message to NSP server
terohoo 0:58c4f13c4b9a 231 *
screamer 4:0f845ba8adff 232 * \param *token_ptr Pointer to token to be used
screamer 4:0f845ba8adff 233 * \param token_len Token length
screamer 4:0f845ba8adff 234 * \param *payload_ptr Pointer to payload to be sent
screamer 4:0f845ba8adff 235 * \param payload_len Payload length
screamer 4:0f845ba8adff 236 * \param *observe_ptr Pointer to observe number to be sent
screamer 4:0f845ba8adff 237 * \param observe_len Observe number len
screamer 4:0f845ba8adff 238 * \param message_type Observation message type (confirmable or non-confirmable)
screamer 4:0f845ba8adff 239 * \param contetnt_type Observation message payload contetnt type
screamer 4:0f845ba8adff 240 *
screamer 4:0f845ba8adff 241 * \return !0 Success, observation messages message ID
screamer 4:0f845ba8adff 242 * \return 0 Failure
screamer 4:0f845ba8adff 243 */
screamer 4:0f845ba8adff 244 extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len,
screamer 4:0f845ba8adff 245 uint8_t *payload_ptr, uint16_t payload_len,
screamer 4:0f845ba8adff 246 uint8_t *observe_ptr, uint8_t observe_len,
screamer 4:0f845ba8adff 247 sn_coap_msg_type_e message_type, uint8_t content_type);
screamer 4:0f845ba8adff 248
screamer 4:0f845ba8adff 249 /**
screamer 4:0f845ba8adff 250 * \fn extern int16_t sn_nsdl_get_capability(void)
screamer 4:0f845ba8adff 251 *
screamer 4:0f845ba8adff 252 * \brief Capability query function.
screamer 4:0f845ba8adff 253 *
screamer 4:0f845ba8adff 254 * Used to retrieve the list of supported protocols from the NSDL module.
terohoo 0:58c4f13c4b9a 255 *
screamer 4:0f845ba8adff 256 * \return >0 Success, supported capabilities reported using bitmask with definitions from sn_nsdl_capab_t
screamer 4:0f845ba8adff 257 * \return 0 Success, no supported capabilities
terohoo 0:58c4f13c4b9a 258 */
terohoo 5:da1db64e7fb9 259 extern int16_t sn_nsdl_get_capability(void);
screamer 2:ab50a2ab6ec9 260
screamer 4:0f845ba8adff 261 /**
screamer 4:0f845ba8adff 262 * \fn extern uint32_t sn_nsdl_get_version(void)
screamer 4:0f845ba8adff 263 *
screamer 4:0f845ba8adff 264 * \brief Version query function.
screamer 4:0f845ba8adff 265 *
screamer 4:0f845ba8adff 266 * Used to retrieve the version information structure from the NSDL library.
screamer 4:0f845ba8adff 267 *
screamer 4:0f845ba8adff 268 * \return !0 MSB 2 bytes major version, LSB 2 bytes minor version.
screamer 4:0f845ba8adff 269 * \return 0 Failure
screamer 4:0f845ba8adff 270 */
terohoo 5:da1db64e7fb9 271 extern uint32_t sn_nsdl_get_version(void);
screamer 4:0f845ba8adff 272
screamer 4:0f845ba8adff 273 /**
screamer 4:0f845ba8adff 274 * \fn extern int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src)
screamer 4:0f845ba8adff 275 *
screamer 4:0f845ba8adff 276 * \brief Currently HTTP is not supported
screamer 4:0f845ba8adff 277 *
screamer 4:0f845ba8adff 278 * \return -1 Failure
screamer 4:0f845ba8adff 279 */
terohoo 5:da1db64e7fb9 280 extern int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src);
screamer 2:ab50a2ab6ec9 281
screamer 2:ab50a2ab6ec9 282 /**
screamer 4:0f845ba8adff 283 * \fn extern int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src)
screamer 4:0f845ba8adff 284 *
screamer 4:0f845ba8adff 285 * \brief To push CoAP packet to NSDL library
screamer 4:0f845ba8adff 286 *
screamer 4:0f845ba8adff 287 * Used to push an CoAP packet to NSDL library for processing.
screamer 4:0f845ba8adff 288 *
screamer 4:0f845ba8adff 289 * \param *packet Pointer to a uint8_t array containing the packet (including the CoAP headers).
screamer 4:0f845ba8adff 290 * After successful execution this array may contain the response packet.
screamer 4:0f845ba8adff 291 *
screamer 4:0f845ba8adff 292 * \param *packet_len Pointer to length of the packet. After successful execution this array may contain the length
screamer 4:0f845ba8adff 293 * of the response packet.
screamer 4:0f845ba8adff 294 *
screamer 4:0f845ba8adff 295 * \param *src Pointer to packet source address information. After successful execution this array may contain
screamer 4:0f845ba8adff 296 * the destination address of the response packet.
screamer 4:0f845ba8adff 297 *
screamer 4:0f845ba8adff 298 * \return 0 Success
screamer 4:0f845ba8adff 299 * \return -1 Failure
screamer 2:ab50a2ab6ec9 300 */
terohoo 5:da1db64e7fb9 301 extern int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src);
screamer 2:ab50a2ab6ec9 302
screamer 2:ab50a2ab6ec9 303 /**
screamer 4:0f845ba8adff 304 * \fn extern int8_t sn_nsdl_exec(uint32_t time);
screamer 4:0f845ba8adff 305 *
screamer 4:0f845ba8adff 306 * \brief CoAP retransmission function.
screamer 4:0f845ba8adff 307 *
screamer 4:0f845ba8adff 308 * Used to give execution time for the NSDL (CoAP) library for retransmissions. The NSDL library
screamer 4:0f845ba8adff 309 * will call the exec functions of all enabled protocol modules.
screamer 4:0f845ba8adff 310 *
screamer 4:0f845ba8adff 311 * \param time Time in seconds.
screamer 4:0f845ba8adff 312 *
screamer 4:0f845ba8adff 313 * \return 0 Success
screamer 4:0f845ba8adff 314 * \return -1 Failure
screamer 2:ab50a2ab6ec9 315 */
terohoo 5:da1db64e7fb9 316 extern int8_t sn_nsdl_exec(uint32_t time);
screamer 2:ab50a2ab6ec9 317
screamer 2:ab50a2ab6ec9 318 /**
screamer 4:0f845ba8adff 319 * \fn extern int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res)
screamer 4:0f845ba8adff 320 *
screamer 4:0f845ba8adff 321 * \brief Resource creating function.
screamer 4:0f845ba8adff 322 *
screamer 4:0f845ba8adff 323 * Used to create a static or dynamic HTTP(S) or CoAP resource.
screamer 4:0f845ba8adff 324 *
screamer 4:0f845ba8adff 325 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information
screamer 4:0f845ba8adff 326 * about the resource.
screamer 4:0f845ba8adff 327 *
screamer 4:0f845ba8adff 328 * \return 0 Success
screamer 4:0f845ba8adff 329 * \return -1 Failure
screamer 4:0f845ba8adff 330 * \return -2 Resource already exists
screamer 4:0f845ba8adff 331 * \return -3 Invalid path
screamer 4:0f845ba8adff 332 * \return -4 List adding failure
screamer 2:ab50a2ab6ec9 333 */
terohoo 5:da1db64e7fb9 334 extern int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res);
screamer 2:ab50a2ab6ec9 335
screamer 2:ab50a2ab6ec9 336 /**
screamer 4:0f845ba8adff 337 * \fn extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res)
screamer 4:0f845ba8adff 338 *
screamer 4:0f845ba8adff 339 * \brief Resource updating function.
screamer 4:0f845ba8adff 340 *
screamer 4:0f845ba8adff 341 * Used to update the direct value of a static resource, the callback function pointer of a dynamic resource
screamer 4:0f845ba8adff 342 * and access rights of the recource.
screamer 4:0f845ba8adff 343 *
screamer 4:0f845ba8adff 344 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information
screamer 4:0f845ba8adff 345 * about the resource. Only the pathlen and path elements are evaluated along with
screamer 4:0f845ba8adff 346 * either resourcelen and resource or the function pointer.
screamer 4:0f845ba8adff 347 *
screamer 4:0f845ba8adff 348 * \return 0 Success
screamer 4:0f845ba8adff 349 * \return -1 Failure
screamer 2:ab50a2ab6ec9 350 */
terohoo 5:da1db64e7fb9 351 extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res);
screamer 2:ab50a2ab6ec9 352
screamer 2:ab50a2ab6ec9 353 /**
screamer 4:0f845ba8adff 354 * \fn extern int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path)
screamer 4:0f845ba8adff 355 *
screamer 4:0f845ba8adff 356 * \brief Resource delete function.
screamer 4:0f845ba8adff 357 *
screamer 4:0f845ba8adff 358 * Used to delete a resource. If resource has a subresources, these all must also be removed.
screamer 4:0f845ba8adff 359 *
screamer 4:0f845ba8adff 360 * \param pathlen Contains the length of the path that is to be deleted (excluding possible trailing "\0").
screamer 4:0f845ba8adff 361 *
screamer 4:0f845ba8adff 362 * \param *path_ptr A pointer to an array containing the path.
screamer 4:0f845ba8adff 363 *
screamer 4:0f845ba8adff 364 * \return 0 Success
screamer 4:0f845ba8adff 365 * \return -1 Failure (No such resource)
screamer 2:ab50a2ab6ec9 366 */
terohoo 5:da1db64e7fb9 367 extern int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path);
screamer 2:ab50a2ab6ec9 368
screamer 4:0f845ba8adff 369 /**
terohoo 5:da1db64e7fb9 370 * \fn extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint16_t pathlen, uint8_t *path)
screamer 4:0f845ba8adff 371 *
screamer 4:0f845ba8adff 372 * \brief Resource get function.
screamer 4:0f845ba8adff 373 *
screamer 4:0f845ba8adff 374 * Used to get a resource.
screamer 4:0f845ba8adff 375 *
screamer 4:0f845ba8adff 376 * \param pathlen Contains the length of the path that is to be returned (excluding possible trailing '\0').
screamer 4:0f845ba8adff 377 *
screamer 4:0f845ba8adff 378 * \param *path A pointer to an array containing the path.
screamer 4:0f845ba8adff 379 *
screamer 4:0f845ba8adff 380 * \return !NULL Success, pointer to a sn_nsdl_resource_info_s that contains the resource information\n
screamer 4:0f845ba8adff 381 * \return NULL Failure
screamer 4:0f845ba8adff 382 */
terohoo 5:da1db64e7fb9 383 extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint16_t pathlen, uint8_t *path);
screamer 2:ab50a2ab6ec9 384
screamer 4:0f845ba8adff 385 /**
terohoo 5:da1db64e7fb9 386 * \fn extern sn_grs_resource_list_s *sn_nsdl_list_resource(uint16_t pathlen, uint8_t *path)
screamer 4:0f845ba8adff 387 *
screamer 4:0f845ba8adff 388 * \brief Resource list function.
screamer 4:0f845ba8adff 389 *
screamer 4:0f845ba8adff 390 * \param pathlen Contains the length of the target path (excluding possible trailing '\0').
screamer 4:0f845ba8adff 391 * The length value is not examined if the path itself is a NULL pointer.
screamer 4:0f845ba8adff 392 *
screamer 4:0f845ba8adff 393 * \param *path A pointer to an array containing the path or a NULL pointer.
screamer 4:0f845ba8adff 394 *
screamer 4:0f845ba8adff 395 * \return !NULL A pointer to a sn_grs_resource_list_s structure containing the resource listing.
screamer 4:0f845ba8adff 396 * \return NULL Failure with an unspecified error
screamer 4:0f845ba8adff 397 */
terohoo 5:da1db64e7fb9 398 extern sn_grs_resource_list_s *sn_nsdl_list_resource(uint16_t pathlen, uint8_t *path);
screamer 2:ab50a2ab6ec9 399
screamer 2:ab50a2ab6ec9 400 /**
screamer 4:0f845ba8adff 401 * \fn extern int8_t sn_nsdl_send_coap_message(sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr);
screamer 4:0f845ba8adff 402 *
screamer 3:d8cb1afd7285 403 * \brief Send an outgoing CoAP request.
screamer 4:0f845ba8adff 404 *
screamer 4:0f845ba8adff 405 * \param *address_ptr Pointer to source address struct
screamer 4:0f845ba8adff 406 *
screamer 4:0f845ba8adff 407 * \param *coap_hdr_ptr Pointer to CoAP message to be sent
screamer 4:0f845ba8adff 408 *
screamer 4:0f845ba8adff 409 * \return 0 Success
screamer 4:0f845ba8adff 410 * \return -1 Failure
screamer 2:ab50a2ab6ec9 411 */
terohoo 5:da1db64e7fb9 412 extern int8_t sn_nsdl_send_coap_message(sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr);
screamer 2:ab50a2ab6ec9 413
terohoo 0:58c4f13c4b9a 414 /**
screamer 4:0f845ba8adff 415 * \fn extern int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type);
screamer 2:ab50a2ab6ec9 416 *
terohoo 0:58c4f13c4b9a 417 * \brief This function is used to set the NSP address given by an application.
screamer 2:ab50a2ab6ec9 418 *
screamer 4:0f845ba8adff 419 * \return 0 Success
screamer 4:0f845ba8adff 420 * \return -1 Failed to indicate that NSDL internal address pointer is not allocated (call nsdl_init() first).
terohoo 0:58c4f13c4b9a 421 */
terohoo 5:da1db64e7fb9 422 extern int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type);
terohoo 0:58c4f13c4b9a 423
terohoo 0:58c4f13c4b9a 424 /**
screamer 2:ab50a2ab6ec9 425 * \fn extern int8_t sn_nsdl_destroy(void);
screamer 2:ab50a2ab6ec9 426 *
terohoo 0:58c4f13c4b9a 427 * \brief This function releases all allocated memory in nsdl and grs modules.
terohoo 0:58c4f13c4b9a 428 */
terohoo 0:58c4f13c4b9a 429 extern int8_t sn_nsdl_destroy(void);
terohoo 0:58c4f13c4b9a 430
terohoo 0:58c4f13c4b9a 431 #ifdef __cplusplus
terohoo 0:58c4f13c4b9a 432 }
terohoo 0:58c4f13c4b9a 433 #endif
bogdanm 7:050d0f54a0dc 434
bogdanm 7:050d0f54a0dc 435 #endif // SN_NSDL_LIB_H_