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

Committer:
ansond
Date:
Wed Jun 08 22:32:08 2016 +0000
Revision:
13:9edad7677211
Parent:
10:3f79b5e67c22
Child:
15:c11dbe4d354c
updated to latest revision with new DM functions

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 0:1f1f55e73248 92 }
ansond 0:1f1f55e73248 93
ansond 0:1f1f55e73248 94 // Copy Constructor
ansond 0:1f1f55e73248 95 Endpoint::Endpoint(const Endpoint &ep)
ansond 0:1f1f55e73248 96 {
ansond 0:1f1f55e73248 97 this->m_logger = ep.m_logger;
ansond 0:1f1f55e73248 98 this->m_options = ep.m_options;
ansond 0:1f1f55e73248 99 this->m_interface = ep.m_interface;
ansond 0:1f1f55e73248 100 this->m_server_instance = ep.m_server_instance;
ansond 0:1f1f55e73248 101 this->m_object_list = ep.m_object_list;
ansond 0:1f1f55e73248 102 this->m_device_object = ep.m_device_object;
ansond 13:9edad7677211 103 this->m_device_manager = ep.m_device_manager;
ansond 13:9edad7677211 104 this->m_connected = ep.m_connected;
ansond 0:1f1f55e73248 105 }
ansond 0:1f1f55e73248 106
ansond 0:1f1f55e73248 107 // Destructor
ansond 0:1f1f55e73248 108 Endpoint::~Endpoint() {
ansond 0:1f1f55e73248 109 if (this->m_interface != NULL)
ansond 0:1f1f55e73248 110 delete this->m_interface;
ansond 0:1f1f55e73248 111 if (this->m_server_instance != NULL)
ansond 0:1f1f55e73248 112 delete this->m_server_instance;
ansond 0:1f1f55e73248 113 }
ansond 0:1f1f55e73248 114
ansond 13:9edad7677211 115 // set the device manager
ansond 13:9edad7677211 116 void Endpoint::setDeviceManager(void *device_manager) {
ansond 13:9edad7677211 117 this->m_device_manager = device_manager;
ansond 13:9edad7677211 118 }
ansond 13:9edad7677211 119
ansond 13:9edad7677211 120 // get the device manager
ansond 13:9edad7677211 121 void *Endpoint::getDeviceManager(void) {
ansond 13:9edad7677211 122 return this->m_device_manager;
ansond 13:9edad7677211 123 }
ansond 13:9edad7677211 124
ansond 1:16f0fb5b8d97 125 // router node behavior setting
ansond 1:16f0fb5b8d97 126 void Endpoint::asRouterNode(bool canActAsRouterNode) {
ansond 1:16f0fb5b8d97 127 this->m_canActAsRouterNode = canActAsRouterNode;
ansond 1:16f0fb5b8d97 128 }
ansond 1:16f0fb5b8d97 129
ansond 1:16f0fb5b8d97 130 // set our Options
ansond 1:16f0fb5b8d97 131 void Endpoint::setOptions(Options *options) {
ansond 1:16f0fb5b8d97 132 this->m_options = options;
ansond 1:16f0fb5b8d97 133 }
ansond 1:16f0fb5b8d97 134
ansond 0:1f1f55e73248 135 // get our Options
ansond 0:1f1f55e73248 136 Options *Endpoint::getOptions() {
ansond 0:1f1f55e73248 137 return this->m_options;
ansond 0:1f1f55e73248 138 }
ansond 0:1f1f55e73248 139
ansond 0:1f1f55e73248 140 // get our Server
ansond 0:1f1f55e73248 141 M2MSecurity *Endpoint::getServer() {
ansond 0:1f1f55e73248 142 return this->m_server_instance;
ansond 0:1f1f55e73248 143 }
ansond 0:1f1f55e73248 144
ansond 0:1f1f55e73248 145 // get our ObjectList
ansond 0:1f1f55e73248 146 M2MObjectList Endpoint::getObjectList() {
ansond 0:1f1f55e73248 147 return this->m_object_list;
ansond 0:1f1f55e73248 148 }
ansond 0:1f1f55e73248 149
ansond 0:1f1f55e73248 150 // mbed-client: create our interface
ansond 0:1f1f55e73248 151 void Endpoint::create_interface() {
ansond 10:3f79b5e67c22 152 // get the CoAP listening port
ansond 10:3f79b5e67c22 153 uint16_t listening_port = (uint16_t)this->m_options->getConnectorPort();
ansond 10:3f79b5e67c22 154
ansond 10:3f79b5e67c22 155 // randomize the port if we are using certificates...
ansond 10:3f79b5e67c22 156 if (this->m_options->getServerCertificateSize() > 0) {
ansond 0:1f1f55e73248 157 // Randomizing listening port for Certificate mode connectivity
ansond 0:1f1f55e73248 158 srand(time(NULL));
ansond 10:3f79b5e67c22 159 listening_port = rand() % 65535 + 12345;
ansond 10:3f79b5e67c22 160 }
ansond 10:3f79b5e67c22 161
ansond 10:3f79b5e67c22 162 // Binding Mode - TCP or UDP
ansond 10:3f79b5e67c22 163 M2MInterface::BindingMode network_protocol = M2MInterface::UDP;
ansond 10:3f79b5e67c22 164 if (this->m_options->getCoAPConnectionType() == COAP_TCP) network_protocol = M2MInterface::TCP;
ansond 10:3f79b5e67c22 165
ansond 10:3f79b5e67c22 166 // Network Type IPv4 or IPv6
ansond 10:3f79b5e67c22 167 M2MInterface::NetworkStack ip_address_type = M2MInterface::LwIP_IPv4;
ansond 10:3f79b5e67c22 168 if (this->m_options->getIPAddressType() == IP_ADDRESS_TYPE_IPV6) ip_address_type = M2MInterface::LwIP_IPv6;
ansond 10:3f79b5e67c22 169
ansond 10:3f79b5e67c22 170 // DEBUG
ansond 10:3f79b5e67c22 171 if (network_protocol == M2MInterface::TCP) this->logger()->log("Endpoint: Underlying Protocol: TCP");
ansond 10:3f79b5e67c22 172 if (network_protocol == M2MInterface::UDP) this->logger()->log("Endpoint: Underlying Protocol: UDP");
ansond 10:3f79b5e67c22 173 if (ip_address_type == M2MInterface::LwIP_IPv4) this->logger()->log("Endpoint: IP Address Type: IPv4");
ansond 10:3f79b5e67c22 174 if (ip_address_type == M2MInterface::LwIP_IPv6) this->logger()->log("Endpoint: IP Address Type: IPv6");
ansond 10:3f79b5e67c22 175
ansond 10:3f79b5e67c22 176 // Create the M2M Interface instance
ansond 10:3f79b5e67c22 177 this->m_interface = M2MInterfaceFactory::create_interface(*this,
ansond 10:3f79b5e67c22 178 (char *)this->m_options->getEndpointNodename().c_str(),
ansond 10:3f79b5e67c22 179 (char *)this->m_options->getEndpointType().c_str(),
ansond 10:3f79b5e67c22 180 (int32_t)this->m_options->getLifetime(),
ansond 10:3f79b5e67c22 181 listening_port, // listening port
ansond 10:3f79b5e67c22 182 (char *)this->m_options->getDomain().c_str(),
ansond 10:3f79b5e67c22 183 network_protocol, // CoAP over UDP or TCP...
ansond 10:3f79b5e67c22 184 ip_address_type); // IPv4 addressing or IPv6 addressing
ansond 0:1f1f55e73248 185 }
ansond 0:1f1f55e73248 186
ansond 0:1f1f55e73248 187 // mbed-client: create_server_instance()
ansond 0:1f1f55e73248 188 M2MSecurity *Endpoint::create_server_instance() {
ansond 0:1f1f55e73248 189 // Creates register server object with mbed device server address and other parameters
ansond 0:1f1f55e73248 190 M2MSecurity *server = M2MInterfaceFactory::create_security(M2MSecurity::M2MServer);
ansond 0:1f1f55e73248 191 if (server != NULL) {
ansond 0:1f1f55e73248 192 const String url = this->m_options->getConnectorURL();
ansond 0:1f1f55e73248 193 server->set_resource_value(M2MSecurity::M2MServerUri, url);
ansond 8:f950fb1b78c0 194 server->set_resource_value(M2MSecurity::BootstrapServer, NULL);
ansond 0:1f1f55e73248 195 server->set_resource_value(M2MSecurity::SecurityMode, M2MSecurity::Certificate);
ansond 0:1f1f55e73248 196 server->set_resource_value(M2MSecurity::ServerPublicKey,this->m_options->getServerCertificate(),this->m_options->getServerCertificateSize());
ansond 0:1f1f55e73248 197 server->set_resource_value(M2MSecurity::PublicKey,this->m_options->getClientCertificate(),this->m_options->getClientCertificateSize());
ansond 0:1f1f55e73248 198 server->set_resource_value(M2MSecurity::Secretkey,this->m_options->getClientKey(),this->m_options->getClientKeySize());
ansond 0:1f1f55e73248 199 }
ansond 0:1f1f55e73248 200 return server;
ansond 0:1f1f55e73248 201 }
ansond 0:1f1f55e73248 202
ansond 0:1f1f55e73248 203 // mbed-client: Callback from mbed client stack if any error is encountered
ansond 0:1f1f55e73248 204 void Endpoint::error(M2MInterface::Error error) {
ansond 0:1f1f55e73248 205 switch(error){
ansond 0:1f1f55e73248 206 case M2MInterface::AlreadyExists:
ansond 0:1f1f55e73248 207 DEBUG_OUT("[ERROR:] M2MInterface::AlreadyExists");
ansond 0:1f1f55e73248 208 break;
ansond 0:1f1f55e73248 209 case M2MInterface::BootstrapFailed:
ansond 0:1f1f55e73248 210 DEBUG_OUT("[ERROR:] M2MInterface::BootstrapFailed");
ansond 0:1f1f55e73248 211 break;
ansond 0:1f1f55e73248 212 case M2MInterface::InvalidParameters:
ansond 0:1f1f55e73248 213 DEBUG_OUT("[ERROR:] M2MInterface::InvalidParameters");
ansond 0:1f1f55e73248 214 break;
ansond 0:1f1f55e73248 215 case M2MInterface::NotRegistered:
ansond 0:1f1f55e73248 216 DEBUG_OUT("[ERROR:] M2MInterface::NotRegistered");
ansond 0:1f1f55e73248 217 break;
ansond 0:1f1f55e73248 218 case M2MInterface::Timeout:
ansond 0:1f1f55e73248 219 DEBUG_OUT("[ERROR:] M2MInterface::Timeout");
ansond 0:1f1f55e73248 220 break;
ansond 0:1f1f55e73248 221 case M2MInterface::NetworkError:
ansond 0:1f1f55e73248 222 DEBUG_OUT("[ERROR:] M2MInterface::NetworkError");
ansond 0:1f1f55e73248 223 break;
ansond 0:1f1f55e73248 224 case M2MInterface::ResponseParseFailed:
ansond 0:1f1f55e73248 225 DEBUG_OUT("[ERROR:] M2MInterface::ResponseParseFailed");
ansond 0:1f1f55e73248 226 break;
ansond 0:1f1f55e73248 227 case M2MInterface::UnknownError:
ansond 0:1f1f55e73248 228 DEBUG_OUT("[ERROR:] M2MInterface::UnknownError");
ansond 0:1f1f55e73248 229 break;
ansond 0:1f1f55e73248 230 case M2MInterface::MemoryFail:
ansond 0:1f1f55e73248 231 DEBUG_OUT("[ERROR:] M2MInterface::MemoryFail");
ansond 0:1f1f55e73248 232 break;
ansond 0:1f1f55e73248 233 case M2MInterface::NotAllowed:
ansond 0:1f1f55e73248 234 DEBUG_OUT("[ERROR:] M2MInterface::NotAllowed");
ansond 0:1f1f55e73248 235 break;
ansond 0:1f1f55e73248 236 default:
ansond 0:1f1f55e73248 237 break;
ansond 0:1f1f55e73248 238 }
ansond 0:1f1f55e73248 239 }
ansond 0:1f1f55e73248 240
ansond 8:f950fb1b78c0 241 // register the endpoint
ansond 8:f950fb1b78c0 242 void Endpoint::register_endpoint(M2MSecurity *server_instance, M2MObjectList resources) {
ansond 8:f950fb1b78c0 243 if (this->m_interface != NULL && server_instance != NULL && resources.size() > 0) {
ansond 8:f950fb1b78c0 244 // register endpoint
ansond 8:f950fb1b78c0 245 this->logger()->log("Registering endpoint...");
ansond 8:f950fb1b78c0 246 this->m_interface->register_object(server_instance, resources);
ansond 8:f950fb1b78c0 247 }
ansond 0:1f1f55e73248 248 }
ansond 0:1f1f55e73248 249
ansond 8:f950fb1b78c0 250 // re-register the endpoint
ansond 8:f950fb1b78c0 251 void Endpoint::re_register_endpoint() {
ansond 8:f950fb1b78c0 252 if (this->m_interface != NULL) {
ansond 8:f950fb1b78c0 253 this->m_interface->update_registration(this->m_server_instance, this->m_options->getLifetime());
ansond 8:f950fb1b78c0 254 }
ansond 8:f950fb1b78c0 255 }
ansond 8:f950fb1b78c0 256
ansond 8:f950fb1b78c0 257 // de-register endpoint
ansond 8:f950fb1b78c0 258 void Endpoint::de_register_endpoint(void) {
ansond 0:1f1f55e73248 259 if (this->m_interface != NULL) {
ansond 0:1f1f55e73248 260 // de-register endpoint
ansond 0:1f1f55e73248 261 this->logger()->log("De-registering endpoint...");
ansond 0:1f1f55e73248 262 this->m_interface->unregister_object(NULL);
ansond 0:1f1f55e73248 263 }
ansond 0:1f1f55e73248 264 }
ansond 0:1f1f55e73248 265
ansond 8:f950fb1b78c0 266 // object registered
ansond 8:f950fb1b78c0 267 void Endpoint::object_registered(M2MSecurity */*security_object */, const M2MServer &/*server_object*/) {
ansond 8:f950fb1b78c0 268 this->logger()->log("Endpoint registered");
ansond 8:f950fb1b78c0 269 }
ansond 8:f950fb1b78c0 270
ansond 8:f950fb1b78c0 271 // registration updated
ansond 8:f950fb1b78c0 272 void Endpoint::registration_updated(M2MSecurity */*security_object*/, const M2MServer &/*server_object*/) {
ansond 8:f950fb1b78c0 273 this->logger()->log("Endpoint re-registered.");
ansond 8:f950fb1b78c0 274 }
ansond 8:f950fb1b78c0 275
ansond 8:f950fb1b78c0 276 // object unregistered
ansond 8:f950fb1b78c0 277 void Endpoint::object_unregistered(M2MSecurity */*server_object*/) {
ansond 8:f950fb1b78c0 278 // ready to exit
ansond 8:f950fb1b78c0 279 this->logger()->log("Endpoint de-registered... Ready to exit...");
ansond 8:f950fb1b78c0 280
ansond 8:f950fb1b78c0 281 // stop
ansond 8:f950fb1b78c0 282 exit(0);
ansond 0:1f1f55e73248 283 }
ansond 0:1f1f55e73248 284
ansond 0:1f1f55e73248 285 // bootstrap done
ansond 0:1f1f55e73248 286 void Endpoint::bootstrap_done(M2MSecurity * /*server_object */) {
ansond 0:1f1f55e73248 287 this->logger()->log("Bootstrapped");
ansond 0:1f1f55e73248 288 }
ansond 0:1f1f55e73248 289
ansond 0:1f1f55e73248 290 // resource value updated
ansond 0:1f1f55e73248 291 void Endpoint::value_updated(M2MBase *base, M2MBase::BaseType type) {
ansond 0:1f1f55e73248 292 this->logger()->log("Value Updated");
ansond 0:1f1f55e73248 293 DynamicResource *target_res = this->lookupDynamicResource(base);
ansond 0:1f1f55e73248 294 target_res->process(base->operation(),type);
ansond 0:1f1f55e73248 295 }
ansond 0:1f1f55e73248 296
ansond 0:1f1f55e73248 297 // lookup which DynamicResource cooresponds to a given M2MBase instance...
ansond 0:1f1f55e73248 298 DynamicResource *Endpoint::lookupDynamicResource(M2MBase *base) {
ansond 0:1f1f55e73248 299 DynamicResource *res = NULL;
ansond 0:1f1f55e73248 300 bool found = false;
ansond 0:1f1f55e73248 301 const DynamicResourcesList *dynamic_resources = this->m_options->getDynamicResourceList();
ansond 0:1f1f55e73248 302 for(int i=0; i<(int)dynamic_resources->size() && found == false; ++i) {
ansond 0:1f1f55e73248 303 M2MBase *t = dynamic_resources->at(i)->getResource();
ansond 0:1f1f55e73248 304 if (t == base) {
ansond 0:1f1f55e73248 305 res = dynamic_resources->at(i);
ansond 0:1f1f55e73248 306 found = true;
ansond 0:1f1f55e73248 307 }
ansond 0:1f1f55e73248 308 }
ansond 0:1f1f55e73248 309
ansond 0:1f1f55e73248 310 return res;
ansond 0:1f1f55e73248 311 }
ansond 0:1f1f55e73248 312
ansond 8:f950fb1b78c0 313 // build out the endpoint
ansond 8:f950fb1b78c0 314 void Endpoint::build_endpoint()
ansond 0:1f1f55e73248 315 {
ansond 0:1f1f55e73248 316 // initialize as an mbed-client
ansond 0:1f1f55e73248 317 this->create_interface();
ansond 0:1f1f55e73248 318
ansond 0:1f1f55e73248 319 // Create our server instance
ansond 0:1f1f55e73248 320 this->m_server_instance = this->create_server_instance();
ansond 0:1f1f55e73248 321
ansond 0:1f1f55e73248 322 // Loop through Static Resources and bind each of them...
ansond 8:f950fb1b78c0 323 this->logger()->log("Endpoint::build(): adding device resources...");
ansond 0:1f1f55e73248 324 const DeviceResourcesList *device_resources = this->m_options->getDeviceResourceList();
ansond 0:1f1f55e73248 325 for(int i=0; i<(int)device_resources->size(); ++i) {
ansond 8:f950fb1b78c0 326 this->logger()->log("Endpoint::build(): binding device resource: [%s]...",device_resources->at(i)->getFullName().c_str());
ansond 0:1f1f55e73248 327 this->m_object_list.push_back(device_resources->at(i)->bind(this));
ansond 0:1f1f55e73248 328 }
ansond 0:1f1f55e73248 329
ansond 0:1f1f55e73248 330 // Loop through Static Resources and bind each of them...
ansond 8:f950fb1b78c0 331 this->logger()->log("Endpoint::build(): adding static resources...");
ansond 0:1f1f55e73248 332 const StaticResourcesList *static_resources = this->m_options->getStaticResourceList();
ansond 0:1f1f55e73248 333 for(int i=0; i<(int)static_resources->size(); ++i) {
ansond 8:f950fb1b78c0 334 this->logger()->log("Endpoint::build(): binding static resource: [%s]...",static_resources->at(i)->getFullName().c_str());
ansond 0:1f1f55e73248 335 this->m_object_list.push_back(static_resources->at(i)->bind(this));
ansond 0:1f1f55e73248 336 }
ansond 0:1f1f55e73248 337
ansond 0:1f1f55e73248 338 // Loop through Dynamic Resources and bind each of them...
ansond 8:f950fb1b78c0 339 this->logger()->log("Endpoint::build(): adding dynamic resources...");
ansond 0:1f1f55e73248 340 const DynamicResourcesList *dynamic_resources = this->m_options->getDynamicResourceList();
ansond 0:1f1f55e73248 341 for(int i=0; i<(int)dynamic_resources->size(); ++i) {
ansond 8:f950fb1b78c0 342 this->logger()->log("Endpoint::build(): binding dynamic resource: [%s]...",dynamic_resources->at(i)->getFullName().c_str());
ansond 0:1f1f55e73248 343 this->m_object_list.push_back(dynamic_resources->at(i)->bind(this));
ansond 0:1f1f55e73248 344 }
ansond 0:1f1f55e73248 345 }
ansond 0:1f1f55e73248 346
ansond 13:9edad7677211 347 // underlying network is connected (SET)
ansond 13:9edad7677211 348 void Endpoint::isConnected(bool connected) {
ansond 13:9edad7677211 349 this->m_connected = connected;
ansond 13:9edad7677211 350 }
ansond 13:9edad7677211 351
ansond 13:9edad7677211 352 // underlying network is connected (GET)
ansond 13:9edad7677211 353 bool Endpoint::isConnected() {
ansond 13:9edad7677211 354 return this->m_connected;
ansond 13:9edad7677211 355 }
ansond 13:9edad7677211 356
ansond 0:1f1f55e73248 357 // our logger
ansond 0:1f1f55e73248 358 Logger *Endpoint::logger()
ansond 0:1f1f55e73248 359 {
ansond 0:1f1f55e73248 360 return this->m_logger;
ansond 0:1f1f55e73248 361 }
ansond 0:1f1f55e73248 362
ansond 0:1f1f55e73248 363 } // namespace Connector