1- //
2- // Adafruit invests time and resources providing this open source code.
3- // Please support Adafruit and open source hardware by purchasing
4- // products from Adafruit!
5- //
6- // Copyright (c) 2015-2016 Adafruit Industries
7- // Authors: Tony DiCola, Todd Treece
8- // Licensed under the MIT license.
9- //
10- // All text above must be included in any redistribution.
11- //
1+ /* !
2+ * @file AdafruitIO_MKR1000.cpp
3+ *
4+ * Adafruit invests time and resources providing this open source code.
5+ * Please support Adafruit and open source hardware by purchasing
6+ * products from Adafruit!
7+ *
8+ * Copyright (c) 2015-2016 Adafruit Industries
9+ * Authors: Tony DiCola, Todd Treece
10+ * Licensed under the MIT license.
11+ *
12+ * All text above must be included in any redistribution.
13+ */
14+
1215#if defined(ARDUINO_SAMD_MKR1000)
1316
1417#include " AdafruitIO_MKR1000.h"
@@ -32,14 +35,31 @@ AdafruitIO_MKR1000::~AdafruitIO_MKR1000()
3235
3336void AdafruitIO_MKR1000::_connect ()
3437{
38+ if (strlen (_ssid) == 0 ) {
39+ _status = AIO_SSID_INVALID;
40+ } else {
41+ // no shield? bail
42+ if (WiFi.status () == WL_NO_SHIELD)
43+ return ;
3544
36- // no shield? bail
37- if (WiFi.status () == WL_NO_SHIELD)
38- return ;
45+ _disconnect ();
3946
40- WiFi.begin (_ssid, _pass);
41- _status = AIO_NET_DISCONNECTED;
47+ WiFi.begin (_ssid, _pass);
48+ _status = AIO_NET_DISCONNECTED;
49+ }
50+
51+ }
4252
53+ /* *************************************************************************/
54+ /* !
55+ @brief Disconnect the wifi network.
56+ @return none
57+ */
58+ /* *************************************************************************/
59+ void AdafruitIO_MKR1000::_disconnect ()
60+ {
61+ WiFi.disconnect ();
62+ delay (AIO_NET_DISCONNECT_WAIT);
4363}
4464
4565aio_status_t AdafruitIO_MKR1000::networkStatus ()
0 commit comments