mirror of
https://github.com/KevinMidboe/TinyGSM.git
synced 2025-10-29 18:00:18 +00:00
Totally different attempt
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user