NSDL library for Cortex M0 platforms

Committer:
ansond
Date:
Sun Feb 22 04:50:04 2015 +0000
Revision:
2:ba12e13c569a
Parent:
0:cbf069c4db24
updates to archive file

Who changed what in which revision?

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