Doug Anson / mbedConnectorInterfaceV3
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ConnectorEndpoint.h Source File

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 // mbed-client support
00027 #include "mbed-client/m2minterfacefactory.h"
00028 #include "mbed-client/m2mdevice.h"
00029 #include "mbed-client/m2minterfaceobserver.h"
00030 #include "mbed-client/m2minterface.h"
00031 #include "mbed-client/m2mobjectinstance.h"
00032 #include "mbed-client/m2mresource.h"
00033 
00034 // Support for Logging/Debug output
00035 #include "mbed-connector-interface/Logger.h"
00036 
00037 // Options support
00038 #include "mbed-connector-interface/Options.h"
00039 
00040 // Connector namespace
00041 namespace Connector  {
00042 
00043 /** Endpoint class
00044  */
00045 class Endpoint : public M2MInterfaceObserver  {
00046 
00047 public:
00048     /**
00049     Default Constructor
00050     */
00051     Endpoint(const Logger *logger,const Options *ob);
00052 
00053     /**
00054     Copy Constructor
00055     @param ob input endpoint instance to deep copy
00056     */
00057     Endpoint(const Endpoint &ep);
00058 
00059     /**
00060     Destructor
00061     */
00062     virtual ~Endpoint();
00063 
00064     /**
00065     Build out the endpoint.
00066     */
00067     void build_endpoint();
00068 
00069     /**
00070     Plumb the lower RF network stack
00071     @param device_manager input optional device manager (DeviceManager type)
00072     @param canActAsRouterNode input boolean indicating whether this node can act as a router node or not.
00073     */
00074     static void plumbNetwork(void *device_manager = NULL,bool canActAsRouterNode = false);
00075 
00076     /**
00077     Initialize the endpoint's configuration and begin the endpoint's main even loop
00078     */
00079     static void start();
00080     
00081     // register the endpoint
00082     void register_endpoint(M2MSecurity *server_instance, M2MObjectList resources);
00083     
00084     // re-register endpoint
00085     void re_register_endpoint();
00086     
00087     // de-register endpoint and stop scheduling
00088     void de_register_endpoint(void);
00089     
00090     //  mbed-client : object registered
00091     virtual void object_registered(M2MSecurity *server_instance, const M2MServer &server);
00092 
00093     //  mbed-client : registration updated
00094     virtual void registration_updated(M2MSecurity *server_instance, const M2MServer &server) ;
00095 
00096     //  mbed-client : object unregistered
00097     virtual void object_unregistered(M2MSecurity *server_instance);
00098 
00099     //  mbed-client : bootstrap done
00100     virtual void bootstrap_done(M2MSecurity *server_instance);
00101 
00102     //  mbed-client : resource value updated
00103     virtual void value_updated(M2MBase *resource, M2MBase::BaseType type) ;
00104     
00105     //  mbed-client : error handler
00106     virtual void error(M2MInterface::Error error);
00107     
00108     // get our Options
00109     void setOptions(Options *options);
00110     
00111     // get our Options
00112     Options *getOptions();
00113     
00114     // get our Server
00115     M2MSecurity *getServer();
00116     
00117     // get our Object List
00118     M2MObjectList  getObjectList();
00119     
00120     // configure to act as router node
00121     void asRouterNode(bool canActAsRouterNode);
00122     
00123     // access the logger
00124     Logger *logger();
00125     
00126     // set the device manager
00127     void setDeviceManager(void *device_manager);
00128     
00129     // get the device manager
00130     void *getDeviceManager(void);
00131     
00132     // underlying network is connected (SET)
00133     void isConnected(bool connected); 
00134     
00135     // underlying network is connected (GET)
00136     bool isConnected();
00137     
00138     // Registered with mDC/mDS
00139     bool isRegistered();
00140 
00141 private:
00142     Logger            *m_logger;
00143     Options           *m_options;
00144     bool               m_canActAsRouterNode;
00145     bool               m_connected;
00146     bool               m_registered;
00147     
00148     // mbed-client support
00149     M2MInterface      *m_interface;
00150     M2MSecurity       *m_server_instance;
00151     M2MObjectList      m_object_list;
00152     M2MDevice         *m_device_object;
00153     
00154     // mbed-client methods
00155     void create_interface();
00156     M2MSecurity *create_server_instance();
00157     
00158     // Device Manager
00159     void              *m_device_manager;
00160     
00161     // DynamicResource Lookup
00162     DynamicResource *lookupDynamicResource(M2MBase *base);
00163 };
00164 
00165 } // namespace Connector
00166 
00167 #endif // __CONNECTOR_ENDPOINT_H__