Pfp Cybersecurity (Aka Power Fingerprinting, Inc.) / Mbed OS pfp-emon-nxp

Dependencies:   FXAS21002 FXOS8700Q

Committer:
vithyat
Date:
Wed Aug 28 19:24:56 2019 +0000
Revision:
0:977e87915078
init

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vithyat 0:977e87915078 1 /*
vithyat 0:977e87915078 2 * Copyright (c) 2011-2015 ARM Limited. All rights reserved.
vithyat 0:977e87915078 3 * SPDX-License-Identifier: Apache-2.0
vithyat 0:977e87915078 4 * Licensed under the Apache License, Version 2.0 (the License); you may
vithyat 0:977e87915078 5 * not use this file except in compliance with the License.
vithyat 0:977e87915078 6 * You may obtain a copy of the License at
vithyat 0:977e87915078 7 *
vithyat 0:977e87915078 8 * http://www.apache.org/licenses/LICENSE-2.0
vithyat 0:977e87915078 9 *
vithyat 0:977e87915078 10 * Unless required by applicable law or agreed to in writing, software
vithyat 0:977e87915078 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
vithyat 0:977e87915078 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
vithyat 0:977e87915078 13 * See the License for the specific language governing permissions and
vithyat 0:977e87915078 14 * limitations under the License.
vithyat 0:977e87915078 15 */
vithyat 0:977e87915078 16
vithyat 0:977e87915078 17 /**
vithyat 0:977e87915078 18 * \file sn_nsdl_lib.h
vithyat 0:977e87915078 19 *
vithyat 0:977e87915078 20 * \brief NanoService Devices Library header file
vithyat 0:977e87915078 21 *
vithyat 0:977e87915078 22 *
vithyat 0:977e87915078 23 */
vithyat 0:977e87915078 24
vithyat 0:977e87915078 25 #ifndef SN_NSDL_LIB_H_
vithyat 0:977e87915078 26 #define SN_NSDL_LIB_H_
vithyat 0:977e87915078 27
vithyat 0:977e87915078 28 #include "ns_list.h"
vithyat 0:977e87915078 29 #include "sn_client_config.h"
vithyat 0:977e87915078 30
vithyat 0:977e87915078 31 #ifdef __cplusplus
vithyat 0:977e87915078 32 extern "C" {
vithyat 0:977e87915078 33 #endif
vithyat 0:977e87915078 34
vithyat 0:977e87915078 35 #define SN_NSDL_ENDPOINT_NOT_REGISTERED 0
vithyat 0:977e87915078 36 #define SN_NSDL_ENDPOINT_IS_REGISTERED 1
vithyat 0:977e87915078 37
vithyat 0:977e87915078 38 #define MAX_TOKEN_SIZE 8
vithyat 0:977e87915078 39 #define MAX_URI_QUERY_LEN 255
vithyat 0:977e87915078 40
vithyat 0:977e87915078 41 #if defined MBED_CONF_MBED_CLIENT_DISABLE_INTERFACE_DESCRIPTION
vithyat 0:977e87915078 42 #define DISABLE_INTERFACE_DESCRIPTION MBED_CONF_MBED_CLIENT_DISABLE_INTERFACE_DESCRIPTION
vithyat 0:977e87915078 43 #endif
vithyat 0:977e87915078 44
vithyat 0:977e87915078 45 #if defined MBED_CONF_MBED_CLIENT_DISABLE_RESOURCE_TYPE
vithyat 0:977e87915078 46 #define DISABLE_RESOURCE_TYPE MBED_CONF_MBED_CLIENT_DISABLE_RESOURCE_TYPE
vithyat 0:977e87915078 47 #endif
vithyat 0:977e87915078 48
vithyat 0:977e87915078 49 /* Handle structure */
vithyat 0:977e87915078 50 struct nsdl_s;
vithyat 0:977e87915078 51
vithyat 0:977e87915078 52 /**
vithyat 0:977e87915078 53 * \brief Received device server security
vithyat 0:977e87915078 54 */
vithyat 0:977e87915078 55 typedef enum omalw_server_security_ {
vithyat 0:977e87915078 56 SEC_NOT_SET = -1,
vithyat 0:977e87915078 57 PSK = 0,
vithyat 0:977e87915078 58 RPK = 1,
vithyat 0:977e87915078 59 CERTIFICATE = 2,
vithyat 0:977e87915078 60 NO_SEC = 3
vithyat 0:977e87915078 61 } omalw_server_security_t;
vithyat 0:977e87915078 62
vithyat 0:977e87915078 63 /**
vithyat 0:977e87915078 64 * \brief Endpoint binding and mode
vithyat 0:977e87915078 65 */
vithyat 0:977e87915078 66 typedef enum sn_nsdl_oma_binding_and_mode_ {
vithyat 0:977e87915078 67 BINDING_MODE_NOT_SET = 0,
vithyat 0:977e87915078 68 BINDING_MODE_U = 0x01,
vithyat 0:977e87915078 69 BINDING_MODE_Q = 0x02,
vithyat 0:977e87915078 70 BINDING_MODE_S = 0x04
vithyat 0:977e87915078 71 } sn_nsdl_oma_binding_and_mode_t;
vithyat 0:977e87915078 72
vithyat 0:977e87915078 73 //#define RESOURCE_ATTRIBUTES_LIST
vithyat 0:977e87915078 74 #ifdef RESOURCE_ATTRIBUTES_LIST
vithyat 0:977e87915078 75 /*
vithyat 0:977e87915078 76 * \brief Resource attributes types
vithyat 0:977e87915078 77 */
vithyat 0:977e87915078 78 typedef enum sn_nsdl_resource_attribute_ {
vithyat 0:977e87915078 79 ATTR_RESOURCE_TYPE,
vithyat 0:977e87915078 80 ATTR_INTERFACE_DESCRIPTION,
vithyat 0:977e87915078 81 ATTR_ENDPOINT_NAME,
vithyat 0:977e87915078 82 ATTR_QUEUE_MODE,
vithyat 0:977e87915078 83 ATTR_LIFETIME,
vithyat 0:977e87915078 84 ATTR_NOP,
vithyat 0:977e87915078 85 ATTR_END
vithyat 0:977e87915078 86 } sn_nsdl_resource_attribute_t;
vithyat 0:977e87915078 87
vithyat 0:977e87915078 88 typedef struct sn_nsdl_attribute_item_ {
vithyat 0:977e87915078 89 sn_nsdl_resource_attribute_t attribute_name;
vithyat 0:977e87915078 90 char *value;
vithyat 0:977e87915078 91 } sn_nsdl_attribute_item_s;
vithyat 0:977e87915078 92
vithyat 0:977e87915078 93 #endif
vithyat 0:977e87915078 94
vithyat 0:977e87915078 95 /**
vithyat 0:977e87915078 96 * \brief Endpoint registration mode.
vithyat 0:977e87915078 97 * If REGISTER_WITH_RESOURCES, endpoint sends list of all resources during registration.
vithyat 0:977e87915078 98 * If REGISTER_WITH_TEMPLATE, endpoint sends registration without resource list. Device server must have
vithyat 0:977e87915078 99 * correctly configured template.
vithyat 0:977e87915078 100 */
vithyat 0:977e87915078 101 typedef enum sn_nsdl_registration_mode_ {
vithyat 0:977e87915078 102 REGISTER_WITH_RESOURCES = 0,
vithyat 0:977e87915078 103 REGISTER_WITH_TEMPLATE
vithyat 0:977e87915078 104 } sn_nsdl_registration_mode_t;
vithyat 0:977e87915078 105
vithyat 0:977e87915078 106 /**
vithyat 0:977e87915078 107 * \brief Endpoint registration parameters
vithyat 0:977e87915078 108 */
vithyat 0:977e87915078 109 typedef struct sn_nsdl_ep_parameters_ {
vithyat 0:977e87915078 110 uint8_t endpoint_name_len;
vithyat 0:977e87915078 111 uint8_t domain_name_len;
vithyat 0:977e87915078 112 uint8_t type_len;
vithyat 0:977e87915078 113 uint8_t lifetime_len;
vithyat 0:977e87915078 114 uint8_t location_len;
vithyat 0:977e87915078 115
vithyat 0:977e87915078 116 sn_nsdl_registration_mode_t ds_register_mode; /**< Defines registration mode */
vithyat 0:977e87915078 117 sn_nsdl_oma_binding_and_mode_t binding_and_mode; /**< Defines endpoints binding and mode */
vithyat 0:977e87915078 118
vithyat 0:977e87915078 119 uint8_t *endpoint_name_ptr; /**< Endpoint name */
vithyat 0:977e87915078 120 uint8_t *domain_name_ptr; /**< Domain to register. If null, NSP uses default domain */
vithyat 0:977e87915078 121 uint8_t *type_ptr; /**< Endpoint type */
vithyat 0:977e87915078 122 uint8_t *lifetime_ptr; /**< Endpoint lifetime in seconds. eg. "1200" = 1200 seconds */
vithyat 0:977e87915078 123 uint8_t *location_ptr; /**< Endpoint location in server, optional parameter,default is NULL */
vithyat 0:977e87915078 124 } sn_nsdl_ep_parameters_s;
vithyat 0:977e87915078 125
vithyat 0:977e87915078 126 /**
vithyat 0:977e87915078 127 * \brief Resource access rights
vithyat 0:977e87915078 128 */
vithyat 0:977e87915078 129 typedef enum sn_grs_resource_acl_ {
vithyat 0:977e87915078 130 SN_GRS_GET_ALLOWED = 0x01 ,
vithyat 0:977e87915078 131 SN_GRS_PUT_ALLOWED = 0x02,
vithyat 0:977e87915078 132 SN_GRS_POST_ALLOWED = 0x04,
vithyat 0:977e87915078 133 SN_GRS_DELETE_ALLOWED = 0x08
vithyat 0:977e87915078 134 } sn_grs_resource_acl_e;
vithyat 0:977e87915078 135
vithyat 0:977e87915078 136 /**
vithyat 0:977e87915078 137 * \brief Defines the resource mode
vithyat 0:977e87915078 138 */
vithyat 0:977e87915078 139 typedef enum sn_nsdl_resource_mode_ {
vithyat 0:977e87915078 140 SN_GRS_STATIC = 0, /**< Static resources have some value that doesn't change */
vithyat 0:977e87915078 141 SN_GRS_DYNAMIC, /**< Dynamic resources are handled in application. Therefore one must give function callback pointer to them */
vithyat 0:977e87915078 142 SN_GRS_DIRECTORY /**< Directory resources are unused and unsupported */
vithyat 0:977e87915078 143 } sn_nsdl_resource_mode_e;
vithyat 0:977e87915078 144
vithyat 0:977e87915078 145 /**
vithyat 0:977e87915078 146 * Enum defining an status codes that can happen when
vithyat 0:977e87915078 147 * sending notification
vithyat 0:977e87915078 148 */
vithyat 0:977e87915078 149 typedef enum {
vithyat 0:977e87915078 150 NOTIFICATION_STATUS_INIT = 0, // Initial state.
vithyat 0:977e87915078 151 NOTIFICATION_STATUS_BUILD_ERROR, // CoAP message building fails.
vithyat 0:977e87915078 152 NOTIFICATION_STATUS_RESEND_QUEUE_FULL, // CoAP resend queue full.
vithyat 0:977e87915078 153 NOTIFICATION_STATUS_SENT, // Notification sent to the server but ACK not yet received.
vithyat 0:977e87915078 154 NOTIFICATION_STATUS_DELIVERED, // Received ACK from server.
vithyat 0:977e87915078 155 NOTIFICATION_STATUS_SEND_FAILED, // Message sending failed (retransmission completed).
vithyat 0:977e87915078 156 NOTIFICATION_STATUS_SUBSCRIBED, // Server has started the observation
vithyat 0:977e87915078 157 NOTIFICATION_STATUS_UNSUBSCRIBED // Server has stopped the observation (RESET message or GET with observe 1)
vithyat 0:977e87915078 158 } NotificationDeliveryStatus;
vithyat 0:977e87915078 159
vithyat 0:977e87915078 160 /**
vithyat 0:977e87915078 161 * Enum defining an different download types.
vithyat 0:977e87915078 162 * This is used for 'uri-path' when sending a GET request.
vithyat 0:977e87915078 163 */
vithyat 0:977e87915078 164 typedef enum {
vithyat 0:977e87915078 165 FIRMWARE_DOWNLOAD = 0,
vithyat 0:977e87915078 166 GENERIC_DOWNLOAD
vithyat 0:977e87915078 167 } DownloadType;
vithyat 0:977e87915078 168
vithyat 0:977e87915078 169 /** Dummy alias to maintain compatibility with older version which had a typo in the enum name. */
vithyat 0:977e87915078 170 typedef NotificationDeliveryStatus NoticationDeliveryStatus;
vithyat 0:977e87915078 171
vithyat 0:977e87915078 172
vithyat 0:977e87915078 173 /**
vithyat 0:977e87915078 174 * \brief Defines static parameters for the resource.
vithyat 0:977e87915078 175 */
vithyat 0:977e87915078 176 typedef struct sn_nsdl_static_resource_parameters_ {
vithyat 0:977e87915078 177 #ifndef RESOURCE_ATTRIBUTES_LIST
vithyat 0:977e87915078 178 #ifndef DISABLE_RESOURCE_TYPE
vithyat 0:977e87915078 179 char *resource_type_ptr; /**< Type of the resource */
vithyat 0:977e87915078 180 #endif
vithyat 0:977e87915078 181 #ifndef DISABLE_INTERFACE_DESCRIPTION
vithyat 0:977e87915078 182 char *interface_description_ptr; /**< Interface description */
vithyat 0:977e87915078 183 #endif
vithyat 0:977e87915078 184 #else
vithyat 0:977e87915078 185 sn_nsdl_attribute_item_s *attributes_ptr;
vithyat 0:977e87915078 186 #endif
vithyat 0:977e87915078 187 char *path; /**< Resource path */
vithyat 0:977e87915078 188 bool external_memory_block:1; /**< 0 means block messages are handled inside this library,
vithyat 0:977e87915078 189 otherwise block messages are passed to application */
vithyat 0:977e87915078 190 unsigned mode:2; /**< STATIC etc.. */
vithyat 0:977e87915078 191 bool free_on_delete:1; /**< 1 if struct is dynamic allocted --> to be freed */
vithyat 0:977e87915078 192 } sn_nsdl_static_resource_parameters_s;
vithyat 0:977e87915078 193
vithyat 0:977e87915078 194 /**
vithyat 0:977e87915078 195 * \brief Defines dynamic parameters for the resource.
vithyat 0:977e87915078 196 */
vithyat 0:977e87915078 197 typedef struct sn_nsdl_resource_parameters_ {
vithyat 0:977e87915078 198 uint8_t (*sn_grs_dyn_res_callback)(struct nsdl_s *,
vithyat 0:977e87915078 199 sn_coap_hdr_s *,
vithyat 0:977e87915078 200 sn_nsdl_addr_s *,
vithyat 0:977e87915078 201 sn_nsdl_capab_e);
vithyat 0:977e87915078 202 #ifdef MEMORY_OPTIMIZED_API
vithyat 0:977e87915078 203 const sn_nsdl_static_resource_parameters_s *static_resource_parameters;
vithyat 0:977e87915078 204 #else
vithyat 0:977e87915078 205 sn_nsdl_static_resource_parameters_s *static_resource_parameters;
vithyat 0:977e87915078 206 #endif
vithyat 0:977e87915078 207 uint8_t *resource; /**< NULL if dynamic resource */
vithyat 0:977e87915078 208 ns_list_link_t link;
vithyat 0:977e87915078 209 uint16_t resource_len; /**< 0 if dynamic resource, resource information in static resource */
vithyat 0:977e87915078 210 uint16_t coap_content_type; /**< CoAP content type */
vithyat 0:977e87915078 211 unsigned access:4; /**< Allowed operation mode, GET, PUT, etc,
vithyat 0:977e87915078 212 TODO! This should be in static struct but current
vithyat 0:977e87915078 213 mbed-client implementation requires this to be changed at runtime */
vithyat 0:977e87915078 214 unsigned registered:2; /**< Is resource registered or not */
vithyat 0:977e87915078 215 bool publish_uri:1; /**< 1 if resource to be published to server */
vithyat 0:977e87915078 216 bool free_on_delete:1; /**< 1 if struct is dynamic allocted --> to be freed */
vithyat 0:977e87915078 217 bool observable:1; /**< Is resource observable or not */
vithyat 0:977e87915078 218 bool auto_observable:1; /**< Is resource auto observable or not */
vithyat 0:977e87915078 219 bool always_publish:1; /**< 1 if resource should always be published in registration or registration update **/
vithyat 0:977e87915078 220 unsigned publish_value:2; /**< 0 for non-publishing,1 if resource value to be published in registration message,
vithyat 0:977e87915078 221 2 if resource value to be published in Base64 encoded format */
vithyat 0:977e87915078 222 } sn_nsdl_dynamic_resource_parameters_s;
vithyat 0:977e87915078 223
vithyat 0:977e87915078 224
vithyat 0:977e87915078 225 /**
vithyat 0:977e87915078 226 * \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 *),
vithyat 0:977e87915078 227 * uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *),
vithyat 0:977e87915078 228 * sn_nsdl_mem_s *sn_memory)
vithyat 0:977e87915078 229 *
vithyat 0:977e87915078 230 * \brief Initialization function for NSDL library. Initializes NSDL, GRS, HTTP and CoAP.
vithyat 0:977e87915078 231 *
vithyat 0:977e87915078 232 * \param *sn_nsdl_tx_callback A callback function for sending messages.
vithyat 0:977e87915078 233 *
vithyat 0:977e87915078 234 * \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
vithyat 0:977e87915078 235 * reply for some DS messages (register message etc.), rx callback will be called.
vithyat 0:977e87915078 236 *
vithyat 0:977e87915078 237 * \param *sn_memory Memory structure which includes function pointers to the allocation and free functions.
vithyat 0:977e87915078 238 *
vithyat 0:977e87915078 239 * \return pointer to created handle structure. NULL if failed
vithyat 0:977e87915078 240 */
vithyat 0:977e87915078 241 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 *),
vithyat 0:977e87915078 242 uint8_t (*sn_nsdl_rx_cb)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *),
vithyat 0:977e87915078 243 void *(*sn_nsdl_alloc)(uint16_t), void (*sn_nsdl_free)(void *),
vithyat 0:977e87915078 244 uint8_t (*sn_nsdl_auto_obs_token_cb)(struct nsdl_s *, const char *, uint8_t *));
vithyat 0:977e87915078 245
vithyat 0:977e87915078 246 /**
vithyat 0:977e87915078 247 * \fn extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr, const char *uri_query_parameters);
vithyat 0:977e87915078 248 *
vithyat 0:977e87915078 249 * \brief Registers endpoint to mbed Device Server.
vithyat 0:977e87915078 250 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 251 * \param *endpoint_info_ptr Contains endpoint information.
vithyat 0:977e87915078 252 * \param *uri_query_parameters Uri query parameters.
vithyat 0:977e87915078 253 *
vithyat 0:977e87915078 254 * \return registration message ID, 0 if failed
vithyat 0:977e87915078 255 */
vithyat 0:977e87915078 256 extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle,
vithyat 0:977e87915078 257 sn_nsdl_ep_parameters_s *endpoint_info_ptr,
vithyat 0:977e87915078 258 const char *uri_query_parameters);
vithyat 0:977e87915078 259
vithyat 0:977e87915078 260 /**
vithyat 0:977e87915078 261 * \fn extern int32_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle)
vithyat 0:977e87915078 262 *
vithyat 0:977e87915078 263 * \brief Sends unregister-message to mbed Device Server.
vithyat 0:977e87915078 264 *
vithyat 0:977e87915078 265 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 266 *
vithyat 0:977e87915078 267 * \return unregistration message ID, 0 if failed
vithyat 0:977e87915078 268 */
vithyat 0:977e87915078 269 extern int32_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle);
vithyat 0:977e87915078 270
vithyat 0:977e87915078 271 /**
vithyat 0:977e87915078 272 * \fn extern int32_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len);
vithyat 0:977e87915078 273 *
vithyat 0:977e87915078 274 * \brief Update the registration with mbed Device Server.
vithyat 0:977e87915078 275 *
vithyat 0:977e87915078 276 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 277 * \param *lt_ptr Pointer to lifetime value string in ascii form, eg. "1200"
vithyat 0:977e87915078 278 * \param lt_len Length of the lifetime string
vithyat 0:977e87915078 279 *
vithyat 0:977e87915078 280 * \return registration update message ID, <0 if failed
vithyat 0:977e87915078 281 */
vithyat 0:977e87915078 282 extern int32_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len);
vithyat 0:977e87915078 283
vithyat 0:977e87915078 284 /**
vithyat 0:977e87915078 285 * \fn extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len);
vithyat 0:977e87915078 286 *
vithyat 0:977e87915078 287 * \brief Sets the location receievd from Device Server.
vithyat 0:977e87915078 288 *
vithyat 0:977e87915078 289 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 290 * \param *lt_ptr Pointer to location value string , eg. "s322j4k"
vithyat 0:977e87915078 291 * \param lt_len Length of the location string
vithyat 0:977e87915078 292 *
vithyat 0:977e87915078 293 * \return success, <0 if failed
vithyat 0:977e87915078 294 */
vithyat 0:977e87915078 295 extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len);
vithyat 0:977e87915078 296
vithyat 0:977e87915078 297 /**
vithyat 0:977e87915078 298 * \fn extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle)
vithyat 0:977e87915078 299 *
vithyat 0:977e87915078 300 * \brief Checks if endpoint is registered.
vithyat 0:977e87915078 301 *
vithyat 0:977e87915078 302 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 303 *
vithyat 0:977e87915078 304 * \return 1 Endpoint registration is done successfully
vithyat 0:977e87915078 305 * \return 0 Endpoint is not registered
vithyat 0:977e87915078 306 */
vithyat 0:977e87915078 307 extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle);
vithyat 0:977e87915078 308
vithyat 0:977e87915078 309 /**
vithyat 0:977e87915078 310 * \fn extern void sn_nsdl_nsp_lost(struct nsdl_s *handle);
vithyat 0:977e87915078 311 *
vithyat 0:977e87915078 312 * \brief A function to inform mbed Device C client library if application detects a fault in mbed Device Server registration.
vithyat 0:977e87915078 313 *
vithyat 0:977e87915078 314 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 315 *
vithyat 0:977e87915078 316 * After calling this function sn_nsdl_is_ep_registered() will return "not registered".
vithyat 0:977e87915078 317 */
vithyat 0:977e87915078 318 extern void sn_nsdl_nsp_lost(struct nsdl_s *handle);
vithyat 0:977e87915078 319
vithyat 0:977e87915078 320 /**
vithyat 0:977e87915078 321 * \fn extern uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len,
vithyat 0:977e87915078 322 * uint8_t *payload_ptr, uint16_t payload_len,
vithyat 0:977e87915078 323 * sn_coap_observe_e observe,
vithyat 0:977e87915078 324 * sn_coap_msg_type_e message_type, sn_coap_content_format_e content_format)
vithyat 0:977e87915078 325 *
vithyat 0:977e87915078 326 *
vithyat 0:977e87915078 327 * \brief Sends observation message to mbed Device Server
vithyat 0:977e87915078 328 *
vithyat 0:977e87915078 329 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 330 * \param *token_ptr Pointer to token to be used
vithyat 0:977e87915078 331 * \param token_len Token length
vithyat 0:977e87915078 332 * \param *payload_ptr Pointer to payload to be sent
vithyat 0:977e87915078 333 * \param payload_len Payload length
vithyat 0:977e87915078 334 * \param observe Observe option value to be sent
vithyat 0:977e87915078 335 * \param message_type Observation message type (confirmable or non-confirmable)
vithyat 0:977e87915078 336 * \param content_format Observation message payload content format
vithyat 0:977e87915078 337 * \param message_id -1 means stored value to be used otherwise new one is generated
vithyat 0:977e87915078 338 *
vithyat 0:977e87915078 339 * \return >0 Success, observation messages message ID
vithyat 0:977e87915078 340 * \return <=0 Failure
vithyat 0:977e87915078 341 */
vithyat 0:977e87915078 342 extern int32_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len,
vithyat 0:977e87915078 343 uint8_t *payload_ptr, uint16_t payload_len,
vithyat 0:977e87915078 344 sn_coap_observe_e observe,
vithyat 0:977e87915078 345 sn_coap_msg_type_e message_type,
vithyat 0:977e87915078 346 sn_coap_content_format_e content_format,
vithyat 0:977e87915078 347 const int32_t message_id);
vithyat 0:977e87915078 348
vithyat 0:977e87915078 349 /**
vithyat 0:977e87915078 350 * \fn extern uint32_t sn_nsdl_get_version(void)
vithyat 0:977e87915078 351 *
vithyat 0:977e87915078 352 * \brief Version query function.
vithyat 0:977e87915078 353 *
vithyat 0:977e87915078 354 * Used to retrieve the version information from the mbed Device C Client library.
vithyat 0:977e87915078 355 *
vithyat 0:977e87915078 356 * \return Pointer to library version string
vithyat 0:977e87915078 357 */
vithyat 0:977e87915078 358 extern char *sn_nsdl_get_version(void);
vithyat 0:977e87915078 359
vithyat 0:977e87915078 360 /**
vithyat 0:977e87915078 361 * \fn extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src)
vithyat 0:977e87915078 362 *
vithyat 0:977e87915078 363 * \brief To push CoAP packet to mbed Device C Client library
vithyat 0:977e87915078 364 *
vithyat 0:977e87915078 365 * Used to push an CoAP packet to mbed Device C Client library for processing.
vithyat 0:977e87915078 366 *
vithyat 0:977e87915078 367 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 368 *
vithyat 0:977e87915078 369 * \param *packet Pointer to a uint8_t array containing the packet (including the CoAP headers).
vithyat 0:977e87915078 370 * After successful execution this array may contain the response packet.
vithyat 0:977e87915078 371 *
vithyat 0:977e87915078 372 * \param *packet_len Pointer to length of the packet. After successful execution this array may contain the length
vithyat 0:977e87915078 373 * of the response packet.
vithyat 0:977e87915078 374 *
vithyat 0:977e87915078 375 * \param *src Pointer to packet source address information. After successful execution this array may contain
vithyat 0:977e87915078 376 * the destination address of the response packet.
vithyat 0:977e87915078 377 *
vithyat 0:977e87915078 378 * \return 0 Success
vithyat 0:977e87915078 379 * \return -1 Failure
vithyat 0:977e87915078 380 */
vithyat 0:977e87915078 381 extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src);
vithyat 0:977e87915078 382
vithyat 0:977e87915078 383 /**
vithyat 0:977e87915078 384 * \fn extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time);
vithyat 0:977e87915078 385 *
vithyat 0:977e87915078 386 * \brief CoAP retransmission function.
vithyat 0:977e87915078 387 *
vithyat 0:977e87915078 388 * Used to give execution time for the mbed Device C Client library for retransmissions.
vithyat 0:977e87915078 389 *
vithyat 0:977e87915078 390 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 391 *
vithyat 0:977e87915078 392 * \param time Time in seconds.
vithyat 0:977e87915078 393 *
vithyat 0:977e87915078 394 * \return 0 Success
vithyat 0:977e87915078 395 * \return -1 Failure
vithyat 0:977e87915078 396 */
vithyat 0:977e87915078 397 extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time);
vithyat 0:977e87915078 398
vithyat 0:977e87915078 399 /**
vithyat 0:977e87915078 400 * \fn extern int8_t sn_nsdl_put_resource(struct nsdl_s *handle, const sn_nsdl_dynamic_resource_parameters_s *res);
vithyat 0:977e87915078 401 *
vithyat 0:977e87915078 402 * \brief Resource putting function.
vithyat 0:977e87915078 403 *
vithyat 0:977e87915078 404 * Used to put a static or dynamic CoAP resource without creating copy of it.
vithyat 0:977e87915078 405 * NOTE: Remember that only resource will be owned, not data that it contains
vithyat 0:977e87915078 406 * NOTE: The resource may be removed from list by sn_nsdl_pop_resource().
vithyat 0:977e87915078 407 *
vithyat 0:977e87915078 408 * \param *res Pointer to a structure of type sn_nsdl_dynamic_resource_parameters_s that contains the information
vithyat 0:977e87915078 409 * about the resource.
vithyat 0:977e87915078 410 *
vithyat 0:977e87915078 411 * \return 0 Success
vithyat 0:977e87915078 412 * \return -1 Failure
vithyat 0:977e87915078 413 * \return -2 Resource already exists
vithyat 0:977e87915078 414 * \return -3 Invalid path
vithyat 0:977e87915078 415 * \return -4 List adding failure
vithyat 0:977e87915078 416 */
vithyat 0:977e87915078 417 extern int8_t sn_nsdl_put_resource(struct nsdl_s *handle, sn_nsdl_dynamic_resource_parameters_s *res);
vithyat 0:977e87915078 418
vithyat 0:977e87915078 419 /**
vithyat 0:977e87915078 420 * \fn extern int8_t sn_nsdl_pop_resource(struct nsdl_s *handle, const sn_nsdl_dynamic_resource_parameters_s *res);
vithyat 0:977e87915078 421 *
vithyat 0:977e87915078 422 * \brief Resource popping function.
vithyat 0:977e87915078 423 *
vithyat 0:977e87915078 424 * Used to remove a static or dynamic CoAP resource from lists without deleting it.
vithyat 0:977e87915078 425 * NOTE: This function is a counterpart of sn_nsdl_put_resource().
vithyat 0:977e87915078 426 *
vithyat 0:977e87915078 427 * \param *res Pointer to a structure of type sn_nsdl_dynamic_resource_parameters_s that contains the information
vithyat 0:977e87915078 428 * about the resource.
vithyat 0:977e87915078 429 *
vithyat 0:977e87915078 430 * \return 0 Success
vithyat 0:977e87915078 431 * \return -1 Failure
vithyat 0:977e87915078 432 * \return -3 Invalid path
vithyat 0:977e87915078 433 */
vithyat 0:977e87915078 434 extern int8_t sn_nsdl_pop_resource(struct nsdl_s *handle, sn_nsdl_dynamic_resource_parameters_s *res);
vithyat 0:977e87915078 435
vithyat 0:977e87915078 436 /**
vithyat 0:977e87915078 437 * \fn extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, char *path)
vithyat 0:977e87915078 438 *
vithyat 0:977e87915078 439 * \brief Resource delete function.
vithyat 0:977e87915078 440 *
vithyat 0:977e87915078 441 * Used to delete a resource. If resource has a subresources, these all must also be removed.
vithyat 0:977e87915078 442 *
vithyat 0:977e87915078 443 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 444 * \param *path_ptr A pointer to an array containing the path.
vithyat 0:977e87915078 445 *
vithyat 0:977e87915078 446 * \return 0 Success
vithyat 0:977e87915078 447 * \return -1 Failure (No such resource)
vithyat 0:977e87915078 448 */
vithyat 0:977e87915078 449 extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, const char *path);
vithyat 0:977e87915078 450
vithyat 0:977e87915078 451 /**
vithyat 0:977e87915078 452 * \fn extern sn_nsdl_dynamic_resource_parameters_s *sn_nsdl_get_resource(struct nsdl_s *handle, char *path)
vithyat 0:977e87915078 453 *
vithyat 0:977e87915078 454 * \brief Resource get function.
vithyat 0:977e87915078 455 *
vithyat 0:977e87915078 456 * Used to get a resource.
vithyat 0:977e87915078 457 *
vithyat 0:977e87915078 458 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 459 * \param *path A pointer to an array containing the path.
vithyat 0:977e87915078 460 *
vithyat 0:977e87915078 461 * \return !NULL Success, pointer to a sn_nsdl_dynamic_resource_parameters_s that contains the resource information\n
vithyat 0:977e87915078 462 * \return NULL Failure
vithyat 0:977e87915078 463 */
vithyat 0:977e87915078 464 extern sn_nsdl_dynamic_resource_parameters_s *sn_nsdl_get_resource(struct nsdl_s *handle, const char *path);
vithyat 0:977e87915078 465
vithyat 0:977e87915078 466 /**
vithyat 0:977e87915078 467 * \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);
vithyat 0:977e87915078 468 *
vithyat 0:977e87915078 469 * \brief Send an outgoing CoAP request.
vithyat 0:977e87915078 470 *
vithyat 0:977e87915078 471 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 472 * \param *address_ptr Pointer to source address struct
vithyat 0:977e87915078 473 * \param *coap_hdr_ptr Pointer to CoAP message to be sent
vithyat 0:977e87915078 474 *
vithyat 0:977e87915078 475 * \return 0 Success
vithyat 0:977e87915078 476 * \return -1 Failure
vithyat 0:977e87915078 477 */
vithyat 0:977e87915078 478 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);
vithyat 0:977e87915078 479
vithyat 0:977e87915078 480 /**
vithyat 0:977e87915078 481 * \fn extern int32_t sn_nsdl_send_request(struct nsdl_s *handle, sn_coap_msg_code_e msg_code, const char *uri_path, const uint32_t token, const size_t offset, const uint16_t payload_len, const uint8_t* payload_ptr);
vithyat 0:977e87915078 482 *
vithyat 0:977e87915078 483 * \brief Send an outgoing CoAP request.
vithyat 0:977e87915078 484 *
vithyat 0:977e87915078 485 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 486 * \param msg-code CoAP message code to use for request
vithyat 0:977e87915078 487 * \param *uri_path Path to the data
vithyat 0:977e87915078 488 * \param *token Message token
vithyat 0:977e87915078 489 * \param offset Offset within response body to request
vithyat 0:977e87915078 490 * \param payload_len Message payload length, can be 0 for no payload
vithyat 0:977e87915078 491 * \param *payload_ptr Message payload pointer, can be NULL for no payload
vithyat 0:977e87915078 492 * \param type Type of the download
vithyat 0:977e87915078 493 *
vithyat 0:977e87915078 494 * \Return > 0 Success else Failure
vithyat 0:977e87915078 495 */
vithyat 0:977e87915078 496 extern int32_t sn_nsdl_send_request(struct nsdl_s *handle,
vithyat 0:977e87915078 497 sn_coap_msg_code_e msg_code,
vithyat 0:977e87915078 498 const char *uri_path,
vithyat 0:977e87915078 499 const uint32_t token,
vithyat 0:977e87915078 500 const size_t offset,
vithyat 0:977e87915078 501 const uint16_t payload_len,
vithyat 0:977e87915078 502 uint8_t* payload_ptr,
vithyat 0:977e87915078 503 DownloadType type);
vithyat 0:977e87915078 504
vithyat 0:977e87915078 505 /**
vithyat 0:977e87915078 506 * \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);
vithyat 0:977e87915078 507 *
vithyat 0:977e87915078 508 * \brief This function is used to set the mbed Device Server address given by an application.
vithyat 0:977e87915078 509 *
vithyat 0:977e87915078 510 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 511 * \return 0 Success
vithyat 0:977e87915078 512 * \return -1 Failed to indicate that internal address pointer is not allocated (call nsdl_init() first).
vithyat 0:977e87915078 513 */
vithyat 0:977e87915078 514 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);
vithyat 0:977e87915078 515
vithyat 0:977e87915078 516 /**
vithyat 0:977e87915078 517 * \fn extern int8_t sn_nsdl_destroy(struct nsdl_s *handle);
vithyat 0:977e87915078 518 *
vithyat 0:977e87915078 519 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 520 * \brief This function releases all allocated memory in mbed Device C Client library.
vithyat 0:977e87915078 521 */
vithyat 0:977e87915078 522 extern int8_t sn_nsdl_destroy(struct nsdl_s *handle);
vithyat 0:977e87915078 523
vithyat 0:977e87915078 524 /**
vithyat 0:977e87915078 525 * \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);
vithyat 0:977e87915078 526 *
vithyat 0:977e87915078 527 * \brief Starts OMA bootstrap process
vithyat 0:977e87915078 528 *
vithyat 0:977e87915078 529 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 530 *
vithyat 0:977e87915078 531 * \return bootstrap message ID, 0 if failed
vithyat 0:977e87915078 532 */
vithyat 0:977e87915078 533 extern uint16_t sn_nsdl_oma_bootstrap(struct nsdl_s *handle,
vithyat 0:977e87915078 534 sn_nsdl_addr_s *bootstrap_address_ptr,
vithyat 0:977e87915078 535 sn_nsdl_ep_parameters_s *endpoint_info_ptr,
vithyat 0:977e87915078 536 const char *uri_query_parameters);
vithyat 0:977e87915078 537
vithyat 0:977e87915078 538 /**
vithyat 0:977e87915078 539 * \fn sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code)
vithyat 0:977e87915078 540 *
vithyat 0:977e87915078 541 * \brief Prepares generic response packet from a request packet. This function allocates memory for the resulting sn_coap_hdr_s
vithyat 0:977e87915078 542 *
vithyat 0:977e87915078 543 * \param *handle Pointer to library handle
vithyat 0:977e87915078 544 * \param *coap_packet_ptr The request packet pointer
vithyat 0:977e87915078 545 * \param msg_code response messages code
vithyat 0:977e87915078 546 *
vithyat 0:977e87915078 547 * \return *coap_packet_ptr The allocated and pre-filled response packet pointer
vithyat 0:977e87915078 548 * NULL Error in parsing the request
vithyat 0:977e87915078 549 *
vithyat 0:977e87915078 550 */
vithyat 0:977e87915078 551 extern sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code);
vithyat 0:977e87915078 552
vithyat 0:977e87915078 553 /**
vithyat 0:977e87915078 554 * \brief Allocates and initializes options list structure
vithyat 0:977e87915078 555 *
vithyat 0:977e87915078 556 * \param *handle Pointer to library handle
vithyat 0:977e87915078 557 * \param *coap_msg_ptr is pointer to CoAP message that will contain the options
vithyat 0:977e87915078 558 *
vithyat 0:977e87915078 559 * If the message already has a pointer to an option structure, that pointer
vithyat 0:977e87915078 560 * is returned, rather than a new structure being allocated.
vithyat 0:977e87915078 561 *
vithyat 0:977e87915078 562 * \return Return value is pointer to the CoAP options structure.\n
vithyat 0:977e87915078 563 * In following failure cases NULL is returned:\n
vithyat 0:977e87915078 564 * -Failure in given pointer (= NULL)\n
vithyat 0:977e87915078 565 * -Failure in memory allocation (malloc() returns NULL)
vithyat 0:977e87915078 566 */
vithyat 0:977e87915078 567 extern sn_coap_options_list_s *sn_nsdl_alloc_options_list(struct nsdl_s *handle, sn_coap_hdr_s *coap_msg_ptr);
vithyat 0:977e87915078 568
vithyat 0:977e87915078 569 /**
vithyat 0:977e87915078 570 * \fn void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr)
vithyat 0:977e87915078 571 *
vithyat 0:977e87915078 572 * \brief Releases memory of given CoAP message
vithyat 0:977e87915078 573 *
vithyat 0:977e87915078 574 * Note!!! Does not release Payload part
vithyat 0:977e87915078 575 *
vithyat 0:977e87915078 576 * \param *handle Pointer to library handle
vithyat 0:977e87915078 577 *
vithyat 0:977e87915078 578 * \param *freed_coap_msg_ptr is pointer to released CoAP message
vithyat 0:977e87915078 579 */
vithyat 0:977e87915078 580 extern void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr);
vithyat 0:977e87915078 581
vithyat 0:977e87915078 582 /**
vithyat 0:977e87915078 583 * \fn int8_t sn_nsdl_set_retransmission_parameters(struct nsdl_s *handle, uint8_t resending_count, uint8_t resending_intervall)
vithyat 0:977e87915078 584 *
vithyat 0:977e87915078 585 * \brief If re-transmissions are enabled, this function changes resending count and interval.
vithyat 0:977e87915078 586 *
vithyat 0:977e87915078 587 * \param *handle Pointer to library handle
vithyat 0:977e87915078 588 * \param uint8_t resending_count max number of resendings for message
vithyat 0:977e87915078 589 * \param uint8_t resending_intervall message resending intervall in seconds
vithyat 0:977e87915078 590 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 591 */
vithyat 0:977e87915078 592 extern int8_t sn_nsdl_set_retransmission_parameters(struct nsdl_s *handle, uint8_t resending_count, uint8_t resending_interval);
vithyat 0:977e87915078 593
vithyat 0:977e87915078 594 /**
vithyat 0:977e87915078 595 * \fn int8_t sn_nsdl_set_retransmission_buffer(struct nsdl_s *handle, uint8_t buffer_size_messages, uint16_t buffer_size_bytes)
vithyat 0:977e87915078 596 *
vithyat 0:977e87915078 597 * \brief If re-transmissions are enabled, this function changes message retransmission queue size.
vithyat 0:977e87915078 598 * Set size to '0' to disable feature. If both are set to '0', then re-sendings are disabled.
vithyat 0:977e87915078 599 *
vithyat 0:977e87915078 600 * \param *handle Pointer to library handle
vithyat 0:977e87915078 601 * \param uint8_t buffer_size_messages queue size - maximum number of messages to be saved to queue
vithyat 0:977e87915078 602 * \param uint8_t buffer_size_bytes queue size - maximum size of messages saved to queue
vithyat 0:977e87915078 603 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 604 */
vithyat 0:977e87915078 605 extern int8_t sn_nsdl_set_retransmission_buffer(struct nsdl_s *handle,
vithyat 0:977e87915078 606 uint8_t buffer_size_messages, uint16_t buffer_size_bytes);
vithyat 0:977e87915078 607
vithyat 0:977e87915078 608 /**
vithyat 0:977e87915078 609 * \fn int8_t sn_nsdl_set_block_size(struct nsdl_s *handle, uint16_t block_size)
vithyat 0:977e87915078 610 *
vithyat 0:977e87915078 611 * \brief If block transfer is enabled, this function changes the block size.
vithyat 0:977e87915078 612 *
vithyat 0:977e87915078 613 * \param *handle Pointer to library handle
vithyat 0:977e87915078 614 * \param uint16_t block_size maximum size of CoAP payload. Valid sizes are 16, 32, 64, 128, 256, 512 and 1024 bytes
vithyat 0:977e87915078 615 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 616 */
vithyat 0:977e87915078 617 extern int8_t sn_nsdl_set_block_size(struct nsdl_s *handle, uint16_t block_size);
vithyat 0:977e87915078 618
vithyat 0:977e87915078 619 /**
vithyat 0:977e87915078 620 * \fn int8_t sn_nsdl_set_duplicate_buffer_size(struct nsdl_s *handle,uint8_t message_count)
vithyat 0:977e87915078 621 *
vithyat 0:977e87915078 622 * \brief If dublicate message detection is enabled, this function changes buffer size.
vithyat 0:977e87915078 623 *
vithyat 0:977e87915078 624 * \param *handle Pointer to library handle
vithyat 0:977e87915078 625 * \param uint8_t message_count max number of messages saved for duplicate control
vithyat 0:977e87915078 626 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 627 */
vithyat 0:977e87915078 628 extern int8_t sn_nsdl_set_duplicate_buffer_size(struct nsdl_s *handle, uint8_t message_count);
vithyat 0:977e87915078 629
vithyat 0:977e87915078 630 /**
vithyat 0:977e87915078 631 * \fn void *sn_nsdl_set_context(const struct nsdl_s *handle, void *context)
vithyat 0:977e87915078 632 *
vithyat 0:977e87915078 633 * \brief Set the application defined context parameter for given handle.
vithyat 0:977e87915078 634 * This is useful for example when interfacing with c++ objects where a
vithyat 0:977e87915078 635 * pointer to object is set as the context, and in the callback functions
vithyat 0:977e87915078 636 * the context pointer can be used to call methods for the correct instance
vithyat 0:977e87915078 637 * of the c++ object.
vithyat 0:977e87915078 638 *
vithyat 0:977e87915078 639 * \param *handle Pointer to library handle
vithyat 0:977e87915078 640 * \param *context Pointer to the application defined context
vithyat 0:977e87915078 641 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 642 */
vithyat 0:977e87915078 643 extern int8_t sn_nsdl_set_context(struct nsdl_s * const handle, void * const context);
vithyat 0:977e87915078 644
vithyat 0:977e87915078 645 /**
vithyat 0:977e87915078 646 * \fn void *sn_nsdl_get_context(const struct nsdl_s *handle)
vithyat 0:977e87915078 647 *
vithyat 0:977e87915078 648 * \brief Get the application defined context parameter for given handle.
vithyat 0:977e87915078 649 * This is useful for example when interfacing with c++ objects where a
vithyat 0:977e87915078 650 * pointer to object is set as the context, and in the callback functions
vithyat 0:977e87915078 651 * the context pointer can be used to call methods for the correct instance
vithyat 0:977e87915078 652 * of the c++ object.
vithyat 0:977e87915078 653 *
vithyat 0:977e87915078 654 * \param *handle Pointer to library handle
vithyat 0:977e87915078 655 * \return Pointer to the application defined context
vithyat 0:977e87915078 656 */
vithyat 0:977e87915078 657 extern void *sn_nsdl_get_context(const struct nsdl_s * const handle);
vithyat 0:977e87915078 658
vithyat 0:977e87915078 659 /**
vithyat 0:977e87915078 660 * \fn int8_t sn_nsdl_clear_coap_resending_queue(struct nsdl_s *handle)
vithyat 0:977e87915078 661 *
vithyat 0:977e87915078 662 * \brief Clean confirmable message list.
vithyat 0:977e87915078 663 *
vithyat 0:977e87915078 664 * \param *handle Pointer to library handle
vithyat 0:977e87915078 665 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 666 */
vithyat 0:977e87915078 667 extern int8_t sn_nsdl_clear_coap_resending_queue(struct nsdl_s *handle);
vithyat 0:977e87915078 668
vithyat 0:977e87915078 669 /**
vithyat 0:977e87915078 670 * \fn int8_t sn_nsdl_clear_coap_sent_blockwise_messages(struct nsdl_s *handle)
vithyat 0:977e87915078 671 *
vithyat 0:977e87915078 672 * \brief Clears the sent blockwise messages from the linked list.
vithyat 0:977e87915078 673 *
vithyat 0:977e87915078 674 * \param *handle Pointer to library handle
vithyat 0:977e87915078 675 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 676 */
vithyat 0:977e87915078 677 extern int8_t sn_nsdl_clear_coap_sent_blockwise_messages(struct nsdl_s *handle);
vithyat 0:977e87915078 678
vithyat 0:977e87915078 679 /**
vithyat 0:977e87915078 680 * \fn int8_t sn_nsdl_clear_coap_received_blockwise_messages(struct nsdl_s *handle)
vithyat 0:977e87915078 681 *
vithyat 0:977e87915078 682 * \brief Clears the received blockwise messages from the linked list.
vithyat 0:977e87915078 683 *
vithyat 0:977e87915078 684 * \param *handle Pointer to library handle
vithyat 0:977e87915078 685 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 686 */
vithyat 0:977e87915078 687 extern int8_t sn_nsdl_clear_coap_received_blockwise_messages(struct nsdl_s *handle);
vithyat 0:977e87915078 688
vithyat 0:977e87915078 689 /**
vithyat 0:977e87915078 690 * \fn int8_t sn_nsdl_remove_msg_from_retransmission(struct nsdl_s *handle)
vithyat 0:977e87915078 691 *
vithyat 0:977e87915078 692 * \brief Clears item from the resend queue.
vithyat 0:977e87915078 693 *
vithyat 0:977e87915078 694 * \param *handle Pointer to library handle
vithyat 0:977e87915078 695 * \param *token Token to be removed
vithyat 0:977e87915078 696 * \param token_len Length of the token
vithyat 0:977e87915078 697 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 698 */
vithyat 0:977e87915078 699 extern int8_t sn_nsdl_remove_msg_from_retransmission(struct nsdl_s *handle, uint8_t *token, uint8_t token_len);
vithyat 0:977e87915078 700
vithyat 0:977e87915078 701 /**
vithyat 0:977e87915078 702 * \fn int8_t sn_nsdl_handle_block2_response_internally(struct nsdl_s *handle, uint8_t handle_response)
vithyat 0:977e87915078 703 *
vithyat 0:977e87915078 704 * \brief This function change the state whether CoAP library sends the block 2 response automatically or not.
vithyat 0:977e87915078 705 *
vithyat 0:977e87915078 706 * \param *handle Pointer to NSDL library handle
vithyat 0:977e87915078 707 * \param handle_response 1 if CoAP library handles the response sending otherwise 0.
vithyat 0:977e87915078 708 *
vithyat 0:977e87915078 709 * \return 0 = success, -1 = failure
vithyat 0:977e87915078 710 */
vithyat 0:977e87915078 711 extern int8_t sn_nsdl_handle_block2_response_internally(struct nsdl_s *handle, uint8_t handle_response);
vithyat 0:977e87915078 712
vithyat 0:977e87915078 713 #ifdef RESOURCE_ATTRIBUTES_LIST
vithyat 0:977e87915078 714 /**
vithyat 0:977e87915078 715 * \fn int8_t sn_nsdl_free_resource_attributes_list(struct nsdl_s *handle, sn_nsdl_static_resource_parameters_s *params)
vithyat 0:977e87915078 716 *
vithyat 0:977e87915078 717 * \brief Free resource attributes list if free_on_delete is true for params. This will also free all attributes values
vithyat 0:977e87915078 718 * if they are pointer types.
vithyat 0:977e87915078 719 *
vithyat 0:977e87915078 720 * \param *params Pointer to resource static parameters
vithyat 0:977e87915078 721 */
vithyat 0:977e87915078 722 extern void sn_nsdl_free_resource_attributes_list(sn_nsdl_static_resource_parameters_s *params);
vithyat 0:977e87915078 723
vithyat 0:977e87915078 724 /*
vithyat 0:977e87915078 725 * \fn bool sn_nsdl_set_resource_attribute(sn_nsdl_static_resource_parameters_s *params, sn_nsdl_attribute_item_s attribute)
vithyat 0:977e87915078 726 *
vithyat 0:977e87915078 727 * \brief Set resource link-format attribute value, create if it doesn't exist yet.
vithyat 0:977e87915078 728 *
vithyat 0:977e87915078 729 * \param *params Pointer to resource static parameters
vithyat 0:977e87915078 730 * \param attribute sn_nsdl_attribute_item_s structure containing attribute to set
vithyat 0:977e87915078 731 * \return True if successful, false on error
vithyat 0:977e87915078 732 */
vithyat 0:977e87915078 733 extern bool sn_nsdl_set_resource_attribute(sn_nsdl_static_resource_parameters_s *params, const sn_nsdl_attribute_item_s *attribute);
vithyat 0:977e87915078 734
vithyat 0:977e87915078 735 /*
vithyat 0:977e87915078 736 * \fn bool sn_nsdl_get_resource_attribute(sn_nsdl_static_resource_parameters_s *params, sn_nsdl_resource_attribute_t attribute)
vithyat 0:977e87915078 737 *
vithyat 0:977e87915078 738 * \brief Get resource link-format attribute value
vithyat 0:977e87915078 739 *
vithyat 0:977e87915078 740 * \param *params Pointer to resource static parameters
vithyat 0:977e87915078 741 * \param attribute sn_nsdl_resource_attribute_t enum value for attribute to get
vithyat 0:977e87915078 742 * \return Pointer to value or null if attribute did not exist or had no value
vithyat 0:977e87915078 743 */
vithyat 0:977e87915078 744 extern const char* sn_nsdl_get_resource_attribute(const sn_nsdl_static_resource_parameters_s *params, sn_nsdl_resource_attribute_t attribute);
vithyat 0:977e87915078 745
vithyat 0:977e87915078 746 /*
vithyat 0:977e87915078 747 * \fn bool sn_nsdl_remove_resource_attribute(sn_nsdl_static_resource_parameters_s *params, sn_nsdl_resource_attribute_t attribute)
vithyat 0:977e87915078 748 *
vithyat 0:977e87915078 749 * \brief Remove resource link-format attribute value
vithyat 0:977e87915078 750 *
vithyat 0:977e87915078 751 * \param *params Pointer to resource static parameters
vithyat 0:977e87915078 752 * \param attribute sn_nsdl_resource_attribute_t enum value for attribute to remove
vithyat 0:977e87915078 753 */
vithyat 0:977e87915078 754 extern bool sn_nsdl_remove_resource_attribute(sn_nsdl_static_resource_parameters_s *params, sn_nsdl_resource_attribute_t attribute);
vithyat 0:977e87915078 755 #endif
vithyat 0:977e87915078 756
vithyat 0:977e87915078 757 /**
vithyat 0:977e87915078 758 * \fn bool sn_nsdl_print_coap_data(sn_coap_hdr_s *coap_header_ptr, bool outgoing)
vithyat 0:977e87915078 759 *
vithyat 0:977e87915078 760 * \brief Utility function to print all the CoAP header parameters
vithyat 0:977e87915078 761 *
vithyat 0:977e87915078 762 * \param *coap_header_ptr CoAP header
vithyat 0:977e87915078 763 * \param outgoing If True, package is going to be sent to server otherwise receiving
vithyat 0:977e87915078 764 */
vithyat 0:977e87915078 765 extern void sn_nsdl_print_coap_data(sn_coap_hdr_s *coap_header_ptr, bool outgoing);
vithyat 0:977e87915078 766
vithyat 0:977e87915078 767 /**
vithyat 0:977e87915078 768 * \fn uint16_t sn_nsdl_get_block_size(struct nsdl_s *handle)
vithyat 0:977e87915078 769 *
vithyat 0:977e87915078 770 * \brief Get CoAP block size
vithyat 0:977e87915078 771 *
vithyat 0:977e87915078 772 * \param *handle Pointer to library handle
vithyat 0:977e87915078 773 * \return block size
vithyat 0:977e87915078 774 */
vithyat 0:977e87915078 775 extern uint16_t sn_nsdl_get_block_size(const struct nsdl_s *handle);
vithyat 0:977e87915078 776
vithyat 0:977e87915078 777 /**
vithyat 0:977e87915078 778 * \fn uint8_t sn_nsdl_get_retransmission_count(struct nsdl_s *handle)
vithyat 0:977e87915078 779 *
vithyat 0:977e87915078 780 * \brief Returns retransmission coint
vithyat 0:977e87915078 781 *
vithyat 0:977e87915078 782 * \param *handle Pointer to library handle
vithyat 0:977e87915078 783 * \return Retransmission count
vithyat 0:977e87915078 784 */
vithyat 0:977e87915078 785 extern uint8_t sn_nsdl_get_retransmission_count(struct nsdl_s *handle);
vithyat 0:977e87915078 786
vithyat 0:977e87915078 787 /**
vithyat 0:977e87915078 788 * \fn extern int32_t sn_nsdl_send_coap_ping(struct nsdl_s *handle);
vithyat 0:977e87915078 789 *
vithyat 0:977e87915078 790 * \brief Send confirmable CoAP ping message.
vithyat 0:977e87915078 791 *
vithyat 0:977e87915078 792 * \param *handle Pointer to nsdl-library handle
vithyat 0:977e87915078 793 *
vithyat 0:977e87915078 794 * \return message ID, 0 if failed
vithyat 0:977e87915078 795 */
vithyat 0:977e87915078 796 extern int32_t sn_nsdl_send_coap_ping(struct nsdl_s *handle);
vithyat 0:977e87915078 797
vithyat 0:977e87915078 798 #ifdef __cplusplus
vithyat 0:977e87915078 799 }
vithyat 0:977e87915078 800 #endif
vithyat 0:977e87915078 801
vithyat 0:977e87915078 802 #endif /* SN_NSDL_LIB_H_ */