Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-client-c by
sn_nsdl_lib.h
00001 /* 00002 * Copyright (c) 2011-2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /** 00018 * \file sn_nsdl_lib.h 00019 * 00020 * \brief NanoService Devices Library header file 00021 * 00022 * 00023 */ 00024 00025 #ifndef SN_NSDL_LIB_H_ 00026 #define SN_NSDL_LIB_H_ 00027 00028 #include "ns_list.h" 00029 00030 #ifdef __cplusplus 00031 extern "C" { 00032 #endif 00033 00034 #define SN_NSDL_ENDPOINT_NOT_REGISTERED 0 00035 #define SN_NSDL_ENDPOINT_IS_REGISTERED 1 00036 00037 /* Handle structure */ 00038 struct nsdl_s; 00039 00040 /** 00041 * \brief Received device server security 00042 */ 00043 typedef enum omalw_server_security_ { 00044 SEC_NOT_SET = -1, 00045 PSK = 0, 00046 RPK = 1, 00047 CERTIFICATE = 2, 00048 NO_SEC = 3 00049 } omalw_server_security_t; 00050 00051 /** 00052 * \brief Endpoint binding and mode 00053 */ 00054 typedef enum sn_nsdl_oma_binding_and_mode_ { 00055 BINDING_MODE_NOT_SET = 0, 00056 BINDING_MODE_U = 0x01, 00057 BINDING_MODE_Q = 0x02, 00058 BINDING_MODE_S = 0x04 00059 } sn_nsdl_oma_binding_and_mode_t; 00060 00061 /** 00062 * \brief Endpoint registration mode. 00063 * If REGISTER_WITH_RESOURCES, endpoint sends list of all resources during registration. 00064 * If REGISTER_WITH_TEMPLATE, endpoint sends registration without resource list. Device server must have 00065 * correctly configured template. 00066 */ 00067 typedef enum sn_nsdl_registration_mode_ { 00068 REGISTER_WITH_RESOURCES = 0, 00069 REGISTER_WITH_TEMPLATE 00070 } sn_nsdl_registration_mode_t; 00071 00072 00073 typedef struct omalw_certificate_list_ { 00074 uint8_t certificate_chain_len; 00075 uint8_t *certificate_ptr[2]; 00076 uint16_t certificate_len[2]; 00077 uint8_t *own_private_key_ptr; 00078 uint16_t own_private_key_len; 00079 } omalw_certificate_list_t; 00080 00081 /** 00082 * \brief Endpoint registration parameters 00083 */ 00084 typedef struct sn_nsdl_ep_parameters_ { 00085 uint8_t *endpoint_name_ptr; /**< Endpoint name */ 00086 uint8_t endpoint_name_len; 00087 00088 uint8_t *domain_name_ptr; /**< Domain to register. If null, NSP uses default domain */ 00089 uint8_t domain_name_len; 00090 00091 uint8_t *type_ptr; /**< Endpoint type */ 00092 uint8_t type_len; 00093 00094 uint8_t *lifetime_ptr; /**< Endpoint lifetime in seconds. eg. "1200" = 1200 seconds */ 00095 uint8_t lifetime_len; 00096 00097 sn_nsdl_registration_mode_t ds_register_mode; /**< Defines registration mode */ 00098 sn_nsdl_oma_binding_and_mode_t binding_and_mode; /**< Defines endpoints binding and mode */ 00099 00100 uint8_t *location_ptr; /**< Endpoint location in server, optional parameter,default is NULL */ 00101 uint8_t location_len; 00102 00103 } sn_nsdl_ep_parameters_s; 00104 00105 /** 00106 * \brief For internal use 00107 */ 00108 typedef struct sn_nsdl_sent_messages_ { 00109 uint16_t msg_id_number; 00110 uint8_t message_type; 00111 ns_list_link_t link; 00112 } sn_nsdl_sent_messages_s; 00113 00114 /** 00115 * \brief Includes resource path 00116 */ 00117 typedef struct sn_grs_resource_ { 00118 uint8_t pathlen; 00119 uint8_t *path; 00120 } sn_grs_resource_s; 00121 00122 /** 00123 * \brief Table of created resources 00124 */ 00125 typedef struct sn_grs_resource_list_ { 00126 uint8_t res_count; /**< Number of resources */ 00127 sn_grs_resource_s *res; 00128 } sn_grs_resource_list_s; 00129 00130 /** 00131 * \brief Resource access rights 00132 */ 00133 typedef enum sn_grs_resource_acl_ { 00134 SN_GRS_GET_ALLOWED = 0x01 , 00135 SN_GRS_PUT_ALLOWED = 0x02, 00136 SN_GRS_POST_ALLOWED = 0x04, 00137 SN_GRS_DELETE_ALLOWED = 0x08 00138 } sn_grs_resource_acl_e; 00139 00140 00141 typedef enum sn_nsdl_oma_device_error_ { 00142 NO_ERROR = 0, 00143 LOW_BATTERY_POWER = 1, 00144 EXTERNAL_POWER_SUPPLY_OFF = 2, 00145 GPS_MODULE_FAILURE = 3, 00146 LOW_RECEIVED_SIGNAL_STRENGTH = 4, 00147 OUT_OF_MEMORY = 5, 00148 SMS_FAILURE = 6, 00149 IP_CONN_FAILURE = 7, 00150 PERIPHERAL_MALFUNCTION = 8 00151 } sn_nsdl_oma_device_error_t; 00152 00153 /** 00154 * \brief Defines the resource mode 00155 */ 00156 typedef enum sn_nsdl_resource_mode_ { 00157 SN_GRS_STATIC, /**< Static resources have some value that doesn't change */ 00158 SN_GRS_DYNAMIC, /**< Dynamic resources are handled in application. Therefore one must give function callback pointer to them */ 00159 SN_GRS_DIRECTORY /**< Directory resources are unused and unsupported */ 00160 } sn_nsdl_resource_mode_e; 00161 00162 /** 00163 * \brief Resource registration parameters 00164 */ 00165 typedef struct sn_nsdl_resource_parameters_ { 00166 uint8_t *resource_type_ptr; 00167 uint16_t resource_type_len; 00168 00169 uint8_t *interface_description_ptr; 00170 uint16_t interface_description_len; 00171 00172 uint8_t coap_content_type; 00173 00174 uint8_t mime_content_type; 00175 00176 uint8_t observable; 00177 00178 uint8_t registered; 00179 00180 } sn_nsdl_resource_parameters_s; 00181 00182 /** 00183 * \brief Defines parameters for the resource. 00184 */ 00185 typedef struct sn_nsdl_resource_info_ { 00186 sn_nsdl_resource_parameters_s *resource_parameters_ptr; 00187 00188 sn_nsdl_resource_mode_e mode; /**< STATIC etc.. */ 00189 00190 uint16_t pathlen; /**< Address */ 00191 uint8_t *path; 00192 00193 uint16_t resourcelen; /**< 0 if dynamic resource, resource information in static resource */ 00194 uint8_t *resource; /**< NULL if dynamic resource */ 00195 00196 sn_grs_resource_acl_e access; 00197 00198 uint8_t (*sn_grs_dyn_res_callback)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *, sn_nsdl_capab_e); 00199 00200 ns_list_link_t link; 00201 00202 uint8_t publish_uri; 00203 00204 } sn_nsdl_resource_info_s; 00205 00206 /** 00207 * \brief Defines OMA device object parameters. 00208 */ 00209 typedef struct sn_nsdl_oma_device_ { 00210 sn_nsdl_oma_device_error_t error_code; /**< Error code. Mandatory. Can be more than one */ 00211 uint8_t (*sn_oma_device_boot_callback)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *, sn_nsdl_capab_e); /**< Device boot callback function. If defined, this is called when reset request is received */ 00212 00213 } sn_nsdl_oma_device_t; 00214 00215 /** 00216 * \brief Defines OMAlw server information 00217 */ 00218 typedef struct sn_nsdl_oma_server_info_ { 00219 sn_nsdl_addr_s *omalw_address_ptr; 00220 omalw_server_security_t omalw_server_security; 00221 00222 } sn_nsdl_oma_server_info_t; 00223 00224 /** 00225 * \brief Defines endpoint parameters to OMA bootstrap. 00226 */ 00227 typedef struct sn_nsdl_bs_ep_info_ { 00228 void (*oma_bs_status_cb)(sn_nsdl_oma_server_info_t *); /**< Callback for OMA bootstrap status */ 00229 sn_nsdl_oma_device_t *device_object; /**< OMA LWM2M mandatory device resources */ 00230 } sn_nsdl_bs_ep_info_t; 00231 00232 00233 00234 00235 /** 00236 * \fn struct nsdl_s *sn_nsdl_init (uint8_t (*sn_nsdl_tx_cb)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *), 00237 * uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *), 00238 * sn_nsdl_mem_s *sn_memory) 00239 * 00240 * \brief Initialization function for NSDL library. Initializes NSDL, GRS, HTTP and CoAP. 00241 * 00242 * \param *sn_nsdl_tx_callback A callback function for sending messages. 00243 * 00244 * \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 00245 * reply for some DS messages (register message etc.), rx callback will be called. 00246 * 00247 * \param *sn_memory Memory structure which includes function pointers to the allocation and free functions. 00248 * 00249 * \return pointer to created handle structure. NULL if failed 00250 */ 00251 struct nsdl_s *sn_nsdl_init(uint8_t (*sn_nsdl_tx_cb)(struct nsdl_s *, sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *), 00252 uint8_t (*sn_nsdl_rx_cb)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *), 00253 void *(*sn_nsdl_alloc)(uint16_t), void (*sn_nsdl_free)(void *)); 00254 00255 /** 00256 * \fn extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr); 00257 * 00258 * \brief Registers endpoint to mbed Device Server. 00259 * \param *handle Pointer to nsdl-library handle 00260 * \param *endpoint_info_ptr Contains endpoint information. 00261 * 00262 * \return registration message ID, 0 if failed 00263 */ 00264 extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr); 00265 00266 /** 00267 * \fn extern uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle) 00268 * 00269 * \brief Sends unregister-message to mbed Device Server. 00270 * 00271 * \param *handle Pointer to nsdl-library handle 00272 * 00273 * \return unregistration message ID, 0 if failed 00274 */ 00275 extern uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle); 00276 00277 /** 00278 * \fn extern uint16_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len); 00279 * 00280 * \brief Update the registration with mbed Device Server. 00281 * 00282 * \param *handle Pointer to nsdl-library handle 00283 * \param *lt_ptr Pointer to lifetime value string in ascii form, eg. "1200" 00284 * \param lt_len Length of the lifetime string 00285 * 00286 * \return registration update message ID, 0 if failed 00287 */ 00288 extern uint16_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len); 00289 00290 /** 00291 * \fn extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len); 00292 * 00293 * \brief Sets the location receievd from Device Server. 00294 * 00295 * \param *handle Pointer to nsdl-library handle 00296 * \param *lt_ptr Pointer to location value string , eg. "s322j4k" 00297 * \param lt_len Length of the location string 00298 * 00299 * \return success, 0 if failed -1 00300 */ 00301 extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len); 00302 00303 00304 /** 00305 * \fn extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle) 00306 * 00307 * \brief Checks if endpoint is registered. 00308 * 00309 * \param *handle Pointer to nsdl-library handle 00310 * 00311 * \return 1 Endpoint registration is done successfully 00312 * \return 0 Endpoint is not registered 00313 */ 00314 extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle); 00315 00316 /** 00317 * \fn extern void sn_nsdl_nsp_lost(struct nsdl_s *handle); 00318 * 00319 * \brief A function to inform mbed Device C client library if application detects a fault in mbed Device Server registration. 00320 * 00321 * \param *handle Pointer to nsdl-library handle 00322 * 00323 * After calling this function sn_nsdl_is_ep_registered() will return "not registered". 00324 */ 00325 extern void sn_nsdl_nsp_lost(struct nsdl_s *handle); 00326 00327 /** 00328 * \fn extern uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, 00329 * uint8_t *payload_ptr, uint16_t payload_len, 00330 * uint8_t *observe_ptr, uint8_t observe_len, 00331 * sn_coap_msg_type_e message_type, uint8_t content_type) 00332 * 00333 * 00334 * \brief Sends observation message to mbed Device Server 00335 * 00336 * \param *handle Pointer to nsdl-library handle 00337 * \param *token_ptr Pointer to token to be used 00338 * \param token_len Token length 00339 * \param *payload_ptr Pointer to payload to be sent 00340 * \param payload_len Payload length 00341 * \param *observe_ptr Pointer to observe number to be sent 00342 * \param observe_len Observe number len 00343 * \param message_type Observation message type (confirmable or non-confirmable) 00344 * \param content_type Observation message payload contetnt type 00345 * 00346 * \return !0 Success, observation messages message ID 00347 * \return 0 Failure 00348 */ 00349 extern uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, 00350 uint8_t *payload_ptr, uint16_t payload_len, 00351 uint8_t *observe_ptr, uint8_t observe_len, 00352 sn_coap_msg_type_e message_type, 00353 uint8_t content_type); 00354 00355 /** 00356 * \fn extern uint16_t sn_nsdl_send_observation_notification_with_uri_path(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, 00357 * uint8_t *payload_ptr, uint16_t payload_len, 00358 * uint8_t *observe_ptr, uint8_t observe_len, 00359 * sn_coap_msg_type_e message_type, uint8_t content_type, 00360 * uint8_t *uri_path_ptr, 00361 * uint16_t uri_path_len) 00362 * 00363 * 00364 * \brief Sends observation message to mbed Device Server with uri path 00365 * 00366 * \param *handle Pointer to nsdl-library handle 00367 * \param *token_ptr Pointer to token to be used 00368 * \param token_len Token length 00369 * \param *payload_ptr Pointer to payload to be sent 00370 * \param payload_len Payload length 00371 * \param *observe_ptr Pointer to observe number to be sent 00372 * \param observe_len Observe number len 00373 * \param message_type Observation message type (confirmable or non-confirmable) 00374 * \param content_type Observation message payload contetnt type 00375 * \param uri_path_ptr Pointer to uri path to be sent 00376 * \param uri_path_len Uri path len 00377 * 00378 * \return !0 Success, observation messages message ID 00379 * \return 0 Failure 00380 */ 00381 extern uint16_t sn_nsdl_send_observation_notification_with_uri_path(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, 00382 uint8_t *payload_ptr, uint16_t payload_len, 00383 uint8_t *observe_ptr, uint8_t observe_len, 00384 sn_coap_msg_type_e message_type, 00385 uint8_t content_type, 00386 uint8_t *uri_path_ptr, 00387 uint16_t uri_path_len); 00388 00389 /** 00390 * \fn extern uint32_t sn_nsdl_get_version(void) 00391 * 00392 * \brief Version query function. 00393 * 00394 * Used to retrieve the version information from the mbed Device C Client library. 00395 * 00396 * \return Pointer to library version string 00397 */ 00398 extern char *sn_nsdl_get_version(void); 00399 00400 /** 00401 * \fn extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src) 00402 * 00403 * \brief To push CoAP packet to mbed Device C Client library 00404 * 00405 * Used to push an CoAP packet to mbed Device C Client library for processing. 00406 * 00407 * \param *handle Pointer to nsdl-library handle 00408 * 00409 * \param *packet Pointer to a uint8_t array containing the packet (including the CoAP headers). 00410 * After successful execution this array may contain the response packet. 00411 * 00412 * \param *packet_len Pointer to length of the packet. After successful execution this array may contain the length 00413 * of the response packet. 00414 * 00415 * \param *src Pointer to packet source address information. After successful execution this array may contain 00416 * the destination address of the response packet. 00417 * 00418 * \return 0 Success 00419 * \return -1 Failure 00420 */ 00421 extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src); 00422 00423 /** 00424 * \fn extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time); 00425 * 00426 * \brief CoAP retransmission function. 00427 * 00428 * Used to give execution time for the mbed Device C Client library for retransmissions. 00429 * 00430 * \param *handle Pointer to nsdl-library handle 00431 * 00432 * \param time Time in seconds. 00433 * 00434 * \return 0 Success 00435 * \return -1 Failure 00436 */ 00437 extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time); 00438 00439 /** 00440 * \fn extern int8_t sn_nsdl_create_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res); 00441 * 00442 * \brief Resource creating function. 00443 * 00444 * Used to create a static or dynamic CoAP resource. 00445 * 00446 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information 00447 * about the resource. 00448 * 00449 * \return 0 Success 00450 * \return -1 Failure 00451 * \return -2 Resource already exists 00452 * \return -3 Invalid path 00453 * \return -4 List adding failure 00454 */ 00455 extern int8_t sn_nsdl_create_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res); 00456 00457 /** 00458 * \fn extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res) 00459 * 00460 * \brief Resource updating function. 00461 * 00462 * Used to update the direct value of a static resource, the callback function pointer of a dynamic resource 00463 * and access rights of the recource. 00464 * 00465 * \param *handle Pointer to nsdl-library handle 00466 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information 00467 * about the resource. Only the pathlen and path elements are evaluated along with 00468 * either resourcelen and resource or the function pointer. 00469 * 00470 * \return 0 Success 00471 * \return -1 Failure 00472 */ 00473 extern int8_t sn_nsdl_update_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res); 00474 00475 /** 00476 * \fn extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, uint8_t pathlen, uint8_t *path) 00477 * 00478 * \brief Resource delete function. 00479 * 00480 * Used to delete a resource. If resource has a subresources, these all must also be removed. 00481 * 00482 * \param *handle Pointer to nsdl-library handle 00483 * \param pathlen Contains the length of the path that is to be deleted (excluding possible trailing "\0"). 00484 * \param *path_ptr A pointer to an array containing the path. 00485 * 00486 * \return 0 Success 00487 * \return -1 Failure (No such resource) 00488 */ 00489 extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path); 00490 00491 /** 00492 * \fn extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path) 00493 * 00494 * \brief Resource get function. 00495 * 00496 * Used to get a resource. 00497 * 00498 * \param *handle Pointer to nsdl-library handle 00499 * \param pathlen Contains the length of the path that is to be returned (excluding possible trailing '\0'). 00500 * \param *path A pointer to an array containing the path. 00501 * 00502 * \return !NULL Success, pointer to a sn_nsdl_resource_info_s that contains the resource information\n 00503 * \return NULL Failure 00504 */ 00505 extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path); 00506 00507 /** 00508 * \fn extern sn_grs_resource_list_s *sn_nsdl_list_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path) 00509 * 00510 * \brief Resource list function. 00511 * 00512 * \param *handle Pointer to nsdl-library handle 00513 * \param pathlen Contains the length of the target path (excluding possible trailing '\0'). 00514 * The length value is not examined if the path itself is a NULL pointer. 00515 * \param *path A pointer to an array containing the path or a NULL pointer. 00516 * 00517 * \return !NULL A pointer to a sn_grs_resource_list_s structure containing the resource listing. 00518 * \return NULL Failure with an unspecified error 00519 */ 00520 sn_grs_resource_list_s *sn_nsdl_list_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path); 00521 00522 /** 00523 * \fn extern void sn_nsdl_free_resource_list(struct nsdl_s *handle, sn_grs_resource_list_s *list) 00524 * 00525 * \brief Free a resource list obtained from sn_nsdl_list_resource() 00526 * 00527 * \param list The list to free, or NULL. 00528 */ 00529 void sn_nsdl_free_resource_list(struct nsdl_s *handle, sn_grs_resource_list_s *list); 00530 00531 /** 00532 * \fn extern int8_t sn_nsdl_send_coap_message(struct nsdl_s *handle, sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr); 00533 * 00534 * \brief Send an outgoing CoAP request. 00535 * 00536 * \param *handle Pointer to nsdl-library handle 00537 * \param *address_ptr Pointer to source address struct 00538 * \param *coap_hdr_ptr Pointer to CoAP message to be sent 00539 * 00540 * \return 0 Success 00541 * \return -1 Failure 00542 */ 00543 extern int8_t sn_nsdl_send_coap_message(struct nsdl_s *handle, sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr); 00544 00545 /** 00546 * \fn extern int8_t set_NSP_address(struct nsdl_s *handle, uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type); 00547 * 00548 * \brief This function is used to set the mbed Device Server address given by an application. 00549 * 00550 * \param *handle Pointer to nsdl-library handle 00551 * \return 0 Success 00552 * \return -1 Failed to indicate that internal address pointer is not allocated (call nsdl_init() first). 00553 */ 00554 extern int8_t set_NSP_address(struct nsdl_s *handle, uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type); 00555 00556 /** 00557 * \fn extern int8_t sn_nsdl_destroy(struct nsdl_s *handle); 00558 * 00559 * \param *handle Pointer to nsdl-library handle 00560 * \brief This function releases all allocated memory in mbed Device C Client library. 00561 */ 00562 extern int8_t sn_nsdl_destroy(struct nsdl_s *handle); 00563 00564 /** 00565 * \fn extern uint16_t sn_nsdl_oma_bootstrap(struct nsdl_s *handle, sn_nsdl_addr_s *bootstrap_address_ptr, sn_nsdl_ep_parameters_s *endpoint_info_ptr, sn_nsdl_bs_ep_info_t *bootstrap_endpoint_info_ptr); 00566 * 00567 * \brief Starts OMA bootstrap process 00568 * 00569 * \param *handle Pointer to nsdl-library handle 00570 * 00571 * \return bootstrap message ID, 0 if failed 00572 */ 00573 extern uint16_t sn_nsdl_oma_bootstrap(struct nsdl_s *handle, sn_nsdl_addr_s *bootstrap_address_ptr, sn_nsdl_ep_parameters_s *endpoint_info_ptr, sn_nsdl_bs_ep_info_t *bootstrap_endpoint_info_ptr); 00574 00575 /** 00576 * \fn extern omalw_certificate_list_t *sn_nsdl_get_certificates(struct nsdl_s *handle); 00577 * 00578 * \brief Get pointer to received device server certificates 00579 * 00580 * \param *handle Pointer to nsdl-library handle 00581 */ 00582 extern omalw_certificate_list_t *sn_nsdl_get_certificates(struct nsdl_s *handle); 00583 00584 /** 00585 * \fn extern int8_t sn_nsdl_update_certificates(struct nsdl_s *handle, omalw_certificate_list_t* certificate_ptr, uint8_t certificate_chain); 00586 * 00587 * \brief Updates certificate pointers to resource server. 00588 * 00589 * \param *handle Pointer to nsdl-library handle 00590 */ 00591 extern int8_t sn_nsdl_update_certificates(struct nsdl_s *handle, omalw_certificate_list_t *certificate_ptr, uint8_t certificate_chain); 00592 00593 /** 00594 * \fn extern int8_t sn_nsdl_create_oma_device_object(struct nsdl_s *handle, sn_nsdl_oma_device_t *device_object_ptr); 00595 * 00596 * \brief Creates new device object resource 00597 * 00598 * \param *handle Pointer to nsdl-library handle 00599 */ 00600 extern int8_t sn_nsdl_create_oma_device_object(struct nsdl_s *handle, sn_nsdl_oma_device_t *device_object_ptr); 00601 00602 /** 00603 * \fn sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code) 00604 * 00605 * \brief Prepares generic response packet from a request packet. This function allocates memory for the resulting sn_coap_hdr_s 00606 * 00607 * \param *handle Pointer to library handle 00608 * \param *coap_packet_ptr The request packet pointer 00609 * \param msg_code response messages code 00610 * 00611 * \return *coap_packet_ptr The allocated and pre-filled response packet pointer 00612 * NULL Error in parsing the request 00613 * 00614 */ 00615 extern sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code); 00616 00617 /** 00618 * \fn void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr) 00619 * 00620 * \brief Releases memory of given CoAP message 00621 * 00622 * Note!!! Does not release Payload part 00623 * 00624 * \param *handle Pointer to CoAP library handle 00625 * 00626 * \param *freed_coap_msg_ptr is pointer to released CoAP message 00627 */ 00628 extern void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr); 00629 00630 /** 00631 * \fn int8_t sn_nsdl_set_retransmission_parameters(struct nsdl_s *handle, uint8_t resending_count, uint8_t resending_intervall) 00632 * 00633 * \brief If re-transmissions are enabled, this function changes resending count and interval. 00634 * 00635 * \param *handle Pointer to library handle 00636 * \param uint8_t resending_count max number of resendings for message 00637 * \param uint8_t resending_intervall message resending intervall in seconds 00638 * \return 0 = success, -1 = failure 00639 */ 00640 extern int8_t sn_nsdl_set_retransmission_parameters(struct nsdl_s *handle, uint8_t resending_count, uint8_t resending_interval); 00641 00642 /** 00643 * \fn int8_t sn_nsdl_set_retransmission_buffer(struct nsdl_s *handle, uint8_t buffer_size_messages, uint16_t buffer_size_bytes) 00644 * 00645 * \brief If re-transmissions are enabled, this function changes message retransmission queue size. 00646 * Set size to '0' to disable feature. If both are set to '0', then re-sendings are disabled. 00647 * 00648 * \param *handle Pointer to library handle 00649 * \param uint8_t buffer_size_messages queue size - maximum number of messages to be saved to queue 00650 * \param uint8_t buffer_size_bytes queue size - maximum size of messages saved to queue 00651 * \return 0 = success, -1 = failure 00652 */ 00653 extern int8_t sn_nsdl_set_retransmission_buffer(struct nsdl_s *handle, 00654 uint8_t buffer_size_messages, uint16_t buffer_size_bytes); 00655 00656 /** 00657 * \fn int8_t sn_nsdl_set_block_size(struct nsdl_s *handle, uint16_t block_size) 00658 * 00659 * \brief If block transfer is enabled, this function changes the block size. 00660 * 00661 * \param *handle Pointer to library handle 00662 * \param uint16_t block_size maximum size of CoAP payload. Valid sizes are 16, 32, 64, 128, 256, 512 and 1024 bytes 00663 * \return 0 = success, -1 = failure 00664 */ 00665 extern int8_t sn_nsdl_set_block_size(struct nsdl_s *handle, uint16_t block_size); 00666 00667 /** 00668 * \fn int8_t sn_nsdl_set_duplicate_buffer_size(struct nsdl_s *handle,uint8_t message_count) 00669 * 00670 * \brief If dublicate message detection is enabled, this function changes buffer size. 00671 * 00672 * \param *handle Pointer to library handle 00673 * \param uint8_t message_count max number of messages saved for duplicate control 00674 * \return 0 = success, -1 = failure 00675 */ 00676 extern int8_t sn_nsdl_set_duplicate_buffer_size(struct nsdl_s *handle, uint8_t message_count); 00677 00678 #ifdef __cplusplus 00679 } 00680 #endif 00681 00682 #endif /* SN_NSDL_LIB_H_ */
Generated on Wed Jul 13 2022 17:43:56 by
1.7.2
