mirror of
https://github.com/KevinMidboe/TinyGSM.git
synced 2026-07-24 02:32:01 +00:00
Added isNetworkConnected for ESP8266
Also shorted time between checks in "isNetworkConnected" for all modems
This commit is contained in:
+1
-1
@@ -361,7 +361,7 @@ public:
|
|||||||
if (isNetworkConnected()) {
|
if (isNetworkConnected()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delay(500);
|
delay(250);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-12
@@ -185,7 +185,7 @@ public:
|
|||||||
if (!testAT()) {
|
if (!testAT()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sendAT(GF("E0"));
|
sendAT(GF("E0")); // Echo Off
|
||||||
if (waitResponse() != 1) {
|
if (waitResponse() != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -209,9 +209,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void maintain() {
|
void maintain() {
|
||||||
//while (stream.available()) {
|
|
||||||
waitResponse(10, NULL, NULL);
|
waitResponse(10, NULL, NULL);
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool factoryDefault() {
|
bool factoryDefault() {
|
||||||
@@ -270,13 +268,22 @@ public:
|
|||||||
streamSkipUntil(','); // Skip BSSID/MAC address
|
streamSkipUntil(','); // Skip BSSID/MAC address
|
||||||
streamSkipUntil(','); // Skip Chanel number
|
streamSkipUntil(','); // Skip Chanel number
|
||||||
int res2 = stream.parseInt(); // Read RSSI
|
int res2 = stream.parseInt(); // Read RSSI
|
||||||
DBG(res2);
|
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNetworkConnected() {
|
bool isNetworkConnected() {
|
||||||
return true; // TODO
|
sendAT(GF("+CIPSTATUS"));
|
||||||
|
int res1 = waitResponse(3000, GF("STATUS:"));
|
||||||
|
if (res1 == 1) {
|
||||||
|
int res2 = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5"));
|
||||||
|
if (res2 == 2 || res2 == 3 || res2 == 4) return true;
|
||||||
|
}
|
||||||
|
// <stat> status of ESP8266 station interface
|
||||||
|
// 2 : ESP8266 station connected to an AP and has obtained IP
|
||||||
|
// 3 : ESP8266 station created a TCP or UDP transmission
|
||||||
|
// 4 : the TCP or UDP transmission of ESP8266 station disconnected (but AP is connected)
|
||||||
|
// 5 : ESP8266 station did NOT connect to an AP
|
||||||
}
|
}
|
||||||
|
|
||||||
bool waitForNetwork(unsigned long timeout = 60000L) {
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
@@ -287,12 +294,7 @@ public:
|
|||||||
int res2 = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5"));
|
int res2 = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5"));
|
||||||
if (res2 == 2 || res2 == 3 || res2 == 4) return true;
|
if (res2 == 2 || res2 == 3 || res2 == 4) return true;
|
||||||
}
|
}
|
||||||
// <stat> status of ESP8266 station interface
|
delay(250);
|
||||||
// 2 : ESP8266 station connected to an AP and has obtained IP
|
|
||||||
// 3 : ESP8266 station created a TCP or UDP transmission
|
|
||||||
// 4 : the TCP or UDP transmission of ESP8266 station disconnected (but AP is connected)
|
|
||||||
// 5 : ESP8266 station did NOT connect to an AP
|
|
||||||
delay(1000);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -332,7 +334,6 @@ public:
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String res2 = stream.readStringUntil('"');
|
String res2 = stream.readStringUntil('"');
|
||||||
DBG(res2);
|
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -367,7 +367,7 @@ public:
|
|||||||
if (isNetworkConnected()) {
|
if (isNetworkConnected()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delay(500);
|
delay(250);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ public:
|
|||||||
if (isNetworkConnected()) {
|
if (isNetworkConnected()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delay(500);
|
delay(250);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -372,7 +372,7 @@ public:
|
|||||||
if (isNetworkConnected()) {
|
if (isNetworkConnected()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delay(500);
|
delay(250);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -341,7 +341,7 @@ public:
|
|||||||
if (res == GF("0")) {
|
if (res == GF("0")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delay(1000);
|
delay(250);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user