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) 2019 Adafruit Industries
7+ // Authors: Brent Rubell
8+ // Licensed under the MIT license.
9+ //
10+ // All text above must be included in any redistribution.
11+ //
12+ #if !defined(ARDUINO_SAMD_MKR1000) && defined(ARDUINO_ARCH_SAMD)
13+
14+ #include " AdafruitIO_AIRLIFT.h"
15+
16+
17+ AdafruitIO_AIRLIFT::AdafruitIO_AIRLIFT (const char *user, const char *key, const char *ssid, const char *pass):AdafruitIO(user, key)
18+ {
19+ _ssid = ssid;
20+ _pass = pass;
21+ _mqtt_client = new WiFiSSLClient;
22+ _mqtt = new Adafruit_MQTT_Client (_mqtt_client, _host, _mqtt_port);
23+ _http_client = new WiFiSSLClient;
24+ _http = new HttpClient (*_http_client, _host, _http_port);
25+ }
26+
27+ AdafruitIO_AIRLIFT::~AdafruitIO_AIRLIFT ()
28+ {
29+ if (_mqtt_client)
30+ delete _http_client;
31+ if (_http_client)
32+ delete _mqtt_client;
33+ if (_mqtt)
34+ delete _mqtt;
35+ if (_http)
36+ delete _http;
37+ }
38+
39+
40+ void AdafruitIO_AIRLIFT::_connect ()
41+ {
42+ // for breakouts, check if the pins would be externally defined
43+ #ifdef BOARDEF
44+ WiFi.setPins (SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
45+ #endif
46+
47+ // check esp32 module status
48+ if (WiFi.status () == WL_NO_MODULE){
49+ Serial.print (WiFi.status ());
50+ }
51+
52+ WiFi.begin (_ssid, _pass);
53+ _status = AIO_NET_DISCONNECTED;
54+
55+ }
56+
57+ aio_status_t AdafruitIO_AIRLIFT::networkStatus ()
58+ {
59+ switch (WiFi.status ()) {
60+ case WL_CONNECTED:
61+ return AIO_NET_CONNECTED;
62+ case WL_CONNECT_FAILED:
63+ return AIO_NET_CONNECT_FAILED;
64+ case WL_IDLE_STATUS:
65+ return AIO_IDLE;
66+ default :
67+ return AIO_NET_DISCONNECTED;
68+ }
69+ }
70+
71+ const char * AdafruitIO_AIRLIFT::connectionType ()
72+ {
73+ return " AIRLIFT" ;
74+ }
75+
76+ #endif // ARDUINO_ARCH_SAMD
0 commit comments