Skip to content

Commit e638a25

Browse files
author
brentru
committed
update airlift to header only, publish config for sketch
1 parent 3fd9383 commit e638a25

File tree

3 files changed

+58
-86
lines changed

3 files changed

+58
-86
lines changed

examples/adafruitio_00_publish/config.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
#define WIFI_PASS "your_pass"
1919

2020
// comment out the following two lines if you are using fona or ethernet
21-
#include "AdafruitIO_WiFi.h"
22-
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
21+
//#include "AdafruitIO_WiFi.h"
22+
//AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
2323

24+
/******************************* AirLift **************************************/
25+
26+
#include "AdafruitIO_AIRLIFT.h"
27+
AdafruitIO_AIRLIFT io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
2428

2529
/******************************* FONA **************************************/
2630

src/AdafruitIO_AIRLIFT.cpp

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/AdafruitIO_AIRLIFT.h

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#ifndef ADAFRUITIO_AIRLIFT_H
1313
#define ADAFRUITIO_AIRLIFT_H
1414

15-
#if !defined(ARDUINO_SAMD_MKR1000) && defined(ARDUINO_ARCH_SAMD)
16-
1715
#include "Arduino.h"
1816
#include "AdafruitIO.h"
1917
#include "WiFiNINA.h"
@@ -31,25 +29,71 @@
3129
#define ESP32_GPIO0 -1 // Not connected
3230
#endif
3331

32+
// br: try to emulate everything in the header to avoid wifinina-wifi101 conflicts
3433
class AdafruitIO_AIRLIFT : public AdafruitIO {
3534

3635
public:
37-
AdafruitIO_AIRLIFT(const char *user, const char *key, const char *ssid, const char *pass);
38-
~AdafruitIO_AIRLIFT();
36+
AdafruitIO_AIRLIFT(const char *user, const char *key, const char *ssid, const char *pass):AdafruitIO(user, key)
37+
{
38+
_ssid = ssid;
39+
_pass = pass;
40+
_mqtt_client = new WiFiSSLClient;
41+
_mqtt = new Adafruit_MQTT_Client(_mqtt_client, _host, _mqtt_port);
42+
_http_client = new WiFiSSLClient;
43+
_http = new HttpClient(*_http_client, _host, _http_port);
44+
}
45+
46+
//~AdafruitIO_AIRLIFT();
47+
48+
aio_status_t networkStatus()
49+
{
50+
switch (WiFi.status())
51+
{
52+
case WL_CONNECTED:
53+
return AIO_NET_CONNECTED;
54+
case WL_CONNECT_FAILED:
55+
return AIO_NET_CONNECT_FAILED;
56+
case WL_IDLE_STATUS:
57+
return AIO_IDLE;
58+
default:
59+
return AIO_NET_DISCONNECTED;
60+
}
61+
}
3962

40-
aio_status_t networkStatus();
41-
const char* connectionType();
63+
const char *connectionType()
64+
{
65+
return "AIRLIFT";
66+
}
67+
68+
//aio_status_t networkStatus();
69+
//const char* connectionType();
4270

4371
protected:
44-
void _connect();
72+
//void _connect();
4573
const char *_ssid;
4674
const char *_pass;
4775

4876
WiFiSSLClient *_http_client;
4977
WiFiSSLClient *_mqtt_client;
5078

79+
void _connect()
80+
{
81+
// for breakouts, check if the pins would be externally defined
82+
#ifdef BOARDEF
83+
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
84+
#endif
85+
86+
// check esp32 module status
87+
if (WiFi.status() == WL_NO_MODULE)
88+
{
89+
Serial.println("No Module!!");
90+
Serial.print(WiFi.status());
91+
}
92+
93+
WiFi.begin(_ssid, _pass);
94+
_status = AIO_NET_DISCONNECTED;
95+
}
5196
};
5297

53-
#endif // ARDUINO_ARCH_SAMD
5498

5599
#endif // ADAFRUITIO_AIRLIFT_H

0 commit comments

Comments
 (0)