Fix gprsConnect, add getLocalIP(). Fix #9
This commit is contained in:
@@ -337,9 +337,17 @@ public:
|
|||||||
bool gprsConnect(const char* apn, const char* user, const char* pwd) {
|
bool gprsConnect(const char* apn, const char* user, const char* pwd) {
|
||||||
gprsDisconnect();
|
gprsDisconnect();
|
||||||
|
|
||||||
|
sendAT(GF("+CGATT=1"));
|
||||||
|
if (waitResponse(60000L) != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// TODO: wait AT+CGATT?
|
||||||
|
|
||||||
sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"');
|
sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"');
|
||||||
waitResponse();
|
waitResponse();
|
||||||
|
|
||||||
|
if (!user) user = "";
|
||||||
|
if (!pwd) pwd = "";
|
||||||
sendAT(GF("+CSTT=\""), apn, GF("\",\""), user, GF("\",\""), pwd, GF("\""));
|
sendAT(GF("+CSTT=\""), apn, GF("\",\""), user, GF("\",\""), pwd, GF("\""));
|
||||||
if (waitResponse(60000L) != 1) {
|
if (waitResponse(60000L) != 1) {
|
||||||
return false;
|
return false;
|
||||||
@@ -348,12 +356,6 @@ public:
|
|||||||
sendAT(GF("+CGACT=1,1"));
|
sendAT(GF("+CGACT=1,1"));
|
||||||
waitResponse(60000L);
|
waitResponse(60000L);
|
||||||
|
|
||||||
sendAT(GF("+CGATT=1"));
|
|
||||||
if (waitResponse(60000L) != 1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// TODO: wait AT+CGATT?
|
|
||||||
|
|
||||||
sendAT(GF("+CIPMUX=1"));
|
sendAT(GF("+CIPMUX=1"));
|
||||||
if (waitResponse() != 1) {
|
if (waitResponse() != 1) {
|
||||||
return false;
|
return false;
|
||||||
@@ -376,6 +378,16 @@ public:
|
|||||||
return waitResponse(60000L) == 1;
|
return waitResponse(60000L) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getLocalIP() {
|
||||||
|
sendAT(GF("+CIFSR"));
|
||||||
|
String res;
|
||||||
|
if (waitResponse(10000L, res) != 1) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
res.trim();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phone Call functions
|
* Phone Call functions
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user