Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FXAS21002 FXOS8700Q
m2mnsdlinterface.h
00001 /* 00002 * Copyright (c) 2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef M2MNSDLINTERFACE_H 00017 #define M2MNSDLINTERFACE_H 00018 00019 #include "ns_list.h" 00020 #include "mbed-client/m2mvector.h" 00021 #include "mbed-client/m2mconfig.h" 00022 #include "mbed-client/m2minterface.h" 00023 #include "mbed-client/m2mtimerobserver.h" 00024 #include "mbed-client/m2mobservationhandler.h" 00025 #include "mbed-client/m2mtimer.h" 00026 #include "mbed-client/m2mbase.h" 00027 #include "mbed-client/m2mserver.h" 00028 #include "include/nsdllinker.h" 00029 #include "eventOS_event.h" 00030 00031 //FORWARD DECLARARTION 00032 class M2MSecurity; 00033 class M2MObject; 00034 class M2MObjectInstance; 00035 class M2MResource; 00036 class M2MResourceInstance; 00037 class M2MNsdlObserver; 00038 class M2MServer; 00039 class M2MConnectionHandler; 00040 class M2MNotificationHandler; 00041 00042 const int UNDEFINED_MSG_ID = -1; 00043 00044 /** 00045 * @brief M2MNsdlInterface 00046 * Class which interacts between mbed Client C++ Library and mbed-client-c library. 00047 */ 00048 class M2MNsdlInterface : public M2MTimerObserver, 00049 public M2MObservationHandler 00050 { 00051 private: 00052 // Prevents the use of assignment operator by accident. 00053 M2MNsdlInterface& operator=( const M2MNsdlInterface& /*other*/ ); 00054 00055 // Prevents the use of copy constructor by accident 00056 M2MNsdlInterface( const M2MNsdlInterface& /*other*/ ); 00057 00058 public: 00059 00060 struct request_context_s { 00061 request_data_cb on_request_data_cb; 00062 request_error_cb on_request_error_cb; 00063 size_t received_size; 00064 uint32_t msg_token; 00065 char *uri_path; 00066 void *context; 00067 bool async_req; 00068 sn_coap_msg_code_e msg_code; 00069 bool resend; 00070 DownloadType download_type; 00071 ns_list_link_t link; 00072 }; 00073 00074 struct nsdl_coap_data_s { 00075 nsdl_s *nsdl_handle; 00076 sn_coap_hdr_s *received_coap_header; 00077 sn_nsdl_addr_s address; 00078 }; 00079 00080 struct coap_response_s { 00081 char *uri_path; 00082 int32_t msg_id; 00083 M2MBase::MessageType type; 00084 bool blockwise_used; 00085 ns_list_link_t link; 00086 }; 00087 00088 typedef NS_LIST_HEAD(request_context_s, link) request_context_list_t; 00089 00090 typedef NS_LIST_HEAD(coap_response_s, link) response_list_t; 00091 00092 /** 00093 * @brief Constructor 00094 * @param observer, Observer to pass the event callbacks from nsdl library. 00095 */ 00096 M2MNsdlInterface(M2MNsdlObserver &observer, M2MConnectionHandler &connection_handler); 00097 00098 /** 00099 * @brief Destructor 00100 */ 00101 virtual ~M2MNsdlInterface(); 00102 00103 /** 00104 * @brief Creates endpoint object for the nsdl stack. 00105 * @param endpoint_name, Endpoint name of the client. 00106 * @param endpoint_type, Endpoint type of the client. 00107 * @param life_time, Life time of the client in seconds 00108 * @param domain, Domain of the client. 00109 * @param mode, Binding mode of the client, default is UDP 00110 * @param context_address, Context address default is empty. 00111 */ 00112 void create_endpoint(const String &endpoint_name, 00113 const String &endpoint_type, 00114 const int32_t life_time, 00115 const String &domain, 00116 const uint8_t mode, 00117 const String &context_address); 00118 00119 /** 00120 * @brief Deletes the endpoint. 00121 */ 00122 void delete_endpoint(); 00123 00124 /** 00125 * @brief Updates endpoint name. 00126 */ 00127 void update_endpoint(const String &name); 00128 00129 /** 00130 * @brief Updates domain. 00131 */ 00132 void update_domain(const String &domain); 00133 00134 /** 00135 * @brief Creates the NSDL structure for the registered objectlist. 00136 * @param list, List of objects implementing the M2MBase interface to be registered. 00137 * @return true if structure created successfully else false. 00138 */ 00139 bool create_nsdl_list_structure(const M2MBaseList &list); 00140 00141 /** 00142 * @brief Removed the NSDL resource for the given resource. 00143 * @param base, Resource to be removed. 00144 * @return true if removed successfully else false. 00145 */ 00146 bool remove_nsdl_resource(M2MBase *base); 00147 00148 /** 00149 * @brief Creates the bootstrap object. 00150 * @param address Bootstrap address. 00151 * @return true if created and sent successfully else false. 00152 */ 00153 bool create_bootstrap_resource(sn_nsdl_addr_s *address); 00154 00155 /** 00156 * @brief Sets the register message to the server. 00157 * @param address M2MServer address. 00158 * @param address_length M2MServer address length. 00159 * @param port M2MServer port. 00160 * @param address_type IP Address type. 00161 */ 00162 void set_server_address(uint8_t* address, 00163 uint8_t address_length, 00164 const uint16_t port, 00165 sn_nsdl_addr_type_e address_type); 00166 /** 00167 * @brief Sends the register message to the server. 00168 * @return true if register sent successfully else false. 00169 */ 00170 bool send_register_message(); 00171 00172 /** 00173 * @brief Sends the CoAP request to the server. 00174 * @type Download type. 00175 * @uri Uri path to the data. 00176 * @msg_code CoAP message code of request to send. 00177 * @offset Data offset. 00178 * @async In async mode application must call this API again with the updated offset. 00179 * If set to false then client will automatically download the whole package. 00180 * @token The token to use for the request, 0 value will generate new token. 00181 * @payload_len Length of payload buffer. 00182 * @payload_ptr Pointer to payload buffer. 00183 * @request_data_cb Callback which is triggered once there is data available. 00184 * @request_error_cb Callback which is trigged in case of any error. 00185 * @context Application context. 00186 */ 00187 void send_request(DownloadType type, 00188 const char *uri, 00189 const sn_coap_msg_code_e msg_code, 00190 const size_t offset, 00191 const bool async, 00192 uint32_t token, 00193 const uint16_t payload_len, 00194 uint8_t *payload_ptr, 00195 request_data_cb data_cb, 00196 request_error_cb error_cb, 00197 void *context); 00198 00199 /** 00200 * @brief Sends the update registration message to the server. 00201 * @param lifetime, Updated lifetime value in seconds. 00202 * @return true if sent successfully else false. 00203 * 00204 */ 00205 bool send_update_registration(const uint32_t lifetime = 0); 00206 00207 /** 00208 * @brief Sends unregister message to the server. 00209 * @return true if unregister sent successfully else false. 00210 */ 00211 bool send_unregister_message(); 00212 00213 /** 00214 * @brief Memory Allocation required for libCoap. 00215 * @param size, Size of memory to be reserved. 00216 */ 00217 static void* memory_alloc(uint32_t size); 00218 00219 /** 00220 * @brief Memory free functions required for libCoap 00221 * @param ptr, Object whose memory needs to be freed. 00222 */ 00223 static void memory_free(void *ptr); 00224 00225 /** 00226 * @brief Callback from nsdl library to inform the data is ready 00227 * to be sent to server. 00228 * @param nsdl_handle, Handler for the nsdl structure for this endpoint 00229 * @param protocol, Protocol format of the data 00230 * @param data, Data to be sent. 00231 * @param data_len, Size of the data to be sent 00232 * @param address, server address where data has to be sent. 00233 * @return 1 if successful else 0. 00234 */ 00235 uint8_t send_to_server_callback(struct nsdl_s * nsdl_handle, 00236 sn_nsdl_capab_e protocol, 00237 uint8_t *data, 00238 uint16_t data_len, 00239 sn_nsdl_addr_s *address); 00240 00241 /** 00242 * @brief Callback from nsdl library to inform the data which is 00243 * received from server for the client has been converted to coap message. 00244 * @param nsdl_handle, Handler for the nsdl structure for this endpoint 00245 * @param coap_header, Coap message formed from data. 00246 * @param address, Server address from where the data is received. 00247 * @return 1 if successful else 0. 00248 */ 00249 uint8_t received_from_server_callback(struct nsdl_s * nsdl_handle, 00250 sn_coap_hdr_s *coap_header, 00251 sn_nsdl_addr_s *address); 00252 00253 /** 00254 * @brief Callback from nsdl library to inform the data which is 00255 * received from server for the resources has been converted to coap message. 00256 * @param nsdl_handle, Handler for the nsdl resource structure for this endpoint.. 00257 * @param coap_header, Coap message formed from data. 00258 * @param address, Server address from where the data is received. 00259 * @param nsdl_capab, Protocol for the message, currently only coap is supported. 00260 * @return 1 if successful else 0. 00261 */ 00262 uint8_t resource_callback(struct nsdl_s *nsdl_handle, sn_coap_hdr_s *coap, 00263 sn_nsdl_addr_s *address, 00264 sn_nsdl_capab_e nsdl_capab); 00265 00266 /** 00267 * @brief Callback from event loop for handling CoAP messages received from server for the resources 00268 * that has been converted to coap message. 00269 * @param coap_header, Coap message formed from data. 00270 * @param address, Server address from where the data is received. 00271 * @return 0 if successful else 1. 00272 */ 00273 uint8_t resource_callback_handle_event(sn_coap_hdr_s *coap, 00274 sn_nsdl_addr_s *address); 00275 00276 00277 /** 00278 * @brief Callback when there is data received from server and needs to be processed. 00279 * @param data, data received from server. 00280 * @param data_size, data size received from server. 00281 * @param addres, address structure of the server. 00282 * @return true if successfully processed else false. 00283 */ 00284 bool process_received_data(uint8_t *data, 00285 uint16_t data_size, 00286 sn_nsdl_addr_s *address); 00287 00288 /** 00289 * @brief Stops all the timers in case there is any errors. 00290 */ 00291 void stop_timers(); 00292 00293 /** 00294 * @brief Returns nsdl handle. 00295 * @return ndsl handle 00296 */ 00297 nsdl_s* get_nsdl_handle() const; 00298 00299 /** 00300 * @brief Get endpoint name 00301 * @return endpoint name 00302 */ 00303 const String& endpoint_name() const; 00304 00305 /** 00306 * @brief Get internal endpoint name 00307 * @return internal endpoint name 00308 */ 00309 const String internal_endpoint_name() const; 00310 00311 /** 00312 * @brief Set server address 00313 * @param server_address, Bootstrap or M2M server address. 00314 */ 00315 void set_server_address(const char *server_address); 00316 00317 /** 00318 * @brief Remove an object from the list kept by the NSDLInteface. 00319 * Does not call delete on the object. 00320 */ 00321 bool remove_object_from_list(M2MBase *base); 00322 00323 /* 00324 * @brief Get NSDL timer. 00325 * @return NSDL execution timer. 00326 */ 00327 M2MTimer &get_nsdl_execution_timer(); 00328 00329 /** 00330 * @brief Get unregister state. 00331 * @return Is unregistration ongoing. 00332 */ 00333 bool is_unregister_ongoing() const; 00334 00335 /** 00336 * @brief Get update register state. 00337 * @return Is updare registration ongoing. 00338 */ 00339 bool is_update_register_ongoing() const; 00340 00341 /** 00342 * @brief Starts the NSDL execution timer. 00343 */ 00344 void start_nsdl_execution_timer(); 00345 00346 /** 00347 * @brief Returns security object. 00348 * @return M2MSecurity object, contains lwm2m server information. 00349 */ 00350 M2MSecurity* get_security_object(); 00351 00352 /** 00353 * @brief Returns auto-observation token. 00354 * @param path, Resource path, used for searching the right object. 00355 * @param token[OUT], Token data. 00356 * @return Length of the token if found otherwise 0. 00357 */ 00358 uint8_t find_auto_obs_token(const char *path, uint8_t *token) const; 00359 00360 /** 00361 * @brief Set custom uri query paramaters used in LWM2M registration. 00362 * @uri_query_params Uri query params. Parameters must be in key-value pair format: 00363 * "a=100&b=200". Maximum length can be up to 64 bytes. 00364 * @return False if maximum length exceeded otherwise True. 00365 */ 00366 bool set_uri_query_parameters(const char *uri_query_params); 00367 00368 /** 00369 * @brief Clears the sent blockwise message list in CoAP library. 00370 */ 00371 void clear_sent_blockwise_messages(); 00372 00373 /** 00374 * @brief Clears the received blockwise message list in CoAP library. 00375 */ 00376 void clear_received_blockwise_messages(); 00377 00378 /** 00379 * @brief Send next notification message. 00380 */ 00381 void send_next_notification(bool clear_token); 00382 00383 /** 00384 * @brief Store the "BS finished" response id. 00385 * @param msg_id Response id. 00386 */ 00387 void store_bs_finished_response_id(uint16_t msg_id); 00388 00389 /** 00390 * @brief Store the registration state. 00391 * @param registered Registered to lwm2m server or not. 00392 */ 00393 void set_registration_status(bool registered); 00394 00395 /** 00396 * @brief Handle incoming bootstrap PUT message. 00397 * @param coap_header, Received CoAP message 00398 * @param address, Server address 00399 */ 00400 void handle_bootstrap_put_message(sn_coap_hdr_s *coap_header, sn_nsdl_addr_s *address); 00401 00402 /** 00403 * @brief Handle bootstrap finish acknowledgement. 00404 */ 00405 void handle_bootstrap_finish_ack(uint16_t msg_id); 00406 00407 /** 00408 * @brief Returns total retransmission time 00409 * @resend_count Resend count 00410 * @return Total retransmission time 00411 */ 00412 uint32_t total_retransmission_time(uint32_t resend_count); 00413 00414 /** 00415 * @brief Returns CoAP retransmission count 00416 * @return CoAP retransmission count 00417 */ 00418 uint8_t get_resend_count(); 00419 00420 /** 00421 * @brief Mark request to be resend again after network break 00422 * @param token, Message token 00423 * @param token_len, Message token length 00424 */ 00425 void set_request_context_to_be_resend(uint8_t *token, uint8_t token_len); 00426 00427 /** 00428 * @brief Create a new time when to send CoAP ping. 00429 */ 00430 void calculate_new_coap_ping_send_time(); 00431 00432 protected: // from M2MTimerObserver 00433 00434 virtual void timer_expired(M2MTimerObserver::Type type); 00435 00436 protected: // from M2MObservationHandler 00437 00438 virtual bool observation_to_be_sent(M2MBase *object, 00439 uint16_t obs_number, 00440 const m2m::Vector<uint16_t> &changed_instance_ids, 00441 bool send_object = false); 00442 00443 virtual void resource_to_be_deleted(M2MBase* base); 00444 00445 virtual void value_updated(M2MBase *base); 00446 00447 virtual void remove_object(M2MBase *object); 00448 #ifndef DISABLE_DELAYED_RESPONSE 00449 virtual void send_delayed_response(M2MBase *base); 00450 #endif //DISABLE_DELAYED_RESPONSE 00451 00452 #ifdef ENABLE_ASYNC_REST_RESPONSE 00453 virtual void send_asynchronous_response(M2MBase *base, 00454 const uint8_t *payload, 00455 size_t payload_len, 00456 const uint8_t* token, 00457 const uint8_t token_len, 00458 coap_response_code_e code); 00459 #endif //ENABLE_ASYNC_REST_RESPONSE 00460 00461 private: 00462 00463 /** 00464 * Enum defining an LWM2M object type. 00465 */ 00466 typedef enum { 00467 SECURITY = 0x00, 00468 SERVER = 0x01, 00469 DEVICE = 0x02 00470 }ObjectType; 00471 00472 /** 00473 * @brief Initializes all the nsdl library component to be usable. 00474 * @return true if initialization is successful else false. 00475 */ 00476 bool initialize(); 00477 00478 bool add_object_to_list(M2MBase *base); 00479 00480 bool create_nsdl_structure(M2MBase *base); 00481 00482 #ifdef MBED_CLOUD_CLIENT_EDGE_EXTENSION 00483 bool create_nsdl_endpoint_structure(M2MEndpoint *endpoint); 00484 #endif 00485 00486 bool create_nsdl_object_structure(M2MObject *object); 00487 00488 bool create_nsdl_object_instance_structure(M2MObjectInstance *object_instance); 00489 00490 bool create_nsdl_resource_structure(M2MResource *resource, 00491 bool multiple_instances = false); 00492 00493 bool create_nsdl_resource(M2MBase *base); 00494 00495 static String coap_to_string(const uint8_t *coap_data_ptr, 00496 int coap_data_ptr_length); 00497 00498 void execute_nsdl_process_loop(); 00499 00500 uint64_t registration_time() const; 00501 00502 M2MBase* find_resource(const String &object) const; 00503 00504 #ifdef MBED_CLOUD_CLIENT_EDGE_EXTENSION 00505 M2MBase* find_resource(const M2MEndpoint *endpoint, 00506 const String &object_name) const; 00507 #endif 00508 00509 M2MBase* find_resource(const M2MObject *object, 00510 const String &object_instance) const; 00511 00512 M2MBase* find_resource(const M2MObjectInstance *object_instance, 00513 const String &resource_instance) const; 00514 00515 M2MBase* find_resource(const M2MResource *resource, 00516 const String &object_name, 00517 const String &resource_instance) const; 00518 00519 bool object_present(M2MBase *base) const; 00520 00521 int object_index(M2MBase *base) const; 00522 00523 static M2MInterface::Error interface_error(const sn_coap_hdr_s &coap_header); 00524 00525 void send_object_observation(M2MObject *object, 00526 uint16_t obs_number, 00527 const m2m::Vector<uint16_t> &changed_instance_ids, 00528 bool send_object); 00529 00530 void send_object_instance_observation(M2MObjectInstance *object_instance, 00531 uint16_t obs_number); 00532 00533 void send_resource_observation(M2MResource *resource, uint16_t obs_number); 00534 00535 00536 00537 /** 00538 * @brief Allocate (size + 1) amount of memory, copy size bytes into 00539 * it and add zero termination. 00540 * @param source Source string to copy, may not be NULL. 00541 * @param size The size of memory to be reserved. 00542 */ 00543 static uint8_t* alloc_string_copy(const uint8_t* source, uint16_t size); 00544 00545 /** 00546 * @brief Utility method to convert given lifetime int to ascii 00547 * and allocate a buffer for it and set it to _endpoint->lifetime_ptr. 00548 * @param lifetime A new value for lifetime. 00549 */ 00550 void set_endpoint_lifetime_buffer(int lifetime); 00551 00552 /** 00553 * @brief Handle bootstrap finished message. 00554 * @param coap_header, Received CoAP message 00555 * @param address, Server address 00556 */ 00557 void handle_bootstrap_finished(sn_coap_hdr_s *coap_header,sn_nsdl_addr_s *address); 00558 00559 /** 00560 * @brief Handle bootstrap delete message. 00561 * @param coap_header, Received CoAP message 00562 * @param address, Server address 00563 */ 00564 void handle_bootstrap_delete(sn_coap_hdr_s *coap_header,sn_nsdl_addr_s *address); 00565 00566 /** 00567 * @brief Parse bootstrap TLV message. 00568 * @param coap_header, Received CoAP message 00569 * @return True if parsing was succesful else false 00570 */ 00571 bool parse_bootstrap_message(sn_coap_hdr_s *coap_header, M2MNsdlInterface::ObjectType lwm2m_object_type); 00572 00573 /** 00574 * @brief Parse bootstrap TLV message. 00575 * @param coap_header, Received CoAP message 00576 * @return True if parsing was succesful else false 00577 */ 00578 bool validate_security_object(); 00579 00580 /** 00581 * @brief Handle bootstrap errors. 00582 * @param reason, Reason for Bootstrap failure. 00583 * @param wait, True if need to wait that ACK has been sent. 00584 * False if reconnection can start immediately. 00585 */ 00586 void handle_bootstrap_error(const char *reason, bool wait); 00587 00588 /** 00589 * @brief Handle different coap errors. 00590 * @param coap_header, CoAP structure. 00591 * @return Error reason. 00592 */ 00593 static const char *coap_error(const sn_coap_hdr_s &coap_header); 00594 00595 /** 00596 * @brief Claim 00597 */ 00598 void claim_mutex(); 00599 00600 /** 00601 * @brief Release 00602 */ 00603 void release_mutex(); 00604 00605 /** 00606 * @brief Change operation mode of every resource. 00607 * @param object, Object to be updated. 00608 * @return operation, New operation mode. 00609 */ 00610 void change_operation_mode(M2MObject *object, M2MBase::Operation operation); 00611 00612 /** 00613 * @brief Parse URI query parameters and pass those to nsdl-c. 00614 * @return True if parsing success otherwise False 00615 */ 00616 bool parse_and_send_uri_query_parameters(); 00617 00618 /** 00619 * @brief Callback function that triggers the registration update call. 00620 * @param argument, Arguments part of the POST request. 00621 */ 00622 void update_trigger_callback(void *argument); 00623 00624 bool lifetime_value_changed() const; 00625 00626 void execute_notification_delivery_status_cb(M2MBase* object, int32_t msgid); 00627 00628 bool is_response_to_request(const sn_coap_hdr_s *coap_header, 00629 struct request_context_s &get_data); 00630 00631 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); 00632 00633 void free_response_list(); 00634 00635 void remove_item_from_response_list(const char* uri_path, const int32_t msg_id); 00636 00637 #if !defined(DISABLE_DELAYED_RESPONSE) || defined(ENABLE_ASYNC_REST_RESPONSE) 00638 void remove_items_from_response_list_for_uri(const char* uri_path); 00639 #endif 00640 /** 00641 * @brief Send next notification for object, return true if notification sent, false 00642 * if no notification to send or send already in progress. 00643 * @param object, M2MObject whose next notification should be sent 00644 * @param clear_token, Flag to indicate whether observation token should be cleared. 00645 * @return True if notification sent, false otherwise or if send already in progress 00646 */ 00647 bool send_next_notification_for_object(M2MObject& object, bool clear_token); 00648 00649 static char* parse_uri_query_parameters(char* uri); 00650 00651 void send_coap_ping(); 00652 00653 void send_empty_ack(const sn_coap_hdr_s *header, sn_nsdl_addr_s *address); 00654 00655 struct M2MNsdlInterface::nsdl_coap_data_s* create_coap_event_data(sn_coap_hdr_s *received_coap_header, 00656 sn_nsdl_addr_s *address, 00657 struct nsdl_s *nsdl_handle, 00658 uint8_t coap_msg_code = COAP_MSG_CODE_EMPTY); 00659 00660 void handle_register_response(const sn_coap_hdr_s *coap_header); 00661 00662 void handle_unregister_response(const sn_coap_hdr_s *coap_header); 00663 00664 void handle_register_update_response(const sn_coap_hdr_s *coap_header); 00665 00666 void handle_request_response(const sn_coap_hdr_s *coap_header, struct request_context_s *request_context); 00667 00668 void handle_bootstrap_response(const sn_coap_hdr_s *coap_header); 00669 00670 void handle_message_delivered(M2MBase *base, const M2MBase::MessageType type); 00671 00672 void handle_empty_ack(const sn_coap_hdr_s *coap_header, bool is_bootstrap_msg); 00673 00674 bool handle_post_response(sn_coap_hdr_s *coap_header, 00675 sn_nsdl_addr_s *address, 00676 sn_coap_hdr_s *&coap_response, 00677 M2MObjectInstance *&obj_instance, 00678 bool is_bootstrap_msg); 00679 00680 void set_retransmission_parameters(); 00681 00682 void send_pending_request(); 00683 00684 void store_to_response_list(const char *uri, int32_t msg_id, M2MBase::MessageType type); 00685 00686 struct coap_response_s* find_response(int32_t msg_id); 00687 00688 #if !defined(DISABLE_DELAYED_RESPONSE) || defined(ENABLE_ASYNC_REST_RESPONSE) 00689 struct coap_response_s* find_delayed_response(const char* uri_path, 00690 const M2MBase::MessageType type, 00691 int32_t message_id = UNDEFINED_MSG_ID); 00692 00693 bool handle_delayed_response_store(const char* uri_path, 00694 sn_coap_hdr_s* received_coap, 00695 sn_nsdl_addr_s *address, 00696 const M2MBase::MessageType message_type); 00697 #endif 00698 00699 void failed_to_send_request(request_context_s *request, const sn_coap_hdr_s *coap_header); 00700 00701 bool coap_ping_in_process() const; 00702 00703 void remove_ping_from_response_list(); 00704 00705 #ifdef ENABLE_ASYNC_REST_RESPONSE 00706 static M2MBase::Operation operation_for_message_code(sn_coap_msg_code_e code); 00707 #endif // ENABLE_ASYNC_REST_RESPONSE 00708 00709 private: 00710 M2MNsdlObserver &_observer; 00711 M2MBaseList _base_list; 00712 sn_nsdl_ep_parameters_s *_endpoint; 00713 nsdl_s *_nsdl_handle; 00714 M2MSecurity *_security; // Not owned 00715 M2MServer *_server; 00716 M2MTimer _nsdl_execution_timer; 00717 M2MTimer _registration_timer; 00718 M2MConnectionHandler &_connection_handler; 00719 String _endpoint_name; 00720 String _internal_endpoint_name; 00721 uint32_t _counter_for_nsdl; 00722 uint32_t _next_coap_ping_send_time; 00723 char *_server_address; // BS or M2M address 00724 request_context_list_t _request_context_list; 00725 response_list_t _response_list; 00726 char *_custom_uri_query_params; 00727 M2MNotificationHandler *_notification_handler; 00728 arm_event_storage_t _event; 00729 uint16_t _auto_obs_token; 00730 uint16_t _bootstrap_id; 00731 static int8_t _tasklet_id; 00732 uint8_t _binding_mode; 00733 bool _identity_accepted; 00734 bool _nsdl_execution_timer_running; 00735 bool _notification_send_ongoing; 00736 bool _registered; 00737 bool _bootstrap_finish_ack_received; 00738 M2MTimer _download_retry_timer; 00739 uint64_t _download_retry_time; 00740 00741 friend class Test_M2MNsdlInterface; 00742 00743 }; 00744 00745 #endif // M2MNSDLINTERFACE_H 00746
Generated on Tue Jul 12 2022 20:21:00 by
