Example

Dependencies:   FXAS21002 FXOS8700Q

Committer:
maygup01
Date:
Tue Nov 19 09:49:38 2019 +0000
Revision:
0:11cc2b7889af
Example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maygup01 0:11cc2b7889af 1 /*
maygup01 0:11cc2b7889af 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
maygup01 0:11cc2b7889af 3 * SPDX-License-Identifier: Apache-2.0
maygup01 0:11cc2b7889af 4 * Licensed under the Apache License, Version 2.0 (the License); you may
maygup01 0:11cc2b7889af 5 * not use this file except in compliance with the License.
maygup01 0:11cc2b7889af 6 * You may obtain a copy of the License at
maygup01 0:11cc2b7889af 7 *
maygup01 0:11cc2b7889af 8 * http://www.apache.org/licenses/LICENSE-2.0
maygup01 0:11cc2b7889af 9 *
maygup01 0:11cc2b7889af 10 * Unless required by applicable law or agreed to in writing, software
maygup01 0:11cc2b7889af 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
maygup01 0:11cc2b7889af 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
maygup01 0:11cc2b7889af 13 * See the License for the specific language governing permissions and
maygup01 0:11cc2b7889af 14 * limitations under the License.
maygup01 0:11cc2b7889af 15 */
maygup01 0:11cc2b7889af 16 #ifndef M2MNSDLINTERFACE_H
maygup01 0:11cc2b7889af 17 #define M2MNSDLINTERFACE_H
maygup01 0:11cc2b7889af 18
maygup01 0:11cc2b7889af 19 #include "ns_list.h"
maygup01 0:11cc2b7889af 20 #include "mbed-client/m2mvector.h"
maygup01 0:11cc2b7889af 21 #include "mbed-client/m2mconfig.h"
maygup01 0:11cc2b7889af 22 #include "mbed-client/m2minterface.h"
maygup01 0:11cc2b7889af 23 #include "mbed-client/m2mtimerobserver.h"
maygup01 0:11cc2b7889af 24 #include "mbed-client/m2mobservationhandler.h"
maygup01 0:11cc2b7889af 25 #include "mbed-client/m2mtimer.h"
maygup01 0:11cc2b7889af 26 #include "mbed-client/m2mbase.h"
maygup01 0:11cc2b7889af 27 #include "mbed-client/m2mserver.h"
maygup01 0:11cc2b7889af 28 #include "include/nsdllinker.h"
maygup01 0:11cc2b7889af 29 #include "eventOS_event.h"
maygup01 0:11cc2b7889af 30
maygup01 0:11cc2b7889af 31 //FORWARD DECLARARTION
maygup01 0:11cc2b7889af 32 class M2MSecurity;
maygup01 0:11cc2b7889af 33 class M2MObject;
maygup01 0:11cc2b7889af 34 class M2MObjectInstance;
maygup01 0:11cc2b7889af 35 class M2MResource;
maygup01 0:11cc2b7889af 36 class M2MResourceInstance;
maygup01 0:11cc2b7889af 37 class M2MNsdlObserver;
maygup01 0:11cc2b7889af 38 class M2MServer;
maygup01 0:11cc2b7889af 39 class M2MConnectionHandler;
maygup01 0:11cc2b7889af 40 class M2MNotificationHandler;
maygup01 0:11cc2b7889af 41
maygup01 0:11cc2b7889af 42 const int UNDEFINED_MSG_ID = -1;
maygup01 0:11cc2b7889af 43
maygup01 0:11cc2b7889af 44 /**
maygup01 0:11cc2b7889af 45 * @brief M2MNsdlInterface
maygup01 0:11cc2b7889af 46 * Class which interacts between mbed Client C++ Library and mbed-client-c library.
maygup01 0:11cc2b7889af 47 */
maygup01 0:11cc2b7889af 48 class M2MNsdlInterface : public M2MTimerObserver,
maygup01 0:11cc2b7889af 49 public M2MObservationHandler
maygup01 0:11cc2b7889af 50 {
maygup01 0:11cc2b7889af 51 private:
maygup01 0:11cc2b7889af 52 // Prevents the use of assignment operator by accident.
maygup01 0:11cc2b7889af 53 M2MNsdlInterface& operator=( const M2MNsdlInterface& /*other*/ );
maygup01 0:11cc2b7889af 54
maygup01 0:11cc2b7889af 55 // Prevents the use of copy constructor by accident
maygup01 0:11cc2b7889af 56 M2MNsdlInterface( const M2MNsdlInterface& /*other*/ );
maygup01 0:11cc2b7889af 57
maygup01 0:11cc2b7889af 58 public:
maygup01 0:11cc2b7889af 59
maygup01 0:11cc2b7889af 60 struct request_context_s {
maygup01 0:11cc2b7889af 61 request_data_cb on_request_data_cb;
maygup01 0:11cc2b7889af 62 request_error_cb on_request_error_cb;
maygup01 0:11cc2b7889af 63 size_t received_size;
maygup01 0:11cc2b7889af 64 uint32_t msg_token;
maygup01 0:11cc2b7889af 65 char *uri_path;
maygup01 0:11cc2b7889af 66 void *context;
maygup01 0:11cc2b7889af 67 bool async_req;
maygup01 0:11cc2b7889af 68 sn_coap_msg_code_e msg_code;
maygup01 0:11cc2b7889af 69 bool resend;
maygup01 0:11cc2b7889af 70 DownloadType download_type;
maygup01 0:11cc2b7889af 71 ns_list_link_t link;
maygup01 0:11cc2b7889af 72 };
maygup01 0:11cc2b7889af 73
maygup01 0:11cc2b7889af 74 struct nsdl_coap_data_s {
maygup01 0:11cc2b7889af 75 nsdl_s *nsdl_handle;
maygup01 0:11cc2b7889af 76 sn_coap_hdr_s *received_coap_header;
maygup01 0:11cc2b7889af 77 sn_nsdl_addr_s address;
maygup01 0:11cc2b7889af 78 };
maygup01 0:11cc2b7889af 79
maygup01 0:11cc2b7889af 80 struct coap_response_s {
maygup01 0:11cc2b7889af 81 char *uri_path;
maygup01 0:11cc2b7889af 82 int32_t msg_id;
maygup01 0:11cc2b7889af 83 M2MBase::MessageType type;
maygup01 0:11cc2b7889af 84 bool blockwise_used;
maygup01 0:11cc2b7889af 85 ns_list_link_t link;
maygup01 0:11cc2b7889af 86 };
maygup01 0:11cc2b7889af 87
maygup01 0:11cc2b7889af 88 typedef NS_LIST_HEAD(request_context_s, link) request_context_list_t;
maygup01 0:11cc2b7889af 89
maygup01 0:11cc2b7889af 90 typedef NS_LIST_HEAD(coap_response_s, link) response_list_t;
maygup01 0:11cc2b7889af 91
maygup01 0:11cc2b7889af 92 /**
maygup01 0:11cc2b7889af 93 * @brief Constructor
maygup01 0:11cc2b7889af 94 * @param observer, Observer to pass the event callbacks from nsdl library.
maygup01 0:11cc2b7889af 95 */
maygup01 0:11cc2b7889af 96 M2MNsdlInterface(M2MNsdlObserver &observer, M2MConnectionHandler &connection_handler);
maygup01 0:11cc2b7889af 97
maygup01 0:11cc2b7889af 98 /**
maygup01 0:11cc2b7889af 99 * @brief Destructor
maygup01 0:11cc2b7889af 100 */
maygup01 0:11cc2b7889af 101 virtual ~M2MNsdlInterface();
maygup01 0:11cc2b7889af 102
maygup01 0:11cc2b7889af 103 /**
maygup01 0:11cc2b7889af 104 * @brief Creates endpoint object for the nsdl stack.
maygup01 0:11cc2b7889af 105 * @param endpoint_name, Endpoint name of the client.
maygup01 0:11cc2b7889af 106 * @param endpoint_type, Endpoint type of the client.
maygup01 0:11cc2b7889af 107 * @param life_time, Life time of the client in seconds
maygup01 0:11cc2b7889af 108 * @param domain, Domain of the client.
maygup01 0:11cc2b7889af 109 * @param mode, Binding mode of the client, default is UDP
maygup01 0:11cc2b7889af 110 * @param context_address, Context address default is empty.
maygup01 0:11cc2b7889af 111 */
maygup01 0:11cc2b7889af 112 void create_endpoint(const String &endpoint_name,
maygup01 0:11cc2b7889af 113 const String &endpoint_type,
maygup01 0:11cc2b7889af 114 const int32_t life_time,
maygup01 0:11cc2b7889af 115 const String &domain,
maygup01 0:11cc2b7889af 116 const uint8_t mode,
maygup01 0:11cc2b7889af 117 const String &context_address);
maygup01 0:11cc2b7889af 118
maygup01 0:11cc2b7889af 119 /**
maygup01 0:11cc2b7889af 120 * @brief Deletes the endpoint.
maygup01 0:11cc2b7889af 121 */
maygup01 0:11cc2b7889af 122 void delete_endpoint();
maygup01 0:11cc2b7889af 123
maygup01 0:11cc2b7889af 124 /**
maygup01 0:11cc2b7889af 125 * @brief Updates endpoint name.
maygup01 0:11cc2b7889af 126 */
maygup01 0:11cc2b7889af 127 void update_endpoint(const String &name);
maygup01 0:11cc2b7889af 128
maygup01 0:11cc2b7889af 129 /**
maygup01 0:11cc2b7889af 130 * @brief Updates domain.
maygup01 0:11cc2b7889af 131 */
maygup01 0:11cc2b7889af 132 void update_domain(const String &domain);
maygup01 0:11cc2b7889af 133
maygup01 0:11cc2b7889af 134 /**
maygup01 0:11cc2b7889af 135 * @brief Creates the NSDL structure for the registered objectlist.
maygup01 0:11cc2b7889af 136 * @param list, List of objects implementing the M2MBase interface to be registered.
maygup01 0:11cc2b7889af 137 * @return true if structure created successfully else false.
maygup01 0:11cc2b7889af 138 */
maygup01 0:11cc2b7889af 139 bool create_nsdl_list_structure(const M2MBaseList &list);
maygup01 0:11cc2b7889af 140
maygup01 0:11cc2b7889af 141 /**
maygup01 0:11cc2b7889af 142 * @brief Removed the NSDL resource for the given resource.
maygup01 0:11cc2b7889af 143 * @param base, Resource to be removed.
maygup01 0:11cc2b7889af 144 * @return true if removed successfully else false.
maygup01 0:11cc2b7889af 145 */
maygup01 0:11cc2b7889af 146 bool remove_nsdl_resource(M2MBase *base);
maygup01 0:11cc2b7889af 147
maygup01 0:11cc2b7889af 148 /**
maygup01 0:11cc2b7889af 149 * @brief Creates the bootstrap object.
maygup01 0:11cc2b7889af 150 * @param address Bootstrap address.
maygup01 0:11cc2b7889af 151 * @return true if created and sent successfully else false.
maygup01 0:11cc2b7889af 152 */
maygup01 0:11cc2b7889af 153 bool create_bootstrap_resource(sn_nsdl_addr_s *address);
maygup01 0:11cc2b7889af 154
maygup01 0:11cc2b7889af 155 /**
maygup01 0:11cc2b7889af 156 * @brief Sets the register message to the server.
maygup01 0:11cc2b7889af 157 * @param address M2MServer address.
maygup01 0:11cc2b7889af 158 * @param address_length M2MServer address length.
maygup01 0:11cc2b7889af 159 * @param port M2MServer port.
maygup01 0:11cc2b7889af 160 * @param address_type IP Address type.
maygup01 0:11cc2b7889af 161 */
maygup01 0:11cc2b7889af 162 void set_server_address(uint8_t* address,
maygup01 0:11cc2b7889af 163 uint8_t address_length,
maygup01 0:11cc2b7889af 164 const uint16_t port,
maygup01 0:11cc2b7889af 165 sn_nsdl_addr_type_e address_type);
maygup01 0:11cc2b7889af 166 /**
maygup01 0:11cc2b7889af 167 * @brief Sends the register message to the server.
maygup01 0:11cc2b7889af 168 * @return true if register sent successfully else false.
maygup01 0:11cc2b7889af 169 */
maygup01 0:11cc2b7889af 170 bool send_register_message();
maygup01 0:11cc2b7889af 171
maygup01 0:11cc2b7889af 172 /**
maygup01 0:11cc2b7889af 173 * @brief Sends the CoAP request to the server.
maygup01 0:11cc2b7889af 174 * @type Download type.
maygup01 0:11cc2b7889af 175 * @uri Uri path to the data.
maygup01 0:11cc2b7889af 176 * @msg_code CoAP message code of request to send.
maygup01 0:11cc2b7889af 177 * @offset Data offset.
maygup01 0:11cc2b7889af 178 * @async In async mode application must call this API again with the updated offset.
maygup01 0:11cc2b7889af 179 * If set to false then client will automatically download the whole package.
maygup01 0:11cc2b7889af 180 * @token The token to use for the request, 0 value will generate new token.
maygup01 0:11cc2b7889af 181 * @payload_len Length of payload buffer.
maygup01 0:11cc2b7889af 182 * @payload_ptr Pointer to payload buffer.
maygup01 0:11cc2b7889af 183 * @request_data_cb Callback which is triggered once there is data available.
maygup01 0:11cc2b7889af 184 * @request_error_cb Callback which is trigged in case of any error.
maygup01 0:11cc2b7889af 185 * @context Application context.
maygup01 0:11cc2b7889af 186 */
maygup01 0:11cc2b7889af 187 void send_request(DownloadType type,
maygup01 0:11cc2b7889af 188 const char *uri,
maygup01 0:11cc2b7889af 189 const sn_coap_msg_code_e msg_code,
maygup01 0:11cc2b7889af 190 const size_t offset,
maygup01 0:11cc2b7889af 191 const bool async,
maygup01 0:11cc2b7889af 192 uint32_t token,
maygup01 0:11cc2b7889af 193 const uint16_t payload_len,
maygup01 0:11cc2b7889af 194 uint8_t *payload_ptr,
maygup01 0:11cc2b7889af 195 request_data_cb data_cb,
maygup01 0:11cc2b7889af 196 request_error_cb error_cb,
maygup01 0:11cc2b7889af 197 void *context);
maygup01 0:11cc2b7889af 198
maygup01 0:11cc2b7889af 199 /**
maygup01 0:11cc2b7889af 200 * @brief Sends the update registration message to the server.
maygup01 0:11cc2b7889af 201 * @param lifetime, Updated lifetime value in seconds.
maygup01 0:11cc2b7889af 202 * @return true if sent successfully else false.
maygup01 0:11cc2b7889af 203 *
maygup01 0:11cc2b7889af 204 */
maygup01 0:11cc2b7889af 205 bool send_update_registration(const uint32_t lifetime = 0);
maygup01 0:11cc2b7889af 206
maygup01 0:11cc2b7889af 207 /**
maygup01 0:11cc2b7889af 208 * @brief Sends unregister message to the server.
maygup01 0:11cc2b7889af 209 * @return true if unregister sent successfully else false.
maygup01 0:11cc2b7889af 210 */
maygup01 0:11cc2b7889af 211 bool send_unregister_message();
maygup01 0:11cc2b7889af 212
maygup01 0:11cc2b7889af 213 /**
maygup01 0:11cc2b7889af 214 * @brief Memory Allocation required for libCoap.
maygup01 0:11cc2b7889af 215 * @param size, Size of memory to be reserved.
maygup01 0:11cc2b7889af 216 */
maygup01 0:11cc2b7889af 217 static void* memory_alloc(uint32_t size);
maygup01 0:11cc2b7889af 218
maygup01 0:11cc2b7889af 219 /**
maygup01 0:11cc2b7889af 220 * @brief Memory free functions required for libCoap
maygup01 0:11cc2b7889af 221 * @param ptr, Object whose memory needs to be freed.
maygup01 0:11cc2b7889af 222 */
maygup01 0:11cc2b7889af 223 static void memory_free(void *ptr);
maygup01 0:11cc2b7889af 224
maygup01 0:11cc2b7889af 225 /**
maygup01 0:11cc2b7889af 226 * @brief Callback from nsdl library to inform the data is ready
maygup01 0:11cc2b7889af 227 * to be sent to server.
maygup01 0:11cc2b7889af 228 * @param nsdl_handle, Handler for the nsdl structure for this endpoint
maygup01 0:11cc2b7889af 229 * @param protocol, Protocol format of the data
maygup01 0:11cc2b7889af 230 * @param data, Data to be sent.
maygup01 0:11cc2b7889af 231 * @param data_len, Size of the data to be sent
maygup01 0:11cc2b7889af 232 * @param address, server address where data has to be sent.
maygup01 0:11cc2b7889af 233 * @return 1 if successful else 0.
maygup01 0:11cc2b7889af 234 */
maygup01 0:11cc2b7889af 235 uint8_t send_to_server_callback(struct nsdl_s * nsdl_handle,
maygup01 0:11cc2b7889af 236 sn_nsdl_capab_e protocol,
maygup01 0:11cc2b7889af 237 uint8_t *data,
maygup01 0:11cc2b7889af 238 uint16_t data_len,
maygup01 0:11cc2b7889af 239 sn_nsdl_addr_s *address);
maygup01 0:11cc2b7889af 240
maygup01 0:11cc2b7889af 241 /**
maygup01 0:11cc2b7889af 242 * @brief Callback from nsdl library to inform the data which is
maygup01 0:11cc2b7889af 243 * received from server for the client has been converted to coap message.
maygup01 0:11cc2b7889af 244 * @param nsdl_handle, Handler for the nsdl structure for this endpoint
maygup01 0:11cc2b7889af 245 * @param coap_header, Coap message formed from data.
maygup01 0:11cc2b7889af 246 * @param address, Server address from where the data is received.
maygup01 0:11cc2b7889af 247 * @return 1 if successful else 0.
maygup01 0:11cc2b7889af 248 */
maygup01 0:11cc2b7889af 249 uint8_t received_from_server_callback(struct nsdl_s * nsdl_handle,
maygup01 0:11cc2b7889af 250 sn_coap_hdr_s *coap_header,
maygup01 0:11cc2b7889af 251 sn_nsdl_addr_s *address);
maygup01 0:11cc2b7889af 252
maygup01 0:11cc2b7889af 253 /**
maygup01 0:11cc2b7889af 254 * @brief Callback from nsdl library to inform the data which is
maygup01 0:11cc2b7889af 255 * received from server for the resources has been converted to coap message.
maygup01 0:11cc2b7889af 256 * @param nsdl_handle, Handler for the nsdl resource structure for this endpoint..
maygup01 0:11cc2b7889af 257 * @param coap_header, Coap message formed from data.
maygup01 0:11cc2b7889af 258 * @param address, Server address from where the data is received.
maygup01 0:11cc2b7889af 259 * @param nsdl_capab, Protocol for the message, currently only coap is supported.
maygup01 0:11cc2b7889af 260 * @return 1 if successful else 0.
maygup01 0:11cc2b7889af 261 */
maygup01 0:11cc2b7889af 262 uint8_t resource_callback(struct nsdl_s *nsdl_handle, sn_coap_hdr_s *coap,
maygup01 0:11cc2b7889af 263 sn_nsdl_addr_s *address,
maygup01 0:11cc2b7889af 264 sn_nsdl_capab_e nsdl_capab);
maygup01 0:11cc2b7889af 265
maygup01 0:11cc2b7889af 266 /**
maygup01 0:11cc2b7889af 267 * @brief Callback from event loop for handling CoAP messages received from server for the resources
maygup01 0:11cc2b7889af 268 * that has been converted to coap message.
maygup01 0:11cc2b7889af 269 * @param coap_header, Coap message formed from data.
maygup01 0:11cc2b7889af 270 * @param address, Server address from where the data is received.
maygup01 0:11cc2b7889af 271 * @return 0 if successful else 1.
maygup01 0:11cc2b7889af 272 */
maygup01 0:11cc2b7889af 273 uint8_t resource_callback_handle_event(sn_coap_hdr_s *coap,
maygup01 0:11cc2b7889af 274 sn_nsdl_addr_s *address);
maygup01 0:11cc2b7889af 275
maygup01 0:11cc2b7889af 276
maygup01 0:11cc2b7889af 277 /**
maygup01 0:11cc2b7889af 278 * @brief Callback when there is data received from server and needs to be processed.
maygup01 0:11cc2b7889af 279 * @param data, data received from server.
maygup01 0:11cc2b7889af 280 * @param data_size, data size received from server.
maygup01 0:11cc2b7889af 281 * @param addres, address structure of the server.
maygup01 0:11cc2b7889af 282 * @return true if successfully processed else false.
maygup01 0:11cc2b7889af 283 */
maygup01 0:11cc2b7889af 284 bool process_received_data(uint8_t *data,
maygup01 0:11cc2b7889af 285 uint16_t data_size,
maygup01 0:11cc2b7889af 286 sn_nsdl_addr_s *address);
maygup01 0:11cc2b7889af 287
maygup01 0:11cc2b7889af 288 /**
maygup01 0:11cc2b7889af 289 * @brief Stops all the timers in case there is any errors.
maygup01 0:11cc2b7889af 290 */
maygup01 0:11cc2b7889af 291 void stop_timers();
maygup01 0:11cc2b7889af 292
maygup01 0:11cc2b7889af 293 /**
maygup01 0:11cc2b7889af 294 * @brief Returns nsdl handle.
maygup01 0:11cc2b7889af 295 * @return ndsl handle
maygup01 0:11cc2b7889af 296 */
maygup01 0:11cc2b7889af 297 nsdl_s* get_nsdl_handle() const;
maygup01 0:11cc2b7889af 298
maygup01 0:11cc2b7889af 299 /**
maygup01 0:11cc2b7889af 300 * @brief Get endpoint name
maygup01 0:11cc2b7889af 301 * @return endpoint name
maygup01 0:11cc2b7889af 302 */
maygup01 0:11cc2b7889af 303 const String& endpoint_name() const;
maygup01 0:11cc2b7889af 304
maygup01 0:11cc2b7889af 305 /**
maygup01 0:11cc2b7889af 306 * @brief Get internal endpoint name
maygup01 0:11cc2b7889af 307 * @return internal endpoint name
maygup01 0:11cc2b7889af 308 */
maygup01 0:11cc2b7889af 309 const String internal_endpoint_name() const;
maygup01 0:11cc2b7889af 310
maygup01 0:11cc2b7889af 311 /**
maygup01 0:11cc2b7889af 312 * @brief Set server address
maygup01 0:11cc2b7889af 313 * @param server_address, Bootstrap or M2M server address.
maygup01 0:11cc2b7889af 314 */
maygup01 0:11cc2b7889af 315 void set_server_address(const char *server_address);
maygup01 0:11cc2b7889af 316
maygup01 0:11cc2b7889af 317 /**
maygup01 0:11cc2b7889af 318 * @brief Remove an object from the list kept by the NSDLInteface.
maygup01 0:11cc2b7889af 319 * Does not call delete on the object.
maygup01 0:11cc2b7889af 320 */
maygup01 0:11cc2b7889af 321 bool remove_object_from_list(M2MBase *base);
maygup01 0:11cc2b7889af 322
maygup01 0:11cc2b7889af 323 /*
maygup01 0:11cc2b7889af 324 * @brief Get NSDL timer.
maygup01 0:11cc2b7889af 325 * @return NSDL execution timer.
maygup01 0:11cc2b7889af 326 */
maygup01 0:11cc2b7889af 327 M2MTimer &get_nsdl_execution_timer();
maygup01 0:11cc2b7889af 328
maygup01 0:11cc2b7889af 329 /**
maygup01 0:11cc2b7889af 330 * @brief Get unregister state.
maygup01 0:11cc2b7889af 331 * @return Is unregistration ongoing.
maygup01 0:11cc2b7889af 332 */
maygup01 0:11cc2b7889af 333 bool is_unregister_ongoing() const;
maygup01 0:11cc2b7889af 334
maygup01 0:11cc2b7889af 335 /**
maygup01 0:11cc2b7889af 336 * @brief Get update register state.
maygup01 0:11cc2b7889af 337 * @return Is updare registration ongoing.
maygup01 0:11cc2b7889af 338 */
maygup01 0:11cc2b7889af 339 bool is_update_register_ongoing() const;
maygup01 0:11cc2b7889af 340
maygup01 0:11cc2b7889af 341 /**
maygup01 0:11cc2b7889af 342 * @brief Starts the NSDL execution timer.
maygup01 0:11cc2b7889af 343 */
maygup01 0:11cc2b7889af 344 void start_nsdl_execution_timer();
maygup01 0:11cc2b7889af 345
maygup01 0:11cc2b7889af 346 /**
maygup01 0:11cc2b7889af 347 * @brief Returns security object.
maygup01 0:11cc2b7889af 348 * @return M2MSecurity object, contains lwm2m server information.
maygup01 0:11cc2b7889af 349 */
maygup01 0:11cc2b7889af 350 M2MSecurity* get_security_object();
maygup01 0:11cc2b7889af 351
maygup01 0:11cc2b7889af 352 /**
maygup01 0:11cc2b7889af 353 * @brief Returns auto-observation token.
maygup01 0:11cc2b7889af 354 * @param path, Resource path, used for searching the right object.
maygup01 0:11cc2b7889af 355 * @param token[OUT], Token data.
maygup01 0:11cc2b7889af 356 * @return Length of the token if found otherwise 0.
maygup01 0:11cc2b7889af 357 */
maygup01 0:11cc2b7889af 358 uint8_t find_auto_obs_token(const char *path, uint8_t *token) const;
maygup01 0:11cc2b7889af 359
maygup01 0:11cc2b7889af 360 /**
maygup01 0:11cc2b7889af 361 * @brief Set custom uri query paramaters used in LWM2M registration.
maygup01 0:11cc2b7889af 362 * @uri_query_params Uri query params. Parameters must be in key-value pair format:
maygup01 0:11cc2b7889af 363 * "a=100&b=200". Maximum length can be up to 64 bytes.
maygup01 0:11cc2b7889af 364 * @return False if maximum length exceeded otherwise True.
maygup01 0:11cc2b7889af 365 */
maygup01 0:11cc2b7889af 366 bool set_uri_query_parameters(const char *uri_query_params);
maygup01 0:11cc2b7889af 367
maygup01 0:11cc2b7889af 368 /**
maygup01 0:11cc2b7889af 369 * @brief Clears the sent blockwise message list in CoAP library.
maygup01 0:11cc2b7889af 370 */
maygup01 0:11cc2b7889af 371 void clear_sent_blockwise_messages();
maygup01 0:11cc2b7889af 372
maygup01 0:11cc2b7889af 373 /**
maygup01 0:11cc2b7889af 374 * @brief Clears the received blockwise message list in CoAP library.
maygup01 0:11cc2b7889af 375 */
maygup01 0:11cc2b7889af 376 void clear_received_blockwise_messages();
maygup01 0:11cc2b7889af 377
maygup01 0:11cc2b7889af 378 /**
maygup01 0:11cc2b7889af 379 * @brief Send next notification message.
maygup01 0:11cc2b7889af 380 */
maygup01 0:11cc2b7889af 381 void send_next_notification(bool clear_token);
maygup01 0:11cc2b7889af 382
maygup01 0:11cc2b7889af 383 /**
maygup01 0:11cc2b7889af 384 * @brief Store the "BS finished" response id.
maygup01 0:11cc2b7889af 385 * @param msg_id Response id.
maygup01 0:11cc2b7889af 386 */
maygup01 0:11cc2b7889af 387 void store_bs_finished_response_id(uint16_t msg_id);
maygup01 0:11cc2b7889af 388
maygup01 0:11cc2b7889af 389 /**
maygup01 0:11cc2b7889af 390 * @brief Store the registration state.
maygup01 0:11cc2b7889af 391 * @param registered Registered to lwm2m server or not.
maygup01 0:11cc2b7889af 392 */
maygup01 0:11cc2b7889af 393 void set_registration_status(bool registered);
maygup01 0:11cc2b7889af 394
maygup01 0:11cc2b7889af 395 /**
maygup01 0:11cc2b7889af 396 * @brief Handle incoming bootstrap PUT message.
maygup01 0:11cc2b7889af 397 * @param coap_header, Received CoAP message
maygup01 0:11cc2b7889af 398 * @param address, Server address
maygup01 0:11cc2b7889af 399 */
maygup01 0:11cc2b7889af 400 void handle_bootstrap_put_message(sn_coap_hdr_s *coap_header, sn_nsdl_addr_s *address);
maygup01 0:11cc2b7889af 401
maygup01 0:11cc2b7889af 402 /**
maygup01 0:11cc2b7889af 403 * @brief Handle bootstrap finish acknowledgement.
maygup01 0:11cc2b7889af 404 */
maygup01 0:11cc2b7889af 405 void handle_bootstrap_finish_ack(uint16_t msg_id);
maygup01 0:11cc2b7889af 406
maygup01 0:11cc2b7889af 407 /**
maygup01 0:11cc2b7889af 408 * @brief Returns total retransmission time
maygup01 0:11cc2b7889af 409 * @resend_count Resend count
maygup01 0:11cc2b7889af 410 * @return Total retransmission time
maygup01 0:11cc2b7889af 411 */
maygup01 0:11cc2b7889af 412 uint32_t total_retransmission_time(uint32_t resend_count);
maygup01 0:11cc2b7889af 413
maygup01 0:11cc2b7889af 414 /**
maygup01 0:11cc2b7889af 415 * @brief Returns CoAP retransmission count
maygup01 0:11cc2b7889af 416 * @return CoAP retransmission count
maygup01 0:11cc2b7889af 417 */
maygup01 0:11cc2b7889af 418 uint8_t get_resend_count();
maygup01 0:11cc2b7889af 419
maygup01 0:11cc2b7889af 420 /**
maygup01 0:11cc2b7889af 421 * @brief Mark request to be resend again after network break
maygup01 0:11cc2b7889af 422 * @param token, Message token
maygup01 0:11cc2b7889af 423 * @param token_len, Message token length
maygup01 0:11cc2b7889af 424 */
maygup01 0:11cc2b7889af 425 void set_request_context_to_be_resend(uint8_t *token, uint8_t token_len);
maygup01 0:11cc2b7889af 426
maygup01 0:11cc2b7889af 427 /**
maygup01 0:11cc2b7889af 428 * @brief Create a new time when to send CoAP ping.
maygup01 0:11cc2b7889af 429 */
maygup01 0:11cc2b7889af 430 void calculate_new_coap_ping_send_time();
maygup01 0:11cc2b7889af 431
maygup01 0:11cc2b7889af 432 protected: // from M2MTimerObserver
maygup01 0:11cc2b7889af 433
maygup01 0:11cc2b7889af 434 virtual void timer_expired(M2MTimerObserver::Type type);
maygup01 0:11cc2b7889af 435
maygup01 0:11cc2b7889af 436 protected: // from M2MObservationHandler
maygup01 0:11cc2b7889af 437
maygup01 0:11cc2b7889af 438 virtual bool observation_to_be_sent(M2MBase *object,
maygup01 0:11cc2b7889af 439 uint16_t obs_number,
maygup01 0:11cc2b7889af 440 const m2m::Vector<uint16_t> &changed_instance_ids,
maygup01 0:11cc2b7889af 441 bool send_object = false);
maygup01 0:11cc2b7889af 442
maygup01 0:11cc2b7889af 443 virtual void resource_to_be_deleted(M2MBase* base);
maygup01 0:11cc2b7889af 444
maygup01 0:11cc2b7889af 445 virtual void value_updated(M2MBase *base);
maygup01 0:11cc2b7889af 446
maygup01 0:11cc2b7889af 447 virtual void remove_object(M2MBase *object);
maygup01 0:11cc2b7889af 448 #ifndef DISABLE_DELAYED_RESPONSE
maygup01 0:11cc2b7889af 449 virtual void send_delayed_response(M2MBase *base);
maygup01 0:11cc2b7889af 450 #endif //DISABLE_DELAYED_RESPONSE
maygup01 0:11cc2b7889af 451
maygup01 0:11cc2b7889af 452 #ifdef ENABLE_ASYNC_REST_RESPONSE
maygup01 0:11cc2b7889af 453 virtual void send_asynchronous_response(M2MBase *base,
maygup01 0:11cc2b7889af 454 const uint8_t *payload,
maygup01 0:11cc2b7889af 455 size_t payload_len,
maygup01 0:11cc2b7889af 456 const uint8_t* token,
maygup01 0:11cc2b7889af 457 const uint8_t token_len,
maygup01 0:11cc2b7889af 458 coap_response_code_e code);
maygup01 0:11cc2b7889af 459 #endif //ENABLE_ASYNC_REST_RESPONSE
maygup01 0:11cc2b7889af 460
maygup01 0:11cc2b7889af 461 private:
maygup01 0:11cc2b7889af 462
maygup01 0:11cc2b7889af 463 /**
maygup01 0:11cc2b7889af 464 * Enum defining an LWM2M object type.
maygup01 0:11cc2b7889af 465 */
maygup01 0:11cc2b7889af 466 typedef enum {
maygup01 0:11cc2b7889af 467 SECURITY = 0x00,
maygup01 0:11cc2b7889af 468 SERVER = 0x01,
maygup01 0:11cc2b7889af 469 DEVICE = 0x02
maygup01 0:11cc2b7889af 470 }ObjectType;
maygup01 0:11cc2b7889af 471
maygup01 0:11cc2b7889af 472 /**
maygup01 0:11cc2b7889af 473 * @brief Initializes all the nsdl library component to be usable.
maygup01 0:11cc2b7889af 474 * @return true if initialization is successful else false.
maygup01 0:11cc2b7889af 475 */
maygup01 0:11cc2b7889af 476 bool initialize();
maygup01 0:11cc2b7889af 477
maygup01 0:11cc2b7889af 478 bool add_object_to_list(M2MBase *base);
maygup01 0:11cc2b7889af 479
maygup01 0:11cc2b7889af 480 bool create_nsdl_structure(M2MBase *base);
maygup01 0:11cc2b7889af 481
maygup01 0:11cc2b7889af 482 #ifdef MBED_CLOUD_CLIENT_EDGE_EXTENSION
maygup01 0:11cc2b7889af 483 bool create_nsdl_endpoint_structure(M2MEndpoint *endpoint);
maygup01 0:11cc2b7889af 484 #endif
maygup01 0:11cc2b7889af 485
maygup01 0:11cc2b7889af 486 bool create_nsdl_object_structure(M2MObject *object);
maygup01 0:11cc2b7889af 487
maygup01 0:11cc2b7889af 488 bool create_nsdl_object_instance_structure(M2MObjectInstance *object_instance);
maygup01 0:11cc2b7889af 489
maygup01 0:11cc2b7889af 490 bool create_nsdl_resource_structure(M2MResource *resource,
maygup01 0:11cc2b7889af 491 bool multiple_instances = false);
maygup01 0:11cc2b7889af 492
maygup01 0:11cc2b7889af 493 bool create_nsdl_resource(M2MBase *base);
maygup01 0:11cc2b7889af 494
maygup01 0:11cc2b7889af 495 static String coap_to_string(const uint8_t *coap_data_ptr,
maygup01 0:11cc2b7889af 496 int coap_data_ptr_length);
maygup01 0:11cc2b7889af 497
maygup01 0:11cc2b7889af 498 void execute_nsdl_process_loop();
maygup01 0:11cc2b7889af 499
maygup01 0:11cc2b7889af 500 uint64_t registration_time() const;
maygup01 0:11cc2b7889af 501
maygup01 0:11cc2b7889af 502 M2MBase* find_resource(const String &object) const;
maygup01 0:11cc2b7889af 503
maygup01 0:11cc2b7889af 504 #ifdef MBED_CLOUD_CLIENT_EDGE_EXTENSION
maygup01 0:11cc2b7889af 505 M2MBase* find_resource(const M2MEndpoint *endpoint,
maygup01 0:11cc2b7889af 506 const String &object_name) const;
maygup01 0:11cc2b7889af 507 #endif
maygup01 0:11cc2b7889af 508
maygup01 0:11cc2b7889af 509 M2MBase* find_resource(const M2MObject *object,
maygup01 0:11cc2b7889af 510 const String &object_instance) const;
maygup01 0:11cc2b7889af 511
maygup01 0:11cc2b7889af 512 M2MBase* find_resource(const M2MObjectInstance *object_instance,
maygup01 0:11cc2b7889af 513 const String &resource_instance) const;
maygup01 0:11cc2b7889af 514
maygup01 0:11cc2b7889af 515 M2MBase* find_resource(const M2MResource *resource,
maygup01 0:11cc2b7889af 516 const String &object_name,
maygup01 0:11cc2b7889af 517 const String &resource_instance) const;
maygup01 0:11cc2b7889af 518
maygup01 0:11cc2b7889af 519 bool object_present(M2MBase *base) const;
maygup01 0:11cc2b7889af 520
maygup01 0:11cc2b7889af 521 int object_index(M2MBase *base) const;
maygup01 0:11cc2b7889af 522
maygup01 0:11cc2b7889af 523 static M2MInterface::Error interface_error(const sn_coap_hdr_s &coap_header);
maygup01 0:11cc2b7889af 524
maygup01 0:11cc2b7889af 525 void send_object_observation(M2MObject *object,
maygup01 0:11cc2b7889af 526 uint16_t obs_number,
maygup01 0:11cc2b7889af 527 const m2m::Vector<uint16_t> &changed_instance_ids,
maygup01 0:11cc2b7889af 528 bool send_object);
maygup01 0:11cc2b7889af 529
maygup01 0:11cc2b7889af 530 void send_object_instance_observation(M2MObjectInstance *object_instance,
maygup01 0:11cc2b7889af 531 uint16_t obs_number);
maygup01 0:11cc2b7889af 532
maygup01 0:11cc2b7889af 533 void send_resource_observation(M2MResource *resource, uint16_t obs_number);
maygup01 0:11cc2b7889af 534
maygup01 0:11cc2b7889af 535
maygup01 0:11cc2b7889af 536
maygup01 0:11cc2b7889af 537 /**
maygup01 0:11cc2b7889af 538 * @brief Allocate (size + 1) amount of memory, copy size bytes into
maygup01 0:11cc2b7889af 539 * it and add zero termination.
maygup01 0:11cc2b7889af 540 * @param source Source string to copy, may not be NULL.
maygup01 0:11cc2b7889af 541 * @param size The size of memory to be reserved.
maygup01 0:11cc2b7889af 542 */
maygup01 0:11cc2b7889af 543 static uint8_t* alloc_string_copy(const uint8_t* source, uint16_t size);
maygup01 0:11cc2b7889af 544
maygup01 0:11cc2b7889af 545 /**
maygup01 0:11cc2b7889af 546 * @brief Utility method to convert given lifetime int to ascii
maygup01 0:11cc2b7889af 547 * and allocate a buffer for it and set it to _endpoint->lifetime_ptr.
maygup01 0:11cc2b7889af 548 * @param lifetime A new value for lifetime.
maygup01 0:11cc2b7889af 549 */
maygup01 0:11cc2b7889af 550 void set_endpoint_lifetime_buffer(int lifetime);
maygup01 0:11cc2b7889af 551
maygup01 0:11cc2b7889af 552 /**
maygup01 0:11cc2b7889af 553 * @brief Handle bootstrap finished message.
maygup01 0:11cc2b7889af 554 * @param coap_header, Received CoAP message
maygup01 0:11cc2b7889af 555 * @param address, Server address
maygup01 0:11cc2b7889af 556 */
maygup01 0:11cc2b7889af 557 void handle_bootstrap_finished(sn_coap_hdr_s *coap_header,sn_nsdl_addr_s *address);
maygup01 0:11cc2b7889af 558
maygup01 0:11cc2b7889af 559 /**
maygup01 0:11cc2b7889af 560 * @brief Handle bootstrap delete message.
maygup01 0:11cc2b7889af 561 * @param coap_header, Received CoAP message
maygup01 0:11cc2b7889af 562 * @param address, Server address
maygup01 0:11cc2b7889af 563 */
maygup01 0:11cc2b7889af 564 void handle_bootstrap_delete(sn_coap_hdr_s *coap_header,sn_nsdl_addr_s *address);
maygup01 0:11cc2b7889af 565
maygup01 0:11cc2b7889af 566 /**
maygup01 0:11cc2b7889af 567 * @brief Parse bootstrap TLV message.
maygup01 0:11cc2b7889af 568 * @param coap_header, Received CoAP message
maygup01 0:11cc2b7889af 569 * @return True if parsing was succesful else false
maygup01 0:11cc2b7889af 570 */
maygup01 0:11cc2b7889af 571 bool parse_bootstrap_message(sn_coap_hdr_s *coap_header, M2MNsdlInterface::ObjectType lwm2m_object_type);
maygup01 0:11cc2b7889af 572
maygup01 0:11cc2b7889af 573 /**
maygup01 0:11cc2b7889af 574 * @brief Parse bootstrap TLV message.
maygup01 0:11cc2b7889af 575 * @param coap_header, Received CoAP message
maygup01 0:11cc2b7889af 576 * @return True if parsing was succesful else false
maygup01 0:11cc2b7889af 577 */
maygup01 0:11cc2b7889af 578 bool validate_security_object();
maygup01 0:11cc2b7889af 579
maygup01 0:11cc2b7889af 580 /**
maygup01 0:11cc2b7889af 581 * @brief Handle bootstrap errors.
maygup01 0:11cc2b7889af 582 * @param reason, Reason for Bootstrap failure.
maygup01 0:11cc2b7889af 583 * @param wait, True if need to wait that ACK has been sent.
maygup01 0:11cc2b7889af 584 * False if reconnection can start immediately.
maygup01 0:11cc2b7889af 585 */
maygup01 0:11cc2b7889af 586 void handle_bootstrap_error(const char *reason, bool wait);
maygup01 0:11cc2b7889af 587
maygup01 0:11cc2b7889af 588 /**
maygup01 0:11cc2b7889af 589 * @brief Handle different coap errors.
maygup01 0:11cc2b7889af 590 * @param coap_header, CoAP structure.
maygup01 0:11cc2b7889af 591 * @return Error reason.
maygup01 0:11cc2b7889af 592 */
maygup01 0:11cc2b7889af 593 static const char *coap_error(const sn_coap_hdr_s &coap_header);
maygup01 0:11cc2b7889af 594
maygup01 0:11cc2b7889af 595 /**
maygup01 0:11cc2b7889af 596 * @brief Claim
maygup01 0:11cc2b7889af 597 */
maygup01 0:11cc2b7889af 598 void claim_mutex();
maygup01 0:11cc2b7889af 599
maygup01 0:11cc2b7889af 600 /**
maygup01 0:11cc2b7889af 601 * @brief Release
maygup01 0:11cc2b7889af 602 */
maygup01 0:11cc2b7889af 603 void release_mutex();
maygup01 0:11cc2b7889af 604
maygup01 0:11cc2b7889af 605 /**
maygup01 0:11cc2b7889af 606 * @brief Change operation mode of every resource.
maygup01 0:11cc2b7889af 607 * @param object, Object to be updated.
maygup01 0:11cc2b7889af 608 * @return operation, New operation mode.
maygup01 0:11cc2b7889af 609 */
maygup01 0:11cc2b7889af 610 void change_operation_mode(M2MObject *object, M2MBase::Operation operation);
maygup01 0:11cc2b7889af 611
maygup01 0:11cc2b7889af 612 /**
maygup01 0:11cc2b7889af 613 * @brief Parse URI query parameters and pass those to nsdl-c.
maygup01 0:11cc2b7889af 614 * @return True if parsing success otherwise False
maygup01 0:11cc2b7889af 615 */
maygup01 0:11cc2b7889af 616 bool parse_and_send_uri_query_parameters();
maygup01 0:11cc2b7889af 617
maygup01 0:11cc2b7889af 618 /**
maygup01 0:11cc2b7889af 619 * @brief Callback function that triggers the registration update call.
maygup01 0:11cc2b7889af 620 * @param argument, Arguments part of the POST request.
maygup01 0:11cc2b7889af 621 */
maygup01 0:11cc2b7889af 622 void update_trigger_callback(void *argument);
maygup01 0:11cc2b7889af 623
maygup01 0:11cc2b7889af 624 bool lifetime_value_changed() const;
maygup01 0:11cc2b7889af 625
maygup01 0:11cc2b7889af 626 void execute_notification_delivery_status_cb(M2MBase* object, int32_t msgid);
maygup01 0:11cc2b7889af 627
maygup01 0:11cc2b7889af 628 bool is_response_to_request(const sn_coap_hdr_s *coap_header,
maygup01 0:11cc2b7889af 629 struct request_context_s &get_data);
maygup01 0:11cc2b7889af 630
maygup01 0:11cc2b7889af 631 void free_request_context_list(const sn_coap_hdr_s *coap_header, bool call_error_cb, request_error_t error_code = FAILED_TO_SEND_MSG);
maygup01 0:11cc2b7889af 632
maygup01 0:11cc2b7889af 633 void free_response_list();
maygup01 0:11cc2b7889af 634
maygup01 0:11cc2b7889af 635 void remove_item_from_response_list(const char* uri_path, const int32_t msg_id);
maygup01 0:11cc2b7889af 636
maygup01 0:11cc2b7889af 637 #if !defined(DISABLE_DELAYED_RESPONSE) || defined(ENABLE_ASYNC_REST_RESPONSE)
maygup01 0:11cc2b7889af 638 void remove_items_from_response_list_for_uri(const char* uri_path);
maygup01 0:11cc2b7889af 639 #endif
maygup01 0:11cc2b7889af 640 /**
maygup01 0:11cc2b7889af 641 * @brief Send next notification for object, return true if notification sent, false
maygup01 0:11cc2b7889af 642 * if no notification to send or send already in progress.
maygup01 0:11cc2b7889af 643 * @param object, M2MObject whose next notification should be sent
maygup01 0:11cc2b7889af 644 * @param clear_token, Flag to indicate whether observation token should be cleared.
maygup01 0:11cc2b7889af 645 * @return True if notification sent, false otherwise or if send already in progress
maygup01 0:11cc2b7889af 646 */
maygup01 0:11cc2b7889af 647 bool send_next_notification_for_object(M2MObject& object, bool clear_token);
maygup01 0:11cc2b7889af 648
maygup01 0:11cc2b7889af 649 static char* parse_uri_query_parameters(char* uri);
maygup01 0:11cc2b7889af 650
maygup01 0:11cc2b7889af 651 void send_coap_ping();
maygup01 0:11cc2b7889af 652
maygup01 0:11cc2b7889af 653 void send_empty_ack(const sn_coap_hdr_s *header, sn_nsdl_addr_s *address);
maygup01 0:11cc2b7889af 654
maygup01 0:11cc2b7889af 655 struct M2MNsdlInterface::nsdl_coap_data_s* create_coap_event_data(sn_coap_hdr_s *received_coap_header,
maygup01 0:11cc2b7889af 656 sn_nsdl_addr_s *address,
maygup01 0:11cc2b7889af 657 struct nsdl_s *nsdl_handle,
maygup01 0:11cc2b7889af 658 uint8_t coap_msg_code = COAP_MSG_CODE_EMPTY);
maygup01 0:11cc2b7889af 659
maygup01 0:11cc2b7889af 660 void handle_register_response(const sn_coap_hdr_s *coap_header);
maygup01 0:11cc2b7889af 661
maygup01 0:11cc2b7889af 662 void handle_unregister_response(const sn_coap_hdr_s *coap_header);
maygup01 0:11cc2b7889af 663
maygup01 0:11cc2b7889af 664 void handle_register_update_response(const sn_coap_hdr_s *coap_header);
maygup01 0:11cc2b7889af 665
maygup01 0:11cc2b7889af 666 void handle_request_response(const sn_coap_hdr_s *coap_header, struct request_context_s *request_context);
maygup01 0:11cc2b7889af 667
maygup01 0:11cc2b7889af 668 void handle_bootstrap_response(const sn_coap_hdr_s *coap_header);
maygup01 0:11cc2b7889af 669
maygup01 0:11cc2b7889af 670 void handle_message_delivered(M2MBase *base, const M2MBase::MessageType type);
maygup01 0:11cc2b7889af 671
maygup01 0:11cc2b7889af 672 void handle_empty_ack(const sn_coap_hdr_s *coap_header, bool is_bootstrap_msg);
maygup01 0:11cc2b7889af 673
maygup01 0:11cc2b7889af 674 bool handle_post_response(sn_coap_hdr_s *coap_header,
maygup01 0:11cc2b7889af 675 sn_nsdl_addr_s *address,
maygup01 0:11cc2b7889af 676 sn_coap_hdr_s *&coap_response,
maygup01 0:11cc2b7889af 677 M2MObjectInstance *&obj_instance,
maygup01 0:11cc2b7889af 678 bool is_bootstrap_msg);
maygup01 0:11cc2b7889af 679
maygup01 0:11cc2b7889af 680 void set_retransmission_parameters();
maygup01 0:11cc2b7889af 681
maygup01 0:11cc2b7889af 682 void send_pending_request();
maygup01 0:11cc2b7889af 683
maygup01 0:11cc2b7889af 684 void store_to_response_list(const char *uri, int32_t msg_id, M2MBase::MessageType type);
maygup01 0:11cc2b7889af 685
maygup01 0:11cc2b7889af 686 struct coap_response_s* find_response(int32_t msg_id);
maygup01 0:11cc2b7889af 687
maygup01 0:11cc2b7889af 688 #if !defined(DISABLE_DELAYED_RESPONSE) || defined(ENABLE_ASYNC_REST_RESPONSE)
maygup01 0:11cc2b7889af 689 struct coap_response_s* find_delayed_response(const char* uri_path,
maygup01 0:11cc2b7889af 690 const M2MBase::MessageType type,
maygup01 0:11cc2b7889af 691 int32_t message_id = UNDEFINED_MSG_ID);
maygup01 0:11cc2b7889af 692
maygup01 0:11cc2b7889af 693 bool handle_delayed_response_store(const char* uri_path,
maygup01 0:11cc2b7889af 694 sn_coap_hdr_s* received_coap,
maygup01 0:11cc2b7889af 695 sn_nsdl_addr_s *address,
maygup01 0:11cc2b7889af 696 const M2MBase::MessageType message_type);
maygup01 0:11cc2b7889af 697 #endif
maygup01 0:11cc2b7889af 698
maygup01 0:11cc2b7889af 699 void failed_to_send_request(request_context_s *request, const sn_coap_hdr_s *coap_header);
maygup01 0:11cc2b7889af 700
maygup01 0:11cc2b7889af 701 bool coap_ping_in_process() const;
maygup01 0:11cc2b7889af 702
maygup01 0:11cc2b7889af 703 void remove_ping_from_response_list();
maygup01 0:11cc2b7889af 704
maygup01 0:11cc2b7889af 705 #ifdef ENABLE_ASYNC_REST_RESPONSE
maygup01 0:11cc2b7889af 706 static M2MBase::Operation operation_for_message_code(sn_coap_msg_code_e code);
maygup01 0:11cc2b7889af 707 #endif // ENABLE_ASYNC_REST_RESPONSE
maygup01 0:11cc2b7889af 708
maygup01 0:11cc2b7889af 709 private:
maygup01 0:11cc2b7889af 710 M2MNsdlObserver &_observer;
maygup01 0:11cc2b7889af 711 M2MBaseList _base_list;
maygup01 0:11cc2b7889af 712 sn_nsdl_ep_parameters_s *_endpoint;
maygup01 0:11cc2b7889af 713 nsdl_s *_nsdl_handle;
maygup01 0:11cc2b7889af 714 M2MSecurity *_security; // Not owned
maygup01 0:11cc2b7889af 715 M2MServer *_server;
maygup01 0:11cc2b7889af 716 M2MTimer _nsdl_execution_timer;
maygup01 0:11cc2b7889af 717 M2MTimer _registration_timer;
maygup01 0:11cc2b7889af 718 M2MConnectionHandler &_connection_handler;
maygup01 0:11cc2b7889af 719 String _endpoint_name;
maygup01 0:11cc2b7889af 720 String _internal_endpoint_name;
maygup01 0:11cc2b7889af 721 uint32_t _counter_for_nsdl;
maygup01 0:11cc2b7889af 722 uint32_t _next_coap_ping_send_time;
maygup01 0:11cc2b7889af 723 char *_server_address; // BS or M2M address
maygup01 0:11cc2b7889af 724 request_context_list_t _request_context_list;
maygup01 0:11cc2b7889af 725 response_list_t _response_list;
maygup01 0:11cc2b7889af 726 char *_custom_uri_query_params;
maygup01 0:11cc2b7889af 727 M2MNotificationHandler *_notification_handler;
maygup01 0:11cc2b7889af 728 arm_event_storage_t _event;
maygup01 0:11cc2b7889af 729 uint16_t _auto_obs_token;
maygup01 0:11cc2b7889af 730 uint16_t _bootstrap_id;
maygup01 0:11cc2b7889af 731 static int8_t _tasklet_id;
maygup01 0:11cc2b7889af 732 uint8_t _binding_mode;
maygup01 0:11cc2b7889af 733 bool _identity_accepted;
maygup01 0:11cc2b7889af 734 bool _nsdl_execution_timer_running;
maygup01 0:11cc2b7889af 735 bool _notification_send_ongoing;
maygup01 0:11cc2b7889af 736 bool _registered;
maygup01 0:11cc2b7889af 737 bool _bootstrap_finish_ack_received;
maygup01 0:11cc2b7889af 738 M2MTimer _download_retry_timer;
maygup01 0:11cc2b7889af 739 uint64_t _download_retry_time;
maygup01 0:11cc2b7889af 740
maygup01 0:11cc2b7889af 741 friend class Test_M2MNsdlInterface;
maygup01 0:11cc2b7889af 742
maygup01 0:11cc2b7889af 743 };
maygup01 0:11cc2b7889af 744
maygup01 0:11cc2b7889af 745 #endif // M2MNSDLINTERFACE_H
maygup01 0:11cc2b7889af 746