Browse Source

Merge branch 'master' into master

v_master
Volodymyr Shymanskyy 7 years ago
committed by GitHub
parent
commit
cd185cf770
3 changed files with 36 additions and 6 deletions
  1. +33
    -5
      TinyGsmClientSIM800.h
  2. +1
    -1
      examples/HttpsClient/HttpsClient.ino
  3. +2
    -0
      keywords.txt

+ 33
- 5
TinyGsmClientSIM800.h View File

@ -171,7 +171,7 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private:
TinyGsmSim800* at;
TinyGsmSim800* at;
uint8_t mux;
uint16_t sock_available;
uint32_t prev_check;
@ -411,13 +411,17 @@ public:
return res;
}
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
}
bool waitForNetwork(unsigned long timeout = 60000L) {
for (unsigned long start = millis(); millis() - start < timeout; ) {
RegStatus s = getRegistrationStatus();
if (s == REG_OK_HOME || s == REG_OK_ROAMING) {
if (isNetworkConnected()) {
return true;
}
delay(1000);
delay(500);
}
return false;
}
@ -514,7 +518,31 @@ public:
bool gprsDisconnect() {
sendAT(GF("+CIPSHUT"));
return waitResponse(60000L) == 1;
if (waitResponse(60000L) != 1)
return false;
sendAT(GF("+CGATT=0"));
if (waitResponse(60000L) != 1)
return false;
return true;
}
bool isGprsConnected() {
sendAT(GF("+CGATT?"));
if (waitResponse(GF(GSM_NL "+CGATT:")) != 1) {
return false;
}
int res = stream.readStringUntil('\n').toInt();
waitResponse();
if (res != 1)
return false;
sendAT(GF("+CIFSR;E0")); // Another option is to use AT+CGPADDR=1
if (waitResponse() != 1)
return false;
return true;
}
String getLocalIP() {


+ 1
- 1
examples/HttpsClient/HttpsClient.ino View File

@ -15,7 +15,7 @@
// Select your modem
// SSL/TLS is currently supported only with SIM8xx series
#define TINY_GSM_MODEM_SIM800
#define TINY_GSM_MODEM_SIM808
//#define TINY_GSM_MODEM_SIM808
// Increase RX buffer
#define TINY_GSM_RX_BUFFER 64


+ 2
- 0
keywords.txt View File

@ -17,6 +17,8 @@ waitForNetwork KEYWORD2
getSimStatus KEYWORD2
gprsConnect KEYWORD2
gprsDisconnect KEYWORD2
isGprsConnected KEYWORD2
isNetworkConnected KEYWORD2
factoryReset KEYWORD2
#######################################


Loading…
Cancel
Save