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
+
12
15
#if defined(ARDUINO_SAMD_MKR1000)
13
16
14
17
#include " AdafruitIO_MKR1000.h"
@@ -32,14 +35,31 @@ AdafruitIO_MKR1000::~AdafruitIO_MKR1000()
32
35
33
36
void AdafruitIO_MKR1000::_connect ()
34
37
{
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 ;
35
44
36
- // no shield? bail
37
- if (WiFi.status () == WL_NO_SHIELD)
38
- return ;
45
+ _disconnect ();
39
46
40
- WiFi.begin (_ssid, _pass);
41
- _status = AIO_NET_DISCONNECTED;
47
+ WiFi.begin (_ssid, _pass);
48
+ _status = AIO_NET_DISCONNECTED;
49
+ }
50
+
51
+ }
42
52
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);
43
63
}
44
64
45
65
aio_status_t AdafruitIO_MKR1000::networkStatus ()
0 commit comments