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:
terohoo
Date:
Mon Oct 14 11:00:30 2013 +0000
Revision:
5:da1db64e7fb9
Parent:
0:58c4f13c4b9a
Child:
6:1caf76131c9a
- New library build; - Header cleaning

Who changed what in which revision?

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