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.
Fork of mbedConnectorInterfaceV3 by
ConnectorEndpoint.h
00001 /** 00002 * @file Endpoint.h 00003 * @brief mbed CoAP Endpoint base class 00004 * @author Doug Anson/Chris Paola 00005 * @version 1.0 00006 * @see 00007 * 00008 * Copyright (c) 2014 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); 00011 * you may not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, 00018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 */ 00022 00023 #ifndef __CONNECTOR_ENDPOINT_H__ 00024 #define __CONNECTOR_ENDPOINT_H__ 00025 00026 // Support for Logging/Debug output 00027 #include "mbed-connector-interface/Logger.h" 00028 00029 // mbed-client support 00030 #include "mbed-client/m2minterfacefactory.h" 00031 #include "mbed-client/m2minterfaceobserver.h" 00032 #include "mbed-client/m2minterface.h" 00033 #include "mbed-client/m2mobjectinstance.h" 00034 #include "mbed-client/m2mresource.h" 00035 #include "mbed-client/m2mdevice.h" 00036 #include "mbed-client/m2mfirmware.h" 00037 00038 // Options support 00039 #include "mbed-connector-interface/Options.h" 00040 00041 // ConnectionStatusInterface support 00042 #include "mbed-connector-interface/ConnectionStatusInterface.h" 00043 00044 // ObjectInstanceManager support 00045 #include "mbed-connector-interface/ObjectInstanceManager.h" 00046 00047 // Connector namespace 00048 namespace Connector { 00049 00050 /** Endpoint class 00051 */ 00052 #ifdef ENABLE_MBED_CLOUD_SUPPORT 00053 class Endpoint : public MbedCloudClientCallback, public M2MInterfaceObserver { 00054 #else 00055 class Endpoint : public M2MInterfaceObserver { 00056 #endif 00057 00058 public: 00059 /** 00060 Default Constructor 00061 */ 00062 Endpoint(const Logger *logger,const Options *ob); 00063 00064 /** 00065 Copy Constructor 00066 @param ob input endpoint instance to deep copy 00067 */ 00068 Endpoint(const Endpoint &ep); 00069 00070 /** 00071 Destructor 00072 */ 00073 virtual ~Endpoint(); 00074 00075 /** 00076 Build out the endpoint. 00077 */ 00078 void buildEndpoint(); 00079 00080 /** 00081 Plumb the lower RF network stack 00082 @param device_manager input optional device manager (DeviceManager type) 00083 @param canActAsRouterNode input boolean indicating whether this node can act as a router node or not. 00084 */ 00085 static void plumbNetwork(void *device_manager = NULL,bool canActAsRouterNode = false); 00086 00087 /** 00088 Initialize the endpoint's configuration and begin the endpoint's main even loop 00089 */ 00090 static void start(); 00091 00092 /** 00093 Set the ConnectionStatusInterface instance 00094 @param csi input instance pointer to the ConnectionStatusInterface implementation to be used 00095 */ 00096 static void setConnectionStatusInterface(ConnectionStatusInterface *csi); 00097 00098 // re-register endpoint 00099 void re_register_endpoint(); 00100 00101 // de-register endpoint and stop scheduling 00102 void de_register_endpoint(void); 00103 00104 // mbed-client : register the endpoint 00105 void register_endpoint(M2MSecurity *server_instance, M2MObjectList resources); 00106 00107 #ifdef ENABLE_MBED_CLOUD_SUPPORT 00108 // mbed-cloud-client : object registered 00109 static void on_registered(); 00110 00111 // mbed-cloud-client : registration updated 00112 static void on_registration_updated(); 00113 00114 // mbed-cloud-client : object unregistered 00115 static void on_unregistered(); 00116 00117 // mbed-cloud-client: error 00118 static void on_error(int error_code); 00119 00120 /** 00121 * @brief Function for authorizing firmware downloads and reboots. 00122 * @param request The request under consideration. 00123 */ 00124 static void update_authorize(int32_t request); 00125 00126 /** 00127 * @brief Callback function for reporting the firmware download progress. 00128 * @param progress Received bytes. 00129 * @param total Total amount of bytes to be received. 00130 */ 00131 static void update_progress(uint32_t progress, uint32_t total); 00132 #endif 00133 00134 // mbed-client : object registered 00135 virtual void object_registered(M2MSecurity *security, const M2MServer &server); 00136 void object_registered(void *security = NULL,void *server = NULL); 00137 00138 // mbed-client : registration updated 00139 virtual void registration_updated(M2MSecurity *security, const M2MServer &server); 00140 void registration_updated(void *security = NULL,void *server = NULL); 00141 00142 // mbed-client : object unregistered 00143 virtual void object_unregistered(M2MSecurity *security = NULL); 00144 00145 // mbed-client : bootstrap done 00146 virtual void bootstrap_done(M2MSecurity *security = NULL); 00147 00148 // mbed-client : resource value updated 00149 virtual void value_updated(M2MBase *resource, M2MBase::BaseType type) ; 00150 00151 // mbed-client : error handler 00152 virtual void error(M2MInterface::Error error); 00153 00154 // get our Options 00155 void setOptions(Options *options); 00156 00157 // get our Options 00158 Options *getOptions(); 00159 00160 #ifdef ENABLE_MBED_CLOUD_SUPPORT 00161 // get our Endpoint Interface 00162 MbedCloudClient *getEndpointInterface(); 00163 #else 00164 // get our Endpoint Interface 00165 M2MInterface *getEndpointInterface(); 00166 #endif 00167 00168 // get our Endpoint Security 00169 M2MSecurity *getSecurityInstance(); 00170 00171 // get our Endpoint Object List 00172 M2MObjectList getEndpointObjectList(); 00173 00174 // configure to act as router node 00175 void asRouterNode(bool canActAsRouterNode); 00176 00177 // access the logger 00178 Logger *logger(); 00179 00180 // set the device manager 00181 void setDeviceManager(void *device_manager); 00182 00183 // get the device manager 00184 void *getDeviceManager(void); 00185 00186 // underlying network is connected (SET) 00187 void isConnected(bool connected); 00188 00189 // underlying network is connected (GET) 00190 bool isConnected(); 00191 00192 // Registered with mDC/mDS 00193 bool isRegistered(); 00194 00195 /** 00196 Set the ConnectionStatusInterface instance 00197 @param csi input instance pointer to the ConnectionStatusInterface implementation to be used 00198 */ 00199 void setConnectionStatusInterfaceImpl(ConnectionStatusInterface *csi); 00200 00201 // Set ObjectInstanceManager 00202 void setObjectInstanceManager(ObjectInstanceManager *oim); 00203 00204 // Get ObjectInstanceManager 00205 ObjectInstanceManager *getObjectInstanceManager(); 00206 00207 private: 00208 Logger *m_logger; 00209 Options *m_options; 00210 bool m_canActAsRouterNode; 00211 bool m_connected; 00212 bool m_registered; 00213 00214 // mbed-client support 00215 #ifdef ENABLE_MBED_CLOUD_SUPPORT 00216 MbedCloudClient *m_endpoint_interface; 00217 #else 00218 M2MInterface *m_endpoint_interface; 00219 #endif 00220 M2MSecurity *m_endpoint_security; 00221 M2MObjectList m_endpoint_object_list; 00222 00223 // Device Manager 00224 void *m_device_manager; 00225 00226 // ConnectionStatusInterface implementation 00227 ConnectionStatusInterface *m_csi; 00228 00229 // ObjectInstanceManager 00230 ObjectInstanceManager *m_oim; 00231 00232 // create our endpoint interface 00233 void createEndpointInterface(); 00234 00235 #ifdef ENABLE_MBED_CLOUD_SUPPORT 00236 // mbed-cloud methods (R1.2+) 00237 bool initializeStorage(); 00238 bool initializeFactoryFlow(); 00239 void createCloudEndpointInterface(); 00240 #else 00241 // mbed-client methods 00242 void createConnectorEndpointInterface(); 00243 #endif 00244 00245 // create our endpoint security instance 00246 M2MSecurity *createEndpointSecurityInstance(); 00247 00248 // DynamicResource Lookup 00249 DynamicResource *lookupDynamicResource(M2MBase *base); 00250 00251 // stop underlying observers 00252 void stopObservations(); 00253 00254 // set our endpoint security instance 00255 void setSecurityInstance(M2MSecurity *security); 00256 }; 00257 00258 } // namespace Connector 00259 00260 #endif // __CONNECTOR_ENDPOINT_H__
Generated on Tue Jul 12 2022 18:16:51 by
1.7.2
