1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-26 07:02:15 +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:
Ivan Grokhotkov
2015-06-11 18:01:08 +03:00
parent 567d401ed3
commit e6e57a8b81
7 changed files with 118 additions and 12 deletions

View File

@ -0,0 +1,38 @@
#ifndef SLIST_H
#define SLIST_H
template<typename T>
class SList {
public:
SList() : _next(0) { }
protected:
static void _add(T* self) {
T* tmp = _s_first;
_s_first = self;
self->_next = tmp;
}
static void _remove(T* self) {
if (_s_first == self) {
_s_first = self->_next;
self->_next = 0;
return;
}
for (T* prev = _s_first; prev->_next; _s_first = _s_first->_next) {
if (prev->_next == self) {
prev->_next = self->_next;
self->_next = 0;
return;
}
}
}
static T* _s_first;
T* _next;
};
#endif //SLIST_H