nsp specific components for the NSP version of the impact endpoint

Dependents:   mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet mbed_nsp_endpoint_nxp

Committer:
ansond
Date:
Tue Jul 01 19:29:55 2014 +0000
Revision:
21:272df0444756
Parent:
20:def10d2d9273
Child:
22:0f2a0269ce6d
updates for cellular

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:e1c4378df3fe 1 /* Copyright C2013 Doug Anson, MIT License
ansond 0:e1c4378df3fe 2 *
ansond 0:e1c4378df3fe 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 0:e1c4378df3fe 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 0:e1c4378df3fe 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 0:e1c4378df3fe 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 0:e1c4378df3fe 7 * furnished to do so, subject to the following conditions:
ansond 0:e1c4378df3fe 8 *
ansond 0:e1c4378df3fe 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 0:e1c4378df3fe 10 * substantial portions of the Software.
ansond 0:e1c4378df3fe 11 *
ansond 0:e1c4378df3fe 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 0:e1c4378df3fe 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 0:e1c4378df3fe 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 0:e1c4378df3fe 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 0:e1c4378df3fe 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 0:e1c4378df3fe 17 */
ansond 0:e1c4378df3fe 18
ansond 0:e1c4378df3fe 19 #include "NSPTransport.h"
ansond 0:e1c4378df3fe 20 #include "MBEDEndpoint.h"
ansond 0:e1c4378df3fe 21
ansond 4:7f7fe167d9c0 22 // Light Personality Support: MBED Light support
ansond 0:e1c4378df3fe 23 #include "MBEDLight.h"
ansond 0:e1c4378df3fe 24
ansond 4:7f7fe167d9c0 25 // Light Personality Support: NSP Resource Factory
ansond 4:7f7fe167d9c0 26 #include "NSPLightResourceFactory.h"
ansond 0:e1c4378df3fe 27
ansond 4:7f7fe167d9c0 28 // Light Personality Support: NSP Actions we can act on
ansond 0:e1c4378df3fe 29 #include "NSPLightDimmerAction.h"
ansond 0:e1c4378df3fe 30 #include "NSPLightSwitchAction.h"
ansond 0:e1c4378df3fe 31
ansond 0:e1c4378df3fe 32 // shutdown endpoint reference
ansond 0:e1c4378df3fe 33 extern void closedown(int code);
ansond 0:e1c4378df3fe 34
ansond 0:e1c4378df3fe 35 // default constructor
ansond 21:272df0444756 36 MBEDEndpoint::MBEDEndpoint(ErrorHandler *error_handler,void *transport,void *extra) : BaseClass(error_handler,NULL) {
ansond 0:e1c4378df3fe 37 bool success = true;
ansond 0:e1c4378df3fe 38 this->m_preferences = NULL;
ansond 0:e1c4378df3fe 39 this->m_instance_id = 0;
ansond 0:e1c4378df3fe 40 memset(this->m_lcd_status,0,TEMP_BUFFER_LEN+1);
ansond 0:e1c4378df3fe 41 memset(this->m_nsp_address,0,PREFERENCE_VALUE_LEN+1);
ansond 0:e1c4378df3fe 42 for(int i=0;i<NUM_TRANSPORTS;++i) this->m_transports[i] = NULL;
ansond 5:94d000e6fa70 43 this->logger()->setEndpoint((void *)this);
ansond 0:e1c4378df3fe 44 if (success) this->initPreferences();
ansond 0:e1c4378df3fe 45 if (success) this->initEndpointName();
ansond 0:e1c4378df3fe 46 if (success) this->logger()->turnLEDBlue();
ansond 0:e1c4378df3fe 47 #ifdef MAC_ADDRESS
ansond 0:e1c4378df3fe 48 extern char fmt_mac[RESOURCE_VALUE_LEN+1];
ansond 0:e1c4378df3fe 49 if (success)this->logger()->log("%s (MAC: %s)",ENDPOINT_VERSION_ANNOUNCE,fmt_mac);
ansond 0:e1c4378df3fe 50 #else
ansond 0:e1c4378df3fe 51 if (success)this->logger()->log(ENDPOINT_VERSION_ANNOUNCE);
ansond 0:e1c4378df3fe 52 #endif
ansond 0:e1c4378df3fe 53 if (success) this->initNSPAddress();
ansond 0:e1c4378df3fe 54 if (PL_ENABLE && success) this->logger()->log("Philips Light ID: %d Philips Gateway IP: %s",PL_LIGHT_ID,PL_GW_ADDRESS);
ansond 11:c4d02616e10f 55 #ifdef CELLULAR_NETWORK
ansond 11:c4d02616e10f 56 this->m_cellular_modem = NULL;
ansond 11:c4d02616e10f 57 this->m_gps = NULL;
ansond 19:3cecccc1a3d4 58 this->logger()->log("initializing Cellular Modem...");
ansond 21:272df0444756 59 if (success) success = this->initializeCellularModem(transport);
ansond 19:3cecccc1a3d4 60 //this->logger()->log("initializing GPS Receiver...");
ansond 19:3cecccc1a3d4 61 //if (success) success = this->initializeGPSReceiver(this,extra);
ansond 11:c4d02616e10f 62 #else
ansond 21:272df0444756 63 if (success) success = this->initializeEthernet((EthernetInterface *)transport);
ansond 6:edf306673e54 64 #endif
ansond 0:e1c4378df3fe 65 if (success) this->logger()->turnLEDYellow();
ansond 16:6936310c9501 66 this->logger()->log("initializing transports...");
ansond 0:e1c4378df3fe 67 if (success) success = this->initializeTransports();
ansond 16:6936310c9501 68 this->logger()->log("initializing personalities...");
ansond 16:6936310c9501 69 if (success) success = this->initializePersonalities();
ansond 16:6936310c9501 70 this->logger()->log("initialization complete for endpoint...");
ansond 0:e1c4378df3fe 71 if (success) this->logger()->turnLEDOrange();
ansond 0:e1c4378df3fe 72 this->logger()->lcdStatusOnly(true);
ansond 0:e1c4378df3fe 73 if (!success) closedown(2);
ansond 0:e1c4378df3fe 74 }
ansond 0:e1c4378df3fe 75
ansond 0:e1c4378df3fe 76 // default destructor
ansond 0:e1c4378df3fe 77 MBEDEndpoint::~MBEDEndpoint() {
ansond 0:e1c4378df3fe 78 bool success = true;
ansond 0:e1c4378df3fe 79 if (success) this->logger()->turnLEDYellow();
ansond 4:7f7fe167d9c0 80 if (success) success = this->closePersonalities();
ansond 0:e1c4378df3fe 81 if (success) success = this->closeTransports();
ansond 11:c4d02616e10f 82 #ifdef CELLULAR_NETWORK
ansond 11:c4d02616e10f 83 if (success) success = this->closeCellularModem();
ansond 11:c4d02616e10f 84 if (success) success = this->closeGPSReceiver();
ansond 11:c4d02616e10f 85 if (this->m_cellular_modem != NULL) delete this->m_cellular_modem;
ansond 11:c4d02616e10f 86 if (this->m_gps != NULL) delete this->m_gps;
ansond 11:c4d02616e10f 87 #else
ansond 0:e1c4378df3fe 88 if (success) success = this->closeEthernet();
ansond 6:edf306673e54 89 #endif
ansond 0:e1c4378df3fe 90 if (success) this->logger()->turnLEDBlue();
ansond 0:e1c4378df3fe 91 }
ansond 0:e1c4378df3fe 92
ansond 0:e1c4378df3fe 93 // initialize our preferences
ansond 0:e1c4378df3fe 94 void MBEDEndpoint::initPreferences() { if (this->m_preferences == NULL) this->m_preferences = new Preferences(this->logger()); }
ansond 0:e1c4378df3fe 95
ansond 0:e1c4378df3fe 96 // get our preferences
ansond 0:e1c4378df3fe 97 Preferences *MBEDEndpoint::preferences() { return this->m_preferences; }
ansond 0:e1c4378df3fe 98
ansond 0:e1c4378df3fe 99 // initialize the NSP address from the configuration
ansond 0:e1c4378df3fe 100 void MBEDEndpoint::initNSPAddress() {
ansond 0:e1c4378df3fe 101 memset(this->m_nsp_address,0,PREFERENCE_VALUE_LEN+1);
ansond 0:e1c4378df3fe 102 this->preferences()->getPreference("nsp_address",this->m_nsp_address,PREFERENCE_VALUE_LEN,NSP_ADDRESS);
ansond 0:e1c4378df3fe 103 this->logger()->log("NSP IP: %s PORT: %d",this->getNSPAddress(),NSP_PORT);
ansond 0:e1c4378df3fe 104 }
ansond 0:e1c4378df3fe 105
ansond 0:e1c4378df3fe 106 // get our NSP address
ansond 0:e1c4378df3fe 107 char *MBEDEndpoint::getNSPAddress() { return this->m_nsp_address; }
ansond 0:e1c4378df3fe 108
ansond 0:e1c4378df3fe 109 // get our LCD status
ansond 0:e1c4378df3fe 110 char *MBEDEndpoint::getLCDStatus() {
ansond 0:e1c4378df3fe 111 memset(this->m_lcd_status,0,TEMP_BUFFER_LEN+1);
ansond 0:e1c4378df3fe 112
ansond 0:e1c4378df3fe 113 // look at Light#0 to determine the IOC linkage ID...
ansond 4:7f7fe167d9c0 114 char *ioc = this->m_personalities[0]->getResourceFactory()->getResourceValue(EXTERNAL_LINKAGE_RESOURCE);
ansond 0:e1c4378df3fe 115
ansond 0:e1c4378df3fe 116 // color our LED depending on whether we have IOC linkage or not...
ansond 4:7f7fe167d9c0 117 if (ioc == NULL || strcmp(ioc,EXTERNAL_LINKAGE_UNSET) == 0) this->logger()->turnLEDOrange();
ansond 0:e1c4378df3fe 118 else this->logger()->turnLEDGreen();
ansond 0:e1c4378df3fe 119
ansond 0:e1c4378df3fe 120 sprintf(this->m_lcd_status,"Node: %s\nNSP IP: %s\nIOC Link: %s",this->getEndpointName(),this->getNSPAddress(),ioc);
ansond 0:e1c4378df3fe 121 return this->m_lcd_status;
ansond 0:e1c4378df3fe 122 }
ansond 4:7f7fe167d9c0 123
ansond 4:7f7fe167d9c0 124 // initialize our Personalities
ansond 4:7f7fe167d9c0 125 bool MBEDEndpoint::initializePersonalities() {
ansond 4:7f7fe167d9c0 126 #ifdef LIGHT_PERSONALITY
ansond 4:7f7fe167d9c0 127 return this->initializeLights();
ansond 7:0207dfb9c36b 128 #endif
ansond 7:0207dfb9c36b 129 #ifdef COPCAR_PERSONALITY
ansond 7:0207dfb9c36b 130 return this->initializeLights();
ansond 4:7f7fe167d9c0 131 #endif
ansond 4:7f7fe167d9c0 132 }
ansond 0:e1c4378df3fe 133
ansond 0:e1c4378df3fe 134 // initialize the Lights
ansond 0:e1c4378df3fe 135 bool MBEDEndpoint::initializeLights() {
ansond 4:7f7fe167d9c0 136 int index = this->preferences()->getIntPreference("endpoint_id",PERSONALITY_NAME_INDEX);
ansond 8:4060275b2246 137 this->logger()->log("Initializing Personality(%s)...",PERSONALITY_TYPE);
ansond 4:7f7fe167d9c0 138 for(int i=0;i<NUM_PERSONALITY_INSTANCES;++i) {
ansond 4:7f7fe167d9c0 139 this->m_personalities[i] = new MBEDLight(this->logger(),this->m_transports,i+index,this);
ansond 4:7f7fe167d9c0 140 ((Light *)this->m_personalities[i])->setDimmerAction(new NSPLightDimmerAction(this->logger(),(Light *)this->m_personalities[i]));
ansond 4:7f7fe167d9c0 141 ((Light *)this->m_personalities[i])->setSwitchAction(new NSPLightSwitchAction(this->logger(),(Light *)this->m_personalities[i]));
ansond 0:e1c4378df3fe 142 }
ansond 0:e1c4378df3fe 143 return true;
ansond 0:e1c4378df3fe 144 }
ansond 0:e1c4378df3fe 145
ansond 0:e1c4378df3fe 146 // send any observations we may have
ansond 0:e1c4378df3fe 147 void MBEDEndpoint::sendObservations() {
ansond 4:7f7fe167d9c0 148 for(int i=0;i<NUM_PERSONALITY_INSTANCES;++i) {
ansond 4:7f7fe167d9c0 149 if (this->m_personalities[i] != NULL) {
ansond 4:7f7fe167d9c0 150 NSPResourceFactory *resource_factory = (NSPResourceFactory *)(this->m_personalities[i]->getResourceFactory());
ansond 4:7f7fe167d9c0 151 if (resource_factory != NULL) resource_factory->sendObservations();
ansond 0:e1c4378df3fe 152 }
ansond 0:e1c4378df3fe 153 }
ansond 0:e1c4378df3fe 154 }
ansond 0:e1c4378df3fe 155
ansond 0:e1c4378df3fe 156 // initialize our ResourceFactory
ansond 4:7f7fe167d9c0 157 ResourceFactory *MBEDEndpoint::initResourceFactory() {
ansond 4:7f7fe167d9c0 158 #ifdef LIGHT_PERSONALITY
ansond 4:7f7fe167d9c0 159 return new NSPLightResourceFactory(this->logger(),(void *)this);
ansond 7:0207dfb9c36b 160 #endif
ansond 7:0207dfb9c36b 161 #ifdef COPCAR_PERSONALITY
ansond 7:0207dfb9c36b 162 return new NSPLightResourceFactory(this->logger(),(void *)this);
ansond 4:7f7fe167d9c0 163 #endif
ansond 4:7f7fe167d9c0 164 }
ansond 0:e1c4378df3fe 165
ansond 0:e1c4378df3fe 166 // Initialize the Endpoint Name - will be the first Light resource name (and there must be one...)
ansond 0:e1c4378df3fe 167 void MBEDEndpoint::initEndpointName() {
ansond 4:7f7fe167d9c0 168 this->m_instance_id = this->preferences()->getIntPreference("endpoint_id",PERSONALITY_NAME_INDEX);
ansond 4:7f7fe167d9c0 169 memset(_endpoint_name,0,PERSONALITY_NAME_LEN+1);
ansond 4:7f7fe167d9c0 170 memset(this->m_endpoint_name,0,PERSONALITY_NAME_LEN+1);
ansond 4:7f7fe167d9c0 171 sprintf(this->m_endpoint_name,PERSONALITY_NAME,this->m_instance_id);
ansond 4:7f7fe167d9c0 172 sprintf(_endpoint_name,PERSONALITY_NAME,this->m_instance_id);
ansond 0:e1c4378df3fe 173 }
ansond 0:e1c4378df3fe 174
ansond 0:e1c4378df3fe 175 // get our endpoint name
ansond 0:e1c4378df3fe 176 char *MBEDEndpoint::getEndpointName() { return this->m_endpoint_name; }
ansond 0:e1c4378df3fe 177
ansond 0:e1c4378df3fe 178 // get our instance id
ansond 0:e1c4378df3fe 179 int MBEDEndpoint::getInstanceID() { return this->m_instance_id; }
ansond 0:e1c4378df3fe 180
ansond 0:e1c4378df3fe 181 // initialize a specific transport
ansond 0:e1c4378df3fe 182 bool MBEDEndpoint::initializeTransport(int index,char *key,Transport *transport) {
ansond 0:e1c4378df3fe 183 bool success = false;
ansond 0:e1c4378df3fe 184 if (this->m_transports[index] == NULL) {
ansond 0:e1c4378df3fe 185 this->logger()->log("Initializing %s Transport...", key);
ansond 0:e1c4378df3fe 186 this->m_transports[index] = transport;
ansond 0:e1c4378df3fe 187 if (this->m_transports[index] != NULL) success = this->m_transports[index]->connect();
ansond 0:e1c4378df3fe 188 }
ansond 0:e1c4378df3fe 189 else {
ansond 0:e1c4378df3fe 190 this->logger()->log("%s already connected (OK)...", key);
ansond 0:e1c4378df3fe 191 success = true;
ansond 0:e1c4378df3fe 192 }
ansond 0:e1c4378df3fe 193 return success;
ansond 0:e1c4378df3fe 194 }
ansond 0:e1c4378df3fe 195
ansond 0:e1c4378df3fe 196 // initialize our transports
ansond 0:e1c4378df3fe 197 bool MBEDEndpoint::initializeTransports() {
ansond 0:e1c4378df3fe 198 bool success = true;
ansond 0:e1c4378df3fe 199
ansond 0:e1c4378df3fe 200 if (success == true) {
ansond 0:e1c4378df3fe 201 // NSP Initialization
ansond 5:94d000e6fa70 202 success = this->initializeTransport(NSP_TRANSPORT,"NSP",new NSPTransport(this->logger(),this));
ansond 0:e1c4378df3fe 203 }
ansond 0:e1c4378df3fe 204
ansond 0:e1c4378df3fe 205 if (success == true) {
ansond 0:e1c4378df3fe 206 // HTTP Initialization
ansond 5:94d000e6fa70 207 success = this->initializeTransport(HTTP_TRANSPORT,"HTTP",new HTTPTransport(this->logger(),this));
ansond 0:e1c4378df3fe 208 }
ansond 0:e1c4378df3fe 209
ansond 0:e1c4378df3fe 210 return success;
ansond 0:e1c4378df3fe 211 }
ansond 0:e1c4378df3fe 212
ansond 11:c4d02616e10f 213 #ifdef CELLULAR_NETWORK
ansond 21:272df0444756 214 bool MBEDEndpoint::initializeCellularModem(void *modem) {
ansond 11:c4d02616e10f 215 bool success = false;
ansond 11:c4d02616e10f 216
ansond 11:c4d02616e10f 217 // initialize
ansond 19:3cecccc1a3d4 218 if (this->m_cellular_modem == NULL) this->m_cellular_modem = new MBEDUbloxCellRadio(this->logger(),(void *)this,modem);
ansond 11:c4d02616e10f 219 if (this->m_cellular_modem != NULL) success = this->m_cellular_modem->connect();
ansond 11:c4d02616e10f 220
ansond 11:c4d02616e10f 221 // return our status
ansond 11:c4d02616e10f 222 return success;
ansond 11:c4d02616e10f 223 }
ansond 11:c4d02616e10f 224
ansond 19:3cecccc1a3d4 225 bool MBEDEndpoint::initializeGPSReceiver(void *gps) {
ansond 11:c4d02616e10f 226 bool success = false;
ansond 11:c4d02616e10f 227
ansond 11:c4d02616e10f 228 // initialize
ansond 19:3cecccc1a3d4 229 if (this->m_gps == NULL) this->m_gps = new MBEDUbloxGPS(this->logger(),(void *)this,gps);
ansond 11:c4d02616e10f 230 if (this->m_gps != NULL) success = this->m_gps->connect();
ansond 11:c4d02616e10f 231
ansond 11:c4d02616e10f 232 // return our status
ansond 11:c4d02616e10f 233 return success;
ansond 11:c4d02616e10f 234 }
ansond 11:c4d02616e10f 235 #endif
ansond 11:c4d02616e10f 236
ansond 6:edf306673e54 237 #ifndef CELLULAR_NETWORK
ansond 0:e1c4378df3fe 238 // initialize our Ethernet
ansond 0:e1c4378df3fe 239 bool MBEDEndpoint::initializeEthernet(EthernetInterface *ethernet) {
ansond 0:e1c4378df3fe 240 bool success = false;
ansond 0:e1c4378df3fe 241 this->m_ethernet = ethernet;
ansond 0:e1c4378df3fe 242 if (this->m_ethernet != NULL) {
ansond 0:e1c4378df3fe 243 this->logger()->log("Initializing Ethernet...");
ansond 0:e1c4378df3fe 244
ansond 0:e1c4378df3fe 245 // connect up ethernet
ansond 20:def10d2d9273 246 this->m_ethernet->init(); // DHCP
ansond 20:def10d2d9273 247 //this->m_ethernet->init("192.168.1.220","255.255.255.0","192.168.1.1");
ansond 0:e1c4378df3fe 248 this->m_ethernet->connect();
ansond 0:e1c4378df3fe 249
ansond 0:e1c4378df3fe 250 // display our IP address
ansond 0:e1c4378df3fe 251 char *ipaddr = this->m_ethernet->getIPAddress();
ansond 0:e1c4378df3fe 252 if (ipaddr != NULL && strlen(ipaddr) > 0) {
ansond 0:e1c4378df3fe 253 this->logger()->log("IPAddress: %s",this->m_ethernet->getIPAddress());
ansond 0:e1c4378df3fe 254 success = true;
ansond 0:e1c4378df3fe 255 }
ansond 0:e1c4378df3fe 256 else {
ansond 0:e1c4378df3fe 257 this->logger()->log("Ethernet Not Connected...");
ansond 0:e1c4378df3fe 258 success = false;
ansond 0:e1c4378df3fe 259 }
ansond 0:e1c4378df3fe 260 }
ansond 0:e1c4378df3fe 261 else {
ansond 0:e1c4378df3fe 262 this->logger()->log("No Ethernet instance found");
ansond 0:e1c4378df3fe 263 success = false;
ansond 0:e1c4378df3fe 264 }
ansond 0:e1c4378df3fe 265 return success;
ansond 0:e1c4378df3fe 266 }
ansond 6:edf306673e54 267 #endif
ansond 0:e1c4378df3fe 268
ansond 4:7f7fe167d9c0 269 // close down the Personalities
ansond 4:7f7fe167d9c0 270 bool MBEDEndpoint::closePersonalities() {
ansond 0:e1c4378df3fe 271 bool success = true;
ansond 4:7f7fe167d9c0 272 this->logger()->log("Closing down Personalities...");
ansond 0:e1c4378df3fe 273 return success;
ansond 0:e1c4378df3fe 274 }
ansond 0:e1c4378df3fe 275
ansond 0:e1c4378df3fe 276 // close a given transport
ansond 0:e1c4378df3fe 277 bool MBEDEndpoint::closeTransport(int index,char *key) {
ansond 0:e1c4378df3fe 278 this->logger()->log("Closing down %s Transport...", key);
ansond 0:e1c4378df3fe 279 if (this->m_transports[index] != NULL) delete this->m_transports[index];
ansond 0:e1c4378df3fe 280 return true;
ansond 0:e1c4378df3fe 281 }
ansond 0:e1c4378df3fe 282
ansond 0:e1c4378df3fe 283 // close down our transports
ansond 0:e1c4378df3fe 284 bool MBEDEndpoint::closeTransports() {
ansond 0:e1c4378df3fe 285 bool success = true;
ansond 0:e1c4378df3fe 286
ansond 0:e1c4378df3fe 287 if (success) {
ansond 0:e1c4378df3fe 288 // close NSP
ansond 0:e1c4378df3fe 289 success = this->closeTransport(NSP_TRANSPORT,"NSP");
ansond 0:e1c4378df3fe 290 }
ansond 0:e1c4378df3fe 291
ansond 0:e1c4378df3fe 292 return success;
ansond 0:e1c4378df3fe 293 }
ansond 0:e1c4378df3fe 294
ansond 11:c4d02616e10f 295 #ifdef CELLULAR_NETWORK
ansond 11:c4d02616e10f 296 bool MBEDEndpoint::closeCellularModem() {
ansond 11:c4d02616e10f 297 bool success = true;
ansond 11:c4d02616e10f 298 if (this->m_cellular_modem != NULL) success = this->m_cellular_modem->disconnect();
ansond 11:c4d02616e10f 299 return success;
ansond 11:c4d02616e10f 300 }
ansond 11:c4d02616e10f 301
ansond 11:c4d02616e10f 302 bool MBEDEndpoint::closeGPSReceiver() {
ansond 11:c4d02616e10f 303 bool success = true;
ansond 11:c4d02616e10f 304 if (this->m_gps != NULL) success = this->m_gps->disconnect();
ansond 11:c4d02616e10f 305 return success;
ansond 11:c4d02616e10f 306 }
ansond 11:c4d02616e10f 307 #endif
ansond 11:c4d02616e10f 308
ansond 6:edf306673e54 309 #ifndef CELLULAR_NETWORK
ansond 0:e1c4378df3fe 310 // close down our Ethernet
ansond 0:e1c4378df3fe 311 bool MBEDEndpoint::closeEthernet() {
ansond 0:e1c4378df3fe 312 this->logger()->log("Closing down Ethernet...");
ansond 0:e1c4378df3fe 313 if (this->m_ethernet != NULL) this->m_ethernet->disconnect();
ansond 0:e1c4378df3fe 314 return true;
ansond 0:e1c4378df3fe 315 }
ansond 6:edf306673e54 316 #endif
ansond 0:e1c4378df3fe 317
ansond 0:e1c4378df3fe 318 // main running loop
ansond 0:e1c4378df3fe 319 void MBEDEndpoint::run() {
ansond 0:e1c4378df3fe 320 this->logger()->log("Endpoint Main Loop");
ansond 0:e1c4378df3fe 321 this->m_transports[NSP_TRANSPORT]->checkAndProcess();
ansond 0:e1c4378df3fe 322 }
ansond 0:e1c4378df3fe 323