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.
simple-mbed-cloud-client/mbed-cloud-client/mbed-client/source/include/m2minterfaceimpl.h@0:8f0bb79ddd48, 2021-05-04 (annotated)
- Committer:
- leothedragon
- Date:
- Tue May 04 08:55:12 2021 +0000
- Revision:
- 0:8f0bb79ddd48
nmn
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leothedragon | 0:8f0bb79ddd48 | 1 | /* |
leothedragon | 0:8f0bb79ddd48 | 2 | * Copyright (c) 2015 ARM Limited. All rights reserved. |
leothedragon | 0:8f0bb79ddd48 | 3 | * SPDX-License-Identifier: Apache-2.0 |
leothedragon | 0:8f0bb79ddd48 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
leothedragon | 0:8f0bb79ddd48 | 5 | * not use this file except in compliance with the License. |
leothedragon | 0:8f0bb79ddd48 | 6 | * You may obtain a copy of the License at |
leothedragon | 0:8f0bb79ddd48 | 7 | * |
leothedragon | 0:8f0bb79ddd48 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
leothedragon | 0:8f0bb79ddd48 | 9 | * |
leothedragon | 0:8f0bb79ddd48 | 10 | * Unless required by applicable law or agreed to in writing, software |
leothedragon | 0:8f0bb79ddd48 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
leothedragon | 0:8f0bb79ddd48 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
leothedragon | 0:8f0bb79ddd48 | 13 | * See the License for the specific language governing permissions and |
leothedragon | 0:8f0bb79ddd48 | 14 | * limitations under the License. |
leothedragon | 0:8f0bb79ddd48 | 15 | */ |
leothedragon | 0:8f0bb79ddd48 | 16 | #ifndef M2M_INTERFACE_IMPL_H |
leothedragon | 0:8f0bb79ddd48 | 17 | #define M2M_INTERFACE_IMPL_H |
leothedragon | 0:8f0bb79ddd48 | 18 | |
leothedragon | 0:8f0bb79ddd48 | 19 | #include "mbed-client/m2minterface.h" |
leothedragon | 0:8f0bb79ddd48 | 20 | #include "mbed-client/m2mserver.h" |
leothedragon | 0:8f0bb79ddd48 | 21 | #include "mbed-client/m2mconnectionobserver.h" |
leothedragon | 0:8f0bb79ddd48 | 22 | #include "mbed-client/m2mconnectionsecurity.h" |
leothedragon | 0:8f0bb79ddd48 | 23 | #include "include/m2mnsdlobserver.h" |
leothedragon | 0:8f0bb79ddd48 | 24 | #include "include/m2mnsdlinterface.h" |
leothedragon | 0:8f0bb79ddd48 | 25 | #include "mbed-client/m2mtimerobserver.h" |
leothedragon | 0:8f0bb79ddd48 | 26 | #include "mbed-client/m2mtimer.h" |
leothedragon | 0:8f0bb79ddd48 | 27 | #include "mbed-client/m2mconnectionhandler.h" |
leothedragon | 0:8f0bb79ddd48 | 28 | #include "mbed-client/m2mconstants.h" |
leothedragon | 0:8f0bb79ddd48 | 29 | |
leothedragon | 0:8f0bb79ddd48 | 30 | //FORWARD DECLARATION |
leothedragon | 0:8f0bb79ddd48 | 31 | class M2MConnectionSecurity; |
leothedragon | 0:8f0bb79ddd48 | 32 | class EventData; |
leothedragon | 0:8f0bb79ddd48 | 33 | class M2MUpdateRegisterData; |
leothedragon | 0:8f0bb79ddd48 | 34 | /** |
leothedragon | 0:8f0bb79ddd48 | 35 | * @brief M2MInterfaceImpl. |
leothedragon | 0:8f0bb79ddd48 | 36 | * This class implements handling of all mbed Client Interface operations |
leothedragon | 0:8f0bb79ddd48 | 37 | * defined in OMA LWM2M specifications. |
leothedragon | 0:8f0bb79ddd48 | 38 | * This includes Bootstrapping, Client Registration, Device Management & |
leothedragon | 0:8f0bb79ddd48 | 39 | * Service Enablement and Information Reporting. |
leothedragon | 0:8f0bb79ddd48 | 40 | */ |
leothedragon | 0:8f0bb79ddd48 | 41 | |
leothedragon | 0:8f0bb79ddd48 | 42 | class M2MInterfaceImpl : public M2MInterface, |
leothedragon | 0:8f0bb79ddd48 | 43 | public M2MNsdlObserver, |
leothedragon | 0:8f0bb79ddd48 | 44 | public M2MConnectionObserver, |
leothedragon | 0:8f0bb79ddd48 | 45 | public M2MTimerObserver |
leothedragon | 0:8f0bb79ddd48 | 46 | { |
leothedragon | 0:8f0bb79ddd48 | 47 | private: |
leothedragon | 0:8f0bb79ddd48 | 48 | // Prevents the use of assignment operator by accident. |
leothedragon | 0:8f0bb79ddd48 | 49 | M2MInterfaceImpl& operator=( const M2MInterfaceImpl& /*other*/ ); |
leothedragon | 0:8f0bb79ddd48 | 50 | |
leothedragon | 0:8f0bb79ddd48 | 51 | // Prevents the use of copy constructor by accident |
leothedragon | 0:8f0bb79ddd48 | 52 | M2MInterfaceImpl( const M2MInterfaceImpl& /*other*/ ); |
leothedragon | 0:8f0bb79ddd48 | 53 | |
leothedragon | 0:8f0bb79ddd48 | 54 | friend class M2MInterfaceFactory; |
leothedragon | 0:8f0bb79ddd48 | 55 | |
leothedragon | 0:8f0bb79ddd48 | 56 | private: |
leothedragon | 0:8f0bb79ddd48 | 57 | |
leothedragon | 0:8f0bb79ddd48 | 58 | /** |
leothedragon | 0:8f0bb79ddd48 | 59 | * @brief Constructor |
leothedragon | 0:8f0bb79ddd48 | 60 | * @param observer, Observer to pass the event callbacks for various |
leothedragon | 0:8f0bb79ddd48 | 61 | * interface operations. |
leothedragon | 0:8f0bb79ddd48 | 62 | * @param endpoint_name Endpoint name of the client. |
leothedragon | 0:8f0bb79ddd48 | 63 | * @param endpoint_type Endpoint type of the client. |
leothedragon | 0:8f0bb79ddd48 | 64 | * @param life_time Life time of the client in seconds |
leothedragon | 0:8f0bb79ddd48 | 65 | * @param listen_port Listening port for the endpoint, default is 8000. |
leothedragon | 0:8f0bb79ddd48 | 66 | * @param domain Domain of the client. |
leothedragon | 0:8f0bb79ddd48 | 67 | * @param mode Binding mode of the client, default is UDP |
leothedragon | 0:8f0bb79ddd48 | 68 | * @param stack Network stack to be used for connection, default is LwIP_IPv4. |
leothedragon | 0:8f0bb79ddd48 | 69 | * @param context_address Context address, default is empty. |
leothedragon | 0:8f0bb79ddd48 | 70 | */ |
leothedragon | 0:8f0bb79ddd48 | 71 | M2MInterfaceImpl(M2MInterfaceObserver& observer, |
leothedragon | 0:8f0bb79ddd48 | 72 | const String &endpoint_name, |
leothedragon | 0:8f0bb79ddd48 | 73 | const String &endpoint_type, |
leothedragon | 0:8f0bb79ddd48 | 74 | const int32_t life_time, |
leothedragon | 0:8f0bb79ddd48 | 75 | const uint16_t listen_port, |
leothedragon | 0:8f0bb79ddd48 | 76 | const String &domain = "", |
leothedragon | 0:8f0bb79ddd48 | 77 | BindingMode mode = M2MInterface::NOT_SET, |
leothedragon | 0:8f0bb79ddd48 | 78 | M2MInterface::NetworkStack stack = M2MInterface::LwIP_IPv4, |
leothedragon | 0:8f0bb79ddd48 | 79 | const String &context_address = ""); |
leothedragon | 0:8f0bb79ddd48 | 80 | |
leothedragon | 0:8f0bb79ddd48 | 81 | public: |
leothedragon | 0:8f0bb79ddd48 | 82 | |
leothedragon | 0:8f0bb79ddd48 | 83 | /** |
leothedragon | 0:8f0bb79ddd48 | 84 | * @brief Destructor |
leothedragon | 0:8f0bb79ddd48 | 85 | */ |
leothedragon | 0:8f0bb79ddd48 | 86 | virtual ~M2MInterfaceImpl(); |
leothedragon | 0:8f0bb79ddd48 | 87 | |
leothedragon | 0:8f0bb79ddd48 | 88 | /** |
leothedragon | 0:8f0bb79ddd48 | 89 | * @brief Initiates bootstrapping of the client with the provided Bootstrap |
leothedragon | 0:8f0bb79ddd48 | 90 | * server information. |
leothedragon | 0:8f0bb79ddd48 | 91 | * @param security_object Security object which contains information |
leothedragon | 0:8f0bb79ddd48 | 92 | * required for successful bootstrapping of the client. |
leothedragon | 0:8f0bb79ddd48 | 93 | */ |
leothedragon | 0:8f0bb79ddd48 | 94 | virtual void bootstrap(M2MSecurity *security); |
leothedragon | 0:8f0bb79ddd48 | 95 | |
leothedragon | 0:8f0bb79ddd48 | 96 | /** |
leothedragon | 0:8f0bb79ddd48 | 97 | * @brief Cancels on going bootstrapping operation of the client. If the client has |
leothedragon | 0:8f0bb79ddd48 | 98 | * already successfully bootstrapped then this function deletes existing |
leothedragon | 0:8f0bb79ddd48 | 99 | * bootstrap information from the client. |
leothedragon | 0:8f0bb79ddd48 | 100 | */ |
leothedragon | 0:8f0bb79ddd48 | 101 | virtual void cancel_bootstrap(); |
leothedragon | 0:8f0bb79ddd48 | 102 | |
leothedragon | 0:8f0bb79ddd48 | 103 | /** |
leothedragon | 0:8f0bb79ddd48 | 104 | * @brief Finishes on going bootstrap in cases where client is the one to finish it. |
leothedragon | 0:8f0bb79ddd48 | 105 | */ |
leothedragon | 0:8f0bb79ddd48 | 106 | virtual void finish_bootstrap(); |
leothedragon | 0:8f0bb79ddd48 | 107 | |
leothedragon | 0:8f0bb79ddd48 | 108 | /** |
leothedragon | 0:8f0bb79ddd48 | 109 | * @brief Initiates registration of the provided Security object to the |
leothedragon | 0:8f0bb79ddd48 | 110 | * corresponding LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 111 | * @param security_object Security object which contains information |
leothedragon | 0:8f0bb79ddd48 | 112 | * required for registering to the LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 113 | * If client wants to register to multiple LWM2M servers then it has call |
leothedragon | 0:8f0bb79ddd48 | 114 | * this function once for each of LWM2M server object separately. |
leothedragon | 0:8f0bb79ddd48 | 115 | * @param object_list Objects which contains information |
leothedragon | 0:8f0bb79ddd48 | 116 | * which the client want to register to the LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 117 | */ |
leothedragon | 0:8f0bb79ddd48 | 118 | virtual void register_object(M2MSecurity *security_object, const M2MBaseList &list); |
leothedragon | 0:8f0bb79ddd48 | 119 | |
leothedragon | 0:8f0bb79ddd48 | 120 | /** |
leothedragon | 0:8f0bb79ddd48 | 121 | * @brief Initiates registration of the provided Security object to the |
leothedragon | 0:8f0bb79ddd48 | 122 | * corresponding LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 123 | * @param security_object Security object which contains information |
leothedragon | 0:8f0bb79ddd48 | 124 | * required for registering to the LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 125 | * If client wants to register to multiple LWM2M servers then it has call |
leothedragon | 0:8f0bb79ddd48 | 126 | * this function once for each of LWM2M server object separately. |
leothedragon | 0:8f0bb79ddd48 | 127 | * @param object_list Objects which contains information |
leothedragon | 0:8f0bb79ddd48 | 128 | * which the client want to register to the LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 129 | */ |
leothedragon | 0:8f0bb79ddd48 | 130 | virtual void register_object(M2MSecurity *security_object, const M2MObjectList &object_list); |
leothedragon | 0:8f0bb79ddd48 | 131 | |
leothedragon | 0:8f0bb79ddd48 | 132 | /** |
leothedragon | 0:8f0bb79ddd48 | 133 | * @brief Updates or refreshes the client's registration on the LWM2M |
leothedragon | 0:8f0bb79ddd48 | 134 | * server. |
leothedragon | 0:8f0bb79ddd48 | 135 | * @param security_object Security object from which the device object |
leothedragon | 0:8f0bb79ddd48 | 136 | * needs to update registration, if there is only one LWM2M server registered |
leothedragon | 0:8f0bb79ddd48 | 137 | * then this parameter can be NULL. |
leothedragon | 0:8f0bb79ddd48 | 138 | * @param lifetime Lifetime for the endpoint client in seconds. |
leothedragon | 0:8f0bb79ddd48 | 139 | */ |
leothedragon | 0:8f0bb79ddd48 | 140 | virtual void update_registration(M2MSecurity *security_object, const uint32_t lifetime = 0); |
leothedragon | 0:8f0bb79ddd48 | 141 | |
leothedragon | 0:8f0bb79ddd48 | 142 | /** |
leothedragon | 0:8f0bb79ddd48 | 143 | * @brief Updates or refreshes the client's registration on the LWM2M |
leothedragon | 0:8f0bb79ddd48 | 144 | * server. Use this function to publish new objects to LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 145 | * @param security_object The security object from which the device object |
leothedragon | 0:8f0bb79ddd48 | 146 | * needs to update the registration. If there is only one LWM2M server registered, |
leothedragon | 0:8f0bb79ddd48 | 147 | * this parameter can be NULL. |
leothedragon | 0:8f0bb79ddd48 | 148 | * @param object_list Objects that contain information about the |
leothedragon | 0:8f0bb79ddd48 | 149 | * client attempting to register to the LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 150 | * @param lifetime The lifetime of the endpoint client in seconds. If the same value |
leothedragon | 0:8f0bb79ddd48 | 151 | * has to be passed, set the default value to 0. |
leothedragon | 0:8f0bb79ddd48 | 152 | */ |
leothedragon | 0:8f0bb79ddd48 | 153 | virtual void update_registration(M2MSecurity *security_object, const M2MBaseList &list, |
leothedragon | 0:8f0bb79ddd48 | 154 | const uint32_t lifetime = 0); |
leothedragon | 0:8f0bb79ddd48 | 155 | |
leothedragon | 0:8f0bb79ddd48 | 156 | /** |
leothedragon | 0:8f0bb79ddd48 | 157 | * @brief Updates or refreshes the client's registration on the LWM2M |
leothedragon | 0:8f0bb79ddd48 | 158 | * server. Use this function to publish new objects to LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 159 | * @param security_object The security object from which the device object |
leothedragon | 0:8f0bb79ddd48 | 160 | * needs to update the registration. If there is only one LWM2M server registered, |
leothedragon | 0:8f0bb79ddd48 | 161 | * this parameter can be NULL. |
leothedragon | 0:8f0bb79ddd48 | 162 | * @param object_list Objects that contain information about the |
leothedragon | 0:8f0bb79ddd48 | 163 | * client attempting to register to the LWM2M server. |
leothedragon | 0:8f0bb79ddd48 | 164 | * @param lifetime The lifetime of the endpoint client in seconds. If the same value |
leothedragon | 0:8f0bb79ddd48 | 165 | * has to be passed, set the default value to 0. |
leothedragon | 0:8f0bb79ddd48 | 166 | */ |
leothedragon | 0:8f0bb79ddd48 | 167 | virtual void update_registration(M2MSecurity *security_object, const M2MObjectList &object_list, |
leothedragon | 0:8f0bb79ddd48 | 168 | const uint32_t lifetime = 0); |
leothedragon | 0:8f0bb79ddd48 | 169 | |
leothedragon | 0:8f0bb79ddd48 | 170 | /** |
leothedragon | 0:8f0bb79ddd48 | 171 | * @brief Unregisters the registered object from the LWM2M server |
leothedragon | 0:8f0bb79ddd48 | 172 | * @param security_object Security object from which the device object |
leothedragon | 0:8f0bb79ddd48 | 173 | * needs to be unregistered. If there is only one LWM2M server registered |
leothedragon | 0:8f0bb79ddd48 | 174 | * this parameter can be NULL. |
leothedragon | 0:8f0bb79ddd48 | 175 | */ |
leothedragon | 0:8f0bb79ddd48 | 176 | virtual void unregister_object(M2MSecurity* security = NULL); |
leothedragon | 0:8f0bb79ddd48 | 177 | |
leothedragon | 0:8f0bb79ddd48 | 178 | /** |
leothedragon | 0:8f0bb79ddd48 | 179 | * @brief Sets the function which will be called indicating client |
leothedragon | 0:8f0bb79ddd48 | 180 | * is going to sleep when the Binding mode is selected with Queue mode. |
leothedragon | 0:8f0bb79ddd48 | 181 | * @param callback A function pointer that will be called when client |
leothedragon | 0:8f0bb79ddd48 | 182 | * goes to sleep. |
leothedragon | 0:8f0bb79ddd48 | 183 | */ |
leothedragon | 0:8f0bb79ddd48 | 184 | virtual void set_queue_sleep_handler(callback_handler handler); |
leothedragon | 0:8f0bb79ddd48 | 185 | |
leothedragon | 0:8f0bb79ddd48 | 186 | /** |
leothedragon | 0:8f0bb79ddd48 | 187 | * @brief Sets the network interface handler that is used by client to connect |
leothedragon | 0:8f0bb79ddd48 | 188 | * to a network over IP. |
leothedragon | 0:8f0bb79ddd48 | 189 | * @param handler A network interface handler that is used by client to connect. |
leothedragon | 0:8f0bb79ddd48 | 190 | * This API is optional but provides a mechanism for different platforms to |
leothedragon | 0:8f0bb79ddd48 | 191 | * manage usage of underlying network interface by client. |
leothedragon | 0:8f0bb79ddd48 | 192 | */ |
leothedragon | 0:8f0bb79ddd48 | 193 | virtual void set_platform_network_handler(void *handler = NULL); |
leothedragon | 0:8f0bb79ddd48 | 194 | |
leothedragon | 0:8f0bb79ddd48 | 195 | /** |
leothedragon | 0:8f0bb79ddd48 | 196 | * \brief Sets the function callback that will be called by mbed-client for |
leothedragon | 0:8f0bb79ddd48 | 197 | * fetching random number from application for ensuring strong entropy. |
leothedragon | 0:8f0bb79ddd48 | 198 | * \param random_callback A function pointer that will be called by mbed-client |
leothedragon | 0:8f0bb79ddd48 | 199 | * while performing secure handshake. |
leothedragon | 0:8f0bb79ddd48 | 200 | * Function signature should be uint32_t (*random_number_callback)(void); |
leothedragon | 0:8f0bb79ddd48 | 201 | */ |
leothedragon | 0:8f0bb79ddd48 | 202 | virtual void set_random_number_callback(random_number_cb callback); |
leothedragon | 0:8f0bb79ddd48 | 203 | |
leothedragon | 0:8f0bb79ddd48 | 204 | /** |
leothedragon | 0:8f0bb79ddd48 | 205 | * \brief Sets the function callback that will be called by mbed-client for |
leothedragon | 0:8f0bb79ddd48 | 206 | * providing entropy source from application for ensuring strong entropy. |
leothedragon | 0:8f0bb79ddd48 | 207 | * \param entropy_callback A function pointer that will be called by mbed-client |
leothedragon | 0:8f0bb79ddd48 | 208 | * while performing secure handshake. |
leothedragon | 0:8f0bb79ddd48 | 209 | * Function signature , if using mbed-client-mbedtls should be |
leothedragon | 0:8f0bb79ddd48 | 210 | * int (*mbedtls_entropy_f_source_ptr)(void *data, unsigned char *output, |
leothedragon | 0:8f0bb79ddd48 | 211 | * size_t len, size_t *olen); |
leothedragon | 0:8f0bb79ddd48 | 212 | */ |
leothedragon | 0:8f0bb79ddd48 | 213 | virtual void set_entropy_callback(entropy_cb callback); |
leothedragon | 0:8f0bb79ddd48 | 214 | |
leothedragon | 0:8f0bb79ddd48 | 215 | /** |
leothedragon | 0:8f0bb79ddd48 | 216 | * \brief Removes an object from M2MInterfaceImpl. |
leothedragon | 0:8f0bb79ddd48 | 217 | * Does not call delete on the object though. |
leothedragon | 0:8f0bb79ddd48 | 218 | * \return true if the object was found and false if the object was not found. |
leothedragon | 0:8f0bb79ddd48 | 219 | */ |
leothedragon | 0:8f0bb79ddd48 | 220 | virtual bool remove_object(M2MBase *object); |
leothedragon | 0:8f0bb79ddd48 | 221 | |
leothedragon | 0:8f0bb79ddd48 | 222 | /** |
leothedragon | 0:8f0bb79ddd48 | 223 | * @brief Updates the endpoint name. |
leothedragon | 0:8f0bb79ddd48 | 224 | * @param name New endpoint name |
leothedragon | 0:8f0bb79ddd48 | 225 | */ |
leothedragon | 0:8f0bb79ddd48 | 226 | virtual void update_endpoint(const String &name); |
leothedragon | 0:8f0bb79ddd48 | 227 | |
leothedragon | 0:8f0bb79ddd48 | 228 | /** |
leothedragon | 0:8f0bb79ddd48 | 229 | * @brief Updates the domain name. |
leothedragon | 0:8f0bb79ddd48 | 230 | * @param domain New domain name |
leothedragon | 0:8f0bb79ddd48 | 231 | */ |
leothedragon | 0:8f0bb79ddd48 | 232 | virtual void update_domain(const String &domain); |
leothedragon | 0:8f0bb79ddd48 | 233 | |
leothedragon | 0:8f0bb79ddd48 | 234 | /** |
leothedragon | 0:8f0bb79ddd48 | 235 | * @brief Return internal endpoint name |
leothedragon | 0:8f0bb79ddd48 | 236 | * @return internal endpoint name |
leothedragon | 0:8f0bb79ddd48 | 237 | */ |
leothedragon | 0:8f0bb79ddd48 | 238 | virtual const String internal_endpoint_name() const; |
leothedragon | 0:8f0bb79ddd48 | 239 | |
leothedragon | 0:8f0bb79ddd48 | 240 | /** |
leothedragon | 0:8f0bb79ddd48 | 241 | * @brief Return error description for the latest error code |
leothedragon | 0:8f0bb79ddd48 | 242 | * @return Error description string |
leothedragon | 0:8f0bb79ddd48 | 243 | */ |
leothedragon | 0:8f0bb79ddd48 | 244 | virtual const char *error_description() const; |
leothedragon | 0:8f0bb79ddd48 | 245 | |
leothedragon | 0:8f0bb79ddd48 | 246 | /** |
leothedragon | 0:8f0bb79ddd48 | 247 | * @brief Sends the CoAP GET request to the server. |
leothedragon | 0:8f0bb79ddd48 | 248 | * @type Download type. |
leothedragon | 0:8f0bb79ddd48 | 249 | * @uri Uri path to the data. |
leothedragon | 0:8f0bb79ddd48 | 250 | * @offset Data offset. |
leothedragon | 0:8f0bb79ddd48 | 251 | * @async In async mode application must call this API again with the updated offset. |
leothedragon | 0:8f0bb79ddd48 | 252 | * If set to false then client will automatically download the whole package. |
leothedragon | 0:8f0bb79ddd48 | 253 | * @get_data_cb Callback which is triggered once there is data available. |
leothedragon | 0:8f0bb79ddd48 | 254 | * @get_data_error_cb Callback which is trigged in case of any error. |
leothedragon | 0:8f0bb79ddd48 | 255 | */ |
leothedragon | 0:8f0bb79ddd48 | 256 | virtual void get_data_request(DownloadType type, |
leothedragon | 0:8f0bb79ddd48 | 257 | const char *uri, |
leothedragon | 0:8f0bb79ddd48 | 258 | const size_t offset, |
leothedragon | 0:8f0bb79ddd48 | 259 | const bool async, |
leothedragon | 0:8f0bb79ddd48 | 260 | get_data_cb data_cb, |
leothedragon | 0:8f0bb79ddd48 | 261 | get_data_error_cb error_cb, |
leothedragon | 0:8f0bb79ddd48 | 262 | void *context); |
leothedragon | 0:8f0bb79ddd48 | 263 | |
leothedragon | 0:8f0bb79ddd48 | 264 | /** |
leothedragon | 0:8f0bb79ddd48 | 265 | * @brief Sends the CoAP POST request to the server. |
leothedragon | 0:8f0bb79ddd48 | 266 | * @uri Uri path to the data. |
leothedragon | 0:8f0bb79ddd48 | 267 | * @async In async mode application must call this API again with the updated offset. |
leothedragon | 0:8f0bb79ddd48 | 268 | * If set to false then client will automatically download the whole package. |
leothedragon | 0:8f0bb79ddd48 | 269 | * @payload_len Length of payload. |
leothedragon | 0:8f0bb79ddd48 | 270 | * @payload_ptr, Pointer to payload buffer. |
leothedragon | 0:8f0bb79ddd48 | 271 | * @get_data_cb Callback which is triggered once there is data available. |
leothedragon | 0:8f0bb79ddd48 | 272 | * @get_data_error_cb Callback which is trigged in case of any error. |
leothedragon | 0:8f0bb79ddd48 | 273 | */ |
leothedragon | 0:8f0bb79ddd48 | 274 | virtual void post_data_request(const char *uri, |
leothedragon | 0:8f0bb79ddd48 | 275 | const bool async, |
leothedragon | 0:8f0bb79ddd48 | 276 | const uint16_t payload_len, |
leothedragon | 0:8f0bb79ddd48 | 277 | uint8_t *payload_ptr, |
leothedragon | 0:8f0bb79ddd48 | 278 | get_data_cb data_cb, |
leothedragon | 0:8f0bb79ddd48 | 279 | get_data_error_cb error_cb, |
leothedragon | 0:8f0bb79ddd48 | 280 | void *context); |
leothedragon | 0:8f0bb79ddd48 | 281 | |
leothedragon | 0:8f0bb79ddd48 | 282 | /** |
leothedragon | 0:8f0bb79ddd48 | 283 | * @brief Set custom uri query paramaters used in LWM2M registration. |
leothedragon | 0:8f0bb79ddd48 | 284 | * @uri_query_params Uri query params. Parameters must be in key-value format: |
leothedragon | 0:8f0bb79ddd48 | 285 | * "a=100&b=200". Maximum length can be up to 64 bytes. |
leothedragon | 0:8f0bb79ddd48 | 286 | * @return False if maximum length exceeded otherwise True. |
leothedragon | 0:8f0bb79ddd48 | 287 | */ |
leothedragon | 0:8f0bb79ddd48 | 288 | virtual bool set_uri_query_parameters(const char *uri_query_params); |
leothedragon | 0:8f0bb79ddd48 | 289 | |
leothedragon | 0:8f0bb79ddd48 | 290 | /** |
leothedragon | 0:8f0bb79ddd48 | 291 | * \brief Pauses client's timed functionality and closes network connection |
leothedragon | 0:8f0bb79ddd48 | 292 | * to the Cloud. After successful call the operation is continued |
leothedragon | 0:8f0bb79ddd48 | 293 | * by calling resume(). |
leothedragon | 0:8f0bb79ddd48 | 294 | * |
leothedragon | 0:8f0bb79ddd48 | 295 | * \note This operation does not unregister client from the Cloud. |
leothedragon | 0:8f0bb79ddd48 | 296 | * Closes the socket and removes interface from the interface list. |
leothedragon | 0:8f0bb79ddd48 | 297 | */ |
leothedragon | 0:8f0bb79ddd48 | 298 | virtual void pause(); |
leothedragon | 0:8f0bb79ddd48 | 299 | |
leothedragon | 0:8f0bb79ddd48 | 300 | /** |
leothedragon | 0:8f0bb79ddd48 | 301 | * \brief Resumes client's timed functionality and network connection |
leothedragon | 0:8f0bb79ddd48 | 302 | * to the Cloud. Updates registration. Can be only called after |
leothedragon | 0:8f0bb79ddd48 | 303 | * a successful call to pause(). |
leothedragon | 0:8f0bb79ddd48 | 304 | * |
leothedragon | 0:8f0bb79ddd48 | 305 | * \param iface A handler to the network interface. |
leothedragon | 0:8f0bb79ddd48 | 306 | */ |
leothedragon | 0:8f0bb79ddd48 | 307 | virtual void resume(void *iface, const M2MBaseList &list); |
leothedragon | 0:8f0bb79ddd48 | 308 | |
leothedragon | 0:8f0bb79ddd48 | 309 | protected: // From M2MNsdlObserver |
leothedragon | 0:8f0bb79ddd48 | 310 | |
leothedragon | 0:8f0bb79ddd48 | 311 | virtual void coap_message_ready(uint8_t *data_ptr, |
leothedragon | 0:8f0bb79ddd48 | 312 | uint16_t data_len, |
leothedragon | 0:8f0bb79ddd48 | 313 | sn_nsdl_addr_s *address_ptr); |
leothedragon | 0:8f0bb79ddd48 | 314 | |
leothedragon | 0:8f0bb79ddd48 | 315 | virtual void client_registered(M2MServer *server_object); |
leothedragon | 0:8f0bb79ddd48 | 316 | |
leothedragon | 0:8f0bb79ddd48 | 317 | virtual void registration_updated(const M2MServer &server_object); |
leothedragon | 0:8f0bb79ddd48 | 318 | |
leothedragon | 0:8f0bb79ddd48 | 319 | virtual void registration_error(uint8_t error_code, bool retry = false, bool full_registration = false); |
leothedragon | 0:8f0bb79ddd48 | 320 | |
leothedragon | 0:8f0bb79ddd48 | 321 | virtual void client_unregistered(); |
leothedragon | 0:8f0bb79ddd48 | 322 | |
leothedragon | 0:8f0bb79ddd48 | 323 | virtual void bootstrap_done(); |
leothedragon | 0:8f0bb79ddd48 | 324 | |
leothedragon | 0:8f0bb79ddd48 | 325 | virtual void bootstrap_finish(); |
leothedragon | 0:8f0bb79ddd48 | 326 | |
leothedragon | 0:8f0bb79ddd48 | 327 | virtual void bootstrap_wait(); |
leothedragon | 0:8f0bb79ddd48 | 328 | |
leothedragon | 0:8f0bb79ddd48 | 329 | virtual void bootstrap_error_wait(const char *reason); |
leothedragon | 0:8f0bb79ddd48 | 330 | |
leothedragon | 0:8f0bb79ddd48 | 331 | virtual void bootstrap_error(const char *reason); |
leothedragon | 0:8f0bb79ddd48 | 332 | |
leothedragon | 0:8f0bb79ddd48 | 333 | virtual void coap_data_processed(); |
leothedragon | 0:8f0bb79ddd48 | 334 | |
leothedragon | 0:8f0bb79ddd48 | 335 | virtual void value_updated(M2MBase *base); |
leothedragon | 0:8f0bb79ddd48 | 336 | |
leothedragon | 0:8f0bb79ddd48 | 337 | protected: // From M2MConnectionObserver |
leothedragon | 0:8f0bb79ddd48 | 338 | |
leothedragon | 0:8f0bb79ddd48 | 339 | virtual void data_available(uint8_t* data, |
leothedragon | 0:8f0bb79ddd48 | 340 | uint16_t data_size, |
leothedragon | 0:8f0bb79ddd48 | 341 | const M2MConnectionObserver::SocketAddress &address); |
leothedragon | 0:8f0bb79ddd48 | 342 | |
leothedragon | 0:8f0bb79ddd48 | 343 | virtual void socket_error(int error_code, bool retry = true); |
leothedragon | 0:8f0bb79ddd48 | 344 | |
leothedragon | 0:8f0bb79ddd48 | 345 | virtual void address_ready(const M2MConnectionObserver::SocketAddress &address, |
leothedragon | 0:8f0bb79ddd48 | 346 | M2MConnectionObserver::ServerType server_type, |
leothedragon | 0:8f0bb79ddd48 | 347 | const uint16_t server_port); |
leothedragon | 0:8f0bb79ddd48 | 348 | |
leothedragon | 0:8f0bb79ddd48 | 349 | virtual void data_sent(); |
leothedragon | 0:8f0bb79ddd48 | 350 | |
leothedragon | 0:8f0bb79ddd48 | 351 | protected: // from M2MTimerObserver |
leothedragon | 0:8f0bb79ddd48 | 352 | |
leothedragon | 0:8f0bb79ddd48 | 353 | virtual void timer_expired(M2MTimerObserver::Type type); |
leothedragon | 0:8f0bb79ddd48 | 354 | |
leothedragon | 0:8f0bb79ddd48 | 355 | |
leothedragon | 0:8f0bb79ddd48 | 356 | private: // state machine state functions |
leothedragon | 0:8f0bb79ddd48 | 357 | |
leothedragon | 0:8f0bb79ddd48 | 358 | /** |
leothedragon | 0:8f0bb79ddd48 | 359 | * When the state is Idle. |
leothedragon | 0:8f0bb79ddd48 | 360 | */ |
leothedragon | 0:8f0bb79ddd48 | 361 | void state_idle(EventData* data); |
leothedragon | 0:8f0bb79ddd48 | 362 | |
leothedragon | 0:8f0bb79ddd48 | 363 | /** |
leothedragon | 0:8f0bb79ddd48 | 364 | * When the client starts bootstrap. |
leothedragon | 0:8f0bb79ddd48 | 365 | */ |
leothedragon | 0:8f0bb79ddd48 | 366 | void state_bootstrap( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 367 | |
leothedragon | 0:8f0bb79ddd48 | 368 | /** |
leothedragon | 0:8f0bb79ddd48 | 369 | * When the bootstrap server address is resolved. |
leothedragon | 0:8f0bb79ddd48 | 370 | */ |
leothedragon | 0:8f0bb79ddd48 | 371 | void state_bootstrap_address_resolved( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 372 | |
leothedragon | 0:8f0bb79ddd48 | 373 | /** |
leothedragon | 0:8f0bb79ddd48 | 374 | * When the bootstrap resource is created. |
leothedragon | 0:8f0bb79ddd48 | 375 | */ |
leothedragon | 0:8f0bb79ddd48 | 376 | void state_bootstrap_resource_created( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 377 | |
leothedragon | 0:8f0bb79ddd48 | 378 | /** |
leothedragon | 0:8f0bb79ddd48 | 379 | * When the server has sent response and bootstrapping is done. |
leothedragon | 0:8f0bb79ddd48 | 380 | */ |
leothedragon | 0:8f0bb79ddd48 | 381 | void state_bootstrapped( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 382 | |
leothedragon | 0:8f0bb79ddd48 | 383 | /** |
leothedragon | 0:8f0bb79ddd48 | 384 | * When the client starts register. |
leothedragon | 0:8f0bb79ddd48 | 385 | */ |
leothedragon | 0:8f0bb79ddd48 | 386 | void state_register( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 387 | |
leothedragon | 0:8f0bb79ddd48 | 388 | /** |
leothedragon | 0:8f0bb79ddd48 | 389 | * When the server address for register is resolved. |
leothedragon | 0:8f0bb79ddd48 | 390 | */ |
leothedragon | 0:8f0bb79ddd48 | 391 | void state_register_address_resolved( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 392 | |
leothedragon | 0:8f0bb79ddd48 | 393 | /** |
leothedragon | 0:8f0bb79ddd48 | 394 | * When the client is registered. |
leothedragon | 0:8f0bb79ddd48 | 395 | */ |
leothedragon | 0:8f0bb79ddd48 | 396 | void state_registered( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 397 | |
leothedragon | 0:8f0bb79ddd48 | 398 | /** |
leothedragon | 0:8f0bb79ddd48 | 399 | * When the client is updating registration. |
leothedragon | 0:8f0bb79ddd48 | 400 | */ |
leothedragon | 0:8f0bb79ddd48 | 401 | void state_update_registration( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 402 | |
leothedragon | 0:8f0bb79ddd48 | 403 | /** |
leothedragon | 0:8f0bb79ddd48 | 404 | * When the client starts unregister. |
leothedragon | 0:8f0bb79ddd48 | 405 | */ |
leothedragon | 0:8f0bb79ddd48 | 406 | void state_unregister( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 407 | |
leothedragon | 0:8f0bb79ddd48 | 408 | /** |
leothedragon | 0:8f0bb79ddd48 | 409 | * When the client has been unregistered. |
leothedragon | 0:8f0bb79ddd48 | 410 | */ |
leothedragon | 0:8f0bb79ddd48 | 411 | void state_unregistered( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 412 | |
leothedragon | 0:8f0bb79ddd48 | 413 | /** |
leothedragon | 0:8f0bb79ddd48 | 414 | * When the coap data is been sent through socket. |
leothedragon | 0:8f0bb79ddd48 | 415 | */ |
leothedragon | 0:8f0bb79ddd48 | 416 | void state_sending_coap_data( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 417 | |
leothedragon | 0:8f0bb79ddd48 | 418 | /** |
leothedragon | 0:8f0bb79ddd48 | 419 | * When the coap data is sent successfully. |
leothedragon | 0:8f0bb79ddd48 | 420 | */ |
leothedragon | 0:8f0bb79ddd48 | 421 | void state_coap_data_sent( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 422 | |
leothedragon | 0:8f0bb79ddd48 | 423 | /** |
leothedragon | 0:8f0bb79ddd48 | 424 | * When the socket is receiving coap data. |
leothedragon | 0:8f0bb79ddd48 | 425 | */ |
leothedragon | 0:8f0bb79ddd48 | 426 | void state_receiving_coap_data( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 427 | |
leothedragon | 0:8f0bb79ddd48 | 428 | /** |
leothedragon | 0:8f0bb79ddd48 | 429 | * When the socket has received coap data. |
leothedragon | 0:8f0bb79ddd48 | 430 | */ |
leothedragon | 0:8f0bb79ddd48 | 431 | void state_coap_data_received( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 432 | |
leothedragon | 0:8f0bb79ddd48 | 433 | /** |
leothedragon | 0:8f0bb79ddd48 | 434 | * When the coap message is being processed. |
leothedragon | 0:8f0bb79ddd48 | 435 | */ |
leothedragon | 0:8f0bb79ddd48 | 436 | void state_processing_coap_data( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 437 | |
leothedragon | 0:8f0bb79ddd48 | 438 | /** |
leothedragon | 0:8f0bb79ddd48 | 439 | * When the coap message has been processed. |
leothedragon | 0:8f0bb79ddd48 | 440 | */ |
leothedragon | 0:8f0bb79ddd48 | 441 | void state_coap_data_processed( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 442 | |
leothedragon | 0:8f0bb79ddd48 | 443 | /** |
leothedragon | 0:8f0bb79ddd48 | 444 | * When the client is waiting to receive or send data. |
leothedragon | 0:8f0bb79ddd48 | 445 | */ |
leothedragon | 0:8f0bb79ddd48 | 446 | void state_waiting( EventData *data); |
leothedragon | 0:8f0bb79ddd48 | 447 | |
leothedragon | 0:8f0bb79ddd48 | 448 | /** |
leothedragon | 0:8f0bb79ddd48 | 449 | * Start registration update. |
leothedragon | 0:8f0bb79ddd48 | 450 | */ |
leothedragon | 0:8f0bb79ddd48 | 451 | void start_register_update(M2MUpdateRegisterData *data); |
leothedragon | 0:8f0bb79ddd48 | 452 | |
leothedragon | 0:8f0bb79ddd48 | 453 | /** |
leothedragon | 0:8f0bb79ddd48 | 454 | * State enumeration order must match the order of state |
leothedragon | 0:8f0bb79ddd48 | 455 | * method entries in the state map |
leothedragon | 0:8f0bb79ddd48 | 456 | */ |
leothedragon | 0:8f0bb79ddd48 | 457 | enum E_States { |
leothedragon | 0:8f0bb79ddd48 | 458 | STATE_IDLE = 0, |
leothedragon | 0:8f0bb79ddd48 | 459 | STATE_BOOTSTRAP, |
leothedragon | 0:8f0bb79ddd48 | 460 | STATE_BOOTSTRAP_ADDRESS_RESOLVED, |
leothedragon | 0:8f0bb79ddd48 | 461 | STATE_BOOTSTRAP_RESOURCE_CREATED, |
leothedragon | 0:8f0bb79ddd48 | 462 | STATE_BOOTSTRAP_WAIT, |
leothedragon | 0:8f0bb79ddd48 | 463 | STATE_BOOTSTRAP_ERROR_WAIT, // 5 |
leothedragon | 0:8f0bb79ddd48 | 464 | STATE_BOOTSTRAPPED, |
leothedragon | 0:8f0bb79ddd48 | 465 | STATE_REGISTER, |
leothedragon | 0:8f0bb79ddd48 | 466 | STATE_REGISTER_ADDRESS_RESOLVED, |
leothedragon | 0:8f0bb79ddd48 | 467 | STATE_REGISTERED, |
leothedragon | 0:8f0bb79ddd48 | 468 | STATE_UPDATE_REGISTRATION, // 10 |
leothedragon | 0:8f0bb79ddd48 | 469 | STATE_UNREGISTER, |
leothedragon | 0:8f0bb79ddd48 | 470 | STATE_UNREGISTERED, |
leothedragon | 0:8f0bb79ddd48 | 471 | STATE_SENDING_COAP_DATA, |
leothedragon | 0:8f0bb79ddd48 | 472 | STATE_COAP_DATA_SENT, |
leothedragon | 0:8f0bb79ddd48 | 473 | STATE_COAP_DATA_RECEIVED, // 15 |
leothedragon | 0:8f0bb79ddd48 | 474 | STATE_PROCESSING_COAP_DATA, |
leothedragon | 0:8f0bb79ddd48 | 475 | STATE_COAP_DATA_PROCESSED, |
leothedragon | 0:8f0bb79ddd48 | 476 | STATE_WAITING, |
leothedragon | 0:8f0bb79ddd48 | 477 | STATE_MAX_STATES |
leothedragon | 0:8f0bb79ddd48 | 478 | }; |
leothedragon | 0:8f0bb79ddd48 | 479 | |
leothedragon | 0:8f0bb79ddd48 | 480 | /** |
leothedragon | 0:8f0bb79ddd48 | 481 | * @brief Redirects the state machine to right function. |
leothedragon | 0:8f0bb79ddd48 | 482 | * @param current_state Current state to be set. |
leothedragon | 0:8f0bb79ddd48 | 483 | * @param data Data to be passed to the state function. |
leothedragon | 0:8f0bb79ddd48 | 484 | */ |
leothedragon | 0:8f0bb79ddd48 | 485 | void state_function( uint8_t current_state, EventData* data ); |
leothedragon | 0:8f0bb79ddd48 | 486 | |
leothedragon | 0:8f0bb79ddd48 | 487 | /** |
leothedragon | 0:8f0bb79ddd48 | 488 | * @brief State Engine maintaining state machine logic. |
leothedragon | 0:8f0bb79ddd48 | 489 | */ |
leothedragon | 0:8f0bb79ddd48 | 490 | void state_engine(void); |
leothedragon | 0:8f0bb79ddd48 | 491 | |
leothedragon | 0:8f0bb79ddd48 | 492 | /** |
leothedragon | 0:8f0bb79ddd48 | 493 | * External event which can trigger the state machine. |
leothedragon | 0:8f0bb79ddd48 | 494 | * @param New The state to which the state machine should go. |
leothedragon | 0:8f0bb79ddd48 | 495 | * @param data The data to be passed to the state machine. |
leothedragon | 0:8f0bb79ddd48 | 496 | */ |
leothedragon | 0:8f0bb79ddd48 | 497 | void external_event(uint8_t, EventData* = NULL); |
leothedragon | 0:8f0bb79ddd48 | 498 | |
leothedragon | 0:8f0bb79ddd48 | 499 | /** |
leothedragon | 0:8f0bb79ddd48 | 500 | * Internal event generated by state machine. |
leothedragon | 0:8f0bb79ddd48 | 501 | * @param New State which the state machine should go to. |
leothedragon | 0:8f0bb79ddd48 | 502 | * @param data The data to be passed to the state machine. |
leothedragon | 0:8f0bb79ddd48 | 503 | */ |
leothedragon | 0:8f0bb79ddd48 | 504 | void internal_event(uint8_t, EventData* = NULL); |
leothedragon | 0:8f0bb79ddd48 | 505 | |
leothedragon | 0:8f0bb79ddd48 | 506 | /** |
leothedragon | 0:8f0bb79ddd48 | 507 | * Queue mode enabled or not. |
leothedragon | 0:8f0bb79ddd48 | 508 | * @return True if queue mode otherwise false. |
leothedragon | 0:8f0bb79ddd48 | 509 | */ |
leothedragon | 0:8f0bb79ddd48 | 510 | bool queue_mode() const; |
leothedragon | 0:8f0bb79ddd48 | 511 | |
leothedragon | 0:8f0bb79ddd48 | 512 | enum |
leothedragon | 0:8f0bb79ddd48 | 513 | { |
leothedragon | 0:8f0bb79ddd48 | 514 | EVENT_IGNORED = 0xFE, |
leothedragon | 0:8f0bb79ddd48 | 515 | CANNOT_HAPPEN |
leothedragon | 0:8f0bb79ddd48 | 516 | }; |
leothedragon | 0:8f0bb79ddd48 | 517 | |
leothedragon | 0:8f0bb79ddd48 | 518 | /** |
leothedragon | 0:8f0bb79ddd48 | 519 | * Helper method for extracting the IP address part and port from the |
leothedragon | 0:8f0bb79ddd48 | 520 | * given server address. |
leothedragon | 0:8f0bb79ddd48 | 521 | * @param server_address Source URL (without "coap" or "coaps" prefix). |
leothedragon | 0:8f0bb79ddd48 | 522 | * @param ip_address The extracted IP. |
leothedragon | 0:8f0bb79ddd48 | 523 | * @param port The extracted port. |
leothedragon | 0:8f0bb79ddd48 | 524 | */ |
leothedragon | 0:8f0bb79ddd48 | 525 | static void process_address(const String& server_address, String& ip_address, uint16_t& port); |
leothedragon | 0:8f0bb79ddd48 | 526 | |
leothedragon | 0:8f0bb79ddd48 | 527 | /** |
leothedragon | 0:8f0bb79ddd48 | 528 | * Helper method for storing the error description to _error_description if the feature |
leothedragon | 0:8f0bb79ddd48 | 529 | * has not been turned off. |
leothedragon | 0:8f0bb79ddd48 | 530 | * @param error description |
leothedragon | 0:8f0bb79ddd48 | 531 | */ |
leothedragon | 0:8f0bb79ddd48 | 532 | void set_error_description(const char *description); |
leothedragon | 0:8f0bb79ddd48 | 533 | |
leothedragon | 0:8f0bb79ddd48 | 534 | enum ReconnectionState{ |
leothedragon | 0:8f0bb79ddd48 | 535 | None, |
leothedragon | 0:8f0bb79ddd48 | 536 | WithUpdate, |
leothedragon | 0:8f0bb79ddd48 | 537 | Unregistration |
leothedragon | 0:8f0bb79ddd48 | 538 | }; |
leothedragon | 0:8f0bb79ddd48 | 539 | |
leothedragon | 0:8f0bb79ddd48 | 540 | private: |
leothedragon | 0:8f0bb79ddd48 | 541 | |
leothedragon | 0:8f0bb79ddd48 | 542 | EventData *_event_data; |
leothedragon | 0:8f0bb79ddd48 | 543 | M2MTimer *_registration_flow_timer; |
leothedragon | 0:8f0bb79ddd48 | 544 | uint16_t _server_port; |
leothedragon | 0:8f0bb79ddd48 | 545 | uint16_t _listen_port; |
leothedragon | 0:8f0bb79ddd48 | 546 | int32_t _life_time; |
leothedragon | 0:8f0bb79ddd48 | 547 | String _server_ip_address; |
leothedragon | 0:8f0bb79ddd48 | 548 | M2MSecurity *_register_server; //TODO: to be the list not owned |
leothedragon | 0:8f0bb79ddd48 | 549 | M2MTimer _queue_sleep_timer; |
leothedragon | 0:8f0bb79ddd48 | 550 | M2MTimer _retry_timer; |
leothedragon | 0:8f0bb79ddd48 | 551 | callback_handler _callback_handler; |
leothedragon | 0:8f0bb79ddd48 | 552 | const uint8_t _max_states; |
leothedragon | 0:8f0bb79ddd48 | 553 | bool _event_ignored; |
leothedragon | 0:8f0bb79ddd48 | 554 | bool _event_generated; |
leothedragon | 0:8f0bb79ddd48 | 555 | bool _reconnecting; |
leothedragon | 0:8f0bb79ddd48 | 556 | bool _retry_timer_expired; |
leothedragon | 0:8f0bb79ddd48 | 557 | bool _bootstrapped; |
leothedragon | 0:8f0bb79ddd48 | 558 | bool _bootstrap_finished; |
leothedragon | 0:8f0bb79ddd48 | 559 | bool _queue_mode_timer_ongoing; |
leothedragon | 0:8f0bb79ddd48 | 560 | uint8_t _current_state; |
leothedragon | 0:8f0bb79ddd48 | 561 | BindingMode _binding_mode; |
leothedragon | 0:8f0bb79ddd48 | 562 | ReconnectionState _reconnection_state; |
leothedragon | 0:8f0bb79ddd48 | 563 | M2MInterfaceObserver &_observer; |
leothedragon | 0:8f0bb79ddd48 | 564 | M2MConnectionSecurity *_security_connection; // Doesn't own |
leothedragon | 0:8f0bb79ddd48 | 565 | M2MConnectionHandler _connection_handler; |
leothedragon | 0:8f0bb79ddd48 | 566 | M2MNsdlInterface _nsdl_interface; |
leothedragon | 0:8f0bb79ddd48 | 567 | M2MSecurity *_security; |
leothedragon | 0:8f0bb79ddd48 | 568 | |
leothedragon | 0:8f0bb79ddd48 | 569 | #ifndef DISABLE_ERROR_DESCRIPTION |
leothedragon | 0:8f0bb79ddd48 | 570 | // The DISABLE_ERROR_DESCRIPTION macro will reduce the flash usage by ~1800 bytes. |
leothedragon | 0:8f0bb79ddd48 | 571 | char _error_description[MAX_ALLOWED_ERROR_STRING_LENGTH]; |
leothedragon | 0:8f0bb79ddd48 | 572 | #endif |
leothedragon | 0:8f0bb79ddd48 | 573 | |
leothedragon | 0:8f0bb79ddd48 | 574 | uint8_t _initial_reconnection_time; |
leothedragon | 0:8f0bb79ddd48 | 575 | uint64_t _reconnection_time; |
leothedragon | 0:8f0bb79ddd48 | 576 | |
leothedragon | 0:8f0bb79ddd48 | 577 | friend class Test_M2MInterfaceImpl; |
leothedragon | 0:8f0bb79ddd48 | 578 | |
leothedragon | 0:8f0bb79ddd48 | 579 | }; |
leothedragon | 0:8f0bb79ddd48 | 580 | |
leothedragon | 0:8f0bb79ddd48 | 581 | #define BEGIN_TRANSITION_MAP \ |
leothedragon | 0:8f0bb79ddd48 | 582 | static const uint8_t TRANSITIONS[] = {\ |
leothedragon | 0:8f0bb79ddd48 | 583 | |
leothedragon | 0:8f0bb79ddd48 | 584 | #define TRANSITION_MAP_ENTRY(entry)\ |
leothedragon | 0:8f0bb79ddd48 | 585 | entry, |
leothedragon | 0:8f0bb79ddd48 | 586 | |
leothedragon | 0:8f0bb79ddd48 | 587 | #define END_TRANSITION_MAP(data) \ |
leothedragon | 0:8f0bb79ddd48 | 588 | 0 };\ |
leothedragon | 0:8f0bb79ddd48 | 589 | external_event(TRANSITIONS[_current_state], data); |
leothedragon | 0:8f0bb79ddd48 | 590 | |
leothedragon | 0:8f0bb79ddd48 | 591 | #endif //M2M_INTERFACE_IMPL_H |
leothedragon | 0:8f0bb79ddd48 | 592 | |
leothedragon | 0:8f0bb79ddd48 | 593 |