mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Better handling of wifi disconnect (#231)
When network interface is down, some nasty things happen, for instance tcp_connect returns without ever calling error callback. This change adds some workarounds for that: before doing a tcp connect and DNS resolve we check if there is a route available. Also added a listener for wifi events which stops (aborts) all the WiFiClients and WiFiUDPs when wifi is disconnected. This should help libraries detect disconnect properly.
This commit is contained in:
@ -26,11 +26,12 @@
|
||||
#include "Client.h"
|
||||
#include "IPAddress.h"
|
||||
#include <memory>
|
||||
#include "include/slist.h"
|
||||
|
||||
class ClientContext;
|
||||
class WiFiServer;
|
||||
|
||||
class WiFiClient : public Client {
|
||||
class WiFiClient : public Client, public SList<WiFiClient> {
|
||||
protected:
|
||||
WiFiClient(ClientContext* client);
|
||||
|
||||
@ -89,6 +90,8 @@ public:
|
||||
|
||||
using Print::write;
|
||||
|
||||
static void stopAll();
|
||||
|
||||
private:
|
||||
|
||||
static int8_t _s_connected(void* arg, void* tpcb, int8_t err);
|
||||
@ -99,7 +102,6 @@ private:
|
||||
|
||||
ClientContext* _client;
|
||||
static uint16_t _localPort;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user