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