Skip to content

Commit f66103f

Browse files
committed
Fix some regressions introduced by the new socket buffer
The last chunk of data received on the socket before it closes was not returned. The URC caused the socket to be in the closed state.
1 parent 9415de4 commit f66103f

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

src/GSMClient.cpp

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20+
#include "Modem.h"
21+
2022
#include "utility/GSMSocketBuffer.h"
2123

2224
#include "GSMClient.h"
@@ -48,12 +50,10 @@ GSMClient::GSMClient(int socket, bool synch) :
4850
_ssl(false),
4951
_writeSync(true)
5052
{
51-
MODEM.addUrcHandler(this);
5253
}
5354

5455
GSMClient::~GSMClient()
5556
{
56-
MODEM.removeUrcHandler(this);
5757
}
5858

5959
int GSMClient::ready()
@@ -309,6 +309,13 @@ uint8_t GSMClient::connected()
309309
return 0;
310310
}
311311

312+
// call available to update socket state
313+
if (GSMSocketBuffer.available(_socket) < 0) {
314+
stop();
315+
316+
return 0;
317+
}
318+
312319
return 1;
313320
}
314321

@@ -395,27 +402,3 @@ void GSMClient::stop()
395402
GSMSocketBuffer.close(_socket);
396403
_socket = -1;
397404
}
398-
399-
void GSMClient::handleUrc(const String& urc)
400-
{
401-
if (urc.startsWith("+UUSOCL: ")) {
402-
int socket = urc.charAt(urc.length() - 1) - '0';
403-
404-
if (socket == _socket) {
405-
// this socket closed
406-
GSMSocketBuffer.close(_socket);
407-
_socket = -1;
408-
}
409-
} else if (urc.startsWith("+UUSORD: ")) {
410-
int socket = urc.charAt(9) - '0';
411-
412-
if (socket == _socket) {
413-
if (urc.endsWith(",4294967295")) {
414-
// SSL disconnect
415-
// this socket closed
416-
GSMSocketBuffer.close(_socket);
417-
_socket = -1;
418-
}
419-
}
420-
}
421-
}

src/GSMClient.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222

2323
#include <Client.h>
2424

25-
#include "Modem.h"
26-
27-
class GSMClient : public Client, public ModemUrcHandler {
25+
class GSMClient : public Client {
2826

2927
public:
3028

@@ -128,8 +126,6 @@ class GSMClient : public Client, public ModemUrcHandler {
128126
*/
129127
void stop();
130128

131-
virtual void handleUrc(const String& urc);
132-
133129
private:
134130
int connect();
135131

0 commit comments

Comments
 (0)