Official reference client implementation for Cumulocity SmartREST on u-blox C027.
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: util/SmartRestSocket.cpp
- Revision:
- 99:e369fc75c000
- Parent:
- 97:ea056f6be2e8
- Child:
- 106:c61f0d62b625
--- a/util/SmartRestSocket.cpp Mon Apr 27 13:30:21 2015 +0000 +++ b/util/SmartRestSocket.cpp Thu May 07 09:57:55 2015 +0000 @@ -12,13 +12,13 @@ ipLock.lock(); for (size_t i = 0; i < 3; ++i) { if (cachedIP[0] == '\0') { - MDMParser::IP ip = pMdm->gethostbyname(getHost()); + MDMParser::IP ip = pMdm->gethostbyname(srHost); if (ip == NOIP) continue; const unsigned char *c = (const unsigned char*)&ip; snprintf(cachedIP, sizeof(cachedIP), "%u.%u.%u.%u", c[3], c[2], c[1], c[0]); } - n = TCPSocketConnection::connect(cachedIP, getPort()); + n = TCPSocketConnection::connect(cachedIP, srPort); if (n >= 0) { break; } else { @@ -54,6 +54,8 @@ return -2; } else { l = receive(buf, maxSize); + if (l >= 0 && l < maxSize) + buf[l] = 0; close(); return l; }