mbedConnectorInterface back port from mbedOS v3 using mbed-client C++ call interface

Committer:
ansond
Date:
Sun Jun 12 03:18:25 2016 +0000
Revision:
26:d7b009313e3b
Parent:
23:5852c0884714
updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:1f1f55e73248 1 /**
ansond 0:1f1f55e73248 2 * @file ConnectorEndpoint.cpp
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 // Lower level Network
ansond 0:1f1f55e73248 24 #include "mbed-connector-interface/mbedEndpointNetwork.h"
ansond 0:1f1f55e73248 25
ansond 0:1f1f55e73248 26 // ConnectorEndpoint
ansond 0:1f1f55e73248 27 #include "mbed-connector-interface/ConnectorEndpoint.h"
ansond 0:1f1f55e73248 28
ansond 0:1f1f55e73248 29 // Utils support
ansond 0:1f1f55e73248 30 #include "mbed-connector-interface/Utils.h"
ansond 0:1f1f55e73248 31
ansond 0:1f1f55e73248 32 // DEBUG
ansond 0:1f1f55e73248 33 #ifndef NDEBUG
ansond 0:1f1f55e73248 34 #define DEBUG_OUT(...) { printf(__VA_ARGS__); }
ansond 0:1f1f55e73248 35 #else
ansond 0:1f1f55e73248 36 #define DEBUG_OUT(...) /* nothing */
ansond 0:1f1f55e73248 37 #endif
ansond 0:1f1f55e73248 38
ansond 1:16f0fb5b8d97 39 // our endpoint instance
ansond 1:16f0fb5b8d97 40 static Connector::Endpoint *__endpoint = NULL;
ansond 0:1f1f55e73248 41
ansond 0:1f1f55e73248 42 // Connector namespace
ansond 0:1f1f55e73248 43 namespace Connector {
ansond 0:1f1f55e73248 44
ansond 0:1f1f55e73248 45 // STATIC: Plumb the network
ansond 13:9edad7677211 46 void Endpoint::plumbNetwork(void *device_manager,bool canActAsRouterNode) {
ansond 1:16f0fb5b8d97 47 if (__endpoint == NULL) {
ansond 1:16f0fb5b8d97 48 // initialize our endpoint instance
ansond 1:16f0fb5b8d97 49 DEBUG_OUT("Endpoint::plumbNetwork: initializing endpoint instance...\r\n");
ansond 1:16f0fb5b8d97 50 __endpoint = (Connector::Endpoint *)utils_init_endpoint(canActAsRouterNode);
ansond 1:16f0fb5b8d97 51 }
ansond 13:9edad7677211 52
ansond 13:9edad7677211 53 // set the device manager
ansond 13:9edad7677211 54 if (device_manager != NULL) {
ansond 13:9edad7677211 55 // device manager has been supplied
ansond 13:9edad7677211 56 DEBUG_OUT("Endpoint::plumbNetwork: setting a device manager...\r\n");
ansond 13:9edad7677211 57 __endpoint->setDeviceManager(device_manager);
ansond 13:9edad7677211 58 }
ansond 13:9edad7677211 59 else {
ansond 13:9edad7677211 60 // no device manager supplied
ansond 13:9edad7677211 61 DEBUG_OUT("Endpoint::plumbNetwork: no device manager supplied (OK)\r\n");
ansond 13:9edad7677211 62 }
ansond 8:f950fb1b78c0 63
ansond 0:1f1f55e73248 64 // configure the endpoint now...
ansond 0:1f1f55e73248 65 DEBUG_OUT("Endpoint::plumbNetwork: configuring endpoint...\r\n");
ansond 1:16f0fb5b8d97 66 utils_configure_endpoint((void *)__endpoint);
ansond 2:1a7a292555d1 67
ansond 2:1a7a292555d1 68 // plumb network
ansond 2:1a7a292555d1 69 DEBUG_OUT("Endpoint::plumbNetwork: plumbing network...\r\n");
ansond 8:f950fb1b78c0 70 net_plumb_network((void *)__endpoint);
ansond 0:1f1f55e73248 71 }
ansond 0:1f1f55e73248 72
ansond 0:1f1f55e73248 73 // STATIC: Finalize the endpoint's configuration and begin the endpoint's main even loop (static, not tied into Logger)
ansond 8:f950fb1b78c0 74 void Endpoint::start()
ansond 8:f950fb1b78c0 75 {
ansond 8:f950fb1b78c0 76 // complete setup of our endpoint...
ansond 8:f950fb1b78c0 77 DEBUG_OUT("Endpoint::start: building out endpoint...\r\n");
ansond 8:f950fb1b78c0 78 utils_build_endpoint((void *)__endpoint);
ansond 0:1f1f55e73248 79
ansond 8:f950fb1b78c0 80 // register the endpoint
ansond 8:f950fb1b78c0 81 DEBUG_OUT("Endpoint::start: completing endpoint build out..\r\n");
ansond 8:f950fb1b78c0 82 net_perform_endpoint_registration(__endpoint);
ansond 0:1f1f55e73248 83 }
ansond 0:1f1f55e73248 84
ansond 0:1f1f55e73248 85 // Constructor
ansond 0:1f1f55e73248 86 Endpoint::Endpoint(const Logger *logger, const Options *options) : M2MInterfaceObserver()
ansond 0:1f1f55e73248 87 {
ansond 0:1f1f55e73248 88 this->m_logger = (Logger *)logger;
ansond 0:1f1f55e73248 89 this->m_options = (Options *)options;
ansond 13:9edad7677211 90 this->m_device_manager = NULL;
ansond 13:9edad7677211 91 this->m_connected = false;
ansond 15:c11dbe4d354c 92 this->m_registered = false;
ansond 0:1f1f55e73248 93 }
ansond 0:1f1f55e73248 94
ansond 0:1f1f55e73248 95 // Copy Constructor
ansond 0:1f1f55e73248 96 Endpoint::Endpoint(const Endpoint &ep)
ansond 0:1f1f55e73248 97 {
ansond 0:1f1f55e73248 98 this->m_logger = ep.m_logger;
ansond 0:1f1f55e73248 99 this->m_options = ep.m_options;
ansond 0:1f1f55e73248 100 this->m_interface = ep.m_interface;
ansond 0:1f1f55e73248 101 this->m_server_instance = ep.m_server_instance;
ansond 0:1f1f55e73248 102 this->m_object_list = ep.m_object_list;
ansond 0:1f1f55e73248 103 this->m_device_object = ep.m_device_object;
ansond 13:9edad7677211 104 this->m_device_manager = ep.m_device_manager;
ansond 13:9edad7677211 105 this->m_connected = ep.m_connected;
ansond 15:c11dbe4d354c 106 this->m_registered = ep.m_registered;
ansond 0:1f1f55e73248 107 }
ansond 0:1f1f55e73248 108
ansond 0:1f1f55e73248 109 // Destructor
ansond 0:1f1f55e73248 110 Endpoint::~Endpoint() {
ansond 0:1f1f55e73248 111 if (this->m_interface != NULL)
ansond 0:1f1f55e73248 112 delete this->m_interface;
ansond 0:1f1f55e73248 113 if (this->m_server_instance != NULL)
ansond 0:1f1f55e73248 114 delete this->m_server_instance;
ansond 0:1f1f55e73248 115 }
ansond 0:1f1f55e73248 116
ansond 13:9edad7677211 117 // set the device manager
ansond 13:9edad7677211 118 void Endpoint::setDeviceManager(void *device_manager) {
ansond 13:9edad7677211 119 this->m_device_manager = device_manager;
ansond 13:9edad7677211 120 }
ansond 13:9edad7677211 121
ansond 13:9edad7677211 122 // get the device manager
ansond 13:9edad7677211 123 void *Endpoint::getDeviceManager(void) {
ansond 13:9edad7677211 124 return this->m_device_manager;
ansond 13:9edad7677211 125 }
ansond 13:9edad7677211 126
ansond 1:16f0fb5b8d97 127 // router node behavior setting
ansond 1:16f0fb5b8d97 128 void Endpoint::asRouterNode(bool canActAsRouterNode) {
ansond 1:16f0fb5b8d97 129 this->m_canActAsRouterNode = canActAsRouterNode;
ansond 1:16f0fb5b8d97 130 }
ansond 1:16f0fb5b8d97 131
ansond 1:16f0fb5b8d97 132 // set our Options
ansond 1:16f0fb5b8d97 133 void Endpoint::setOptions(Options *options) {
ansond 1:16f0fb5b8d97 134 this->m_options = options;
ansond 1:16f0fb5b8d97 135 }
ansond 1:16f0fb5b8d97 136
ansond 0:1f1f55e73248 137 // get our Options
ansond 0:1f1f55e73248 138 Options *Endpoint::getOptions() {
ansond 0:1f1f55e73248 139 return this->m_options;
ansond 0:1f1f55e73248 140 }
ansond 0:1f1f55e73248 141
ansond 0:1f1f55e73248 142 // get our Server
ansond 0:1f1f55e73248 143 M2MSecurity *Endpoint::getServer() {
ansond 0:1f1f55e73248 144 return this->m_server_instance;
ansond 0:1f1f55e73248 145 }
ansond 0:1f1f55e73248 146
ansond 0:1f1f55e73248 147 // get our ObjectList
ansond 0:1f1f55e73248 148 M2MObjectList Endpoint::getObjectList() {
ansond 0:1f1f55e73248 149 return this->m_object_list;
ansond 0:1f1f55e73248 150 }
ansond 0:1f1f55e73248 151
ansond 0:1f1f55e73248 152 // mbed-client: create our interface
ansond 0:1f1f55e73248 153 void Endpoint::create_interface() {
ansond 10:3f79b5e67c22 154 // get the CoAP listening port
ansond 10:3f79b5e67c22 155 uint16_t listening_port = (uint16_t)this->m_options->getConnectorPort();
ansond 10:3f79b5e67c22 156
ansond 10:3f79b5e67c22 157 // randomize the port if we are using certificates...
ansond 10:3f79b5e67c22 158 if (this->m_options->getServerCertificateSize() > 0) {
ansond 0:1f1f55e73248 159 // Randomizing listening port for Certificate mode connectivity
ansond 0:1f1f55e73248 160 srand(time(NULL));
ansond 10:3f79b5e67c22 161 listening_port = rand() % 65535 + 12345;
ansond 10:3f79b5e67c22 162 }
ansond 10:3f79b5e67c22 163
ansond 10:3f79b5e67c22 164 // Binding Mode - TCP or UDP
ansond 10:3f79b5e67c22 165 M2MInterface::BindingMode network_protocol = M2MInterface::UDP;
ansond 10:3f79b5e67c22 166 if (this->m_options->getCoAPConnectionType() == COAP_TCP) network_protocol = M2MInterface::TCP;
ansond 10:3f79b5e67c22 167
ansond 10:3f79b5e67c22 168 // Network Type IPv4 or IPv6
ansond 10:3f79b5e67c22 169 M2MInterface::NetworkStack ip_address_type = M2MInterface::LwIP_IPv4;
ansond 10:3f79b5e67c22 170 if (this->m_options->getIPAddressType() == IP_ADDRESS_TYPE_IPV6) ip_address_type = M2MInterface::LwIP_IPv6;
ansond 10:3f79b5e67c22 171
ansond 10:3f79b5e67c22 172 // DEBUG
ansond 10:3f79b5e67c22 173 if (network_protocol == M2MInterface::TCP) this->logger()->log("Endpoint: Underlying Protocol: TCP");
ansond 10:3f79b5e67c22 174 if (network_protocol == M2MInterface::UDP) this->logger()->log("Endpoint: Underlying Protocol: UDP");
ansond 10:3f79b5e67c22 175 if (ip_address_type == M2MInterface::LwIP_IPv4) this->logger()->log("Endpoint: IP Address Type: IPv4");
ansond 10:3f79b5e67c22 176 if (ip_address_type == M2MInterface::LwIP_IPv6) this->logger()->log("Endpoint: IP Address Type: IPv6");
ansond 10:3f79b5e67c22 177
ansond 10:3f79b5e67c22 178 // Create the M2M Interface instance
ansond 10:3f79b5e67c22 179 this->m_interface = M2MInterfaceFactory::create_interface(*this,
ansond 10:3f79b5e67c22 180 (char *)this->m_options->getEndpointNodename().c_str(),
ansond 10:3f79b5e67c22 181 (char *)this->m_options->getEndpointType().c_str(),
ansond 10:3f79b5e67c22 182 (int32_t)this->m_options->getLifetime(),
ansond 10:3f79b5e67c22 183 listening_port, // listening port
ansond 10:3f79b5e67c22 184 (char *)this->m_options->getDomain().c_str(),
ansond 10:3f79b5e67c22 185 network_protocol, // CoAP over UDP or TCP...
ansond 10:3f79b5e67c22 186 ip_address_type); // IPv4 addressing or IPv6 addressing
ansond 0:1f1f55e73248 187 }
ansond 0:1f1f55e73248 188
ansond 0:1f1f55e73248 189 // mbed-client: create_server_instance()
ansond 0:1f1f55e73248 190 M2MSecurity *Endpoint::create_server_instance() {
ansond 0:1f1f55e73248 191 // Creates register server object with mbed device server address and other parameters
ansond 0:1f1f55e73248 192 M2MSecurity *server = M2MInterfaceFactory::create_security(M2MSecurity::M2MServer);
ansond 0:1f1f55e73248 193 if (server != NULL) {
ansond 0:1f1f55e73248 194 const String url = this->m_options->getConnectorURL();
ansond 0:1f1f55e73248 195 server->set_resource_value(M2MSecurity::M2MServerUri, url);
ansond 8:f950fb1b78c0 196 server->set_resource_value(M2MSecurity::BootstrapServer, NULL);
ansond 0:1f1f55e73248 197 server->set_resource_value(M2MSecurity::SecurityMode, M2MSecurity::Certificate);
ansond 0:1f1f55e73248 198 server->set_resource_value(M2MSecurity::ServerPublicKey,this->m_options->getServerCertificate(),this->m_options->getServerCertificateSize());
ansond 0:1f1f55e73248 199 server->set_resource_value(M2MSecurity::PublicKey,this->m_options->getClientCertificate(),this->m_options->getClientCertificateSize());
ansond 0:1f1f55e73248 200 server->set_resource_value(M2MSecurity::Secretkey,this->m_options->getClientKey(),this->m_options->getClientKeySize());
ansond 0:1f1f55e73248 201 }
ansond 0:1f1f55e73248 202 return server;
ansond 0:1f1f55e73248 203 }
ansond 0:1f1f55e73248 204
ansond 0:1f1f55e73248 205 // mbed-client: Callback from mbed client stack if any error is encountered
ansond 0:1f1f55e73248 206 void Endpoint::error(M2MInterface::Error error) {
ansond 0:1f1f55e73248 207 switch(error){
ansond 0:1f1f55e73248 208 case M2MInterface::AlreadyExists:
ansond 0:1f1f55e73248 209 DEBUG_OUT("[ERROR:] M2MInterface::AlreadyExists");
ansond 0:1f1f55e73248 210 break;
ansond 0:1f1f55e73248 211 case M2MInterface::BootstrapFailed:
ansond 0:1f1f55e73248 212 DEBUG_OUT("[ERROR:] M2MInterface::BootstrapFailed");
ansond 0:1f1f55e73248 213 break;
ansond 0:1f1f55e73248 214 case M2MInterface::InvalidParameters:
ansond 0:1f1f55e73248 215 DEBUG_OUT("[ERROR:] M2MInterface::InvalidParameters");
ansond 0:1f1f55e73248 216 break;
ansond 0:1f1f55e73248 217 case M2MInterface::NotRegistered:
ansond 0:1f1f55e73248 218 DEBUG_OUT("[ERROR:] M2MInterface::NotRegistered");
ansond 0:1f1f55e73248 219 break;
ansond 0:1f1f55e73248 220 case M2MInterface::Timeout:
ansond 0:1f1f55e73248 221 DEBUG_OUT("[ERROR:] M2MInterface::Timeout");
ansond 0:1f1f55e73248 222 break;
ansond 0:1f1f55e73248 223 case M2MInterface::NetworkError:
ansond 0:1f1f55e73248 224 DEBUG_OUT("[ERROR:] M2MInterface::NetworkError");
ansond 0:1f1f55e73248 225 break;
ansond 0:1f1f55e73248 226 case M2MInterface::ResponseParseFailed:
ansond 0:1f1f55e73248 227 DEBUG_OUT("[ERROR:] M2MInterface::ResponseParseFailed");
ansond 0:1f1f55e73248 228 break;
ansond 0:1f1f55e73248 229 case M2MInterface::UnknownError:
ansond 0:1f1f55e73248 230 DEBUG_OUT("[ERROR:] M2MInterface::UnknownError");
ansond 0:1f1f55e73248 231 break;
ansond 0:1f1f55e73248 232 case M2MInterface::MemoryFail:
ansond 0:1f1f55e73248 233 DEBUG_OUT("[ERROR:] M2MInterface::MemoryFail");
ansond 0:1f1f55e73248 234 break;
ansond 0:1f1f55e73248 235 case M2MInterface::NotAllowed:
ansond 0:1f1f55e73248 236 DEBUG_OUT("[ERROR:] M2MInterface::NotAllowed");
ansond 0:1f1f55e73248 237 break;
ansond 0:1f1f55e73248 238 default:
ansond 0:1f1f55e73248 239 break;
ansond 0:1f1f55e73248 240 }
ansond 0:1f1f55e73248 241 }
ansond 0:1f1f55e73248 242
ansond 8:f950fb1b78c0 243 // register the endpoint
ansond 8:f950fb1b78c0 244 void Endpoint::register_endpoint(M2MSecurity *server_instance, M2MObjectList resources) {
ansond 23:5852c0884714 245 if (this->m_interface != NULL && server_instance != NULL && resources.size() > 0) {
ansond 23:5852c0884714 246 // register endpoint
ansond 23:5852c0884714 247 this->logger()->log("Registering endpoint...");
ansond 23:5852c0884714 248 this->m_interface->register_object(server_instance, resources);
ansond 23:5852c0884714 249 }
ansond 0:1f1f55e73248 250 }
ansond 0:1f1f55e73248 251
ansond 8:f950fb1b78c0 252 // re-register the endpoint
ansond 8:f950fb1b78c0 253 void Endpoint::re_register_endpoint() {
ansond 23:5852c0884714 254 if (this->m_interface != NULL) {
ansond 23:5852c0884714 255 this->m_interface->update_registration(this->m_server_instance, this->m_options->getLifetime());
ansond 23:5852c0884714 256 }
ansond 8:f950fb1b78c0 257 }
ansond 8:f950fb1b78c0 258
ansond 8:f950fb1b78c0 259 // de-register endpoint
ansond 8:f950fb1b78c0 260 void Endpoint::de_register_endpoint(void) {
ansond 0:1f1f55e73248 261 if (this->m_interface != NULL) {
ansond 0:1f1f55e73248 262 // de-register endpoint
ansond 0:1f1f55e73248 263 this->logger()->log("De-registering endpoint...");
ansond 0:1f1f55e73248 264 this->m_interface->unregister_object(NULL);
ansond 0:1f1f55e73248 265 }
ansond 0:1f1f55e73248 266 }
ansond 0:1f1f55e73248 267
ansond 8:f950fb1b78c0 268 // object registered
ansond 8:f950fb1b78c0 269 void Endpoint::object_registered(M2MSecurity */*security_object */, const M2MServer &/*server_object*/) {
ansond 8:f950fb1b78c0 270 this->logger()->log("Endpoint registered");
ansond 15:c11dbe4d354c 271 this->m_connected = true;
ansond 15:c11dbe4d354c 272 this->m_registered = true;
ansond 8:f950fb1b78c0 273 }
ansond 8:f950fb1b78c0 274
ansond 8:f950fb1b78c0 275 // registration updated
ansond 8:f950fb1b78c0 276 void Endpoint::registration_updated(M2MSecurity */*security_object*/, const M2MServer &/*server_object*/) {
ansond 8:f950fb1b78c0 277 this->logger()->log("Endpoint re-registered.");
ansond 15:c11dbe4d354c 278 this->m_connected = true;
ansond 15:c11dbe4d354c 279 this->m_registered = true;
ansond 8:f950fb1b78c0 280 }
ansond 8:f950fb1b78c0 281
ansond 8:f950fb1b78c0 282 // object unregistered
ansond 8:f950fb1b78c0 283 void Endpoint::object_unregistered(M2MSecurity */*server_object*/) {
ansond 8:f950fb1b78c0 284 // ready to exit
ansond 8:f950fb1b78c0 285 this->logger()->log("Endpoint de-registered... Ready to exit...");
ansond 15:c11dbe4d354c 286 this->m_registered = false;
ansond 0:1f1f55e73248 287 }
ansond 0:1f1f55e73248 288
ansond 0:1f1f55e73248 289 // bootstrap done
ansond 0:1f1f55e73248 290 void Endpoint::bootstrap_done(M2MSecurity * /*server_object */) {
ansond 0:1f1f55e73248 291 this->logger()->log("Bootstrapped");
ansond 0:1f1f55e73248 292 }
ansond 0:1f1f55e73248 293
ansond 0:1f1f55e73248 294 // resource value updated
ansond 0:1f1f55e73248 295 void Endpoint::value_updated(M2MBase *base, M2MBase::BaseType type) {
ansond 0:1f1f55e73248 296 this->logger()->log("Value Updated");
ansond 0:1f1f55e73248 297 DynamicResource *target_res = this->lookupDynamicResource(base);
ansond 0:1f1f55e73248 298 target_res->process(base->operation(),type);
ansond 0:1f1f55e73248 299 }
ansond 0:1f1f55e73248 300
ansond 0:1f1f55e73248 301 // lookup which DynamicResource cooresponds to a given M2MBase instance...
ansond 0:1f1f55e73248 302 DynamicResource *Endpoint::lookupDynamicResource(M2MBase *base) {
ansond 0:1f1f55e73248 303 DynamicResource *res = NULL;
ansond 0:1f1f55e73248 304 bool found = false;
ansond 0:1f1f55e73248 305 const DynamicResourcesList *dynamic_resources = this->m_options->getDynamicResourceList();
ansond 0:1f1f55e73248 306 for(int i=0; i<(int)dynamic_resources->size() && found == false; ++i) {
ansond 0:1f1f55e73248 307 M2MBase *t = dynamic_resources->at(i)->getResource();
ansond 0:1f1f55e73248 308 if (t == base) {
ansond 0:1f1f55e73248 309 res = dynamic_resources->at(i);
ansond 0:1f1f55e73248 310 found = true;
ansond 0:1f1f55e73248 311 }
ansond 0:1f1f55e73248 312 }
ansond 0:1f1f55e73248 313
ansond 0:1f1f55e73248 314 return res;
ansond 0:1f1f55e73248 315 }
ansond 0:1f1f55e73248 316
ansond 8:f950fb1b78c0 317 // build out the endpoint
ansond 8:f950fb1b78c0 318 void Endpoint::build_endpoint()
ansond 0:1f1f55e73248 319 {
ansond 0:1f1f55e73248 320 // initialize as an mbed-client
ansond 0:1f1f55e73248 321 this->create_interface();
ansond 0:1f1f55e73248 322
ansond 0:1f1f55e73248 323 // Create our server instance
ansond 0:1f1f55e73248 324 this->m_server_instance = this->create_server_instance();
ansond 0:1f1f55e73248 325
ansond 0:1f1f55e73248 326 // Loop through Static Resources and bind each of them...
ansond 8:f950fb1b78c0 327 this->logger()->log("Endpoint::build(): adding device resources...");
ansond 0:1f1f55e73248 328 const DeviceResourcesList *device_resources = this->m_options->getDeviceResourceList();
ansond 0:1f1f55e73248 329 for(int i=0; i<(int)device_resources->size(); ++i) {
ansond 8:f950fb1b78c0 330 this->logger()->log("Endpoint::build(): binding device resource: [%s]...",device_resources->at(i)->getFullName().c_str());
ansond 0:1f1f55e73248 331 this->m_object_list.push_back(device_resources->at(i)->bind(this));
ansond 0:1f1f55e73248 332 }
ansond 0:1f1f55e73248 333
ansond 0:1f1f55e73248 334 // Loop through Static Resources and bind each of them...
ansond 8:f950fb1b78c0 335 this->logger()->log("Endpoint::build(): adding static resources...");
ansond 0:1f1f55e73248 336 const StaticResourcesList *static_resources = this->m_options->getStaticResourceList();
ansond 0:1f1f55e73248 337 for(int i=0; i<(int)static_resources->size(); ++i) {
ansond 8:f950fb1b78c0 338 this->logger()->log("Endpoint::build(): binding static resource: [%s]...",static_resources->at(i)->getFullName().c_str());
ansond 0:1f1f55e73248 339 this->m_object_list.push_back(static_resources->at(i)->bind(this));
ansond 0:1f1f55e73248 340 }
ansond 0:1f1f55e73248 341
ansond 0:1f1f55e73248 342 // Loop through Dynamic Resources and bind each of them...
ansond 8:f950fb1b78c0 343 this->logger()->log("Endpoint::build(): adding dynamic resources...");
ansond 0:1f1f55e73248 344 const DynamicResourcesList *dynamic_resources = this->m_options->getDynamicResourceList();
ansond 0:1f1f55e73248 345 for(int i=0; i<(int)dynamic_resources->size(); ++i) {
ansond 8:f950fb1b78c0 346 this->logger()->log("Endpoint::build(): binding dynamic resource: [%s]...",dynamic_resources->at(i)->getFullName().c_str());
ansond 0:1f1f55e73248 347 this->m_object_list.push_back(dynamic_resources->at(i)->bind(this));
ansond 0:1f1f55e73248 348 }
ansond 0:1f1f55e73248 349 }
ansond 0:1f1f55e73248 350
ansond 13:9edad7677211 351 // underlying network is connected (SET)
ansond 13:9edad7677211 352 void Endpoint::isConnected(bool connected) {
ansond 13:9edad7677211 353 this->m_connected = connected;
ansond 13:9edad7677211 354 }
ansond 13:9edad7677211 355
ansond 13:9edad7677211 356 // underlying network is connected (GET)
ansond 13:9edad7677211 357 bool Endpoint::isConnected() {
ansond 13:9edad7677211 358 return this->m_connected;
ansond 13:9edad7677211 359 }
ansond 13:9edad7677211 360
ansond 15:c11dbe4d354c 361 // Registered with mDC/mDS
ansond 15:c11dbe4d354c 362 bool Endpoint::isRegistered() {
ansond 15:c11dbe4d354c 363 return this->m_registered;
ansond 15:c11dbe4d354c 364 }
ansond 15:c11dbe4d354c 365
ansond 0:1f1f55e73248 366 // our logger
ansond 0:1f1f55e73248 367 Logger *Endpoint::logger()
ansond 0:1f1f55e73248 368 {
ansond 0:1f1f55e73248 369 return this->m_logger;
ansond 0:1f1f55e73248 370 }
ansond 0:1f1f55e73248 371
ansond 0:1f1f55e73248 372 } // namespace Connector