Skip to content

Commit d106fda

Browse files
sandeepmistryRocketct
authored andcommitted
Fix SSL disconnect not triggering
1 parent b615cb3 commit d106fda

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/GSMClient.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,20 @@ GSMClient::GSMClient(bool synch) :
4545
GSMClient::GSMClient(int socket, bool synch) :
4646
_synch(synch),
4747
_socket(socket),
48+
_connected(false),
4849
_state(CLIENT_STATE_IDLE),
4950
_ip((uint32_t)0),
5051
_host(NULL),
5152
_port(0),
5253
_ssl(false),
5354
_writeSync(true)
5455
{
56+
MODEM.addUrcHandler(this);
5557
}
5658

5759
GSMClient::~GSMClient()
5860
{
61+
MODEM.removeUrcHandler(this);
5962
}
6063

6164
int GSMClient::ready()
@@ -158,6 +161,7 @@ int GSMClient::ready()
158161

159162
ready = 0;
160163
} else {
164+
_connected = true;
161165
_state = CLIENT_STATE_IDLE;
162166
}
163167
break;
@@ -335,7 +339,7 @@ uint8_t GSMClient::connected()
335339
}
336340

337341
// call available to update socket state
338-
if (GSMSocketBuffer.available(_socket) < 0) {
342+
if ((GSMSocketBuffer.available(_socket) < 0) || (_ssl && !_connected)) {
339343
stop();
340344

341345
return 0;
@@ -426,4 +430,18 @@ void GSMClient::stop()
426430

427431
GSMSocketBuffer.close(_socket);
428432
_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+
}
429447
}

src/GSMClient.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
#ifndef _GSM_CLIENT_H_INCLUDED
2121
#define _GSM_CLIENT_H_INCLUDED
2222

23+
#include "Modem.h"
24+
2325
#include <Client.h>
2426

25-
class GSMClient : public Client {
27+
class GSMClient : public Client, public ModemUrcHandler {
2628

2729
public:
2830

@@ -126,11 +128,14 @@ class GSMClient : public Client {
126128
*/
127129
void stop();
128130

131+
virtual void handleUrc(const String& urc);
132+
129133
private:
130134
int connect();
131135

132136
bool _synch;
133137
int _socket;
138+
int _connected;
134139

135140
int _state;
136141
IPAddress _ip;

0 commit comments

Comments
 (0)