Totally different attempt

This commit is contained in:
SRGDamia1
2017-05-04 15:22:21 -04:00
parent f84789a49b
commit 8bc626f415
5 changed files with 57 additions and 42 deletions

View File

@@ -312,10 +312,6 @@ public:
commandMode();
sendAT(GF("AP"), 0); // Put in transparent mode
waitResponse();
sendAT(GF("IP"), 1); // Put in TCP mode
waitResponse();
sendAT(GF("EE"), 2); // Set security to WPA2
waitResponse();
@@ -348,10 +344,6 @@ public:
*/
bool gprsConnect(const char* apn, const char* user = "", const char* pw = "") {
commandMode();
sendAT(GF("AP"), 0); // Put in transparent mode
waitResponse();
sendAT(GF("IP"), 1); // Put in TCP mode
waitResponse();
sendAT(GF("AN"), apn); // Set the APN
waitResponse();
writeChanges();
@@ -375,8 +367,6 @@ public:
bool sendSMS(const String& number, const String& text) {
commandMode();
sendAT(GF("AP"), 0); // Put in transparent mode
waitResponse();
sendAT(GF("IP"), 2); // Put in text messaging mode
waitResponse();
sendAT(GF("PH"), number); // Set the phone number
@@ -475,16 +465,16 @@ public:
}
private:
int modemConnect(const char* host, uint16_t port, uint8_t mux = 1) {
int modemConnect(const char* host, uint16_t port, uint8_t mux = 1, bool isUDP=false) {
sendAT(GF("LA"), host);
String ipadd; ipadd.reserve(16);
ipadd = streamReadUntil('\r');
IPAddress ip;
ip.fromString(ipadd);
return modemConnect(ip, port);
return modemConnect(ip, port, mux, isUDP);
}
int modemConnect(IPAddress ip, uint16_t port, uint8_t mux = 1) {
int modemConnect(IPAddress ip, uint16_t port, uint8_t mux = 1, bool isUDP=false) {
String host; host.reserve(16);
host += ip[0];
host += ".";
@@ -493,6 +483,13 @@ private:
host += ip[2];
host += ".";
host += ip[3];
if (isUDP) {
sendAT(GF("IP"), 0); // Put in UDP mode
waitResponse();
} else {
sendAT(GF("IP"), 1); // Put in TCP mode
waitResponse();
}
sendAT(GF("DL"), host);
waitResponse();
sendAT(GF("DE"), String(port, HEX));