Skip to content

Commit 6201370

Browse files
committed
Add _disconnect to other Wifi
also some doxygen
1 parent 3e27a60 commit 6201370

12 files changed

+133
-16
lines changed

src/AdafruitIO.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class AdafruitIO {
7575

7676
protected:
7777
virtual void _connect() = 0;
78+
virtual void _disconnect() = 0;
7879
aio_status_t _status = AIO_IDLE;
7980
uint32_t _last_ping = 0;
8081
uint32_t _last_mqtt_connect = 0;

src/AdafruitIO_Definitions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class AdafruitIOGroupCallback {
7676
#define AIO_MQTT_CONNECTION_TIMEOUT 60000
7777
// Time to wait for a successful reconnection after network disconnect
7878
#define AIO_NET_CONNECTION_TIMEOUT 60000
79+
// Time to wait for a net disconnect to take effect
80+
#define AIO_NET_DISCONNECT_WAIT 300
7981

8082
#define AIO_ERROR_TOPIC "/errors"
8183
#define AIO_THROTTLE_TOPIC "/throttle"

src/wifi/AdafruitIO_AIRLIFT.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ class AdafruitIO_AIRLIFT : public AdafruitIO {
160160
{
161161
if(strlen(_ssid) != 0)
162162
{
163-
WiFi.disconnect();
164-
delay(300);
163+
_disconnect();
165164
// setup ESP32 pins
166165
if (_ssPin != -1) {
167166
WiFi.setPins(_ssPin, _ackPin, _rstPin, _gpio0Pin, _wifi);
@@ -181,6 +180,19 @@ class AdafruitIO_AIRLIFT : public AdafruitIO {
181180
_status = AIO_NET_DISCONNECTED;
182181
}
183182
}
183+
184+
/**************************************************************************/
185+
/*!
186+
@brief Disconnect the wifi network.
187+
@return none
188+
*/
189+
/**************************************************************************/
190+
void _disconnect()
191+
{
192+
WiFi.disconnect();
193+
delay(AIO_NET_DISCONNECT_WAIT);
194+
}
195+
184196
};
185197

186198
#endif // ADAFRUITIO_AIRLIFT_H

src/wifi/AdafruitIO_ESP32.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ void AdafruitIO_ESP32::_connect()
3636
{
3737
if(strlen(_ssid) != 0)
3838
{
39-
WiFi.disconnect();
40-
delay(300);
41-
39+
_disconnect();
4240
delay(100);
4341
WiFi.begin(_ssid, _pass);
4442
delay(100);
@@ -47,6 +45,18 @@ void AdafruitIO_ESP32::_connect()
4745

4846
}
4947

48+
/**************************************************************************/
49+
/*!
50+
@brief Disconnect the wifi network.
51+
@return none
52+
*/
53+
/**************************************************************************/
54+
void AdafruitIO_ESP32::_disconnect()
55+
{
56+
WiFi.disconnect();
57+
delay(AIO_NET_DISCONNECT_WAIT);
58+
}
59+
5060
aio_status_t AdafruitIO_ESP32::networkStatus()
5161
{
5262

src/wifi/AdafruitIO_ESP32.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class AdafruitIO_ESP32 : public AdafruitIO {
3535

3636
protected:
3737
void _connect();
38+
void _disconnect();
3839

3940
const char *_ssid;
4041
const char *_pass;

src/wifi/AdafruitIO_ESP8266.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ void AdafruitIO_ESP8266::_connect()
3838
{
3939
if(strlen(_ssid) != 0)
4040
{
41-
WiFi.disconnect();
42-
delay(300);
43-
41+
_disconnect();
4442
delay(100);
4543
WiFi.begin(_ssid, _pass);
4644
delay(100);
@@ -49,6 +47,18 @@ void AdafruitIO_ESP8266::_connect()
4947

5048
}
5149

50+
/**************************************************************************/
51+
/*!
52+
@brief Disconnect the wifi network.
53+
@return none
54+
*/
55+
/**************************************************************************/
56+
void AdafruitIO_ESP8266::_disconnect()
57+
{
58+
WiFi.disconnect();
59+
delay(AIO_NET_DISCONNECT_WAIT);
60+
}
61+
5262
aio_status_t AdafruitIO_ESP8266::networkStatus()
5363
{
5464

src/wifi/AdafruitIO_ESP8266.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class AdafruitIO_ESP8266 : public AdafruitIO {
3535

3636
protected:
3737
void _connect();
38+
void _disconnect();
3839

3940
const char *_ssid;
4041
const char *_pass;

src/wifi/AdafruitIO_MKR1000.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,30 @@ void AdafruitIO_MKR1000::_connect()
3737
{
3838
if(strlen(_ssid) != 0)
3939
{
40-
WiFi.disconnect();
41-
delay(300);
42-
4340
// no shield? bail
4441
if(WiFi.status() == WL_NO_SHIELD)
4542
return;
4643

44+
_disconnect();
45+
4746
WiFi.begin(_ssid, _pass);
4847
_status = AIO_NET_DISCONNECTED;
4948
}
5049

5150
}
5251

52+
/**************************************************************************/
53+
/*!
54+
@brief Disconnect the wifi network.
55+
@return none
56+
*/
57+
/**************************************************************************/
58+
void AdafruitIO_MKR1000::_disconnect()
59+
{
60+
WiFi.disconnect();
61+
delay(AIO_NET_DISCONNECT_WAIT);
62+
}
63+
5364
aio_status_t AdafruitIO_MKR1000::networkStatus()
5465
{
5566

src/wifi/AdafruitIO_MKR1000.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class AdafruitIO_MKR1000 : public AdafruitIO {
3636

3737
protected:
3838
void _connect();
39+
void _disconnect();
3940

4041
const char *_ssid;
4142
const char *_pass;

src/wifi/AdafruitIO_WICED.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,23 @@ void AdafruitIO_WICED::_connect()
3737
{
3838
if(strlen(_ssid) != 0)
3939
{
40-
Feather.disconnect();
41-
delay(300);
42-
40+
_disconnect();
4341
Feather.connect(_ssid, _pass);
4442
_status = AIO_NET_DISCONNECTED;
4543
}
4644
}
45+
46+
/**************************************************************************/
47+
/*!
48+
@brief Disconnect the wifi network.
49+
@return none
50+
*/
51+
/**************************************************************************/
52+
void AdafruitIO_WICED::_disconnect()
53+
{
54+
Feather.disconnect();
55+
delay(AIO_NET_DISCONNECT_WAIT);
56+
}
4757

4858
aio_status_t AdafruitIO_WICED::networkStatus()
4959
{

0 commit comments

Comments
 (0)