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.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo 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 void (*oma_bs_status_cb_handle)(sn_nsdl_oma_server_info_t *, 00231 struct nsdl_s *); /**< Callback for OMA bootstrap status with nsdl handle */ 00232 } sn_nsdl_bs_ep_info_t; 00233 00234 00235 00236 00237 /** 00238 * \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 *), 00239 * uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *), 00240 * sn_nsdl_mem_s *sn_memory) 00241 * 00242 * \brief Initialization function for NSDL library. Initializes NSDL, GRS, HTTP and CoAP. 00243 * 00244 * \param *sn_nsdl_tx_callback A callback function for sending messages. 00245 * 00246 * \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 00247 * reply for some DS messages (register message etc.), rx callback will be called. 00248 * 00249 * \param *sn_memory Memory structure which includes function pointers to the allocation and free functions. 00250 * 00251 * \return pointer to created handle structure. NULL if failed 00252 */ 00253 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 *), 00254 uint8_t (*sn_nsdl_rx_cb)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *), 00255 void *(*sn_nsdl_alloc)(uint16_t), void (*sn_nsdl_free)(void *)); 00256 00257 /** 00258 * \fn extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr); 00259 * 00260 * \brief Registers endpoint to mbed Device Server. 00261 * \param *handle Pointer to nsdl-library handle 00262 * \param *endpoint_info_ptr Contains endpoint information. 00263 * 00264 * \return registration message ID, 0 if failed 00265 */ 00266 extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr); 00267 00268 /** 00269 * \fn extern uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle) 00270 * 00271 * \brief Sends unregister-message to mbed Device Server. 00272 * 00273 * \param *handle Pointer to nsdl-library handle 00274 * 00275 * \return unregistration message ID, 0 if failed 00276 */ 00277 extern uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle); 00278 00279 /** 00280 * \fn extern uint16_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len); 00281 * 00282 * \brief Update the registration with mbed Device Server. 00283 * 00284 * \param *handle Pointer to nsdl-library handle 00285 * \param *lt_ptr Pointer to lifetime value string in ascii form, eg. "1200" 00286 * \param lt_len Length of the lifetime string 00287 * 00288 * \return registration update message ID, 0 if failed 00289 */ 00290 extern uint16_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len); 00291 00292 /** 00293 * \fn extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len); 00294 * 00295 * \brief Sets the location receievd from Device Server. 00296 * 00297 * \param *handle Pointer to nsdl-library handle 00298 * \param *lt_ptr Pointer to location value string , eg. "s322j4k" 00299 * \param lt_len Length of the location string 00300 * 00301 * \return success, 0 if failed -1 00302 */ 00303 extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len); 00304 00305 00306 /** 00307 * \fn extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle) 00308 * 00309 * \brief Checks if endpoint is registered. 00310 * 00311 * \param *handle Pointer to nsdl-library handle 00312 * 00313 * \return 1 Endpoint registration is done successfully 00314 * \return 0 Endpoint is not registered 00315 */ 00316 extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle); 00317 00318 /** 00319 * \fn extern void sn_nsdl_nsp_lost(struct nsdl_s *handle); 00320 * 00321 * \brief A function to inform mbed Device C client library if application detects a fault in mbed Device Server registration. 00322 * 00323 * \param *handle Pointer to nsdl-library handle 00324 * 00325 * After calling this function sn_nsdl_is_ep_registered() will return "not registered". 00326 */ 00327 extern void sn_nsdl_nsp_lost(struct nsdl_s *handle); 00328 00329 /** 00330 * \fn extern uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, 00331 * uint8_t *payload_ptr, uint16_t payload_len, 00332 * uint8_t *observe_ptr, uint8_t observe_len, 00333 * sn_coap_msg_type_e message_type, uint8_t content_type) 00334 * 00335 * 00336 * \brief Sends observation message to mbed Device Server 00337 * 00338 * \param *handle Pointer to nsdl-library handle 00339 * \param *token_ptr Pointer to token to be used 00340 * \param token_len Token length 00341 * \param *payload_ptr Pointer to payload to be sent 00342 * \param payload_len Payload length 00343 * \param *observe_ptr Pointer to observe number to be sent 00344 * \param observe_len Observe number len 00345 * \param message_type Observation message type (confirmable or non-confirmable) 00346 * \param content_type Observation message payload contetnt type 00347 * 00348 * \return !0 Success, observation messages message ID 00349 * \return 0 Failure 00350 */ 00351 extern uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, 00352 uint8_t *payload_ptr, uint16_t payload_len, 00353 uint8_t *observe_ptr, uint8_t observe_len, 00354 sn_coap_msg_type_e message_type, 00355 uint8_t content_type); 00356 00357 /** 00358 * \fn extern uint16_t sn_nsdl_send_observation_notification_with_uri_path(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, 00359 * uint8_t *payload_ptr, uint16_t payload_len, 00360 * uint8_t *observe_ptr, uint8_t observe_len, 00361 * sn_coap_msg_type_e message_type, uint8_t content_type, 00362 * uint8_t *uri_path_ptr, 00363 * uint16_t uri_path_len) 00364 * 00365 * 00366 * \brief Sends observation message to mbed Device Server with uri path 00367 * 00368 * \param *handle Pointer to nsdl-library handle 00369 * \param *token_ptr Pointer to token to be used 00370 * \param token_len Token length 00371 * \param *payload_ptr Pointer to payload to be sent 00372 * \param payload_len Payload length 00373 * \param *observe_ptr Pointer to observe number to be sent 00374 * \param observe_len Observe number len 00375 * \param message_type Observation message type (confirmable or non-confirmable) 00376 * \param content_type Observation message payload contetnt type 00377 * \param uri_path_ptr Pointer to uri path to be sent 00378 * \param uri_path_len Uri path len 00379 * 00380 * \return !0 Success, observation messages message ID 00381 * \return 0 Failure 00382 */ 00383 extern uint16_t sn_nsdl_send_observation_notification_with_uri_path(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, 00384 uint8_t *payload_ptr, uint16_t payload_len, 00385 uint8_t *observe_ptr, uint8_t observe_len, 00386 sn_coap_msg_type_e message_type, 00387 uint8_t content_type, 00388 uint8_t *uri_path_ptr, 00389 uint16_t uri_path_len); 00390 00391 /** 00392 * \fn extern uint32_t sn_nsdl_get_version(void) 00393 * 00394 * \brief Version query function. 00395 * 00396 * Used to retrieve the version information from the mbed Device C Client library. 00397 * 00398 * \return Pointer to library version string 00399 */ 00400 extern char *sn_nsdl_get_version(void); 00401 00402 /** 00403 * \fn extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src) 00404 * 00405 * \brief To push CoAP packet to mbed Device C Client library 00406 * 00407 * Used to push an CoAP packet to mbed Device C Client library for processing. 00408 * 00409 * \param *handle Pointer to nsdl-library handle 00410 * 00411 * \param *packet Pointer to a uint8_t array containing the packet (including the CoAP headers). 00412 * After successful execution this array may contain the response packet. 00413 * 00414 * \param *packet_len Pointer to length of the packet. After successful execution this array may contain the length 00415 * of the response packet. 00416 * 00417 * \param *src Pointer to packet source address information. After successful execution this array may contain 00418 * the destination address of the response packet. 00419 * 00420 * \return 0 Success 00421 * \return -1 Failure 00422 */ 00423 extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src); 00424 00425 /** 00426 * \fn extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time); 00427 * 00428 * \brief CoAP retransmission function. 00429 * 00430 * Used to give execution time for the mbed Device C Client library for retransmissions. 00431 * 00432 * \param *handle Pointer to nsdl-library handle 00433 * 00434 * \param time Time in seconds. 00435 * 00436 * \return 0 Success 00437 * \return -1 Failure 00438 */ 00439 extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time); 00440 00441 /** 00442 * \fn extern int8_t sn_nsdl_create_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res); 00443 * 00444 * \brief Resource creating function. 00445 * 00446 * Used to create a static or dynamic CoAP resource. 00447 * 00448 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information 00449 * about the resource. 00450 * 00451 * \return 0 Success 00452 * \return -1 Failure 00453 * \return -2 Resource already exists 00454 * \return -3 Invalid path 00455 * \return -4 List adding failure 00456 */ 00457 extern int8_t sn_nsdl_create_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res); 00458 00459 /** 00460 * \fn extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res) 00461 * 00462 * \brief Resource updating function. 00463 * 00464 * Used to update the direct value of a static resource, the callback function pointer of a dynamic resource 00465 * and access rights of the recource. 00466 * 00467 * \param *handle Pointer to nsdl-library handle 00468 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information 00469 * about the resource. Only the pathlen and path elements are evaluated along with 00470 * either resourcelen and resource or the function pointer. 00471 * 00472 * \return 0 Success 00473 * \return -1 Failure 00474 */ 00475 extern int8_t sn_nsdl_update_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res); 00476 00477 /** 00478 * \fn extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, uint8_t pathlen, uint8_t *path) 00479 * 00480 * \brief Resource delete function. 00481 * 00482 * Used to delete a resource. If resource has a subresources, these all must also be removed. 00483 * 00484 * \param *handle Pointer to nsdl-library handle 00485 * \param pathlen Contains the length of the path that is to be deleted (excluding possible trailing "\0"). 00486 * \param *path_ptr A pointer to an array containing the path. 00487 * 00488 * \return 0 Success 00489 * \return -1 Failure (No such resource) 00490 */ 00491 extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path); 00492 00493 /** 00494 * \fn extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path) 00495 * 00496 * \brief Resource get function. 00497 * 00498 * Used to get a resource. 00499 * 00500 * \param *handle Pointer to nsdl-library handle 00501 * \param pathlen Contains the length of the path that is to be returned (excluding possible trailing '\0'). 00502 * \param *path A pointer to an array containing the path. 00503 * 00504 * \return !NULL Success, pointer to a sn_nsdl_resource_info_s that contains the resource information\n 00505 * \return NULL Failure 00506 */ 00507 extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path); 00508 00509 /** 00510 * \fn extern sn_grs_resource_list_s *sn_nsdl_list_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path) 00511 * 00512 * \brief Resource list function. 00513 * 00514 * \param *handle Pointer to nsdl-library handle 00515 * \param pathlen Contains the length of the target path (excluding possible trailing '\0'). 00516 * The length value is not examined if the path itself is a NULL pointer. 00517 * \param *path A pointer to an array containing the path or a NULL pointer. 00518 * 00519 * \return !NULL A pointer to a sn_grs_resource_list_s structure containing the resource listing. 00520 * \return NULL Failure with an unspecified error 00521 */ 00522 sn_grs_resource_list_s *sn_nsdl_list_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path); 00523 00524 /** 00525 * \fn extern void sn_nsdl_free_resource_list(struct nsdl_s *handle, sn_grs_resource_list_s *list) 00526 * 00527 * \brief Free a resource list obtained from sn_nsdl_list_resource() 00528 * 00529 * \param list The list to free, or NULL. 00530 */ 00531 void sn_nsdl_free_resource_list(struct nsdl_s *handle, sn_grs_resource_list_s *list); 00532 00533 /** 00534 * \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); 00535 * 00536 * \brief Send an outgoing CoAP request. 00537 * 00538 * \param *handle Pointer to nsdl-library handle 00539 * \param *address_ptr Pointer to source address struct 00540 * \param *coap_hdr_ptr Pointer to CoAP message to be sent 00541 * 00542 * \return 0 Success 00543 * \return -1 Failure 00544 */ 00545 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); 00546 00547 /** 00548 * \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); 00549 * 00550 * \brief This function is used to set the mbed Device Server address given by an application. 00551 * 00552 * \param *handle Pointer to nsdl-library handle 00553 * \return 0 Success 00554 * \return -1 Failed to indicate that internal address pointer is not allocated (call nsdl_init() first). 00555 */ 00556 extern int8_t set_NSP_address(struct nsdl_s *handle, uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type); 00557 00558 /** 00559 * \fn extern int8_t sn_nsdl_destroy(struct nsdl_s *handle); 00560 * 00561 * \param *handle Pointer to nsdl-library handle 00562 * \brief This function releases all allocated memory in mbed Device C Client library. 00563 */ 00564 extern int8_t sn_nsdl_destroy(struct nsdl_s *handle); 00565 00566 /** 00567 * \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); 00568 * 00569 * \brief Starts OMA bootstrap process 00570 * 00571 * \param *handle Pointer to nsdl-library handle 00572 * 00573 * \return bootstrap message ID, 0 if failed 00574 */ 00575 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); 00576 00577 /** 00578 * \fn extern omalw_certificate_list_t *sn_nsdl_get_certificates(struct nsdl_s *handle); 00579 * 00580 * \brief Get pointer to received device server certificates 00581 * 00582 * \param *handle Pointer to nsdl-library handle 00583 */ 00584 extern omalw_certificate_list_t *sn_nsdl_get_certificates(struct nsdl_s *handle); 00585 00586 /** 00587 * \fn extern int8_t sn_nsdl_update_certificates(struct nsdl_s *handle, omalw_certificate_list_t* certificate_ptr, uint8_t certificate_chain); 00588 * 00589 * \brief Updates certificate pointers to resource server. 00590 * 00591 * \param *handle Pointer to nsdl-library handle 00592 */ 00593 extern int8_t sn_nsdl_update_certificates(struct nsdl_s *handle, omalw_certificate_list_t *certificate_ptr, uint8_t certificate_chain); 00594 00595 /** 00596 * \fn extern int8_t sn_nsdl_create_oma_device_object(struct nsdl_s *handle, sn_nsdl_oma_device_t *device_object_ptr); 00597 * 00598 * \brief Creates new device object resource 00599 * 00600 * \param *handle Pointer to nsdl-library handle 00601 */ 00602 extern int8_t sn_nsdl_create_oma_device_object(struct nsdl_s *handle, sn_nsdl_oma_device_t *device_object_ptr); 00603 00604 /** 00605 * \fn sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code) 00606 * 00607 * \brief Prepares generic response packet from a request packet. This function allocates memory for the resulting sn_coap_hdr_s 00608 * 00609 * \param *handle Pointer to library handle 00610 * \param *coap_packet_ptr The request packet pointer 00611 * \param msg_code response messages code 00612 * 00613 * \return *coap_packet_ptr The allocated and pre-filled response packet pointer 00614 * NULL Error in parsing the request 00615 * 00616 */ 00617 extern sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code); 00618 00619 /** 00620 * \fn void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr) 00621 * 00622 * \brief Releases memory of given CoAP message 00623 * 00624 * Note!!! Does not release Payload part 00625 * 00626 * \param *handle Pointer to CoAP library handle 00627 * 00628 * \param *freed_coap_msg_ptr is pointer to released CoAP message 00629 */ 00630 extern void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr); 00631 00632 /** 00633 * \fn int8_t sn_nsdl_set_retransmission_parameters(struct nsdl_s *handle, uint8_t resending_count, uint8_t resending_intervall) 00634 * 00635 * \brief If re-transmissions are enabled, this function changes resending count and interval. 00636 * 00637 * \param *handle Pointer to library handle 00638 * \param uint8_t resending_count max number of resendings for message 00639 * \param uint8_t resending_intervall message resending intervall in seconds 00640 * \return 0 = success, -1 = failure 00641 */ 00642 extern int8_t sn_nsdl_set_retransmission_parameters(struct nsdl_s *handle, uint8_t resending_count, uint8_t resending_interval); 00643 00644 /** 00645 * \fn int8_t sn_nsdl_set_retransmission_buffer(struct nsdl_s *handle, uint8_t buffer_size_messages, uint16_t buffer_size_bytes) 00646 * 00647 * \brief If re-transmissions are enabled, this function changes message retransmission queue size. 00648 * Set size to '0' to disable feature. If both are set to '0', then re-sendings are disabled. 00649 * 00650 * \param *handle Pointer to library handle 00651 * \param uint8_t buffer_size_messages queue size - maximum number of messages to be saved to queue 00652 * \param uint8_t buffer_size_bytes queue size - maximum size of messages saved to queue 00653 * \return 0 = success, -1 = failure 00654 */ 00655 extern int8_t sn_nsdl_set_retransmission_buffer(struct nsdl_s *handle, 00656 uint8_t buffer_size_messages, uint16_t buffer_size_bytes); 00657 00658 /** 00659 * \fn int8_t sn_nsdl_set_block_size(struct nsdl_s *handle, uint16_t block_size) 00660 * 00661 * \brief If block transfer is enabled, this function changes the block size. 00662 * 00663 * \param *handle Pointer to library handle 00664 * \param uint16_t block_size maximum size of CoAP payload. Valid sizes are 16, 32, 64, 128, 256, 512 and 1024 bytes 00665 * \return 0 = success, -1 = failure 00666 */ 00667 extern int8_t sn_nsdl_set_block_size(struct nsdl_s *handle, uint16_t block_size); 00668 00669 /** 00670 * \fn int8_t sn_nsdl_set_duplicate_buffer_size(struct nsdl_s *handle,uint8_t message_count) 00671 * 00672 * \brief If dublicate message detection is enabled, this function changes buffer size. 00673 * 00674 * \param *handle Pointer to library handle 00675 * \param uint8_t message_count max number of messages saved for duplicate control 00676 * \return 0 = success, -1 = failure 00677 */ 00678 extern int8_t sn_nsdl_set_duplicate_buffer_size(struct nsdl_s *handle, uint8_t message_count); 00679 00680 #ifdef __cplusplus 00681 } 00682 #endif 00683 00684 #endif /* SN_NSDL_LIB_H_ */
Generated on Tue Jul 12 2022 12:28:49 by
