This is the sample program that can see the decode result of barcode data on Watson IoT.

Dependencies:   AsciiFont DisplayApp GR-PEACH_video LCD_shield_config LWIPBP3595Interface_STA_for_mbed-os USBDevice

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/m2minterfaceobserver.h"
00029 #include "mbed-client/m2minterface.h"
00030 #include "mbed-client/m2mobjectinstance.h"
00031 #include "mbed-client/m2mresource.h"
00032 #include "mbed-client/m2mdevice.h"
00033 #include "mbed-client/m2mfirmware.h"
00034 
00035 // Support for Logging/Debug output
00036 #include "mbed-connector-interface/Logger.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 class Endpoint : public M2MInterfaceObserver  {
00053 
00054 public:
00055     /**
00056     Default Constructor
00057     */
00058     Endpoint(const Logger *logger,const Options *ob);
00059 
00060     /**
00061     Copy Constructor
00062     @param ob input endpoint instance to deep copy
00063     */
00064     Endpoint(const Endpoint &ep);
00065 
00066     /**
00067     Destructor
00068     */
00069     virtual ~Endpoint();
00070 
00071     /**
00072     Build out the endpoint.
00073     */
00074     void buildEndpoint();
00075 
00076     /**
00077     Plumb the lower RF network stack
00078     @param device_manager input optional device manager (DeviceManager type)
00079     @param canActAsRouterNode input boolean indicating whether this node can act as a router node or not.
00080     */
00081     static void plumbNetwork(void *device_manager = NULL,bool canActAsRouterNode = false);
00082 
00083     /**
00084     Initialize the endpoint's configuration and begin the endpoint's main even loop
00085     */
00086     static void start();
00087     
00088     /**
00089     Set the ConnectionStatusInterface instance
00090     @param csi input instance pointer to the ConnectionStatusInterface implementation to be used
00091     */
00092     static void setConnectionStatusInterface(ConnectionStatusInterface *csi);
00093     
00094     // register the endpoint
00095     void register_endpoint(M2MSecurity *server_instance, M2MObjectList resources);
00096     
00097     // re-register endpoint
00098     void re_register_endpoint();
00099     
00100     // de-register endpoint and stop scheduling
00101     void de_register_endpoint(void);
00102     
00103     //  mbed-client : object registered
00104     virtual void object_registered(M2MSecurity *server_instance, const M2MServer &server);
00105 
00106     //  mbed-client : registration updated
00107     virtual void registration_updated(M2MSecurity *server_instance, const M2MServer &server) ;
00108 
00109     //  mbed-client : object unregistered
00110     virtual void object_unregistered(M2MSecurity *server_instance);
00111 
00112     //  mbed-client : bootstrap done
00113     virtual void bootstrap_done(M2MSecurity *server_instance);
00114 
00115     //  mbed-client : resource value updated
00116     virtual void value_updated(M2MBase *resource, M2MBase::BaseType type) ;
00117     
00118     //  mbed-client : error handler
00119     virtual void error(M2MInterface::Error error);
00120     
00121     // get our Options
00122     void setOptions(Options *options);
00123     
00124     // get our Options
00125     Options *getOptions();
00126     
00127     // get our Endpoint Interface
00128     M2MInterface *getEndpointInterface();
00129     
00130     // get our Endpoint Security
00131     M2MSecurity *getEndpointSecurity();
00132     
00133     // get our Endpoint Object List
00134     M2MObjectList  getEndpointObjectList();
00135     
00136     // configure to act as router node
00137     void asRouterNode(bool canActAsRouterNode);
00138     
00139     // access the logger
00140     Logger *logger();
00141     
00142     // set the device manager
00143     void setDeviceManager(void *device_manager);
00144     
00145     // get the device manager
00146     void *getDeviceManager(void);
00147     
00148     // underlying network is connected (SET)
00149     void isConnected(bool connected); 
00150     
00151     // underlying network is connected (GET)
00152     bool isConnected();
00153     
00154     // Registered with mDC/mDS
00155     bool isRegistered();
00156     
00157     /**
00158     Set the ConnectionStatusInterface instance
00159     @param csi input instance pointer to the ConnectionStatusInterface implementation to be used
00160     */
00161     void setConnectionStatusInterfaceImpl(ConnectionStatusInterface *csi); 
00162 
00163     // Set ObjectInstanceManager
00164     void setObjectInstanceManager(ObjectInstanceManager *oim);
00165     
00166     // Get ObjectInstanceManager
00167     ObjectInstanceManager *getObjectInstanceManager();
00168     
00169 private:
00170     Logger                      *m_logger;
00171     Options                     *m_options;
00172     bool                         m_canActAsRouterNode;
00173     bool                         m_connected;
00174     bool                         m_registered;
00175     
00176     // mbed-client support
00177     M2MInterface                *m_endpoint_interface;
00178     M2MSecurity                 *m_endpoint_security;
00179     M2MObjectList                m_endpoint_object_list;
00180     
00181     // Device Manager
00182     void                        *m_device_manager;
00183     
00184     // ConnectionStatusInterface implementation
00185     ConnectionStatusInterface   *m_csi;
00186     
00187     // ObjectInstanceManager
00188     ObjectInstanceManager       *m_oim;
00189     
00190     // mbed-client methods
00191     void             createEndpointInterface();
00192     M2MSecurity     *createEndpointInstance();
00193     
00194     // DynamicResource Lookup
00195     DynamicResource *lookupDynamicResource(M2MBase *base);
00196     
00197     // stop underlying observers
00198     void stopObservations();
00199 };
00200 
00201 } // namespace Connector
00202 
00203 #endif // __CONNECTOR_ENDPOINT_H__