sandbox / mbed-client-c

Fork of mbed-client-c by Christopher Haster

Committer:
Christopher Haster
Date:
Fri Jan 22 16:31:54 2016 -0600
Revision:
1:43f5c94c6771
Child:
4:5d91b0f5038c
Initial move of mbed-client-c to mercurial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Christopher Haster 1:43f5c94c6771 1 /*
Christopher Haster 1:43f5c94c6771 2 * Copyright (c) 2011-2015 ARM Limited. All rights reserved.
Christopher Haster 1:43f5c94c6771 3 * SPDX-License-Identifier: Apache-2.0
Christopher Haster 1:43f5c94c6771 4 * Licensed under the Apache License, Version 2.0 (the License); you may
Christopher Haster 1:43f5c94c6771 5 * not use this file except in compliance with the License.
Christopher Haster 1:43f5c94c6771 6 * You may obtain a copy of the License at
Christopher Haster 1:43f5c94c6771 7 *
Christopher Haster 1:43f5c94c6771 8 * http://www.apache.org/licenses/LICENSE-2.0
Christopher Haster 1:43f5c94c6771 9 *
Christopher Haster 1:43f5c94c6771 10 * Unless required by applicable law or agreed to in writing, software
Christopher Haster 1:43f5c94c6771 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
Christopher Haster 1:43f5c94c6771 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Christopher Haster 1:43f5c94c6771 13 * See the License for the specific language governing permissions and
Christopher Haster 1:43f5c94c6771 14 * limitations under the License.
Christopher Haster 1:43f5c94c6771 15 */
Christopher Haster 1:43f5c94c6771 16
Christopher Haster 1:43f5c94c6771 17 /**
Christopher Haster 1:43f5c94c6771 18 * \file sn_nsdl_lib.h
Christopher Haster 1:43f5c94c6771 19 *
Christopher Haster 1:43f5c94c6771 20 * \brief NanoService Devices Library header file
Christopher Haster 1:43f5c94c6771 21 *
Christopher Haster 1:43f5c94c6771 22 *
Christopher Haster 1:43f5c94c6771 23 */
Christopher Haster 1:43f5c94c6771 24
Christopher Haster 1:43f5c94c6771 25 #ifndef SN_NSDL_LIB_H_
Christopher Haster 1:43f5c94c6771 26 #define SN_NSDL_LIB_H_
Christopher Haster 1:43f5c94c6771 27
Christopher Haster 1:43f5c94c6771 28 #include "ns_list.h"
Christopher Haster 1:43f5c94c6771 29
Christopher Haster 1:43f5c94c6771 30 #ifdef __cplusplus
Christopher Haster 1:43f5c94c6771 31 extern "C" {
Christopher Haster 1:43f5c94c6771 32 #endif
Christopher Haster 1:43f5c94c6771 33
Christopher Haster 1:43f5c94c6771 34 #define SN_NSDL_ENDPOINT_NOT_REGISTERED 0
Christopher Haster 1:43f5c94c6771 35 #define SN_NSDL_ENDPOINT_IS_REGISTERED 1
Christopher Haster 1:43f5c94c6771 36
Christopher Haster 1:43f5c94c6771 37 /* Handle structure */
Christopher Haster 1:43f5c94c6771 38 struct nsdl_s;
Christopher Haster 1:43f5c94c6771 39
Christopher Haster 1:43f5c94c6771 40 /**
Christopher Haster 1:43f5c94c6771 41 * \brief Received device server security
Christopher Haster 1:43f5c94c6771 42 */
Christopher Haster 1:43f5c94c6771 43 typedef enum omalw_server_security_ {
Christopher Haster 1:43f5c94c6771 44 SEC_NOT_SET = -1,
Christopher Haster 1:43f5c94c6771 45 PSK = 0,
Christopher Haster 1:43f5c94c6771 46 RPK = 1,
Christopher Haster 1:43f5c94c6771 47 CERTIFICATE = 2,
Christopher Haster 1:43f5c94c6771 48 NO_SEC = 3
Christopher Haster 1:43f5c94c6771 49 } omalw_server_security_t;
Christopher Haster 1:43f5c94c6771 50
Christopher Haster 1:43f5c94c6771 51 /**
Christopher Haster 1:43f5c94c6771 52 * \brief Endpoint binding and mode
Christopher Haster 1:43f5c94c6771 53 */
Christopher Haster 1:43f5c94c6771 54 typedef enum sn_nsdl_oma_binding_and_mode_ {
Christopher Haster 1:43f5c94c6771 55 BINDING_MODE_NOT_SET = 0,
Christopher Haster 1:43f5c94c6771 56 BINDING_MODE_U = 0x01,
Christopher Haster 1:43f5c94c6771 57 BINDING_MODE_Q = 0x02,
Christopher Haster 1:43f5c94c6771 58 BINDING_MODE_S = 0x04
Christopher Haster 1:43f5c94c6771 59 } sn_nsdl_oma_binding_and_mode_t;
Christopher Haster 1:43f5c94c6771 60
Christopher Haster 1:43f5c94c6771 61 /**
Christopher Haster 1:43f5c94c6771 62 * \brief Endpoint registration mode.
Christopher Haster 1:43f5c94c6771 63 * If REGISTER_WITH_RESOURCES, endpoint sends list of all resources during registration.
Christopher Haster 1:43f5c94c6771 64 * If REGISTER_WITH_TEMPLATE, endpoint sends registration without resource list. Device server must have
Christopher Haster 1:43f5c94c6771 65 * correctly configured template.
Christopher Haster 1:43f5c94c6771 66 */
Christopher Haster 1:43f5c94c6771 67 typedef enum sn_nsdl_registration_mode_ {
Christopher Haster 1:43f5c94c6771 68 REGISTER_WITH_RESOURCES = 0,
Christopher Haster 1:43f5c94c6771 69 REGISTER_WITH_TEMPLATE
Christopher Haster 1:43f5c94c6771 70 } sn_nsdl_registration_mode_t;
Christopher Haster 1:43f5c94c6771 71
Christopher Haster 1:43f5c94c6771 72
Christopher Haster 1:43f5c94c6771 73 typedef struct omalw_certificate_list_ {
Christopher Haster 1:43f5c94c6771 74 uint8_t certificate_chain_len;
Christopher Haster 1:43f5c94c6771 75 uint8_t *certificate_ptr[2];
Christopher Haster 1:43f5c94c6771 76 uint16_t certificate_len[2];
Christopher Haster 1:43f5c94c6771 77 uint8_t *own_private_key_ptr;
Christopher Haster 1:43f5c94c6771 78 uint16_t own_private_key_len;
Christopher Haster 1:43f5c94c6771 79 } omalw_certificate_list_t;
Christopher Haster 1:43f5c94c6771 80
Christopher Haster 1:43f5c94c6771 81 /**
Christopher Haster 1:43f5c94c6771 82 * \brief Endpoint registration parameters
Christopher Haster 1:43f5c94c6771 83 */
Christopher Haster 1:43f5c94c6771 84 typedef struct sn_nsdl_ep_parameters_ {
Christopher Haster 1:43f5c94c6771 85 uint8_t *endpoint_name_ptr; /**< Endpoint name */
Christopher Haster 1:43f5c94c6771 86 uint8_t endpoint_name_len;
Christopher Haster 1:43f5c94c6771 87
Christopher Haster 1:43f5c94c6771 88 uint8_t *domain_name_ptr; /**< Domain to register. If null, NSP uses default domain */
Christopher Haster 1:43f5c94c6771 89 uint8_t domain_name_len;
Christopher Haster 1:43f5c94c6771 90
Christopher Haster 1:43f5c94c6771 91 uint8_t *type_ptr; /**< Endpoint type */
Christopher Haster 1:43f5c94c6771 92 uint8_t type_len;
Christopher Haster 1:43f5c94c6771 93
Christopher Haster 1:43f5c94c6771 94 uint8_t *lifetime_ptr; /**< Endpoint lifetime in seconds. eg. "1200" = 1200 seconds */
Christopher Haster 1:43f5c94c6771 95 uint8_t lifetime_len;
Christopher Haster 1:43f5c94c6771 96
Christopher Haster 1:43f5c94c6771 97 sn_nsdl_registration_mode_t ds_register_mode; /**< Defines registration mode */
Christopher Haster 1:43f5c94c6771 98 sn_nsdl_oma_binding_and_mode_t binding_and_mode; /**< Defines endpoints binding and mode */
Christopher Haster 1:43f5c94c6771 99
Christopher Haster 1:43f5c94c6771 100 uint8_t *location_ptr; /**< Endpoint location in server, optional parameter,default is NULL */
Christopher Haster 1:43f5c94c6771 101 uint8_t location_len;
Christopher Haster 1:43f5c94c6771 102
Christopher Haster 1:43f5c94c6771 103 } sn_nsdl_ep_parameters_s;
Christopher Haster 1:43f5c94c6771 104
Christopher Haster 1:43f5c94c6771 105 /**
Christopher Haster 1:43f5c94c6771 106 * \brief For internal use
Christopher Haster 1:43f5c94c6771 107 */
Christopher Haster 1:43f5c94c6771 108 typedef struct sn_nsdl_sent_messages_ {
Christopher Haster 1:43f5c94c6771 109 uint16_t msg_id_number;
Christopher Haster 1:43f5c94c6771 110 uint8_t message_type;
Christopher Haster 1:43f5c94c6771 111 ns_list_link_t link;
Christopher Haster 1:43f5c94c6771 112 } sn_nsdl_sent_messages_s;
Christopher Haster 1:43f5c94c6771 113
Christopher Haster 1:43f5c94c6771 114 /**
Christopher Haster 1:43f5c94c6771 115 * \brief Includes resource path
Christopher Haster 1:43f5c94c6771 116 */
Christopher Haster 1:43f5c94c6771 117 typedef struct sn_grs_resource_ {
Christopher Haster 1:43f5c94c6771 118 uint8_t pathlen;
Christopher Haster 1:43f5c94c6771 119 uint8_t *path;
Christopher Haster 1:43f5c94c6771 120 } sn_grs_resource_s;
Christopher Haster 1:43f5c94c6771 121
Christopher Haster 1:43f5c94c6771 122 /**
Christopher Haster 1:43f5c94c6771 123 * \brief Table of created resources
Christopher Haster 1:43f5c94c6771 124 */
Christopher Haster 1:43f5c94c6771 125 typedef struct sn_grs_resource_list_ {
Christopher Haster 1:43f5c94c6771 126 uint8_t res_count; /**< Number of resources */
Christopher Haster 1:43f5c94c6771 127 sn_grs_resource_s *res;
Christopher Haster 1:43f5c94c6771 128 } sn_grs_resource_list_s;
Christopher Haster 1:43f5c94c6771 129
Christopher Haster 1:43f5c94c6771 130 /**
Christopher Haster 1:43f5c94c6771 131 * \brief Resource access rights
Christopher Haster 1:43f5c94c6771 132 */
Christopher Haster 1:43f5c94c6771 133 typedef enum sn_grs_resource_acl_ {
Christopher Haster 1:43f5c94c6771 134 SN_GRS_GET_ALLOWED = 0x01 ,
Christopher Haster 1:43f5c94c6771 135 SN_GRS_PUT_ALLOWED = 0x02,
Christopher Haster 1:43f5c94c6771 136 SN_GRS_POST_ALLOWED = 0x04,
Christopher Haster 1:43f5c94c6771 137 SN_GRS_DELETE_ALLOWED = 0x08
Christopher Haster 1:43f5c94c6771 138 } sn_grs_resource_acl_e;
Christopher Haster 1:43f5c94c6771 139
Christopher Haster 1:43f5c94c6771 140
Christopher Haster 1:43f5c94c6771 141 typedef enum sn_nsdl_oma_device_error_ {
Christopher Haster 1:43f5c94c6771 142 NO_ERROR = 0,
Christopher Haster 1:43f5c94c6771 143 LOW_BATTERY_POWER = 1,
Christopher Haster 1:43f5c94c6771 144 EXTERNAL_POWER_SUPPLY_OFF = 2,
Christopher Haster 1:43f5c94c6771 145 GPS_MODULE_FAILURE = 3,
Christopher Haster 1:43f5c94c6771 146 LOW_RECEIVED_SIGNAL_STRENGTH = 4,
Christopher Haster 1:43f5c94c6771 147 OUT_OF_MEMORY = 5,
Christopher Haster 1:43f5c94c6771 148 SMS_FAILURE = 6,
Christopher Haster 1:43f5c94c6771 149 IP_CONN_FAILURE = 7,
Christopher Haster 1:43f5c94c6771 150 PERIPHERAL_MALFUNCTION = 8
Christopher Haster 1:43f5c94c6771 151 } sn_nsdl_oma_device_error_t;
Christopher Haster 1:43f5c94c6771 152
Christopher Haster 1:43f5c94c6771 153 /**
Christopher Haster 1:43f5c94c6771 154 * \brief Defines the resource mode
Christopher Haster 1:43f5c94c6771 155 */
Christopher Haster 1:43f5c94c6771 156 typedef enum sn_nsdl_resource_mode_ {
Christopher Haster 1:43f5c94c6771 157 SN_GRS_STATIC, /**< Static resources have some value that doesn't change */
Christopher Haster 1:43f5c94c6771 158 SN_GRS_DYNAMIC, /**< Dynamic resources are handled in application. Therefore one must give function callback pointer to them */
Christopher Haster 1:43f5c94c6771 159 SN_GRS_DIRECTORY /**< Directory resources are unused and unsupported */
Christopher Haster 1:43f5c94c6771 160 } sn_nsdl_resource_mode_e;
Christopher Haster 1:43f5c94c6771 161
Christopher Haster 1:43f5c94c6771 162 /**
Christopher Haster 1:43f5c94c6771 163 * \brief Resource registration parameters
Christopher Haster 1:43f5c94c6771 164 */
Christopher Haster 1:43f5c94c6771 165 typedef struct sn_nsdl_resource_parameters_ {
Christopher Haster 1:43f5c94c6771 166 uint8_t *resource_type_ptr;
Christopher Haster 1:43f5c94c6771 167 uint16_t resource_type_len;
Christopher Haster 1:43f5c94c6771 168
Christopher Haster 1:43f5c94c6771 169 uint8_t *interface_description_ptr;
Christopher Haster 1:43f5c94c6771 170 uint16_t interface_description_len;
Christopher Haster 1:43f5c94c6771 171
Christopher Haster 1:43f5c94c6771 172 uint8_t coap_content_type;
Christopher Haster 1:43f5c94c6771 173
Christopher Haster 1:43f5c94c6771 174 uint8_t mime_content_type;
Christopher Haster 1:43f5c94c6771 175
Christopher Haster 1:43f5c94c6771 176 uint8_t observable;
Christopher Haster 1:43f5c94c6771 177
Christopher Haster 1:43f5c94c6771 178 uint8_t registered;
Christopher Haster 1:43f5c94c6771 179
Christopher Haster 1:43f5c94c6771 180 } sn_nsdl_resource_parameters_s;
Christopher Haster 1:43f5c94c6771 181
Christopher Haster 1:43f5c94c6771 182 /**
Christopher Haster 1:43f5c94c6771 183 * \brief Defines parameters for the resource.
Christopher Haster 1:43f5c94c6771 184 */
Christopher Haster 1:43f5c94c6771 185 typedef struct sn_nsdl_resource_info_ {
Christopher Haster 1:43f5c94c6771 186 sn_nsdl_resource_parameters_s *resource_parameters_ptr;
Christopher Haster 1:43f5c94c6771 187
Christopher Haster 1:43f5c94c6771 188 sn_nsdl_resource_mode_e mode; /**< STATIC etc.. */
Christopher Haster 1:43f5c94c6771 189
Christopher Haster 1:43f5c94c6771 190 uint16_t pathlen; /**< Address */
Christopher Haster 1:43f5c94c6771 191 uint8_t *path;
Christopher Haster 1:43f5c94c6771 192
Christopher Haster 1:43f5c94c6771 193 uint16_t resourcelen; /**< 0 if dynamic resource, resource information in static resource */
Christopher Haster 1:43f5c94c6771 194 uint8_t *resource; /**< NULL if dynamic resource */
Christopher Haster 1:43f5c94c6771 195
Christopher Haster 1:43f5c94c6771 196 sn_grs_resource_acl_e access;
Christopher Haster 1:43f5c94c6771 197
Christopher Haster 1:43f5c94c6771 198 uint8_t (*sn_grs_dyn_res_callback)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *, sn_nsdl_capab_e);
Christopher Haster 1:43f5c94c6771 199
Christopher Haster 1:43f5c94c6771 200 ns_list_link_t link;
Christopher Haster 1:43f5c94c6771 201
Christopher Haster 1:43f5c94c6771 202 } sn_nsdl_resource_info_s;
Christopher Haster 1:43f5c94c6771 203
Christopher Haster 1:43f5c94c6771 204 /**
Christopher Haster 1:43f5c94c6771 205 * \brief Defines OMA device object parameters.
Christopher Haster 1:43f5c94c6771 206 */
Christopher Haster 1:43f5c94c6771 207 typedef struct sn_nsdl_oma_device_ {
Christopher Haster 1:43f5c94c6771 208 sn_nsdl_oma_device_error_t error_code; /**< Error code. Mandatory. Can be more than one */
Christopher Haster 1:43f5c94c6771 209 uint8_t (*sn_oma_device_boot_callback)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *, sn_nsdl_capab_e); /**< Device boot callback function. If defined, this is called when reset request is received */
Christopher Haster 1:43f5c94c6771 210
Christopher Haster 1:43f5c94c6771 211 } sn_nsdl_oma_device_t;
Christopher Haster 1:43f5c94c6771 212
Christopher Haster 1:43f5c94c6771 213 /**
Christopher Haster 1:43f5c94c6771 214 * \brief Defines OMAlw server information
Christopher Haster 1:43f5c94c6771 215 */
Christopher Haster 1:43f5c94c6771 216 typedef struct sn_nsdl_oma_server_info_ {
Christopher Haster 1:43f5c94c6771 217 sn_nsdl_addr_s *omalw_address_ptr;
Christopher Haster 1:43f5c94c6771 218 omalw_server_security_t omalw_server_security;
Christopher Haster 1:43f5c94c6771 219
Christopher Haster 1:43f5c94c6771 220 } sn_nsdl_oma_server_info_t;
Christopher Haster 1:43f5c94c6771 221
Christopher Haster 1:43f5c94c6771 222 /**
Christopher Haster 1:43f5c94c6771 223 * \brief Defines endpoint parameters to OMA bootstrap.
Christopher Haster 1:43f5c94c6771 224 */
Christopher Haster 1:43f5c94c6771 225 typedef struct sn_nsdl_bs_ep_info_ {
Christopher Haster 1:43f5c94c6771 226 void (*oma_bs_status_cb)(sn_nsdl_oma_server_info_t *); /**< Callback for OMA bootstrap status */
Christopher Haster 1:43f5c94c6771 227 sn_nsdl_oma_device_t *device_object; /**< OMA LWM2M mandatory device resources */
Christopher Haster 1:43f5c94c6771 228 } sn_nsdl_bs_ep_info_t;
Christopher Haster 1:43f5c94c6771 229
Christopher Haster 1:43f5c94c6771 230
Christopher Haster 1:43f5c94c6771 231
Christopher Haster 1:43f5c94c6771 232
Christopher Haster 1:43f5c94c6771 233 /**
Christopher Haster 1:43f5c94c6771 234 * \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 *),
Christopher Haster 1:43f5c94c6771 235 * uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *),
Christopher Haster 1:43f5c94c6771 236 * sn_nsdl_mem_s *sn_memory)
Christopher Haster 1:43f5c94c6771 237 *
Christopher Haster 1:43f5c94c6771 238 * \brief Initialization function for NSDL library. Initializes NSDL, GRS, HTTP and CoAP.
Christopher Haster 1:43f5c94c6771 239 *
Christopher Haster 1:43f5c94c6771 240 * \param *sn_nsdl_tx_callback A callback function for sending messages.
Christopher Haster 1:43f5c94c6771 241 *
Christopher Haster 1:43f5c94c6771 242 * \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
Christopher Haster 1:43f5c94c6771 243 * reply for some DS messages (register message etc.), rx callback will be called.
Christopher Haster 1:43f5c94c6771 244 *
Christopher Haster 1:43f5c94c6771 245 * \param *sn_memory Memory structure which includes function pointers to the allocation and free functions.
Christopher Haster 1:43f5c94c6771 246 *
Christopher Haster 1:43f5c94c6771 247 * \return pointer to created handle structure. NULL if failed
Christopher Haster 1:43f5c94c6771 248 */
Christopher Haster 1:43f5c94c6771 249 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 *),
Christopher Haster 1:43f5c94c6771 250 uint8_t (*sn_nsdl_rx_cb)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *),
Christopher Haster 1:43f5c94c6771 251 void *(*sn_nsdl_alloc)(uint16_t), void (*sn_nsdl_free)(void *));
Christopher Haster 1:43f5c94c6771 252
Christopher Haster 1:43f5c94c6771 253 /**
Christopher Haster 1:43f5c94c6771 254 * \fn extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr);
Christopher Haster 1:43f5c94c6771 255 *
Christopher Haster 1:43f5c94c6771 256 * \brief Registers endpoint to mbed Device Server.
Christopher Haster 1:43f5c94c6771 257 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 258 * \param *endpoint_info_ptr Contains endpoint information.
Christopher Haster 1:43f5c94c6771 259 *
Christopher Haster 1:43f5c94c6771 260 * \return registration message ID, 0 if failed
Christopher Haster 1:43f5c94c6771 261 */
Christopher Haster 1:43f5c94c6771 262 extern uint16_t sn_nsdl_register_endpoint(struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr);
Christopher Haster 1:43f5c94c6771 263
Christopher Haster 1:43f5c94c6771 264 /**
Christopher Haster 1:43f5c94c6771 265 * \fn extern uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle)
Christopher Haster 1:43f5c94c6771 266 *
Christopher Haster 1:43f5c94c6771 267 * \brief Sends unregister-message to mbed Device Server.
Christopher Haster 1:43f5c94c6771 268 *
Christopher Haster 1:43f5c94c6771 269 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 270 *
Christopher Haster 1:43f5c94c6771 271 * \return unregistration message ID, 0 if failed
Christopher Haster 1:43f5c94c6771 272 */
Christopher Haster 1:43f5c94c6771 273 extern uint16_t sn_nsdl_unregister_endpoint(struct nsdl_s *handle);
Christopher Haster 1:43f5c94c6771 274
Christopher Haster 1:43f5c94c6771 275 /**
Christopher Haster 1:43f5c94c6771 276 * \fn extern uint16_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len);
Christopher Haster 1:43f5c94c6771 277 *
Christopher Haster 1:43f5c94c6771 278 * \brief Update the registration with mbed Device Server.
Christopher Haster 1:43f5c94c6771 279 *
Christopher Haster 1:43f5c94c6771 280 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 281 * \param *lt_ptr Pointer to lifetime value string in ascii form, eg. "1200"
Christopher Haster 1:43f5c94c6771 282 * \param lt_len Length of the lifetime string
Christopher Haster 1:43f5c94c6771 283 *
Christopher Haster 1:43f5c94c6771 284 * \return registration update message ID, 0 if failed
Christopher Haster 1:43f5c94c6771 285 */
Christopher Haster 1:43f5c94c6771 286 extern uint16_t sn_nsdl_update_registration(struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len);
Christopher Haster 1:43f5c94c6771 287
Christopher Haster 1:43f5c94c6771 288 /**
Christopher Haster 1:43f5c94c6771 289 * \fn extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len);
Christopher Haster 1:43f5c94c6771 290 *
Christopher Haster 1:43f5c94c6771 291 * \brief Sets the location receievd from Device Server.
Christopher Haster 1:43f5c94c6771 292 *
Christopher Haster 1:43f5c94c6771 293 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 294 * \param *lt_ptr Pointer to location value string , eg. "s322j4k"
Christopher Haster 1:43f5c94c6771 295 * \param lt_len Length of the location string
Christopher Haster 1:43f5c94c6771 296 *
Christopher Haster 1:43f5c94c6771 297 * \return success, 0 if failed -1
Christopher Haster 1:43f5c94c6771 298 */
Christopher Haster 1:43f5c94c6771 299 extern int8_t sn_nsdl_set_endpoint_location(struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len);
Christopher Haster 1:43f5c94c6771 300
Christopher Haster 1:43f5c94c6771 301
Christopher Haster 1:43f5c94c6771 302 /**
Christopher Haster 1:43f5c94c6771 303 * \fn extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle)
Christopher Haster 1:43f5c94c6771 304 *
Christopher Haster 1:43f5c94c6771 305 * \brief Checks if endpoint is registered.
Christopher Haster 1:43f5c94c6771 306 *
Christopher Haster 1:43f5c94c6771 307 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 308 *
Christopher Haster 1:43f5c94c6771 309 * \return 1 Endpoint registration is done successfully
Christopher Haster 1:43f5c94c6771 310 * \return 0 Endpoint is not registered
Christopher Haster 1:43f5c94c6771 311 */
Christopher Haster 1:43f5c94c6771 312 extern int8_t sn_nsdl_is_ep_registered(struct nsdl_s *handle);
Christopher Haster 1:43f5c94c6771 313
Christopher Haster 1:43f5c94c6771 314 /**
Christopher Haster 1:43f5c94c6771 315 * \fn extern void sn_nsdl_nsp_lost(struct nsdl_s *handle);
Christopher Haster 1:43f5c94c6771 316 *
Christopher Haster 1:43f5c94c6771 317 * \brief A function to inform mbed Device C client library if application detects a fault in mbed Device Server registration.
Christopher Haster 1:43f5c94c6771 318 *
Christopher Haster 1:43f5c94c6771 319 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 320 *
Christopher Haster 1:43f5c94c6771 321 * After calling this function sn_nsdl_is_ep_registered() will return "not registered".
Christopher Haster 1:43f5c94c6771 322 */
Christopher Haster 1:43f5c94c6771 323 extern void sn_nsdl_nsp_lost(struct nsdl_s *handle);
Christopher Haster 1:43f5c94c6771 324
Christopher Haster 1:43f5c94c6771 325 /**
Christopher Haster 1:43f5c94c6771 326 * \fn extern uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len,
Christopher Haster 1:43f5c94c6771 327 * uint8_t *payload_ptr, uint16_t payload_len,
Christopher Haster 1:43f5c94c6771 328 * uint8_t *observe_ptr, uint8_t observe_len,
Christopher Haster 1:43f5c94c6771 329 * sn_coap_msg_type_e message_type, uint8_t content_type)
Christopher Haster 1:43f5c94c6771 330 *
Christopher Haster 1:43f5c94c6771 331 *
Christopher Haster 1:43f5c94c6771 332 * \brief Sends observation message to mbed Device Server
Christopher Haster 1:43f5c94c6771 333 *
Christopher Haster 1:43f5c94c6771 334 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 335 * \param *token_ptr Pointer to token to be used
Christopher Haster 1:43f5c94c6771 336 * \param token_len Token length
Christopher Haster 1:43f5c94c6771 337 * \param *payload_ptr Pointer to payload to be sent
Christopher Haster 1:43f5c94c6771 338 * \param payload_len Payload length
Christopher Haster 1:43f5c94c6771 339 * \param *observe_ptr Pointer to observe number to be sent
Christopher Haster 1:43f5c94c6771 340 * \param observe_len Observe number len
Christopher Haster 1:43f5c94c6771 341 * \param message_type Observation message type (confirmable or non-confirmable)
Christopher Haster 1:43f5c94c6771 342 * \param contetnt_type Observation message payload contetnt type
Christopher Haster 1:43f5c94c6771 343 *
Christopher Haster 1:43f5c94c6771 344 * \return !0 Success, observation messages message ID
Christopher Haster 1:43f5c94c6771 345 * \return 0 Failure
Christopher Haster 1:43f5c94c6771 346 */
Christopher Haster 1:43f5c94c6771 347 extern uint16_t sn_nsdl_send_observation_notification(struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len,
Christopher Haster 1:43f5c94c6771 348 uint8_t *payload_ptr, uint16_t payload_len,
Christopher Haster 1:43f5c94c6771 349 uint8_t *observe_ptr, uint8_t observe_len,
Christopher Haster 1:43f5c94c6771 350 sn_coap_msg_type_e message_type, uint8_t content_type);
Christopher Haster 1:43f5c94c6771 351
Christopher Haster 1:43f5c94c6771 352 /**
Christopher Haster 1:43f5c94c6771 353 * \fn extern uint32_t sn_nsdl_get_version(void)
Christopher Haster 1:43f5c94c6771 354 *
Christopher Haster 1:43f5c94c6771 355 * \brief Version query function.
Christopher Haster 1:43f5c94c6771 356 *
Christopher Haster 1:43f5c94c6771 357 * Used to retrieve the version information from the mbed Device C Client library.
Christopher Haster 1:43f5c94c6771 358 *
Christopher Haster 1:43f5c94c6771 359 * \return Pointer to library version string
Christopher Haster 1:43f5c94c6771 360 */
Christopher Haster 1:43f5c94c6771 361 extern char *sn_nsdl_get_version(void);
Christopher Haster 1:43f5c94c6771 362
Christopher Haster 1:43f5c94c6771 363 /**
Christopher Haster 1:43f5c94c6771 364 * \fn extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src)
Christopher Haster 1:43f5c94c6771 365 *
Christopher Haster 1:43f5c94c6771 366 * \brief To push CoAP packet to mbed Device C Client library
Christopher Haster 1:43f5c94c6771 367 *
Christopher Haster 1:43f5c94c6771 368 * Used to push an CoAP packet to mbed Device C Client library for processing.
Christopher Haster 1:43f5c94c6771 369 *
Christopher Haster 1:43f5c94c6771 370 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 371 *
Christopher Haster 1:43f5c94c6771 372 * \param *packet Pointer to a uint8_t array containing the packet (including the CoAP headers).
Christopher Haster 1:43f5c94c6771 373 * After successful execution this array may contain the response packet.
Christopher Haster 1:43f5c94c6771 374 *
Christopher Haster 1:43f5c94c6771 375 * \param *packet_len Pointer to length of the packet. After successful execution this array may contain the length
Christopher Haster 1:43f5c94c6771 376 * of the response packet.
Christopher Haster 1:43f5c94c6771 377 *
Christopher Haster 1:43f5c94c6771 378 * \param *src Pointer to packet source address information. After successful execution this array may contain
Christopher Haster 1:43f5c94c6771 379 * the destination address of the response packet.
Christopher Haster 1:43f5c94c6771 380 *
Christopher Haster 1:43f5c94c6771 381 * \return 0 Success
Christopher Haster 1:43f5c94c6771 382 * \return -1 Failure
Christopher Haster 1:43f5c94c6771 383 */
Christopher Haster 1:43f5c94c6771 384 extern int8_t sn_nsdl_process_coap(struct nsdl_s *handle, uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src);
Christopher Haster 1:43f5c94c6771 385
Christopher Haster 1:43f5c94c6771 386 /**
Christopher Haster 1:43f5c94c6771 387 * \fn extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time);
Christopher Haster 1:43f5c94c6771 388 *
Christopher Haster 1:43f5c94c6771 389 * \brief CoAP retransmission function.
Christopher Haster 1:43f5c94c6771 390 *
Christopher Haster 1:43f5c94c6771 391 * Used to give execution time for the mbed Device C Client library for retransmissions.
Christopher Haster 1:43f5c94c6771 392 *
Christopher Haster 1:43f5c94c6771 393 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 394 *
Christopher Haster 1:43f5c94c6771 395 * \param time Time in seconds.
Christopher Haster 1:43f5c94c6771 396 *
Christopher Haster 1:43f5c94c6771 397 * \return 0 Success
Christopher Haster 1:43f5c94c6771 398 * \return -1 Failure
Christopher Haster 1:43f5c94c6771 399 */
Christopher Haster 1:43f5c94c6771 400 extern int8_t sn_nsdl_exec(struct nsdl_s *handle, uint32_t time);
Christopher Haster 1:43f5c94c6771 401
Christopher Haster 1:43f5c94c6771 402 /**
Christopher Haster 1:43f5c94c6771 403 * \fn extern int8_t sn_nsdl_create_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res);
Christopher Haster 1:43f5c94c6771 404 *
Christopher Haster 1:43f5c94c6771 405 * \brief Resource creating function.
Christopher Haster 1:43f5c94c6771 406 *
Christopher Haster 1:43f5c94c6771 407 * Used to create a static or dynamic CoAP resource.
Christopher Haster 1:43f5c94c6771 408 *
Christopher Haster 1:43f5c94c6771 409 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information
Christopher Haster 1:43f5c94c6771 410 * about the resource.
Christopher Haster 1:43f5c94c6771 411 *
Christopher Haster 1:43f5c94c6771 412 * \return 0 Success
Christopher Haster 1:43f5c94c6771 413 * \return -1 Failure
Christopher Haster 1:43f5c94c6771 414 * \return -2 Resource already exists
Christopher Haster 1:43f5c94c6771 415 * \return -3 Invalid path
Christopher Haster 1:43f5c94c6771 416 * \return -4 List adding failure
Christopher Haster 1:43f5c94c6771 417 */
Christopher Haster 1:43f5c94c6771 418 extern int8_t sn_nsdl_create_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res);
Christopher Haster 1:43f5c94c6771 419
Christopher Haster 1:43f5c94c6771 420 /**
Christopher Haster 1:43f5c94c6771 421 * \fn extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res)
Christopher Haster 1:43f5c94c6771 422 *
Christopher Haster 1:43f5c94c6771 423 * \brief Resource updating function.
Christopher Haster 1:43f5c94c6771 424 *
Christopher Haster 1:43f5c94c6771 425 * Used to update the direct value of a static resource, the callback function pointer of a dynamic resource
Christopher Haster 1:43f5c94c6771 426 * and access rights of the recource.
Christopher Haster 1:43f5c94c6771 427 *
Christopher Haster 1:43f5c94c6771 428 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 429 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information
Christopher Haster 1:43f5c94c6771 430 * about the resource. Only the pathlen and path elements are evaluated along with
Christopher Haster 1:43f5c94c6771 431 * either resourcelen and resource or the function pointer.
Christopher Haster 1:43f5c94c6771 432 *
Christopher Haster 1:43f5c94c6771 433 * \return 0 Success
Christopher Haster 1:43f5c94c6771 434 * \return -1 Failure
Christopher Haster 1:43f5c94c6771 435 */
Christopher Haster 1:43f5c94c6771 436 extern int8_t sn_nsdl_update_resource(struct nsdl_s *handle, sn_nsdl_resource_info_s *res);
Christopher Haster 1:43f5c94c6771 437
Christopher Haster 1:43f5c94c6771 438 /**
Christopher Haster 1:43f5c94c6771 439 * \fn extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, uint8_t pathlen, uint8_t *path)
Christopher Haster 1:43f5c94c6771 440 *
Christopher Haster 1:43f5c94c6771 441 * \brief Resource delete function.
Christopher Haster 1:43f5c94c6771 442 *
Christopher Haster 1:43f5c94c6771 443 * Used to delete a resource. If resource has a subresources, these all must also be removed.
Christopher Haster 1:43f5c94c6771 444 *
Christopher Haster 1:43f5c94c6771 445 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 446 * \param pathlen Contains the length of the path that is to be deleted (excluding possible trailing "\0").
Christopher Haster 1:43f5c94c6771 447 * \param *path_ptr A pointer to an array containing the path.
Christopher Haster 1:43f5c94c6771 448 *
Christopher Haster 1:43f5c94c6771 449 * \return 0 Success
Christopher Haster 1:43f5c94c6771 450 * \return -1 Failure (No such resource)
Christopher Haster 1:43f5c94c6771 451 */
Christopher Haster 1:43f5c94c6771 452 extern int8_t sn_nsdl_delete_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path);
Christopher Haster 1:43f5c94c6771 453
Christopher Haster 1:43f5c94c6771 454 /**
Christopher Haster 1:43f5c94c6771 455 * \fn extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path)
Christopher Haster 1:43f5c94c6771 456 *
Christopher Haster 1:43f5c94c6771 457 * \brief Resource get function.
Christopher Haster 1:43f5c94c6771 458 *
Christopher Haster 1:43f5c94c6771 459 * Used to get a resource.
Christopher Haster 1:43f5c94c6771 460 *
Christopher Haster 1:43f5c94c6771 461 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 462 * \param pathlen Contains the length of the path that is to be returned (excluding possible trailing '\0').
Christopher Haster 1:43f5c94c6771 463 * \param *path A pointer to an array containing the path.
Christopher Haster 1:43f5c94c6771 464 *
Christopher Haster 1:43f5c94c6771 465 * \return !NULL Success, pointer to a sn_nsdl_resource_info_s that contains the resource information\n
Christopher Haster 1:43f5c94c6771 466 * \return NULL Failure
Christopher Haster 1:43f5c94c6771 467 */
Christopher Haster 1:43f5c94c6771 468 extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path);
Christopher Haster 1:43f5c94c6771 469
Christopher Haster 1:43f5c94c6771 470 /**
Christopher Haster 1:43f5c94c6771 471 * \fn extern sn_grs_resource_list_s *sn_nsdl_list_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path)
Christopher Haster 1:43f5c94c6771 472 *
Christopher Haster 1:43f5c94c6771 473 * \brief Resource list function.
Christopher Haster 1:43f5c94c6771 474 *
Christopher Haster 1:43f5c94c6771 475 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 476 * \param pathlen Contains the length of the target path (excluding possible trailing '\0').
Christopher Haster 1:43f5c94c6771 477 * The length value is not examined if the path itself is a NULL pointer.
Christopher Haster 1:43f5c94c6771 478 * \param *path A pointer to an array containing the path or a NULL pointer.
Christopher Haster 1:43f5c94c6771 479 *
Christopher Haster 1:43f5c94c6771 480 * \return !NULL A pointer to a sn_grs_resource_list_s structure containing the resource listing.
Christopher Haster 1:43f5c94c6771 481 * \return NULL Failure with an unspecified error
Christopher Haster 1:43f5c94c6771 482 */
Christopher Haster 1:43f5c94c6771 483 sn_grs_resource_list_s *sn_nsdl_list_resource(struct nsdl_s *handle, uint16_t pathlen, uint8_t *path);
Christopher Haster 1:43f5c94c6771 484
Christopher Haster 1:43f5c94c6771 485 /**
Christopher Haster 1:43f5c94c6771 486 * \fn extern void sn_nsdl_free_resource_list(struct nsdl_s *handle, sn_grs_resource_list_s *list)
Christopher Haster 1:43f5c94c6771 487 *
Christopher Haster 1:43f5c94c6771 488 * \brief Free a resource list obtained from sn_nsdl_list_resource()
Christopher Haster 1:43f5c94c6771 489 *
Christopher Haster 1:43f5c94c6771 490 * \param list The list to free, or NULL.
Christopher Haster 1:43f5c94c6771 491 */
Christopher Haster 1:43f5c94c6771 492 void sn_nsdl_free_resource_list(struct nsdl_s *handle, sn_grs_resource_list_s *list);
Christopher Haster 1:43f5c94c6771 493
Christopher Haster 1:43f5c94c6771 494 /**
Christopher Haster 1:43f5c94c6771 495 * \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);
Christopher Haster 1:43f5c94c6771 496 *
Christopher Haster 1:43f5c94c6771 497 * \brief Send an outgoing CoAP request.
Christopher Haster 1:43f5c94c6771 498 *
Christopher Haster 1:43f5c94c6771 499 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 500 * \param *address_ptr Pointer to source address struct
Christopher Haster 1:43f5c94c6771 501 * \param *coap_hdr_ptr Pointer to CoAP message to be sent
Christopher Haster 1:43f5c94c6771 502 *
Christopher Haster 1:43f5c94c6771 503 * \return 0 Success
Christopher Haster 1:43f5c94c6771 504 * \return -1 Failure
Christopher Haster 1:43f5c94c6771 505 */
Christopher Haster 1:43f5c94c6771 506 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);
Christopher Haster 1:43f5c94c6771 507
Christopher Haster 1:43f5c94c6771 508 /**
Christopher Haster 1:43f5c94c6771 509 * \fn extern int8_t set_NSP_address(struct nsdl_s *handle, uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type);
Christopher Haster 1:43f5c94c6771 510 *
Christopher Haster 1:43f5c94c6771 511 * \brief This function is used to set the mbed Device Server address given by an application.
Christopher Haster 1:43f5c94c6771 512 *
Christopher Haster 1:43f5c94c6771 513 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 514 * \return 0 Success
Christopher Haster 1:43f5c94c6771 515 * \return -1 Failed to indicate that internal address pointer is not allocated (call nsdl_init() first).
Christopher Haster 1:43f5c94c6771 516 */
Christopher Haster 1:43f5c94c6771 517 extern int8_t set_NSP_address(struct nsdl_s *handle, uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type);
Christopher Haster 1:43f5c94c6771 518
Christopher Haster 1:43f5c94c6771 519 /**
Christopher Haster 1:43f5c94c6771 520 * \fn extern int8_t sn_nsdl_destroy(struct nsdl_s *handle);
Christopher Haster 1:43f5c94c6771 521 *
Christopher Haster 1:43f5c94c6771 522 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 523 * \brief This function releases all allocated memory in mbed Device C Client library.
Christopher Haster 1:43f5c94c6771 524 */
Christopher Haster 1:43f5c94c6771 525 extern int8_t sn_nsdl_destroy(struct nsdl_s *handle);
Christopher Haster 1:43f5c94c6771 526
Christopher Haster 1:43f5c94c6771 527 /**
Christopher Haster 1:43f5c94c6771 528 * \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);
Christopher Haster 1:43f5c94c6771 529 *
Christopher Haster 1:43f5c94c6771 530 * \brief Starts OMA bootstrap process
Christopher Haster 1:43f5c94c6771 531 *
Christopher Haster 1:43f5c94c6771 532 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 533 *
Christopher Haster 1:43f5c94c6771 534 * \return bootstrap message ID, 0 if failed
Christopher Haster 1:43f5c94c6771 535 */
Christopher Haster 1:43f5c94c6771 536 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);
Christopher Haster 1:43f5c94c6771 537
Christopher Haster 1:43f5c94c6771 538 /**
Christopher Haster 1:43f5c94c6771 539 * \fn extern omalw_certificate_list_t *sn_nsdl_get_certificates(struct nsdl_s *handle);
Christopher Haster 1:43f5c94c6771 540 *
Christopher Haster 1:43f5c94c6771 541 * \brief Get pointer to received device server certificates
Christopher Haster 1:43f5c94c6771 542 *
Christopher Haster 1:43f5c94c6771 543 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 544 */
Christopher Haster 1:43f5c94c6771 545 extern omalw_certificate_list_t *sn_nsdl_get_certificates(struct nsdl_s *handle);
Christopher Haster 1:43f5c94c6771 546
Christopher Haster 1:43f5c94c6771 547 /**
Christopher Haster 1:43f5c94c6771 548 * \fn extern int8_t sn_nsdl_update_certificates(struct nsdl_s *handle, omalw_certificate_list_t* certificate_ptr, uint8_t certificate_chain);
Christopher Haster 1:43f5c94c6771 549 *
Christopher Haster 1:43f5c94c6771 550 * \brief Updates certificate pointers to resource server.
Christopher Haster 1:43f5c94c6771 551 *
Christopher Haster 1:43f5c94c6771 552 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 553 */
Christopher Haster 1:43f5c94c6771 554 extern int8_t sn_nsdl_update_certificates(struct nsdl_s *handle, omalw_certificate_list_t *certificate_ptr, uint8_t certificate_chain);
Christopher Haster 1:43f5c94c6771 555
Christopher Haster 1:43f5c94c6771 556 /**
Christopher Haster 1:43f5c94c6771 557 * \fn extern int8_t sn_nsdl_create_oma_device_object(struct nsdl_s *handle, sn_nsdl_oma_device_t *device_object_ptr);
Christopher Haster 1:43f5c94c6771 558 *
Christopher Haster 1:43f5c94c6771 559 * \brief Creates new device object resource
Christopher Haster 1:43f5c94c6771 560 *
Christopher Haster 1:43f5c94c6771 561 * \param *handle Pointer to nsdl-library handle
Christopher Haster 1:43f5c94c6771 562 */
Christopher Haster 1:43f5c94c6771 563 extern int8_t sn_nsdl_create_oma_device_object(struct nsdl_s *handle, sn_nsdl_oma_device_t *device_object_ptr);
Christopher Haster 1:43f5c94c6771 564
Christopher Haster 1:43f5c94c6771 565 /**
Christopher Haster 1:43f5c94c6771 566 * \fn sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code)
Christopher Haster 1:43f5c94c6771 567 *
Christopher Haster 1:43f5c94c6771 568 * \brief Prepares generic response packet from a request packet. This function allocates memory for the resulting sn_coap_hdr_s
Christopher Haster 1:43f5c94c6771 569 *
Christopher Haster 1:43f5c94c6771 570 * \param *handle Pointer to library handle
Christopher Haster 1:43f5c94c6771 571 * \param *coap_packet_ptr The request packet pointer
Christopher Haster 1:43f5c94c6771 572 * \param msg_code response messages code
Christopher Haster 1:43f5c94c6771 573 *
Christopher Haster 1:43f5c94c6771 574 * \return *coap_packet_ptr The allocated and pre-filled response packet pointer
Christopher Haster 1:43f5c94c6771 575 * NULL Error in parsing the request
Christopher Haster 1:43f5c94c6771 576 *
Christopher Haster 1:43f5c94c6771 577 */
Christopher Haster 1:43f5c94c6771 578 extern sn_coap_hdr_s *sn_nsdl_build_response(struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code);
Christopher Haster 1:43f5c94c6771 579
Christopher Haster 1:43f5c94c6771 580 /**
Christopher Haster 1:43f5c94c6771 581 * \fn void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr)
Christopher Haster 1:43f5c94c6771 582 *
Christopher Haster 1:43f5c94c6771 583 * \brief Releases memory of given CoAP message
Christopher Haster 1:43f5c94c6771 584 *
Christopher Haster 1:43f5c94c6771 585 * Note!!! Does not release Payload part
Christopher Haster 1:43f5c94c6771 586 *
Christopher Haster 1:43f5c94c6771 587 * \param *handle Pointer to CoAP library handle
Christopher Haster 1:43f5c94c6771 588 *
Christopher Haster 1:43f5c94c6771 589 * \param *freed_coap_msg_ptr is pointer to released CoAP message
Christopher Haster 1:43f5c94c6771 590 */
Christopher Haster 1:43f5c94c6771 591 extern void sn_nsdl_release_allocated_coap_msg_mem(struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr);
Christopher Haster 1:43f5c94c6771 592
Christopher Haster 1:43f5c94c6771 593 #ifdef __cplusplus
Christopher Haster 1:43f5c94c6771 594 }
Christopher Haster 1:43f5c94c6771 595 #endif
Christopher Haster 1:43f5c94c6771 596
Christopher Haster 1:43f5c94c6771 597 #endif /* SN_NSDL_LIB_H_ */
Christopher Haster 1:43f5c94c6771 598