version of nsdl to work with lwm2m, updated RD parameters and location option handling

Dependents:   ArchPro_LWM2M_LED_Client Weather_Station_LWM2M mbedEndpointNetwork

Fork of nanoservice_client_1_12 by Zach Shelby

Committer:
michaeljkoster
Date:
Mon Apr 13 22:13:40 2015 +0000
Revision:
10:b5ecd6660d71
Parent:
1:14a9b0f4b9d6
Add error return from sn_nsdl_register_endpoint() in sn_nsdl.c

Who changed what in which revision?

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