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
Diff: MBEDEndpoint.cpp
- Revision:
- 24:b62fec3ff73c
- Parent:
- 23:6f6e97a276b9
- Child:
- 28:b6a7959c8be0
--- a/MBEDEndpoint.cpp Thu Aug 28 21:17:12 2014 +0000 +++ b/MBEDEndpoint.cpp Sat Sep 13 04:27:32 2014 +0000 @@ -79,6 +79,7 @@ if (success) this->logger()->turnLEDOrange(); this->logger()->lcdStatusOnly(true); if (!success) closedown(2); + if (success && AUTO_REGISTER_WITH_IOC) this->autoRegisterWithIOC(); } // default destructor @@ -226,6 +227,42 @@ return success; } + // auto register with the IOC + bool MBEDEndpoint::autoRegisterWithIOC() { + bool success = false; + char url[AUTOREGISTER_URL_LENGTH+1]; + char result[AUTOREGISTER_RESPONSE_LEN+1]; + + // we use the HTTP transport to tell the Gateway to register us on our behalf + HTTPTransport *http = (HTTPTransport *)this->m_transports[HTTP_TRANSPORT]; + if (http != NULL) { + // DEBUG + this->logger()->log("Initiating registration %s with IOC...",this->getEndpointName()); + + // initialize buffers + memset(url,0,AUTOREGISTER_URL_LENGTH+1); + memset(result,0,AUTOREGISTER_RESPONSE_LEN+1); + + // enable basic auth + http->basicAuth(IOC_USERNAME,IOC_PASSWORD); + + // build the URL + sprintf(url,GW_AUTOREGISTER_URL,GW_IPADDRESS,GW_PORT,this->getEndpointName()); + + // DEBUG + //this->logger()->log("AutoRegister: %s...",url); + + // issue the registration request + success = http->httpGet(url,result,AUTOREGISTER_RESPONSE_LEN,GW_AUTOREGISTER_TIMEOUT_MS); + + // reset basic auth + http->basicAuth(NULL,NULL); + } + + // return our status + return success; + } + #ifdef CELLULAR_NETWORK bool MBEDEndpoint::initializeCellularModem(void *modem) { bool success = false;