![](/media/cache/group/fe14.jpg.50x50_q85.jpg)
initial release
Dependencies: BSP_B-L475E-IOT01 MQTT
Fork of Multiprotocol by
COAP_library/sn_nsdl_lib.h@5:69b70c8fc368, 2018-08-22 (annotated)
- Committer:
- fabio_gatti
- Date:
- Wed Aug 22 21:43:31 2018 +0000
- Revision:
- 5:69b70c8fc368
- Parent:
- 3:647e37ef0eec
initial release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fabio_gatti | 3:647e37ef0eec | 1 | /* |
fabio_gatti | 3:647e37ef0eec | 2 | * Copyright (c) 2011-2015 ARM Limited. All rights reserved. |
fabio_gatti | 3:647e37ef0eec | 3 | * SPDX-License-Identifier: Apache-2.0 |
fabio_gatti | 3:647e37ef0eec | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
fabio_gatti | 3:647e37ef0eec | 5 | * not use this file except in compliance with the License. |
fabio_gatti | 3:647e37ef0eec | 6 | * You may obtain a copy of the License at |
fabio_gatti | 3:647e37ef0eec | 7 | * |
fabio_gatti | 3:647e37ef0eec | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
fabio_gatti | 3:647e37ef0eec | 9 | * |
fabio_gatti | 3:647e37ef0eec | 10 | * Unless required by applicable law or agreed to in writing, software |
fabio_gatti | 3:647e37ef0eec | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
fabio_gatti | 3:647e37ef0eec | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
fabio_gatti | 3:647e37ef0eec | 13 | * See the License for the specific language governing permissions and |
fabio_gatti | 3:647e37ef0eec | 14 | * limitations under the License. |
fabio_gatti | 3:647e37ef0eec | 15 | */ |
fabio_gatti | 3:647e37ef0eec | 16 | |
fabio_gatti | 3:647e37ef0eec | 17 | /** |
fabio_gatti | 3:647e37ef0eec | 18 | * \file sn_nsdl_lib.h |
fabio_gatti | 3:647e37ef0eec | 19 | * |
fabio_gatti | 3:647e37ef0eec | 20 | * \brief NanoService Devices Library header file |
fabio_gatti | 3:647e37ef0eec | 21 | * |
fabio_gatti | 3:647e37ef0eec | 22 | * |
fabio_gatti | 3:647e37ef0eec | 23 | */ |
fabio_gatti | 3:647e37ef0eec | 24 | |
fabio_gatti | 3:647e37ef0eec | 25 | #ifndef SN_NSDL_LIB_H_ |
fabio_gatti | 3:647e37ef0eec | 26 | #define SN_NSDL_LIB_H_ |
fabio_gatti | 3:647e37ef0eec | 27 | |
fabio_gatti | 3:647e37ef0eec | 28 | #include "ns_list.h" |
fabio_gatti | 3:647e37ef0eec | 29 | #include "sn_client_config.h" |
fabio_gatti | 3:647e37ef0eec | 30 | |
fabio_gatti | 3:647e37ef0eec | 31 | #ifdef __cplusplus |
fabio_gatti | 3:647e37ef0eec | 32 | extern "C" { |
fabio_gatti | 3:647e37ef0eec | 33 | #endif |
fabio_gatti | 3:647e37ef0eec | 34 | |
fabio_gatti | 3:647e37ef0eec | 35 | #define SN_NSDL_ENDPOINT_NOT_REGISTERED 0 |
fabio_gatti | 3:647e37ef0eec | 36 | #define SN_NSDL_ENDPOINT_IS_REGISTERED 1 |
fabio_gatti | 3:647e37ef0eec | 37 | |
fabio_gatti | 3:647e37ef0eec | 38 | #ifdef YOTTA_CFG_DISABLE_INTERFACE_DESCRIPTION |
fabio_gatti | 3:647e37ef0eec | 39 | #define DISABLE_INTERFACE_DESCRIPTION YOTTA_CFG_DISABLE_INTERFACE_DESCRIPTION |
fabio_gatti | 3:647e37ef0eec | 40 | #elif defined MBED_CONF_MBED_CLIENT_DISABLE_INTERFACE_DESCRIPTION |
fabio_gatti | 3:647e37ef0eec | 41 | #define DISABLE_INTERFACE_DESCRIPTION MBED_CONF_MBED_CLIENT_DISABLE_INTERFACE_DESCRIPTION |
fabio_gatti | 3:647e37ef0eec | 42 | #endif |
fabio_gatti | 3:647e37ef0eec | 43 | |
fabio_gatti | 3:647e37ef0eec | 44 | #ifdef YOTTA_CFG_DISABLE_RESOURCE_TYPE |
fabio_gatti | 3:647e37ef0eec | 45 | #define DISABLE_RESOURCE_TYPE YOTTA_CFG_DISABLE_RESOURCE_TYPE |
fabio_gatti | 3:647e37ef0eec | 46 | #elif defined MBED_CONF_MBED_CLIENT_DISABLE_RESOURCE_TYPE |
fabio_gatti | 3:647e37ef0eec | 47 | #define DISABLE_RESOURCE_TYPE MBED_CONF_MBED_CLIENT_DISABLE_RESOURCE_TYPE |
fabio_gatti | 3:647e37ef0eec | 48 | #endif |
fabio_gatti | 3:647e37ef0eec | 49 | |
fabio_gatti | 3:647e37ef0eec | 50 | /* Handle structure */ |
fabio_gatti | 3:647e37ef0eec | 51 | struct nsdl_s; |
fabio_gatti | 3:647e37ef0eec | 52 | |
fabio_gatti | 3:647e37ef0eec | 53 | /** |
fabio_gatti | 3:647e37ef0eec | 54 | * \brief Received device server security |
fabio_gatti | 3:647e37ef0eec | 55 | */ |
fabio_gatti | 3:647e37ef0eec | 56 | typedef enum omalw_server_security_ { |
fabio_gatti | 3:647e37ef0eec | 57 | SEC_NOT_SET = -1, |
fabio_gatti | 3:647e37ef0eec | 58 | PSK = 0, |
fabio_gatti | 3:647e37ef0eec | 59 | RPK = 1, |
fabio_gatti | 3:647e37ef0eec | 60 | CERTIFICATE = 2, |
fabio_gatti | 3:647e37ef0eec | 61 | NO_SEC = 3 |
fabio_gatti | 3:647e37ef0eec | 62 | } omalw_server_security_t; |
fabio_gatti | 3:647e37ef0eec | 63 | |
fabio_gatti | 3:647e37ef0eec | 64 | /** |
fabio_gatti | 3:647e37ef0eec | 65 | * \brief Endpoint binding and mode |
fabio_gatti | 3:647e37ef0eec | 66 | */ |
fabio_gatti | 3:647e37ef0eec | 67 | typedef enum sn_nsdl_oma_binding_and_mode_ { |
fabio_gatti | 3:647e37ef0eec | 68 | BINDING_MODE_NOT_SET = 0, |
fabio_gatti | 3:647e37ef0eec | 69 | BINDING_MODE_U = 0x01, |
fabio_gatti | 3:647e37ef0eec | 70 | BINDING_MODE_Q = 0x02, |
fabio_gatti | 3:647e37ef0eec | 71 | BINDING_MODE_S = 0x04 |
fabio_gatti | 3:647e37ef0eec | 72 | } sn_nsdl_oma_binding_and_mode_t; |
fabio_gatti | 3:647e37ef0eec | 73 | |
fabio_gatti | 3:647e37ef0eec | 74 | /** |
fabio_gatti | 3:647e37ef0eec | 75 | * \brief Endpoint registration mode. |
fabio_gatti | 3:647e37ef0eec | 76 | * If REGISTER_WITH_RESOURCES, endpoint sends list of all resources during registration. |
fabio_gatti | 3:647e37ef0eec | 77 | * If REGISTER_WITH_TEMPLATE, endpoint sends registration without resource list. Device server must have |
fabio_gatti | 3:647e37ef0eec | 78 | * correctly configured template. |
fabio_gatti | 3:647e37ef0eec | 79 | */ |
fabio_gatti | 3:647e37ef0eec | 80 | typedef enum sn_nsdl_registration_mode_ { |
fabio_gatti | 3:647e37ef0eec | 81 | REGISTER_WITH_RESOURCES = 0, |
fabio_gatti | 3:647e37ef0eec | 82 | REGISTER_WITH_TEMPLATE |
fabio_gatti | 3:647e37ef0eec | 83 | } sn_nsdl_registration_mode_t; |
fabio_gatti | 3:647e37ef0eec | 84 | |
fabio_gatti | 3:647e37ef0eec | 85 | /** |
fabio_gatti | 3:647e37ef0eec | 86 | * \brief Endpoint registration parameters |
fabio_gatti | 3:647e37ef0eec | 87 | */ |
fabio_gatti | 3:647e37ef0eec | 88 | typedef struct sn_nsdl_ep_parameters_ { |
fabio_gatti | 3:647e37ef0eec | 89 | uint8_t endpoint_name_len; |
fabio_gatti | 3:647e37ef0eec | 90 | uint8_t domain_name_len; |
fabio_gatti | 3:647e37ef0eec | 91 | uint8_t type_len; |
fabio_gatti | 3:647e37ef0eec | 92 | uint8_t lifetime_len; |
fabio_gatti | 3:647e37ef0eec | 93 | uint8_t location_len; |
fabio_gatti | 3:647e37ef0eec | 94 | |
fabio_gatti | 3:647e37ef0eec | 95 | sn_nsdl_registration_mode_t ds_register_mode; /**< Defines registration mode */ |
fabio_gatti | 3:647e37ef0eec | 96 | sn_nsdl_oma_binding_and_mode_t binding_and_mode; /**< Defines endpoints binding and mode */ |
fabio_gatti | 3:647e37ef0eec | 97 | |
fabio_gatti | 3:647e37ef0eec | 98 | uint8_t *endpoint_name_ptr; /**< Endpoint name */ |
fabio_gatti | 3:647e37ef0eec | 99 | uint8_t *domain_name_ptr; /**< Domain to register. If null, NSP uses default domain */ |
fabio_gatti | 3:647e37ef0eec | 100 | uint8_t *type_ptr; /**< Endpoint type */ |
fabio_gatti | 3:647e37ef0eec | 101 | uint8_t *lifetime_ptr; /**< Endpoint lifetime in seconds. eg. "1200" = 1200 seconds */ |
fabio_gatti | 3:647e37ef0eec | 102 | uint8_t *location_ptr; /**< Endpoint location in server, optional parameter,default is NULL */ |
fabio_gatti | 3:647e37ef0eec | 103 | } sn_nsdl_ep_parameters_s; |
fabio_gatti | 3:647e37ef0eec | 104 | |
fabio_gatti | 3:647e37ef0eec | 105 | /** |
fabio_gatti | 3:647e37ef0eec | 106 | * \brief For internal use |
fabio_gatti | 3:647e37ef0eec | 107 | */ |
fabio_gatti | 3:647e37ef0eec | 108 | typedef struct sn_nsdl_sent_messages_ { |
fabio_gatti | 3:647e37ef0eec | 109 | uint8_t message_type; |
fabio_gatti | 3:647e37ef0eec | 110 | uint16_t msg_id_number; |
fabio_gatti | 3:647e37ef0eec | 111 | ns_list_link_t link; |
fabio_gatti | 3:647e37ef0eec | 112 | } sn_nsdl_sent_messages_s; |
fabio_gatti | 3:647e37ef0eec | 113 | |
fabio_gatti | 3:647e37ef0eec | 114 | /** |
fabio_gatti | 3:647e37ef0eec | 115 | * \brief Includes resource path |
fabio_gatti | 3:647e37ef0eec | 116 | */ |
fabio_gatti | 3:647e37ef0eec | 117 | typedef struct sn_grs_resource_ { |
fabio_gatti | 3:647e37ef0eec | 118 | char *path; |
fabio_gatti | 3:647e37ef0eec | 119 | } sn_grs_resource_s; |
fabio_gatti | 3:647e37ef0eec | 120 | |
fabio_gatti | 3:647e37ef0eec | 121 | /** |
fabio_gatti | 3:647e37ef0eec | 122 | * \brief Table of created resources |
fabio_gatti | 3:647e37ef0eec | 123 | */ |
fabio_gatti | 3:647e37ef0eec | 124 | typedef struct sn_grs_resource_list_ { |
fabio_gatti | 3:647e37ef0eec | 125 | uint8_t res_count; /**< Number of resources */ |
fabio_gatti | 3:647e37ef0eec | 126 | sn_grs_resource_s *res; |
fabio_gatti | 3:647e37ef0eec | 127 | } sn_grs_resource_list_s; |
fabio_gatti | 3:647e37ef0eec | 128 | |
fabio_gatti | 3:647e37ef0eec | 129 | /** |
fabio_gatti | 3:647e37ef0eec | 130 | * \brief Resource access rights |
fabio_gatti | 3:647e37ef0eec | 131 | */ |
fabio_gatti | 3:647e37ef0eec | 132 | typedef enum sn_grs_resource_acl_ { |
fabio_gatti | 3:647e37ef0eec | 133 | SN_GRS_GET_ALLOWED = 0x01 , |
fabio_gatti | 3:647e37ef0eec | 134 | SN_GRS_PUT_ALLOWED = 0x02, |
fabio_gatti | 3:647e37ef0eec | 135 | SN_GRS_POST_ALLOWED = 0x04, |
fabio_gatti | 3:647e37ef0eec | 136 | SN_GRS_DELETE_ALLOWED = 0x08 |
fabio_gatti | 3:647e37ef0eec | 137 | } sn_grs_resource_acl_e; |
fabio_gatti | 3:647e37ef0eec | 138 | |
fabio_gatti | 3:647e37ef0eec | 139 | /** |
fabio_gatti | 3:647e37ef0eec | 140 | * \brief Defines the resource mode |
fabio_gatti | 3:647e37ef0eec | 141 | */ |
fabio_gatti | 3:647e37ef0eec | 142 | typedef enum sn_nsdl_resource_mode_ { |
fabio_gatti | 3:647e37ef0eec | 143 | SN_GRS_STATIC = 0, /**< Static resources have some value that doesn't change */ |
fabio_gatti | 3:647e37ef0eec | 144 | SN_GRS_DYNAMIC, /**< Dynamic resources are handled in application. Therefore one must give function callback pointer to them */ |
fabio_gatti | 3:647e37ef0eec | 145 | SN_GRS_DIRECTORY /**< Directory resources are unused and unsupported */ |
fabio_gatti | 3:647e37ef0eec | 146 | } sn_nsdl_resource_mode_e; |
fabio_gatti | 3:647e37ef0eec | 147 | |
fabio_gatti | 3:647e37ef0eec | 148 | /** |
fabio_gatti | 3:647e37ef0eec | 149 | * \brief Defines static parameters for the resource. |
fabio_gatti | 3:647e37ef0eec | 150 | */ |
fabio_gatti | 3:647e37ef0eec | 151 | typedef struct sn_nsdl_static_resource_parameters_ { |
fabio_gatti | 3:647e37ef0eec | 152 | #ifndef DISABLE_RESOURCE_TYPE |
fabio_gatti | 3:647e37ef0eec | 153 | char *resource_type_ptr; /**< Type of the resource */ |
fabio_gatti | 3:647e37ef0eec | 154 | #endif |
fabio_gatti | 3:647e37ef0eec | 155 | #ifndef DISABLE_INTERFACE_DESCRIPTION |
fabio_gatti | 3:647e37ef0eec | 156 | char *interface_description_ptr; /**< Interface description */ |
fabio_gatti | 3:647e37ef0eec | 157 | #endif |
fabio_gatti | 3:647e37ef0eec | 158 | char *path; /**< Resource path */ |
fabio_gatti | 3:647e37ef0eec | 159 | bool external_memory_block:1; /**< 0 means block messages are handled inside this library, |
fabio_gatti | 3:647e37ef0eec | 160 | otherwise block messages are passed to application */ |
fabio_gatti | 3:647e37ef0eec | 161 | unsigned mode:2; /**< STATIC etc.. */ |
fabio_gatti | 3:647e37ef0eec | 162 | bool free_on_delete:1; /**< 1 if struct is dynamic allocted --> to be freed */ |
fabio_gatti | 3:647e37ef0eec | 163 | } sn_nsdl_static_resource_parameters_s; |
fabio_gatti | 3:647e37ef0eec | 164 | |
fabio_gatti | 3:647e37ef0eec | 165 | /** |
fabio_gatti | 3:647e37ef0eec | 166 | * \brief Defines dynamic parameters for the resource. |
fabio_gatti | 3:647e37ef0eec | 167 | */ |
fabio_gatti | 3:647e37ef0eec | 168 | typedef struct sn_nsdl_resource_parameters_ { |
fabio_gatti | 3:647e37ef0eec | 169 | uint8_t (*sn_grs_dyn_res_callback)(struct nsdl_s *, |
fabio_gatti | 3:647e37ef0eec | 170 | sn_coap_hdr_s *, |
fabio_gatti | 3:647e37ef0eec | 171 | sn_nsdl_addr_s *, |
fabio_gatti | 3:647e37ef0eec | 172 | sn_nsdl_capab_e); |
fabio_gatti | 3:647e37ef0eec | 173 | #ifdef MEMORY_OPTIMIZED_API |
fabio_gatti | 3:647e37ef0eec | 174 | const sn_nsdl_static_resource_parameters_s *static_resource_parameters; |
fabio_gatti | 3:647e37ef0eec | 175 | #else |
fabio_gatti | 3:647e37ef0eec | 176 | sn_nsdl_static_resource_parameters_s *static_resource_parameters; |
fabio_gatti | 3:647e37ef0eec | 177 | #endif |
fabio_gatti | 3:647e37ef0eec | 178 | uint8_t *resource; /**< NULL if dynamic resource */ |
fabio_gatti | 3:647e37ef0eec | 179 | ns_list_link_t link; |
fabio_gatti | 3:647e37ef0eec | 180 | uint16_t resourcelen; /**< 0 if dynamic resource, resource information in static resource */ |
fabio_gatti | 3:647e37ef0eec | 181 | uint16_t coap_content_type; /**< CoAP content type */ |
fabio_gatti | 3:647e37ef0eec | 182 | unsigned access:4; /**< Allowed operation mode, GET, PUT, etc, |
fabio_gatti | 3:647e37ef0eec | 183 | TODO! This should be in static struct but current |
fabio_gatti | 3:647e37ef0eec | 184 | mbed-client implementation requires this to be changed at runtime */ |
fabio_gatti | 3:647e37ef0eec | 185 | unsigned registered:2; /**< Is resource registered or not */ |
fabio_gatti | 3:647e37ef0eec | 186 | bool publish_uri:1; /**< 1 if resource to be published to server */ |
fabio_gatti | 3:647e37ef0eec | 187 | bool free_on_delete:1; /**< 1 if struct is dynamic allocted --> to be freed */ |
fabio_gatti | 3:647e37ef0eec | 188 | bool observable:1; /**< Is resource observable or not */ |
fabio_gatti | 3:647e37ef0eec | 189 | } sn_nsdl_dynamic_resource_parameters_s; |
fabio_gatti | 3:647e37ef0eec | 190 | |
fabio_gatti | 3:647e37ef0eec | 191 | /** |
fabio_gatti | 3:647e37ef0eec | 192 | * \brief Defines OMAlw server information |
fabio_gatti | 3:647e37ef0eec | 193 | */ |
fabio_gatti | 3:647e37ef0eec | 194 | typedef struct sn_nsdl_oma_server_info_ { |
fabio_gatti | 3:647e37ef0eec | 195 | sn_nsdl_addr_s *omalw_address_ptr; |
fabio_gatti | 3:647e37ef0eec | 196 | omalw_server_security_t omalw_server_security; |
fabio_gatti | 3:647e37ef0eec | 197 | |
fabio_gatti | 3:647e37ef0eec | 198 | } sn_nsdl_oma_server_info_t; |
fabio_gatti | 3:647e37ef0eec | 199 | |
fabio_gatti | 3:647e37ef0eec | 200 | /** |
fabio_gatti | 3:647e37ef0eec | 201 | * \brief Defines endpoint parameters to OMA bootstrap. |
fabio_gatti | 3:647e37ef0eec | 202 | */ |
fabio_gatti | 3:647e37ef0eec | 203 | typedef struct sn_nsdl_bs_ep_info_ { |
fabio_gatti | 3:647e37ef0eec | 204 | void (*oma_bs_status_cb)(sn_nsdl_oma_server_info_t *); /**< Callback for OMA bootstrap status */ |
fabio_gatti | 3:647e37ef0eec | 205 | |
fabio_gatti | 3:647e37ef0eec | 206 | void (*oma_bs_status_cb_handle)(sn_nsdl_oma_server_info_t *, |
fabio_gatti | 3:647e37ef0eec | 207 | struct nsdl_s *); /**< Callback for OMA bootstrap status with nsdl handle */ |
fabio_gatti | 3:647e37ef0eec | 208 | } sn_nsdl_bs_ep_info_t; |
fabio_gatti | 3:647e37ef0eec | 209 | |
fabio_gatti | 3:647e37ef0eec | 210 | /** |
fabio_gatti | 3:647e37ef0eec | 211 | * \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 *), |
fabio_gatti | 3:647e37ef0eec | 212 | * uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *), |
fabio_gatti | 3:647e37ef0eec | 213 | * sn_nsdl_mem_s *sn_memory) |
fabio_gatti | 3:647e37ef0eec | 214 | * |
fabio_gatti | 3:647e37ef0eec | 215 | * \brief Initialization function for NSDL library. Initializes NSDL, GRS, HTTP and CoAP. |
fabio_gatti | 3:647e37ef0eec | 216 | * |
fabio_gatti | 3:647e37ef0eec | 217 | * \param *sn_nsdl_tx_callback A callback function for sending messages. |
fabio_gatti | 3:647e37ef0eec | 218 | * |
fabio_gatti | 3:647e37ef0eec | 219 | * \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 |
fabio_gatti | 3:647e37ef0eec | 220 | * reply for some DS messages (register message etc.), rx callback will be called. |
fabio_gatti | 3:647e37ef0eec | 221 | * |
fabio_gatti | 3:647e37ef0eec | 222 | * \param *sn_memory Memory structure which includes function pointers to the allocation and free functions. |
fabio_gatti | 3:647e37ef0eec | 223 | * |
fabio_gatti | 3:647e37ef0eec | 224 | * \return pointer to created handle structure. NULL if failed |
fabio_gatti | 3:647e37ef0eec | 225 | */ |
fabio_gatti | 3:647e37ef0eec | 226 | 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 *), |
fabio_gatti | 3:647e37ef0eec | 227 | uint8_t (*sn_nsdl_rx_cb)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *), |
fabio_gatti | 3:647e37ef0eec | 228 | void *(*sn_nsdl_alloc)(uint16_t), void (*sn_nsdl_free)(void *)); |
fabio_gatti | 3:647e37ef0eec | 229 | |
fabio_gatti | 3:647e37ef0eec | 230 | /** |
fabio_gatti | 3:647e37ef0eec | 231 | * \fn extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr); |
fabio_gatti | 3:647e37ef0eec | 232 | * |
fabio_gatti | 3:647e37ef0eec | 233 | * \brief Registers endpoint to mbed Device Server. |
fabio_gatti | 3:647e37ef0eec | 234 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 235 | * \param *endpoint_info_ptr Contains endpoint information. |
fabio_gatti | 3:647e37ef0eec | 236 | * |
fabio_gatti | 3:647e37ef0eec | 237 | * \return registration message ID, 0 if failed |
fabio_gatti | 3:647e37ef0eec | 238 | */ |
fabio_gatti | 3:647e37ef0eec | 239 | extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr); |
fabio_gatti | 3:647e37ef0eec | 240 | |
fabio_gatti | 3:647e37ef0eec | 241 | /** |
fabio_gatti | 3:647e37ef0eec | 242 | * \fn extern uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle) |
fabio_gatti | 3:647e37ef0eec | 243 | * |
fabio_gatti | 3:647e37ef0eec | 244 | * \brief Sends unregister-message to mbed Device Server. |
fabio_gatti | 3:647e37ef0eec | 245 | * |
fabio_gatti | 3:647e37ef0eec | 246 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 247 | * |
fabio_gatti | 3:647e37ef0eec | 248 | * \return unregistration message ID, 0 if failed |
fabio_gatti | 3:647e37ef0eec | 249 | */ |
fabio_gatti | 3:647e37ef0eec | 250 | extern uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle); |
fabio_gatti | 3:647e37ef0eec | 251 | |
fabio_gatti | 3:647e37ef0eec | 252 | /** |
fabio_gatti | 3:647e37ef0eec | 253 | * \fn extern uint16_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len); |
fabio_gatti | 3:647e37ef0eec | 254 | * |
fabio_gatti | 3:647e37ef0eec | 255 | * \brief Update the registration with mbed Device Server. |
fabio_gatti | 3:647e37ef0eec | 256 | * |
fabio_gatti | 3:647e37ef0eec | 257 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 258 | * \param *lt_ptr Pointer to lifetime value string in ascii form, eg. "1200" |
fabio_gatti | 3:647e37ef0eec | 259 | * \param lt_len Length of the lifetime string |
fabio_gatti | 3:647e37ef0eec | 260 | * |
fabio_gatti | 3:647e37ef0eec | 261 | * \return registration update message ID, 0 if failed |
fabio_gatti | 3:647e37ef0eec | 262 | */ |
fabio_gatti | 3:647e37ef0eec | 263 | extern uint16_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len); |
fabio_gatti | 3:647e37ef0eec | 264 | |
fabio_gatti | 3:647e37ef0eec | 265 | /** |
fabio_gatti | 3:647e37ef0eec | 266 | * \fn extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len); |
fabio_gatti | 3:647e37ef0eec | 267 | * |
fabio_gatti | 3:647e37ef0eec | 268 | * \brief Sets the location receievd from Device Server. |
fabio_gatti | 3:647e37ef0eec | 269 | * |
fabio_gatti | 3:647e37ef0eec | 270 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 271 | * \param *lt_ptr Pointer to location value string , eg. "s322j4k" |
fabio_gatti | 3:647e37ef0eec | 272 | * \param lt_len Length of the location string |
fabio_gatti | 3:647e37ef0eec | 273 | * |
fabio_gatti | 3:647e37ef0eec | 274 | * \return success, 0 if failed -1 |
fabio_gatti | 3:647e37ef0eec | 275 | */ |
fabio_gatti | 3:647e37ef0eec | 276 | extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len); |
fabio_gatti | 3:647e37ef0eec | 277 | |
fabio_gatti | 3:647e37ef0eec | 278 | /** |
fabio_gatti | 3:647e37ef0eec | 279 | * \fn extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle) |
fabio_gatti | 3:647e37ef0eec | 280 | * |
fabio_gatti | 3:647e37ef0eec | 281 | * \brief Checks if endpoint is registered. |
fabio_gatti | 3:647e37ef0eec | 282 | * |
fabio_gatti | 3:647e37ef0eec | 283 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 284 | * |
fabio_gatti | 3:647e37ef0eec | 285 | * \return 1 Endpoint registration is done successfully |
fabio_gatti | 3:647e37ef0eec | 286 | * \return 0 Endpoint is not registered |
fabio_gatti | 3:647e37ef0eec | 287 | */ |
fabio_gatti | 3:647e37ef0eec | 288 | extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle); |
fabio_gatti | 3:647e37ef0eec | 289 | |
fabio_gatti | 3:647e37ef0eec | 290 | /** |
fabio_gatti | 3:647e37ef0eec | 291 | * \fn extern void sn_nsdl_nsp_lost(struct nsdl_s *handle); |
fabio_gatti | 3:647e37ef0eec | 292 | * |
fabio_gatti | 3:647e37ef0eec | 293 | * \brief A function to inform mbed Device C client library if application detects a fault in mbed Device Server registration. |
fabio_gatti | 3:647e37ef0eec | 294 | * |
fabio_gatti | 3:647e37ef0eec | 295 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 296 | * |
fabio_gatti | 3:647e37ef0eec | 297 | * After calling this function sn_nsdl_is_ep_registered() will return "not registered". |
fabio_gatti | 3:647e37ef0eec | 298 | */ |
fabio_gatti | 3:647e37ef0eec | 299 | extern void sn_nsdl_nsp_lost(struct nsdl_s *handle); |
fabio_gatti | 3:647e37ef0eec | 300 | |
fabio_gatti | 3:647e37ef0eec | 301 | /** |
fabio_gatti | 3:647e37ef0eec | 302 | * \fn extern uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, |
fabio_gatti | 3:647e37ef0eec | 303 | * uint8_t *payload_ptr, uint16_t payload_len, |
fabio_gatti | 3:647e37ef0eec | 304 | * sn_coap_observe_e observe, |
fabio_gatti | 3:647e37ef0eec | 305 | * sn_coap_msg_type_e message_type, sn_coap_content_format_e content_format) |
fabio_gatti | 3:647e37ef0eec | 306 | * |
fabio_gatti | 3:647e37ef0eec | 307 | * |
fabio_gatti | 3:647e37ef0eec | 308 | * \brief Sends observation message to mbed Device Server |
fabio_gatti | 3:647e37ef0eec | 309 | * |
fabio_gatti | 3:647e37ef0eec | 310 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 311 | * \param *token_ptr Pointer to token to be used |
fabio_gatti | 3:647e37ef0eec | 312 | * \param token_len Token length |
fabio_gatti | 3:647e37ef0eec | 313 | * \param *payload_ptr Pointer to payload to be sent |
fabio_gatti | 3:647e37ef0eec | 314 | * \param payload_len Payload length |
fabio_gatti | 3:647e37ef0eec | 315 | * \param observe Observe option value to be sent |
fabio_gatti | 3:647e37ef0eec | 316 | * \param message_type Observation message type (confirmable or non-confirmable) |
fabio_gatti | 3:647e37ef0eec | 317 | * \param content_format Observation message payload content format |
fabio_gatti | 3:647e37ef0eec | 318 | * |
fabio_gatti | 3:647e37ef0eec | 319 | * \return !0 Success, observation messages message ID |
fabio_gatti | 3:647e37ef0eec | 320 | * \return 0 Failure |
fabio_gatti | 3:647e37ef0eec | 321 | */ |
fabio_gatti | 3:647e37ef0eec | 322 | extern uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, |
fabio_gatti | 3:647e37ef0eec | 323 | uint8_t *payload_ptr, uint16_t payload_len, |
fabio_gatti | 3:647e37ef0eec | 324 | sn_coap_observe_e observe, |
fabio_gatti | 3:647e37ef0eec | 325 | sn_coap_msg_type_e message_type, |
fabio_gatti | 3:647e37ef0eec | 326 | sn_coap_content_format_e content_format); |
fabio_gatti | 3:647e37ef0eec | 327 | |
fabio_gatti | 3:647e37ef0eec | 328 | /** |
fabio_gatti | 3:647e37ef0eec | 329 | * \fn extern uint32_t sn_nsdl_get_version(void) |
fabio_gatti | 3:647e37ef0eec | 330 | * |
fabio_gatti | 3:647e37ef0eec | 331 | * \brief Version query function. |
fabio_gatti | 3:647e37ef0eec | 332 | * |
fabio_gatti | 3:647e37ef0eec | 333 | * Used to retrieve the version information from the mbed Device C Client library. |
fabio_gatti | 3:647e37ef0eec | 334 | * |
fabio_gatti | 3:647e37ef0eec | 335 | * \return Pointer to library version string |
fabio_gatti | 3:647e37ef0eec | 336 | */ |
fabio_gatti | 3:647e37ef0eec | 337 | extern char *sn_nsdl_get_version(void); |
fabio_gatti | 3:647e37ef0eec | 338 | |
fabio_gatti | 3:647e37ef0eec | 339 | /** |
fabio_gatti | 3:647e37ef0eec | 340 | * \fn extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src) |
fabio_gatti | 3:647e37ef0eec | 341 | * |
fabio_gatti | 3:647e37ef0eec | 342 | * \brief To push CoAP packet to mbed Device C Client library |
fabio_gatti | 3:647e37ef0eec | 343 | * |
fabio_gatti | 3:647e37ef0eec | 344 | * Used to push an CoAP packet to mbed Device C Client library for processing. |
fabio_gatti | 3:647e37ef0eec | 345 | * |
fabio_gatti | 3:647e37ef0eec | 346 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 347 | * |
fabio_gatti | 3:647e37ef0eec | 348 | * \param *packet Pointer to a uint8_t array containing the packet (including the CoAP headers). |
fabio_gatti | 3:647e37ef0eec | 349 | * After successful execution this array may contain the response packet. |
fabio_gatti | 3:647e37ef0eec | 350 | * |
fabio_gatti | 3:647e37ef0eec | 351 | * \param *packet_len Pointer to length of the packet. After successful execution this array may contain the length |
fabio_gatti | 3:647e37ef0eec | 352 | * of the response packet. |
fabio_gatti | 3:647e37ef0eec | 353 | * |
fabio_gatti | 3:647e37ef0eec | 354 | * \param *src Pointer to packet source address information. After successful execution this array may contain |
fabio_gatti | 3:647e37ef0eec | 355 | * the destination address of the response packet. |
fabio_gatti | 3:647e37ef0eec | 356 | * |
fabio_gatti | 3:647e37ef0eec | 357 | * \return 0 Success |
fabio_gatti | 3:647e37ef0eec | 358 | * \return -1 Failure |
fabio_gatti | 3:647e37ef0eec | 359 | */ |
fabio_gatti | 3:647e37ef0eec | 360 | extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src); |
fabio_gatti | 3:647e37ef0eec | 361 | |
fabio_gatti | 3:647e37ef0eec | 362 | /** |
fabio_gatti | 3:647e37ef0eec | 363 | * \fn extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time); |
fabio_gatti | 3:647e37ef0eec | 364 | * |
fabio_gatti | 3:647e37ef0eec | 365 | * \brief CoAP retransmission function. |
fabio_gatti | 3:647e37ef0eec | 366 | * |
fabio_gatti | 3:647e37ef0eec | 367 | * Used to give execution time for the mbed Device C Client library for retransmissions. |
fabio_gatti | 3:647e37ef0eec | 368 | * |
fabio_gatti | 3:647e37ef0eec | 369 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 370 | * |
fabio_gatti | 3:647e37ef0eec | 371 | * \param time Time in seconds. |
fabio_gatti | 3:647e37ef0eec | 372 | * |
fabio_gatti | 3:647e37ef0eec | 373 | * \return 0 Success |
fabio_gatti | 3:647e37ef0eec | 374 | * \return -1 Failure |
fabio_gatti | 3:647e37ef0eec | 375 | */ |
fabio_gatti | 3:647e37ef0eec | 376 | extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time); |
fabio_gatti | 3:647e37ef0eec | 377 | |
fabio_gatti | 3:647e37ef0eec | 378 | /** |
fabio_gatti | 3:647e37ef0eec | 379 | * \fn extern int8_t sn_nsdl_put_resource(struct nsdl_s *handle, const sn_nsdl_dynamic_resource_parameters_s *res); |
fabio_gatti | 3:647e37ef0eec | 380 | * |
fabio_gatti | 3:647e37ef0eec | 381 | * \brief Resource putting function. |
fabio_gatti | 3:647e37ef0eec | 382 | * |
fabio_gatti | 3:647e37ef0eec | 383 | * Used to put a static or dynamic CoAP resource without creating copy of it. |
fabio_gatti | 3:647e37ef0eec | 384 | * NOTE: Remember that only resource will be owned, not data that it contains |
fabio_gatti | 3:647e37ef0eec | 385 | * NOTE: The resource may be removed from list by sn_nsdl_pop_resource(). |
fabio_gatti | 3:647e37ef0eec | 386 | * |
fabio_gatti | 3:647e37ef0eec | 387 | * \param *res Pointer to a structure of type sn_nsdl_dynamic_resource_parameters_s that contains the information |
fabio_gatti | 3:647e37ef0eec | 388 | * about the resource. |
fabio_gatti | 3:647e37ef0eec | 389 | * |
fabio_gatti | 3:647e37ef0eec | 390 | * \return 0 Success |
fabio_gatti | 3:647e37ef0eec | 391 | * \return -1 Failure |
fabio_gatti | 3:647e37ef0eec | 392 | * \return -2 Resource already exists |
fabio_gatti | 3:647e37ef0eec | 393 | * \return -3 Invalid path |
fabio_gatti | 3:647e37ef0eec | 394 | * \return -4 List adding failure |
fabio_gatti | 3:647e37ef0eec | 395 | */ |
fabio_gatti | 3:647e37ef0eec | 396 | extern int8_t sn_nsdl_put_resource(struct nsdl_s *handle, sn_nsdl_dynamic_resource_parameters_s *res); |
fabio_gatti | 3:647e37ef0eec | 397 | |
fabio_gatti | 3:647e37ef0eec | 398 | /** |
fabio_gatti | 3:647e37ef0eec | 399 | * \fn extern int8_t sn_nsdl_pop_resource(struct nsdl_s *handle, const sn_nsdl_dynamic_resource_parameters_s *res); |
fabio_gatti | 3:647e37ef0eec | 400 | * |
fabio_gatti | 3:647e37ef0eec | 401 | * \brief Resource popping function. |
fabio_gatti | 3:647e37ef0eec | 402 | * |
fabio_gatti | 3:647e37ef0eec | 403 | * Used to remove a static or dynamic CoAP resource from lists without deleting it. |
fabio_gatti | 3:647e37ef0eec | 404 | * NOTE: This function is a counterpart of sn_nsdl_put_resource(). |
fabio_gatti | 3:647e37ef0eec | 405 | * |
fabio_gatti | 3:647e37ef0eec | 406 | * \param *res Pointer to a structure of type sn_nsdl_dynamic_resource_parameters_s that contains the information |
fabio_gatti | 3:647e37ef0eec | 407 | * about the resource. |
fabio_gatti | 3:647e37ef0eec | 408 | * |
fabio_gatti | 3:647e37ef0eec | 409 | * \return 0 Success |
fabio_gatti | 3:647e37ef0eec | 410 | * \return -1 Failure |
fabio_gatti | 3:647e37ef0eec | 411 | * \return -3 Invalid path |
fabio_gatti | 3:647e37ef0eec | 412 | */ |
fabio_gatti | 3:647e37ef0eec | 413 | extern int8_t sn_nsdl_pop_resource(struct nsdl_s *handle, sn_nsdl_dynamic_resource_parameters_s *res); |
fabio_gatti | 3:647e37ef0eec | 414 | |
fabio_gatti | 3:647e37ef0eec | 415 | /** |
fabio_gatti | 3:647e37ef0eec | 416 | * \fn extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, char *path) |
fabio_gatti | 3:647e37ef0eec | 417 | * |
fabio_gatti | 3:647e37ef0eec | 418 | * \brief Resource delete function. |
fabio_gatti | 3:647e37ef0eec | 419 | * |
fabio_gatti | 3:647e37ef0eec | 420 | * Used to delete a resource. If resource has a subresources, these all must also be removed. |
fabio_gatti | 3:647e37ef0eec | 421 | * |
fabio_gatti | 3:647e37ef0eec | 422 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 423 | * \param *path_ptr A pointer to an array containing the path. |
fabio_gatti | 3:647e37ef0eec | 424 | * |
fabio_gatti | 3:647e37ef0eec | 425 | * \return 0 Success |
fabio_gatti | 3:647e37ef0eec | 426 | * \return -1 Failure (No such resource) |
fabio_gatti | 3:647e37ef0eec | 427 | */ |
fabio_gatti | 3:647e37ef0eec | 428 | extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, const char *path); |
fabio_gatti | 3:647e37ef0eec | 429 | |
fabio_gatti | 3:647e37ef0eec | 430 | /** |
fabio_gatti | 3:647e37ef0eec | 431 | * \fn extern sn_nsdl_dynamic_resource_parameters_s *sn_nsdl_get_resource(struct nsdl_s *handle, char *path) |
fabio_gatti | 3:647e37ef0eec | 432 | * |
fabio_gatti | 3:647e37ef0eec | 433 | * \brief Resource get function. |
fabio_gatti | 3:647e37ef0eec | 434 | * |
fabio_gatti | 3:647e37ef0eec | 435 | * Used to get a resource. |
fabio_gatti | 3:647e37ef0eec | 436 | * |
fabio_gatti | 3:647e37ef0eec | 437 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 438 | * \param *path A pointer to an array containing the path. |
fabio_gatti | 3:647e37ef0eec | 439 | * |
fabio_gatti | 3:647e37ef0eec | 440 | * \return !NULL Success, pointer to a sn_nsdl_dynamic_resource_parameters_s that contains the resource information\n |
fabio_gatti | 3:647e37ef0eec | 441 | * \return NULL Failure |
fabio_gatti | 3:647e37ef0eec | 442 | */ |
fabio_gatti | 3:647e37ef0eec | 443 | extern sn_nsdl_dynamic_resource_parameters_s *sn_nsdl_get_resource(struct nsdl_s *handle, const char *path); |
fabio_gatti | 3:647e37ef0eec | 444 | |
fabio_gatti | 3:647e37ef0eec | 445 | /** |
fabio_gatti | 3:647e37ef0eec | 446 | * \fn extern sn_grs_resource_list_s *sn_nsdl_list_resource(struct nsdl_s *handle, char *path) |
fabio_gatti | 3:647e37ef0eec | 447 | * |
fabio_gatti | 3:647e37ef0eec | 448 | * \brief Resource list function. |
fabio_gatti | 3:647e37ef0eec | 449 | * |
fabio_gatti | 3:647e37ef0eec | 450 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 451 | * \param *path A pointer to an array containing the path or a NULL pointer. |
fabio_gatti | 3:647e37ef0eec | 452 | * |
fabio_gatti | 3:647e37ef0eec | 453 | * \return !NULL A pointer to a sn_grs_resource_list_s structure containing the resource listing. |
fabio_gatti | 3:647e37ef0eec | 454 | * \return NULL Failure with an unspecified error |
fabio_gatti | 3:647e37ef0eec | 455 | */ |
fabio_gatti | 3:647e37ef0eec | 456 | sn_grs_resource_list_s *sn_nsdl_list_resource(struct nsdl_s *handle, const char *path); |
fabio_gatti | 3:647e37ef0eec | 457 | |
fabio_gatti | 3:647e37ef0eec | 458 | /** |
fabio_gatti | 3:647e37ef0eec | 459 | * \fn extern void sn_nsdl_free_resource_list(struct nsdl_s *handle, sn_grs_resource_list_s *list) |
fabio_gatti | 3:647e37ef0eec | 460 | * |
fabio_gatti | 3:647e37ef0eec | 461 | * \brief Free a resource list obtained from sn_nsdl_list_resource() |
fabio_gatti | 3:647e37ef0eec | 462 | * |
fabio_gatti | 3:647e37ef0eec | 463 | * \param list The list to free, or NULL. |
fabio_gatti | 3:647e37ef0eec | 464 | */ |
fabio_gatti | 3:647e37ef0eec | 465 | void sn_nsdl_free_resource_list(struct nsdl_s *handle, sn_grs_resource_list_s *list); |
fabio_gatti | 3:647e37ef0eec | 466 | |
fabio_gatti | 3:647e37ef0eec | 467 | /** |
fabio_gatti | 3:647e37ef0eec | 468 | * \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); |
fabio_gatti | 3:647e37ef0eec | 469 | * |
fabio_gatti | 3:647e37ef0eec | 470 | * \brief Send an outgoing CoAP request. |
fabio_gatti | 3:647e37ef0eec | 471 | * |
fabio_gatti | 3:647e37ef0eec | 472 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 473 | * \param *address_ptr Pointer to source address struct |
fabio_gatti | 3:647e37ef0eec | 474 | * \param *coap_hdr_ptr Pointer to CoAP message to be sent |
fabio_gatti | 3:647e37ef0eec | 475 | * |
fabio_gatti | 3:647e37ef0eec | 476 | * \return 0 Success |
fabio_gatti | 3:647e37ef0eec | 477 | * \return -1 Failure |
fabio_gatti | 3:647e37ef0eec | 478 | */ |
fabio_gatti | 3:647e37ef0eec | 479 | 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); |
fabio_gatti | 3:647e37ef0eec | 480 | |
fabio_gatti | 3:647e37ef0eec | 481 | /** |
fabio_gatti | 3:647e37ef0eec | 482 | * \fn extern int8_t set_NSP_address(struct nsdl_s *handle, uint8_t *NSP_address, uint8_t address_length, uint16_t port, sn_nsdl_addr_type_e address_type); |
fabio_gatti | 3:647e37ef0eec | 483 | * |
fabio_gatti | 3:647e37ef0eec | 484 | * \brief This function is used to set the mbed Device Server address given by an application. |
fabio_gatti | 3:647e37ef0eec | 485 | * |
fabio_gatti | 3:647e37ef0eec | 486 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 487 | * \return 0 Success |
fabio_gatti | 3:647e37ef0eec | 488 | * \return -1 Failed to indicate that internal address pointer is not allocated (call nsdl_init() first). |
fabio_gatti | 3:647e37ef0eec | 489 | */ |
fabio_gatti | 3:647e37ef0eec | 490 | extern int8_t set_NSP_address(struct nsdl_s *handle, uint8_t *NSP_address, uint8_t address_length, uint16_t port, sn_nsdl_addr_type_e address_type); |
fabio_gatti | 3:647e37ef0eec | 491 | |
fabio_gatti | 3:647e37ef0eec | 492 | /** |
fabio_gatti | 3:647e37ef0eec | 493 | * \fn extern int8_t sn_nsdl_destroy(struct nsdl_s *handle); |
fabio_gatti | 3:647e37ef0eec | 494 | * |
fabio_gatti | 3:647e37ef0eec | 495 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 496 | * \brief This function releases all allocated memory in mbed Device C Client library. |
fabio_gatti | 3:647e37ef0eec | 497 | */ |
fabio_gatti | 3:647e37ef0eec | 498 | extern int8_t sn_nsdl_destroy(struct nsdl_s *handle); |
fabio_gatti | 3:647e37ef0eec | 499 | |
fabio_gatti | 3:647e37ef0eec | 500 | /** |
fabio_gatti | 3:647e37ef0eec | 501 | * \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); |
fabio_gatti | 3:647e37ef0eec | 502 | * |
fabio_gatti | 3:647e37ef0eec | 503 | * \brief Starts OMA bootstrap process |
fabio_gatti | 3:647e37ef0eec | 504 | * |
fabio_gatti | 3:647e37ef0eec | 505 | * \param *handle Pointer to nsdl-library handle |
fabio_gatti | 3:647e37ef0eec | 506 | * |
fabio_gatti | 3:647e37ef0eec | 507 | * \return bootstrap message ID, 0 if failed |
fabio_gatti | 3:647e37ef0eec | 508 | */ |
fabio_gatti | 3:647e37ef0eec | 509 | 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); |
fabio_gatti | 3:647e37ef0eec | 510 | |
fabio_gatti | 3:647e37ef0eec | 511 | /** |
fabio_gatti | 3:647e37ef0eec | 512 | * \fn sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code) |
fabio_gatti | 3:647e37ef0eec | 513 | * |
fabio_gatti | 3:647e37ef0eec | 514 | * \brief Prepares generic response packet from a request packet. This function allocates memory for the resulting sn_coap_hdr_s |
fabio_gatti | 3:647e37ef0eec | 515 | * |
fabio_gatti | 3:647e37ef0eec | 516 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 517 | * \param *coap_packet_ptr The request packet pointer |
fabio_gatti | 3:647e37ef0eec | 518 | * \param msg_code response messages code |
fabio_gatti | 3:647e37ef0eec | 519 | * |
fabio_gatti | 3:647e37ef0eec | 520 | * \return *coap_packet_ptr The allocated and pre-filled response packet pointer |
fabio_gatti | 3:647e37ef0eec | 521 | * NULL Error in parsing the request |
fabio_gatti | 3:647e37ef0eec | 522 | * |
fabio_gatti | 3:647e37ef0eec | 523 | */ |
fabio_gatti | 3:647e37ef0eec | 524 | extern sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code); |
fabio_gatti | 3:647e37ef0eec | 525 | |
fabio_gatti | 3:647e37ef0eec | 526 | /** |
fabio_gatti | 3:647e37ef0eec | 527 | * \brief Allocates and initializes options list structure |
fabio_gatti | 3:647e37ef0eec | 528 | * |
fabio_gatti | 3:647e37ef0eec | 529 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 530 | * \param *coap_msg_ptr is pointer to CoAP message that will contain the options |
fabio_gatti | 3:647e37ef0eec | 531 | * |
fabio_gatti | 3:647e37ef0eec | 532 | * If the message already has a pointer to an option structure, that pointer |
fabio_gatti | 3:647e37ef0eec | 533 | * is returned, rather than a new structure being allocated. |
fabio_gatti | 3:647e37ef0eec | 534 | * |
fabio_gatti | 3:647e37ef0eec | 535 | * \return Return value is pointer to the CoAP options structure.\n |
fabio_gatti | 3:647e37ef0eec | 536 | * In following failure cases NULL is returned:\n |
fabio_gatti | 3:647e37ef0eec | 537 | * -Failure in given pointer (= NULL)\n |
fabio_gatti | 3:647e37ef0eec | 538 | * -Failure in memory allocation (malloc() returns NULL) |
fabio_gatti | 3:647e37ef0eec | 539 | */ |
fabio_gatti | 3:647e37ef0eec | 540 | extern sn_coap_options_list_s *sn_nsdl_alloc_options_list(struct nsdl_s *handle, sn_coap_hdr_s *coap_msg_ptr); |
fabio_gatti | 3:647e37ef0eec | 541 | |
fabio_gatti | 3:647e37ef0eec | 542 | /** |
fabio_gatti | 3:647e37ef0eec | 543 | * \fn void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr) |
fabio_gatti | 3:647e37ef0eec | 544 | * |
fabio_gatti | 3:647e37ef0eec | 545 | * \brief Releases memory of given CoAP message |
fabio_gatti | 3:647e37ef0eec | 546 | * |
fabio_gatti | 3:647e37ef0eec | 547 | * Note!!! Does not release Payload part |
fabio_gatti | 3:647e37ef0eec | 548 | * |
fabio_gatti | 3:647e37ef0eec | 549 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 550 | * |
fabio_gatti | 3:647e37ef0eec | 551 | * \param *freed_coap_msg_ptr is pointer to released CoAP message |
fabio_gatti | 3:647e37ef0eec | 552 | */ |
fabio_gatti | 3:647e37ef0eec | 553 | extern void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr); |
fabio_gatti | 3:647e37ef0eec | 554 | |
fabio_gatti | 3:647e37ef0eec | 555 | /** |
fabio_gatti | 3:647e37ef0eec | 556 | * \fn int8_t sn_nsdl_set_retransmission_parameters(struct nsdl_s *handle, uint8_t resending_count, uint8_t resending_intervall) |
fabio_gatti | 3:647e37ef0eec | 557 | * |
fabio_gatti | 3:647e37ef0eec | 558 | * \brief If re-transmissions are enabled, this function changes resending count and interval. |
fabio_gatti | 3:647e37ef0eec | 559 | * |
fabio_gatti | 3:647e37ef0eec | 560 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 561 | * \param uint8_t resending_count max number of resendings for message |
fabio_gatti | 3:647e37ef0eec | 562 | * \param uint8_t resending_intervall message resending intervall in seconds |
fabio_gatti | 3:647e37ef0eec | 563 | * \return 0 = success, -1 = failure |
fabio_gatti | 3:647e37ef0eec | 564 | */ |
fabio_gatti | 3:647e37ef0eec | 565 | extern int8_t sn_nsdl_set_retransmission_parameters(struct nsdl_s *handle, uint8_t resending_count, uint8_t resending_interval); |
fabio_gatti | 3:647e37ef0eec | 566 | |
fabio_gatti | 3:647e37ef0eec | 567 | /** |
fabio_gatti | 3:647e37ef0eec | 568 | * \fn int8_t sn_nsdl_set_retransmission_buffer(struct nsdl_s *handle, uint8_t buffer_size_messages, uint16_t buffer_size_bytes) |
fabio_gatti | 3:647e37ef0eec | 569 | * |
fabio_gatti | 3:647e37ef0eec | 570 | * \brief If re-transmissions are enabled, this function changes message retransmission queue size. |
fabio_gatti | 3:647e37ef0eec | 571 | * Set size to '0' to disable feature. If both are set to '0', then re-sendings are disabled. |
fabio_gatti | 3:647e37ef0eec | 572 | * |
fabio_gatti | 3:647e37ef0eec | 573 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 574 | * \param uint8_t buffer_size_messages queue size - maximum number of messages to be saved to queue |
fabio_gatti | 3:647e37ef0eec | 575 | * \param uint8_t buffer_size_bytes queue size - maximum size of messages saved to queue |
fabio_gatti | 3:647e37ef0eec | 576 | * \return 0 = success, -1 = failure |
fabio_gatti | 3:647e37ef0eec | 577 | */ |
fabio_gatti | 3:647e37ef0eec | 578 | extern int8_t sn_nsdl_set_retransmission_buffer(struct nsdl_s *handle, |
fabio_gatti | 3:647e37ef0eec | 579 | uint8_t buffer_size_messages, uint16_t buffer_size_bytes); |
fabio_gatti | 3:647e37ef0eec | 580 | |
fabio_gatti | 3:647e37ef0eec | 581 | /** |
fabio_gatti | 3:647e37ef0eec | 582 | * \fn int8_t sn_nsdl_set_block_size(struct nsdl_s *handle, uint16_t block_size) |
fabio_gatti | 3:647e37ef0eec | 583 | * |
fabio_gatti | 3:647e37ef0eec | 584 | * \brief If block transfer is enabled, this function changes the block size. |
fabio_gatti | 3:647e37ef0eec | 585 | * |
fabio_gatti | 3:647e37ef0eec | 586 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 587 | * \param uint16_t block_size maximum size of CoAP payload. Valid sizes are 16, 32, 64, 128, 256, 512 and 1024 bytes |
fabio_gatti | 3:647e37ef0eec | 588 | * \return 0 = success, -1 = failure |
fabio_gatti | 3:647e37ef0eec | 589 | */ |
fabio_gatti | 3:647e37ef0eec | 590 | extern int8_t sn_nsdl_set_block_size(struct nsdl_s *handle, uint16_t block_size); |
fabio_gatti | 3:647e37ef0eec | 591 | |
fabio_gatti | 3:647e37ef0eec | 592 | /** |
fabio_gatti | 3:647e37ef0eec | 593 | * \fn int8_t sn_nsdl_set_duplicate_buffer_size(struct nsdl_s *handle,uint8_t message_count) |
fabio_gatti | 3:647e37ef0eec | 594 | * |
fabio_gatti | 3:647e37ef0eec | 595 | * \brief If dublicate message detection is enabled, this function changes buffer size. |
fabio_gatti | 3:647e37ef0eec | 596 | * |
fabio_gatti | 3:647e37ef0eec | 597 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 598 | * \param uint8_t message_count max number of messages saved for duplicate control |
fabio_gatti | 3:647e37ef0eec | 599 | * \return 0 = success, -1 = failure |
fabio_gatti | 3:647e37ef0eec | 600 | */ |
fabio_gatti | 3:647e37ef0eec | 601 | extern int8_t sn_nsdl_set_duplicate_buffer_size(struct nsdl_s *handle, uint8_t message_count); |
fabio_gatti | 3:647e37ef0eec | 602 | |
fabio_gatti | 3:647e37ef0eec | 603 | /** |
fabio_gatti | 3:647e37ef0eec | 604 | * \fn void *sn_nsdl_set_context(const struct nsdl_s *handle, void *context) |
fabio_gatti | 3:647e37ef0eec | 605 | * |
fabio_gatti | 3:647e37ef0eec | 606 | * \brief Set the application defined context parameter for given handle. |
fabio_gatti | 3:647e37ef0eec | 607 | * This is useful for example when interfacing with c++ objects where a |
fabio_gatti | 3:647e37ef0eec | 608 | * pointer to object is set as the context, and in the callback functions |
fabio_gatti | 3:647e37ef0eec | 609 | * the context pointer can be used to call methods for the correct instance |
fabio_gatti | 3:647e37ef0eec | 610 | * of the c++ object. |
fabio_gatti | 3:647e37ef0eec | 611 | * |
fabio_gatti | 3:647e37ef0eec | 612 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 613 | * \param *context Pointer to the application defined context |
fabio_gatti | 3:647e37ef0eec | 614 | * \return 0 = success, -1 = failure |
fabio_gatti | 3:647e37ef0eec | 615 | */ |
fabio_gatti | 3:647e37ef0eec | 616 | extern int8_t sn_nsdl_set_context(struct nsdl_s * const handle, void * const context); |
fabio_gatti | 3:647e37ef0eec | 617 | |
fabio_gatti | 3:647e37ef0eec | 618 | /** |
fabio_gatti | 3:647e37ef0eec | 619 | * \fn void *sn_nsdl_get_context(const struct nsdl_s *handle) |
fabio_gatti | 3:647e37ef0eec | 620 | * |
fabio_gatti | 3:647e37ef0eec | 621 | * \brief Get the application defined context parameter for given handle. |
fabio_gatti | 3:647e37ef0eec | 622 | * This is useful for example when interfacing with c++ objects where a |
fabio_gatti | 3:647e37ef0eec | 623 | * pointer to object is set as the context, and in the callback functions |
fabio_gatti | 3:647e37ef0eec | 624 | * the context pointer can be used to call methods for the correct instance |
fabio_gatti | 3:647e37ef0eec | 625 | * of the c++ object. |
fabio_gatti | 3:647e37ef0eec | 626 | * |
fabio_gatti | 3:647e37ef0eec | 627 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 628 | * \return Pointer to the application defined context |
fabio_gatti | 3:647e37ef0eec | 629 | */ |
fabio_gatti | 3:647e37ef0eec | 630 | extern void *sn_nsdl_get_context(const struct nsdl_s * const handle); |
fabio_gatti | 3:647e37ef0eec | 631 | |
fabio_gatti | 3:647e37ef0eec | 632 | /** |
fabio_gatti | 3:647e37ef0eec | 633 | * \fn int8_t sn_nsdl_clear_coap_resending_queue(struct nsdl_s *handle) |
fabio_gatti | 3:647e37ef0eec | 634 | * |
fabio_gatti | 3:647e37ef0eec | 635 | * \brief Clean confirmable message list. |
fabio_gatti | 3:647e37ef0eec | 636 | * |
fabio_gatti | 3:647e37ef0eec | 637 | * \param *handle Pointer to library handle |
fabio_gatti | 3:647e37ef0eec | 638 | * \return 0 = success, -1 = failure |
fabio_gatti | 3:647e37ef0eec | 639 | */ |
fabio_gatti | 3:647e37ef0eec | 640 | extern int8_t sn_nsdl_clear_coap_resending_queue(struct nsdl_s *handle); |
fabio_gatti | 3:647e37ef0eec | 641 | |
fabio_gatti | 3:647e37ef0eec | 642 | #ifdef __cplusplus |
fabio_gatti | 3:647e37ef0eec | 643 | } |
fabio_gatti | 3:647e37ef0eec | 644 | #endif |
fabio_gatti | 3:647e37ef0eec | 645 | |
fabio_gatti | 3:647e37ef0eec | 646 | #endif /* SN_NSDL_LIB_H_ */ |