Simple detection for LE910-NA1 modules
Fork of MTS-Cellular by
Diff: Cellular/EasyIP.cpp
- Revision:
- 60:250c17af30fb
- Parent:
- 59:5535f14e3cc4
- Child:
- 66:8c55e2bf7270
--- a/Cellular/EasyIP.cpp Wed Aug 13 21:15:05 2014 +0000 +++ b/Cellular/EasyIP.cpp Wed Aug 13 21:38:20 2014 +0000 @@ -208,6 +208,7 @@ active = false; } + //Updates pppConnected to reflect current connection state RadioState state; bool ppp = pppConnected; if (signal && regist && active) { @@ -223,6 +224,7 @@ pppConnected = false; } + //Compares current connection state with previous pppConnected variable state if (!ppp && state == CONNECTED) { logWarning("Internal PPP state tracking differs from radio (DISCONNECTED:CONNECTED)"); } else if (ppp && state != CONNECTED) { @@ -262,6 +264,7 @@ } } +//Opens socket connection bool EasyIP::open(const std::string& address, unsigned int port, Mode mode) { char sOpenSocketCmd[256] = {0}; //String for AT command @@ -327,6 +330,7 @@ } else { closeType = 255; } + //5) Open Socket sprintf(sOpenSocketCmd, "AT#SD=1,%d,%d,%s,%d,%d,0", typeSocket, port, address.c_str(),closeType , local_port); std::string response = sendCommand(sOpenSocketCmd, 60000); @@ -346,6 +350,7 @@ return socketOpened; } +//Closes socket connection bool EasyIP::close() { @@ -375,6 +380,7 @@ logDebug("Failed to close socket connection"); } + //Clear receive buffer Timer tmr; int counter = 0; char tmp[256]; @@ -392,6 +398,7 @@ return !socketOpened; } +//Read from socket int EasyIP::read(char* data, int max, int timeout) { if(io == NULL) { @@ -406,7 +413,6 @@ } int bytesRead = 0; - if(timeout >= 0) { bytesRead = io->read(data, max, static_cast<unsigned int>(timeout)); @@ -438,6 +444,7 @@ return bytesRead; } +//Write to socket int EasyIP::write(const char* data, int length, int timeout) { if(io == NULL) {