File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -45,17 +45,20 @@ GSMClient::GSMClient(bool synch) :
45
45
GSMClient::GSMClient (int socket, bool synch) :
46
46
_synch(synch),
47
47
_socket(socket),
48
+ _connected(false ),
48
49
_state(CLIENT_STATE_IDLE),
49
50
_ip((uint32_t )0),
50
51
_host(NULL ),
51
52
_port(0 ),
52
53
_ssl(false ),
53
54
_writeSync(true )
54
55
{
56
+ MODEM.addUrcHandler (this );
55
57
}
56
58
57
59
GSMClient::~GSMClient ()
58
60
{
61
+ MODEM.removeUrcHandler (this );
59
62
}
60
63
61
64
int GSMClient::ready ()
@@ -158,6 +161,7 @@ int GSMClient::ready()
158
161
159
162
ready = 0 ;
160
163
} else {
164
+ _connected = true ;
161
165
_state = CLIENT_STATE_IDLE;
162
166
}
163
167
break ;
@@ -335,7 +339,7 @@ uint8_t GSMClient::connected()
335
339
}
336
340
337
341
// call available to update socket state
338
- if (GSMSocketBuffer.available (_socket) < 0 ) {
342
+ if (( GSMSocketBuffer.available (_socket) < 0 ) || (_ssl && !_connected) ) {
339
343
stop ();
340
344
341
345
return 0 ;
@@ -426,4 +430,18 @@ void GSMClient::stop()
426
430
427
431
GSMSocketBuffer.close (_socket);
428
432
_socket = -1 ;
433
+ _connected = false ;
434
+ }
435
+
436
+ void GSMClient::handleUrc (const String& urc)
437
+ {
438
+ if (urc.startsWith (" +UUSORD: " )) {
439
+ int socket = urc.charAt (9 ) - ' 0' ;
440
+
441
+ if (socket == _socket) {
442
+ if (urc.endsWith (" ,4294967295" )) {
443
+ _connected = false ;
444
+ }
445
+ }
446
+ }
429
447
}
Original file line number Diff line number Diff line change 20
20
#ifndef _GSM_CLIENT_H_INCLUDED
21
21
#define _GSM_CLIENT_H_INCLUDED
22
22
23
+ #include " Modem.h"
24
+
23
25
#include < Client.h>
24
26
25
- class GSMClient : public Client {
27
+ class GSMClient : public Client , public ModemUrcHandler {
26
28
27
29
public:
28
30
@@ -126,11 +128,14 @@ class GSMClient : public Client {
126
128
*/
127
129
void stop ();
128
130
131
+ virtual void handleUrc (const String& urc);
132
+
129
133
private:
130
134
int connect ();
131
135
132
136
bool _synch;
133
137
int _socket;
138
+ int _connected;
134
139
135
140
int _state;
136
141
IPAddress _ip;
You can’t perform that action at this time.
0 commit comments