mirror of
https://github.com/KevinMidboe/TinyGSM.git
synced 2025-12-08 20:48:44 +00:00
Implement connect with timeout, XBee improvements
This commit is contained in:
@@ -77,15 +77,15 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
virtual int connect(const char *host, uint16_t port) {
|
||||
virtual int connect(const char *host, uint16_t port, int timeout) {
|
||||
stop();
|
||||
TINY_GSM_YIELD();
|
||||
rx.clear();
|
||||
sock_connected = at->modemConnect(host, port, mux);
|
||||
sock_connected = at->modemConnect(host, port, mux, timeout);
|
||||
return sock_connected;
|
||||
}
|
||||
|
||||
TINY_GSM_CLIENT_CONNECT_TO_IP()
|
||||
TINY_GSM_CLIENT_CONNECT_OVERLOADS()
|
||||
|
||||
virtual void stop() {
|
||||
TINY_GSM_YIELD();
|
||||
@@ -141,11 +141,11 @@ public:
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual int connect(const char *host, uint16_t port) {
|
||||
virtual int connect(const char *host, uint16_t port, int timeout) {
|
||||
stop();
|
||||
TINY_GSM_YIELD();
|
||||
rx.clear();
|
||||
sock_connected = at->modemConnect(host, port, mux, true);
|
||||
sock_connected = at->modemConnect(host, port, mux, true, timeout);
|
||||
return sock_connected;
|
||||
}
|
||||
};
|
||||
@@ -681,7 +681,9 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
|
||||
|
||||
protected:
|
||||
|
||||
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool ssl = false) {
|
||||
bool modemConnect(const char* host, uint16_t port, uint8_t mux,
|
||||
bool ssl = false, int timeout = 75000L)
|
||||
{
|
||||
int rsp;
|
||||
#if !defined(TINY_GSM_MODEM_SIM900)
|
||||
sendAT(GF("+CIPSSL="), ssl);
|
||||
@@ -691,7 +693,7 @@ protected:
|
||||
}
|
||||
#endif
|
||||
sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port);
|
||||
rsp = waitResponse(75000L,
|
||||
rsp = waitResponse(timeout,
|
||||
GF("CONNECT OK" GSM_NL),
|
||||
GF("CONNECT FAIL" GSM_NL),
|
||||
GF("ALREADY CONNECT" GSM_NL),
|
||||
|
||||
Reference in New Issue
Block a user