use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Fri Feb 19 17:32:14 2016 +0000
Revision:
0:1f1f55e73248
Child:
1:16f0fb5b8d97
initial checkin

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:1f1f55e73248 1 /**
ansond 0:1f1f55e73248 2 * @file Endpoint.h
ansond 0:1f1f55e73248 3 * @brief mbed CoAP Endpoint base class
ansond 0:1f1f55e73248 4 * @author Doug Anson/Chris Paola
ansond 0:1f1f55e73248 5 * @version 1.0
ansond 0:1f1f55e73248 6 * @see
ansond 0:1f1f55e73248 7 *
ansond 0:1f1f55e73248 8 * Copyright (c) 2014
ansond 0:1f1f55e73248 9 *
ansond 0:1f1f55e73248 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 0:1f1f55e73248 11 * you may not use this file except in compliance with the License.
ansond 0:1f1f55e73248 12 * You may obtain a copy of the License at
ansond 0:1f1f55e73248 13 *
ansond 0:1f1f55e73248 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 0:1f1f55e73248 15 *
ansond 0:1f1f55e73248 16 * Unless required by applicable law or agreed to in writing, software
ansond 0:1f1f55e73248 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 0:1f1f55e73248 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 0:1f1f55e73248 19 * See the License for the specific language governing permissions and
ansond 0:1f1f55e73248 20 * limitations under the License.
ansond 0:1f1f55e73248 21 */
ansond 0:1f1f55e73248 22
ansond 0:1f1f55e73248 23 #ifndef __CONNECTOR_ENDPOINT_H__
ansond 0:1f1f55e73248 24 #define __CONNECTOR_ENDPOINT_H__
ansond 0:1f1f55e73248 25
ansond 0:1f1f55e73248 26 // mbed-client support
ansond 0:1f1f55e73248 27 #include "mbed-client/m2minterfacefactory.h"
ansond 0:1f1f55e73248 28 #include "mbed-client/m2mdevice.h"
ansond 0:1f1f55e73248 29 #include "mbed-client/m2minterfaceobserver.h"
ansond 0:1f1f55e73248 30 #include "mbed-client/m2minterface.h"
ansond 0:1f1f55e73248 31 #include "mbed-client/m2mobjectinstance.h"
ansond 0:1f1f55e73248 32 #include "mbed-client/m2mresource.h"
ansond 0:1f1f55e73248 33
ansond 0:1f1f55e73248 34 // Support for Logging/Debug output
ansond 0:1f1f55e73248 35 #include "mbed-connector-interface/Logger.h"
ansond 0:1f1f55e73248 36
ansond 0:1f1f55e73248 37 // Options support
ansond 0:1f1f55e73248 38 #include "mbed-connector-interface/Options.h"
ansond 0:1f1f55e73248 39
ansond 0:1f1f55e73248 40 // Connector namespace
ansond 0:1f1f55e73248 41 namespace Connector {
ansond 0:1f1f55e73248 42
ansond 0:1f1f55e73248 43 /** Endpoint class
ansond 0:1f1f55e73248 44 */
ansond 0:1f1f55e73248 45 class Endpoint : public M2MInterfaceObserver {
ansond 0:1f1f55e73248 46
ansond 0:1f1f55e73248 47 public:
ansond 0:1f1f55e73248 48 /**
ansond 0:1f1f55e73248 49 Default Constructor
ansond 0:1f1f55e73248 50 */
ansond 0:1f1f55e73248 51 Endpoint(const Logger *logger,const Options *ob);
ansond 0:1f1f55e73248 52
ansond 0:1f1f55e73248 53 /**
ansond 0:1f1f55e73248 54 Copy Constructor
ansond 0:1f1f55e73248 55 @param ob input endpoint instance to deep copy
ansond 0:1f1f55e73248 56 */
ansond 0:1f1f55e73248 57 Endpoint(const Endpoint &ep);
ansond 0:1f1f55e73248 58
ansond 0:1f1f55e73248 59 /**
ansond 0:1f1f55e73248 60 Destructor
ansond 0:1f1f55e73248 61 */
ansond 0:1f1f55e73248 62 virtual ~Endpoint();
ansond 0:1f1f55e73248 63
ansond 0:1f1f55e73248 64 /**
ansond 0:1f1f55e73248 65 Register the endpoint with mbed Device Server
ansond 0:1f1f55e73248 66 */
ansond 0:1f1f55e73248 67 void register_endpoint();
ansond 0:1f1f55e73248 68
ansond 0:1f1f55e73248 69 /**
ansond 0:1f1f55e73248 70 Plumb the lower RF network stack
ansond 0:1f1f55e73248 71 @param canActAsRouterNode input boolean indicating whether this node can act as a router node or not.
ansond 0:1f1f55e73248 72 */
ansond 0:1f1f55e73248 73 static void plumbNetwork(bool canActAsRouterNode = false);
ansond 0:1f1f55e73248 74
ansond 0:1f1f55e73248 75 /**
ansond 0:1f1f55e73248 76 Initialize the endpoint's configuration and begin the endpoint's main even loop
ansond 0:1f1f55e73248 77 */
ansond 0:1f1f55e73248 78 static void start();
ansond 0:1f1f55e73248 79
ansond 0:1f1f55e73248 80 // mbed-client : bootstrap done
ansond 0:1f1f55e73248 81 virtual void bootstrap_done(M2MSecurity *server_object);
ansond 0:1f1f55e73248 82
ansond 0:1f1f55e73248 83 // mbed-client : object registered
ansond 0:1f1f55e73248 84 virtual void object_registered(M2MSecurity *security_object, const M2MServer &server_object);
ansond 0:1f1f55e73248 85
ansond 0:1f1f55e73248 86 // mbed-client : object unregistered
ansond 0:1f1f55e73248 87 virtual void object_unregistered(M2MSecurity *server_object);
ansond 0:1f1f55e73248 88
ansond 0:1f1f55e73248 89 // mbed-client : registration updated
ansond 0:1f1f55e73248 90 virtual void registration_updated(M2MSecurity *security_object, const M2MServer & server_object) ;
ansond 0:1f1f55e73248 91
ansond 0:1f1f55e73248 92 // mbed-client : resource value updated
ansond 0:1f1f55e73248 93 virtual void value_updated(M2MBase *base, M2MBase::BaseType type) ;
ansond 0:1f1f55e73248 94
ansond 0:1f1f55e73248 95 // mbed-client : error handler
ansond 0:1f1f55e73248 96 virtual void error(M2MInterface::Error error);
ansond 0:1f1f55e73248 97
ansond 0:1f1f55e73248 98 // mbed-client : complete registration of the endpoint
ansond 0:1f1f55e73248 99 void complete_endpoint_registration(M2MSecurity *register_object, M2MObjectList object_list);
ansond 0:1f1f55e73248 100
ansond 0:1f1f55e73248 101 // mbed-client: re-register endpoint
ansond 0:1f1f55e73248 102 void re_register_endpoint();
ansond 0:1f1f55e73248 103
ansond 0:1f1f55e73248 104 // mbed-client: de-register endpoint and stop scheduling
ansond 0:1f1f55e73248 105 void closedown_endpoint(void);
ansond 0:1f1f55e73248 106
ansond 0:1f1f55e73248 107 // get our Options
ansond 0:1f1f55e73248 108 Options *getOptions();
ansond 0:1f1f55e73248 109
ansond 0:1f1f55e73248 110 // get our Server
ansond 0:1f1f55e73248 111 M2MSecurity *getServer();
ansond 0:1f1f55e73248 112
ansond 0:1f1f55e73248 113 // get our Object List
ansond 0:1f1f55e73248 114 M2MObjectList getObjectList();
ansond 0:1f1f55e73248 115
ansond 0:1f1f55e73248 116 private:
ansond 0:1f1f55e73248 117 Logger *m_logger;
ansond 0:1f1f55e73248 118 Options *m_options;
ansond 0:1f1f55e73248 119
ansond 0:1f1f55e73248 120 // mbed-client support
ansond 0:1f1f55e73248 121 M2MInterface *m_interface;
ansond 0:1f1f55e73248 122 M2MSecurity *m_server_instance;
ansond 0:1f1f55e73248 123 M2MObjectList m_object_list;
ansond 0:1f1f55e73248 124 M2MDevice *m_device_object;
ansond 0:1f1f55e73248 125
ansond 0:1f1f55e73248 126 // mbed-client methods
ansond 0:1f1f55e73248 127 void create_interface();
ansond 0:1f1f55e73248 128 M2MSecurity *create_server_instance();
ansond 0:1f1f55e73248 129
ansond 0:1f1f55e73248 130 // DynamicResource Lookup
ansond 0:1f1f55e73248 131 DynamicResource *lookupDynamicResource(M2MBase *base);
ansond 0:1f1f55e73248 132
ansond 0:1f1f55e73248 133 // access the logger
ansond 0:1f1f55e73248 134 Logger *logger();
ansond 0:1f1f55e73248 135 };
ansond 0:1f1f55e73248 136
ansond 0:1f1f55e73248 137 } // namespace Connector
ansond 0:1f1f55e73248 138
ansond 0:1f1f55e73248 139 #endif // __CONNECTOR_ENDPOINT_H__
ansond 0:1f1f55e73248 140