NSDL C library
Dependents: NSDL_HelloWorld_WiFi UbloxModemNanoServiceClient IOT-NSDL_HelloWorld LWM2M_NanoService_Ethernet ... more
Fork of nsdl_lib by
Note that use of this software requires acceptance of the Sensinode EULA: http://mbed.org/teams/Sensinode/code/nsdl_lib/wiki/EULA
sn_nsdl_lib.h@6:1caf76131c9a, 2013-10-14 (annotated)
- Committer:
- screamer
- Date:
- Mon Oct 14 14:28:21 2013 +0300
- Revision:
- 6:1caf76131c9a
- Parent:
- 5:da1db64e7fb9
- Parent:
- 4:0f845ba8adff
- Child:
- 7:050d0f54a0dc
Merge
Who changed what in which revision?
User | Revision | Line number | New 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 | |
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 | |
screamer | 3:d8cb1afd7285 | 20 | /** |
screamer | 3:d8cb1afd7285 | 21 | * \brief Endpoint registration parameters |
screamer | 3:d8cb1afd7285 | 22 | */ |
terohoo | 0:58c4f13c4b9a | 23 | typedef struct sn_nsdl_ep_parameters_ |
terohoo | 0:58c4f13c4b9a | 24 | { |
screamer | 3:d8cb1afd7285 | 25 | uint8_t *endpoint_name_ptr; /**< Endpoint name */ |
terohoo | 0:58c4f13c4b9a | 26 | uint8_t endpoint_name_len; |
terohoo | 0:58c4f13c4b9a | 27 | |
screamer | 3:d8cb1afd7285 | 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 | |
screamer | 3:d8cb1afd7285 | 31 | uint8_t *type_ptr; /**< Endpoint type */ |
terohoo | 0:58c4f13c4b9a | 32 | uint8_t type_len; |
terohoo | 0:58c4f13c4b9a | 33 | |
screamer | 3:d8cb1afd7285 | 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 | |
screamer | 4:0f845ba8adff | 39 | /** |
screamer | 4:0f845ba8adff | 40 | * \brief For internal use |
screamer | 4:0f845ba8adff | 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; |
screamer | 3:d8cb1afd7285 | 46 | } sn_nsdl_sent_messages_s; |
terohoo | 0:58c4f13c4b9a | 47 | |
screamer | 4:0f845ba8adff | 48 | /** |
screamer | 4:0f845ba8adff | 49 | * \brief Function pointers used for memory allocation and freeing |
screamer | 4:0f845ba8adff | 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 *); |
screamer | 3:d8cb1afd7285 | 55 | } sn_nsdl_mem_s; |
terohoo | 0:58c4f13c4b9a | 56 | |
screamer | 4:0f845ba8adff | 57 | /** |
screamer | 4:0f845ba8adff | 58 | * \brief Includes resource path |
screamer | 4:0f845ba8adff | 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; |
screamer | 3:d8cb1afd7285 | 64 | } sn_grs_resource_s; |
terohoo | 0:58c4f13c4b9a | 65 | |
screamer | 4:0f845ba8adff | 66 | /** |
screamer | 4:0f845ba8adff | 67 | * \brief Table of created resources |
screamer | 4:0f845ba8adff | 68 | */ |
terohoo | 0:58c4f13c4b9a | 69 | typedef struct sn_grs_resource_list_ |
terohoo | 0:58c4f13c4b9a | 70 | { |
screamer | 3:d8cb1afd7285 | 71 | uint8_t res_count; /**< Number of resources */ |
terohoo | 0:58c4f13c4b9a | 72 | sn_grs_resource_s *res; |
screamer | 3:d8cb1afd7285 | 73 | } sn_grs_resource_list_s; |
terohoo | 0:58c4f13c4b9a | 74 | |
screamer | 3:d8cb1afd7285 | 75 | /** |
screamer | 3:d8cb1afd7285 | 76 | * \brief Resource access rights |
screamer | 3:d8cb1afd7285 | 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 |
screamer | 3:d8cb1afd7285 | 84 | } sn_grs_resource_acl_e; |
terohoo | 0:58c4f13c4b9a | 85 | |
screamer | 4:0f845ba8adff | 86 | /** |
screamer | 4:0f845ba8adff | 87 | * \brief Used protocol |
screamer | 4:0f845ba8adff | 88 | */ |
terohoo | 0:58c4f13c4b9a | 89 | typedef struct sn_proto_info_ |
terohoo | 0:58c4f13c4b9a | 90 | { |
screamer | 4:0f845ba8adff | 91 | sn_nsdl_capab_e proto; /**< Only COAP is supported */ |
screamer | 3:d8cb1afd7285 | 92 | } sn_proto_info_s; |
terohoo | 0:58c4f13c4b9a | 93 | |
screamer | 3:d8cb1afd7285 | 94 | /** |
screamer | 3:d8cb1afd7285 | 95 | * \brief Defines the resource mode |
screamer | 3:d8cb1afd7285 | 96 | */ |
screamer | 3:d8cb1afd7285 | 97 | typedef enum sn_nsdl_resource_mode_ |
screamer | 3:d8cb1afd7285 | 98 | { |
screamer | 4:0f845ba8adff | 99 | SN_GRS_STATIC, /**< Static resources have some value that doesn't change */ |
screamer | 4:0f845ba8adff | 100 | SN_GRS_DYNAMIC, /**< Dynamic resources are handled in application. Therefore one must give function callback pointer to them */ |
screamer | 4:0f845ba8adff | 101 | SN_GRS_DIRECTORY /**< Directory resources are unused and unsupported */ |
screamer | 3:d8cb1afd7285 | 102 | } sn_nsdl_resource_mode_e; |
screamer | 3:d8cb1afd7285 | 103 | |
screamer | 3:d8cb1afd7285 | 104 | /** |
screamer | 3:d8cb1afd7285 | 105 | * \brief Resource registration parameters |
screamer | 3:d8cb1afd7285 | 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 | |
screamer | 3:d8cb1afd7285 | 125 | /** |
screamer | 3:d8cb1afd7285 | 126 | * \brief Defines parameters for the resource. |
screamer | 3:d8cb1afd7285 | 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 | |
screamer | 3:d8cb1afd7285 | 132 | sn_nsdl_resource_mode_e mode; /**< STATIC etc.. */ |
terohoo | 0:58c4f13c4b9a | 133 | |
screamer | 3:d8cb1afd7285 | 134 | uint16_t pathlen; /**< Address */ |
terohoo | 0:58c4f13c4b9a | 135 | uint8_t *path; |
terohoo | 0:58c4f13c4b9a | 136 | |
screamer | 3:d8cb1afd7285 | 137 | uint16_t resourcelen; /**< 0 if dynamic resource, resource information in static resource */ |
screamer | 3:d8cb1afd7285 | 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 | * |
screamer | 4:0f845ba8adff | 160 | * \return 0 Success |
screamer | 4:0f845ba8adff | 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 | * |
screamer | 4:0f845ba8adff | 174 | * \return 0 Success |
screamer | 4:0f845ba8adff | 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 | * |
screamer | 4:0f845ba8adff | 184 | * \return 0 Success |
screamer | 4:0f845ba8adff | 185 | * \return -1 Failure |
terohoo | 0:58c4f13c4b9a | 186 | */ |
terohoo | 5:da1db64e7fb9 | 187 | extern int8_t sn_nsdl_unregister_endpoint(void); |
screamer | 2:ab50a2ab6ec9 | 188 | |
screamer | 2:ab50a2ab6ec9 | 189 | /** |
terohoo | 5:da1db64e7fb9 | 190 | * \fn extern int8_t sn_nsdl_update_registration(sn_nsdl_ep_parameters_s *endpoint_parameters_ptr); |
screamer | 4:0f845ba8adff | 191 | * |
screamer | 4:0f845ba8adff | 192 | * \brief Update the registration with NSP. |
screamer | 4:0f845ba8adff | 193 | * |
screamer | 4:0f845ba8adff | 194 | * \param *endpoint_info_ptr Contains endpoint information. |
screamer | 4:0f845ba8adff | 195 | * |
screamer | 4:0f845ba8adff | 196 | * \return 0 Success |
screamer | 4:0f845ba8adff | 197 | * \return -1 Failure |
screamer | 2:ab50a2ab6ec9 | 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 | * |
screamer | 4:0f845ba8adff | 206 | * \return 1 Endpoint registration is done successfully |
screamer | 4:0f845ba8adff | 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 | |
screamer | 1:01d723824294 | 211 | /** |
terohoo | 5:da1db64e7fb9 | 212 | * \fn extern void sn_nsdl_nsp_lost(void); |
screamer | 2:ab50a2ab6ec9 | 213 | * |
screamer | 4:0f845ba8adff | 214 | * \brief A function to inform NSDL-C library if application detects a fault in NSP registration. |
screamer | 4:0f845ba8adff | 215 | * |
screamer | 4:0f845ba8adff | 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); |
screamer | 2:ab50a2ab6ec9 | 219 | |
terohoo | 0:58c4f13c4b9a | 220 | /** |
screamer | 4:0f845ba8adff | 221 | * \fn extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len, |
screamer | 4:0f845ba8adff | 222 | * uint8_t *payload_ptr, uint16_t payload_len, |
screamer | 4:0f845ba8adff | 223 | * uint8_t *observe_ptr, uint8_t observe_len, |
screamer | 4:0f845ba8adff | 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 | * |
screamer | 4:0f845ba8adff | 229 | * \param *token_ptr Pointer to token to be used |
screamer | 4:0f845ba8adff | 230 | * \param token_len Token length |
screamer | 4:0f845ba8adff | 231 | * \param *payload_ptr Pointer to payload to be sent |
screamer | 4:0f845ba8adff | 232 | * \param payload_len Payload length |
screamer | 4:0f845ba8adff | 233 | * \param *observe_ptr Pointer to observe number to be sent |
screamer | 4:0f845ba8adff | 234 | * \param observe_len Observe number len |
screamer | 4:0f845ba8adff | 235 | * \param message_type Observation message type (confirmable or non-confirmable) |
screamer | 4:0f845ba8adff | 236 | * \param contetnt_type Observation message payload contetnt type |
screamer | 4:0f845ba8adff | 237 | * |
screamer | 4:0f845ba8adff | 238 | * \return !0 Success, observation messages message ID |
screamer | 4:0f845ba8adff | 239 | * \return 0 Failure |
screamer | 4:0f845ba8adff | 240 | */ |
screamer | 4:0f845ba8adff | 241 | extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len, |
screamer | 4:0f845ba8adff | 242 | uint8_t *payload_ptr, uint16_t payload_len, |
screamer | 4:0f845ba8adff | 243 | uint8_t *observe_ptr, uint8_t observe_len, |
screamer | 4:0f845ba8adff | 244 | sn_coap_msg_type_e message_type, uint8_t content_type); |
screamer | 4:0f845ba8adff | 245 | |
screamer | 4:0f845ba8adff | 246 | /** |
screamer | 4:0f845ba8adff | 247 | * \fn extern int16_t sn_nsdl_get_capability(void) |
screamer | 4:0f845ba8adff | 248 | * |
screamer | 4:0f845ba8adff | 249 | * \brief Capability query function. |
screamer | 4:0f845ba8adff | 250 | * |
screamer | 4:0f845ba8adff | 251 | * Used to retrieve the list of supported protocols from the NSDL module. |
terohoo | 0:58c4f13c4b9a | 252 | * |
screamer | 4:0f845ba8adff | 253 | * \return >0 Success, supported capabilities reported using bitmask with definitions from sn_nsdl_capab_t |
screamer | 4:0f845ba8adff | 254 | * \return 0 Success, no supported capabilities |
terohoo | 0:58c4f13c4b9a | 255 | */ |
terohoo | 5:da1db64e7fb9 | 256 | extern int16_t sn_nsdl_get_capability(void); |
screamer | 2:ab50a2ab6ec9 | 257 | |
screamer | 4:0f845ba8adff | 258 | /** |
screamer | 4:0f845ba8adff | 259 | * \fn extern uint32_t sn_nsdl_get_version(void) |
screamer | 4:0f845ba8adff | 260 | * |
screamer | 4:0f845ba8adff | 261 | * \brief Version query function. |
screamer | 4:0f845ba8adff | 262 | * |
screamer | 4:0f845ba8adff | 263 | * Used to retrieve the version information structure from the NSDL library. |
screamer | 4:0f845ba8adff | 264 | * |
screamer | 4:0f845ba8adff | 265 | * \return !0 MSB 2 bytes major version, LSB 2 bytes minor version. |
screamer | 4:0f845ba8adff | 266 | * \return 0 Failure |
screamer | 4:0f845ba8adff | 267 | */ |
terohoo | 5:da1db64e7fb9 | 268 | extern uint32_t sn_nsdl_get_version(void); |
screamer | 4:0f845ba8adff | 269 | |
screamer | 4:0f845ba8adff | 270 | /** |
screamer | 4:0f845ba8adff | 271 | * \fn extern int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src) |
screamer | 4:0f845ba8adff | 272 | * |
screamer | 4:0f845ba8adff | 273 | * \brief Currently HTTP is not supported |
screamer | 4:0f845ba8adff | 274 | * |
screamer | 4:0f845ba8adff | 275 | * \return -1 Failure |
screamer | 4:0f845ba8adff | 276 | */ |
terohoo | 5:da1db64e7fb9 | 277 | extern int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src); |
screamer | 2:ab50a2ab6ec9 | 278 | |
screamer | 2:ab50a2ab6ec9 | 279 | /** |
screamer | 4:0f845ba8adff | 280 | * \fn extern int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src) |
screamer | 4:0f845ba8adff | 281 | * |
screamer | 4:0f845ba8adff | 282 | * \brief To push CoAP packet to NSDL library |
screamer | 4:0f845ba8adff | 283 | * |
screamer | 4:0f845ba8adff | 284 | * Used to push an CoAP packet to NSDL library for processing. |
screamer | 4:0f845ba8adff | 285 | * |
screamer | 4:0f845ba8adff | 286 | * \param *packet Pointer to a uint8_t array containing the packet (including the CoAP headers). |
screamer | 4:0f845ba8adff | 287 | * After successful execution this array may contain the response packet. |
screamer | 4:0f845ba8adff | 288 | * |
screamer | 4:0f845ba8adff | 289 | * \param *packet_len Pointer to length of the packet. After successful execution this array may contain the length |
screamer | 4:0f845ba8adff | 290 | * of the response packet. |
screamer | 4:0f845ba8adff | 291 | * |
screamer | 4:0f845ba8adff | 292 | * \param *src Pointer to packet source address information. After successful execution this array may contain |
screamer | 4:0f845ba8adff | 293 | * the destination address of the response packet. |
screamer | 4:0f845ba8adff | 294 | * |
screamer | 4:0f845ba8adff | 295 | * \return 0 Success |
screamer | 4:0f845ba8adff | 296 | * \return -1 Failure |
screamer | 2:ab50a2ab6ec9 | 297 | */ |
terohoo | 5:da1db64e7fb9 | 298 | extern int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src); |
screamer | 2:ab50a2ab6ec9 | 299 | |
screamer | 2:ab50a2ab6ec9 | 300 | /** |
screamer | 4:0f845ba8adff | 301 | * \fn extern int8_t sn_nsdl_exec(uint32_t time); |
screamer | 4:0f845ba8adff | 302 | * |
screamer | 4:0f845ba8adff | 303 | * \brief CoAP retransmission function. |
screamer | 4:0f845ba8adff | 304 | * |
screamer | 4:0f845ba8adff | 305 | * Used to give execution time for the NSDL (CoAP) library for retransmissions. The NSDL library |
screamer | 4:0f845ba8adff | 306 | * will call the exec functions of all enabled protocol modules. |
screamer | 4:0f845ba8adff | 307 | * |
screamer | 4:0f845ba8adff | 308 | * \param time Time in seconds. |
screamer | 4:0f845ba8adff | 309 | * |
screamer | 4:0f845ba8adff | 310 | * \return 0 Success |
screamer | 4:0f845ba8adff | 311 | * \return -1 Failure |
screamer | 2:ab50a2ab6ec9 | 312 | */ |
terohoo | 5:da1db64e7fb9 | 313 | extern int8_t sn_nsdl_exec(uint32_t time); |
screamer | 2:ab50a2ab6ec9 | 314 | |
screamer | 2:ab50a2ab6ec9 | 315 | /** |
screamer | 4:0f845ba8adff | 316 | * \fn extern int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res) |
screamer | 4:0f845ba8adff | 317 | * |
screamer | 4:0f845ba8adff | 318 | * \brief Resource creating function. |
screamer | 4:0f845ba8adff | 319 | * |
screamer | 4:0f845ba8adff | 320 | * Used to create a static or dynamic HTTP(S) or CoAP resource. |
screamer | 4:0f845ba8adff | 321 | * |
screamer | 4:0f845ba8adff | 322 | * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information |
screamer | 4:0f845ba8adff | 323 | * about the resource. |
screamer | 4:0f845ba8adff | 324 | * |
screamer | 4:0f845ba8adff | 325 | * \return 0 Success |
screamer | 4:0f845ba8adff | 326 | * \return -1 Failure |
screamer | 4:0f845ba8adff | 327 | * \return -2 Resource already exists |
screamer | 4:0f845ba8adff | 328 | * \return -3 Invalid path |
screamer | 4:0f845ba8adff | 329 | * \return -4 List adding failure |
screamer | 2:ab50a2ab6ec9 | 330 | */ |
terohoo | 5:da1db64e7fb9 | 331 | extern int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res); |
screamer | 2:ab50a2ab6ec9 | 332 | |
screamer | 2:ab50a2ab6ec9 | 333 | /** |
screamer | 4:0f845ba8adff | 334 | * \fn extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res) |
screamer | 4:0f845ba8adff | 335 | * |
screamer | 4:0f845ba8adff | 336 | * \brief Resource updating function. |
screamer | 4:0f845ba8adff | 337 | * |
screamer | 4:0f845ba8adff | 338 | * Used to update the direct value of a static resource, the callback function pointer of a dynamic resource |
screamer | 4:0f845ba8adff | 339 | * and access rights of the recource. |
screamer | 4:0f845ba8adff | 340 | * |
screamer | 4:0f845ba8adff | 341 | * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information |
screamer | 4:0f845ba8adff | 342 | * about the resource. Only the pathlen and path elements are evaluated along with |
screamer | 4:0f845ba8adff | 343 | * either resourcelen and resource or the function pointer. |
screamer | 4:0f845ba8adff | 344 | * |
screamer | 4:0f845ba8adff | 345 | * \return 0 Success |
screamer | 4:0f845ba8adff | 346 | * \return -1 Failure |
screamer | 2:ab50a2ab6ec9 | 347 | */ |
terohoo | 5:da1db64e7fb9 | 348 | extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res); |
screamer | 2:ab50a2ab6ec9 | 349 | |
screamer | 2:ab50a2ab6ec9 | 350 | /** |
screamer | 4:0f845ba8adff | 351 | * \fn extern int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path) |
screamer | 4:0f845ba8adff | 352 | * |
screamer | 4:0f845ba8adff | 353 | * \brief Resource delete function. |
screamer | 4:0f845ba8adff | 354 | * |
screamer | 4:0f845ba8adff | 355 | * Used to delete a resource. If resource has a subresources, these all must also be removed. |
screamer | 4:0f845ba8adff | 356 | * |
screamer | 4:0f845ba8adff | 357 | * \param pathlen Contains the length of the path that is to be deleted (excluding possible trailing "\0"). |
screamer | 4:0f845ba8adff | 358 | * |
screamer | 4:0f845ba8adff | 359 | * \param *path_ptr A pointer to an array containing the path. |
screamer | 4:0f845ba8adff | 360 | * |
screamer | 4:0f845ba8adff | 361 | * \return 0 Success |
screamer | 4:0f845ba8adff | 362 | * \return -1 Failure (No such resource) |
screamer | 2:ab50a2ab6ec9 | 363 | */ |
terohoo | 5:da1db64e7fb9 | 364 | extern int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path); |
screamer | 2:ab50a2ab6ec9 | 365 | |
screamer | 4:0f845ba8adff | 366 | /** |
terohoo | 5:da1db64e7fb9 | 367 | * \fn extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint16_t pathlen, uint8_t *path) |
screamer | 4:0f845ba8adff | 368 | * |
screamer | 4:0f845ba8adff | 369 | * \brief Resource get function. |
screamer | 4:0f845ba8adff | 370 | * |
screamer | 4:0f845ba8adff | 371 | * Used to get a resource. |
screamer | 4:0f845ba8adff | 372 | * |
screamer | 4:0f845ba8adff | 373 | * \param pathlen Contains the length of the path that is to be returned (excluding possible trailing '\0'). |
screamer | 4:0f845ba8adff | 374 | * |
screamer | 4:0f845ba8adff | 375 | * \param *path A pointer to an array containing the path. |
screamer | 4:0f845ba8adff | 376 | * |
screamer | 4:0f845ba8adff | 377 | * \return !NULL Success, pointer to a sn_nsdl_resource_info_s that contains the resource information\n |
screamer | 4:0f845ba8adff | 378 | * \return NULL Failure |
screamer | 4:0f845ba8adff | 379 | */ |
terohoo | 5:da1db64e7fb9 | 380 | extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint16_t pathlen, uint8_t *path); |
screamer | 2:ab50a2ab6ec9 | 381 | |
screamer | 4:0f845ba8adff | 382 | /** |
terohoo | 5:da1db64e7fb9 | 383 | * \fn extern sn_grs_resource_list_s *sn_nsdl_list_resource(uint16_t pathlen, uint8_t *path) |
screamer | 4:0f845ba8adff | 384 | * |
screamer | 4:0f845ba8adff | 385 | * \brief Resource list function. |
screamer | 4:0f845ba8adff | 386 | * |
screamer | 4:0f845ba8adff | 387 | * \param pathlen Contains the length of the target path (excluding possible trailing '\0'). |
screamer | 4:0f845ba8adff | 388 | * The length value is not examined if the path itself is a NULL pointer. |
screamer | 4:0f845ba8adff | 389 | * |
screamer | 4:0f845ba8adff | 390 | * \param *path A pointer to an array containing the path or a NULL pointer. |
screamer | 4:0f845ba8adff | 391 | * |
screamer | 4:0f845ba8adff | 392 | * \return !NULL A pointer to a sn_grs_resource_list_s structure containing the resource listing. |
screamer | 4:0f845ba8adff | 393 | * \return NULL Failure with an unspecified error |
screamer | 4:0f845ba8adff | 394 | */ |
terohoo | 5:da1db64e7fb9 | 395 | extern sn_grs_resource_list_s *sn_nsdl_list_resource(uint16_t pathlen, uint8_t *path); |
screamer | 2:ab50a2ab6ec9 | 396 | |
screamer | 2:ab50a2ab6ec9 | 397 | /** |
screamer | 4:0f845ba8adff | 398 | * \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 | 399 | * |
screamer | 3:d8cb1afd7285 | 400 | * \brief Send an outgoing CoAP request. |
screamer | 4:0f845ba8adff | 401 | * |
screamer | 4:0f845ba8adff | 402 | * \param *address_ptr Pointer to source address struct |
screamer | 4:0f845ba8adff | 403 | * |
screamer | 4:0f845ba8adff | 404 | * \param *coap_hdr_ptr Pointer to CoAP message to be sent |
screamer | 4:0f845ba8adff | 405 | * |
screamer | 4:0f845ba8adff | 406 | * \return 0 Success |
screamer | 4:0f845ba8adff | 407 | * \return -1 Failure |
screamer | 2:ab50a2ab6ec9 | 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); |
screamer | 2:ab50a2ab6ec9 | 410 | |
terohoo | 0:58c4f13c4b9a | 411 | /** |
screamer | 4:0f845ba8adff | 412 | * \fn extern int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type); |
screamer | 2:ab50a2ab6ec9 | 413 | * |
terohoo | 0:58c4f13c4b9a | 414 | * \brief This function is used to set the NSP address given by an application. |
screamer | 2:ab50a2ab6ec9 | 415 | * |
screamer | 4:0f845ba8adff | 416 | * \return 0 Success |
screamer | 4:0f845ba8adff | 417 | * \return -1 Failed to indicate that NSDL internal address pointer is not allocated (call nsdl_init() first). |
terohoo | 0:58c4f13c4b9a | 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 | 0:58c4f13c4b9a | 420 | |
terohoo | 0:58c4f13c4b9a | 421 | /** |
screamer | 2:ab50a2ab6ec9 | 422 | * \fn extern int8_t sn_nsdl_destroy(void); |
screamer | 2:ab50a2ab6ec9 | 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 |