mbed Connector Interface simplification API on top of mbed-client
Fork of mbedConnectorInterfaceV3 by
NOTE:
This repo has been replaced with https://github.com/ARMmbed/mbedConnectorInterface. No further updates will occur with this repo. Please use the github repo instead. Thanks!
Diff: source/ConnectorEndpoint.cpp
- Revision:
- 71:5069a202e892
- Parent:
- 62:e5882bd28210
- Child:
- 72:6b1d37b5420a
--- a/source/ConnectorEndpoint.cpp Mon Aug 22 19:51:07 2016 +0000 +++ b/source/ConnectorEndpoint.cpp Fri Nov 04 16:29:17 2016 +0000 @@ -164,8 +164,30 @@ return this->m_endpoint_interface; } +// Connector::Endpoint: create our interface +void Endpoint::createEndpointInterface() { +#ifdef ENABLE_MBED_CLOUD_SUPPORT + this.createCloudEndpointInterface(); +#else + this.createConnectorEndpointInterface(); +#endif +} + +#ifdef ENABLE_MBED_CLOUD_SUPPORT +// mbedCloudClient: create our interface +void Endpoint::createCloudEndpointInterface() { + this->m_endpoint_interface = new MbedCloudClient(); + + // bind LWIP network interface pointer... + if (__network_interface != NULL && this->m_endpoint_interface != NULL) { + this->logger()->log("Connector::Endpoint: binding LWIP network instance (Cloud)..."); + this->m_endpoint_interface->setup(__network_interface); + } +} +#endif + // mbed-client: create our interface -void Endpoint::createEndpointInterface() { +void Endpoint::createConnectorEndpointInterface() { // get the CoAP listening port uint16_t listening_port = (uint16_t)this->m_options->getConnectorPort(); @@ -216,11 +238,12 @@ // bind LWIP network interface pointer... if (__network_interface != NULL && this->m_endpoint_interface != NULL) { - this->logger()->log("Connector::Endpoint: binding LWIP network instance..."); + this->logger()->log("Connector::Endpoint: binding LWIP network instance (Connector)..."); this->m_endpoint_interface->set_platform_network_handler((void *)__network_interface); } } +#ifndef ENABLE_MBED_CLOUD_SUPPORT // mbed-client: createEndpointInstance() M2MSecurity *Endpoint::createEndpointInstance() { // Creates register server object with mbed device server address and other parameters @@ -236,6 +259,7 @@ } return server; } +#endif // mbed-client: Callback from mbed client stack if any error is encountered void Endpoint::error(M2MInterface::Error error) { @@ -394,9 +418,11 @@ { // initialize as an mbed-client this->createEndpointInterface(); - + +#ifndef ENABLE_MBED_CLOUD_SUPPORT // Create our server instance this->m_endpoint_security = this->createEndpointInstance(); +#endif // We now have to bind our device resources if (this->m_device_manager != NULL) {