Skip to content

Commit 13bb6ed

Browse files
author
brentru
committed
add back set pin function to AdafruitIO.cpp./.h, winc.cpp->winc.h
1 parent cfa7935 commit 13bb6ed

File tree

7 files changed

+67
-84
lines changed

7 files changed

+67
-84
lines changed

src/AdafruitIO.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ AdafruitIO::AdafruitIO(const char *user, const char *key)
2727
_init();
2828
}
2929

30+
void AdafruitIO::setAirLiftPins(uint16_t ss, uint16_t ack, uint16_t rst)
31+
{
32+
setAirLiftPins(ss, ack, rst);
33+
}
34+
3035
void errorCallback(char *err, uint16_t len)
3136
{
3237
AIO_ERROR_PRINTLN();

src/AdafruitIO.h

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

6868
protected:
6969
virtual void _connect() = 0;
70+
virtual void setAirLiftPins(uint16_t ss, uint16_t ack, uint16_t rst) = 0;
7071
aio_status_t _status = AIO_IDLE;
7172
uint32_t _last_ping = 0;
7273

src/AdafruitIO_AIRLIFT.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
// Configure some pins used for the ESP32 connection
3030
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
31-
#define BOARDEF 1
3231
#define SPIWIFI SPI
3332
#define ESP32_GPIO0 -1 // Not connected
3433
#endif
@@ -146,6 +145,7 @@ class AdafruitIO_AIRLIFT : public AdafruitIO {
146145
void setAirLiftPins(uint16_t ss, uint16_t ack, uint16_t rst)
147146
{
148147
WiFi.setPins(ss, ack, rst, ESP32_GPIO0, &SPIWIFI);
148+
AIO_DEBUG_PRINTLN("Pins Set!")
149149
}
150150

151151

src/AdafruitIO_Definitions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class AdafruitIOGroupCallback {
4242
};
4343

4444
// Uncomment/comment to turn on/off debug output messages.
45-
// #define AIO_DEBUG
45+
#define AIO_DEBUG
4646
// Uncomment/comment to turn on/off error output
47-
// #define AIO_ERROR
47+
#define AIO_ERROR
4848

4949
// Where debug messages will be printed
5050
// note: if you're using something like Zero or Due, change the below to SerialUSB

src/AdafruitIO_WiFi.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
#include "wifi/AdafruitIO_MKR1000.h"
1818
typedef AdafruitIO_MKR1000 AdafruitIO_WiFi;
1919

20-
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL)
20+
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || defined(USE_AIRLIFT)
2121

2222
#include "AdafruitIO_AIRLIFT.h"
2323
typedef AdafruitIO_AIRLIFT AdafruitIO_WiFi;
2424

25-
#elif !defined(ARDUINO_SAMD_MKR1000) && defined(ARDUINO_ARCH_SAMD)
25+
#elif defined(USE_WINC1500)
2626

2727
#include "wifi/AdafruitIO_WINC1500.h"
2828
typedef AdafruitIO_WINC1500 AdafruitIO_WiFi;
@@ -42,6 +42,10 @@
4242
#include "wifi/AdafruitIO_WICED.h"
4343
typedef AdafruitIO_WICED AdafruitIO_WiFi;
4444

45+
#else
46+
47+
#error "Must define USE_AIRLIFT or USE_WINC1500 before including this file."
48+
4549
#endif
4650

4751
#endif // ADAFRUITIO_WIFI_H

src/wifi/AdafruitIO_WINC1500.cpp

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

src/wifi/AdafruitIO_WINC1500.h

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,67 @@
3030
class AdafruitIO_WINC1500 : public AdafruitIO {
3131

3232
public:
33-
AdafruitIO_WINC1500(const char *user, const char *key, const char *ssid, const char *pass);
34-
~AdafruitIO_WINC1500();
33+
AdafruitIO_WINC1500(const char *user, const char *key, const char *ssid, const char *pass) : AdafruitIO(user, key)
34+
{
35+
_ssid = ssid;
36+
_pass = pass;
37+
_mqtt_client = new WiFiSSLClient;
38+
_mqtt = new Adafruit_MQTT_Client(_mqtt_client, _host, _mqtt_port);
39+
_http_client = new WiFiSSLClient;
40+
_http = new HttpClient(*_http_client, _host, _http_port);
41+
}
3542

36-
aio_status_t networkStatus();
37-
const char* connectionType();
43+
~AdafruitIO_WINC1500()
44+
{
45+
if (_mqtt_client)
46+
delete _http_client;
47+
if (_http_client)
48+
delete _mqtt_client;
49+
if (_mqtt)
50+
delete _mqtt;
51+
if (_http)
52+
delete _http;
53+
}
54+
55+
aio_status_t networkStatus()
56+
{
57+
58+
switch (WiFi.status())
59+
{
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+
const char *connectionType()
71+
{
72+
return "winc1500";
73+
}
3874

3975
protected:
40-
void _connect();
4176
const char *_ssid;
4277
const char *_pass;
4378

4479
WiFiSSLClient *_http_client;
4580
WiFiSSLClient *_mqtt_client;
4681

82+
void _connect()
83+
{
84+
85+
WiFi.setPins(WINC_CS, WINC_IRQ, WINC_RST, WINC_EN);
86+
87+
// no shield? bail
88+
if (WiFi.status() == WL_NO_SHIELD)
89+
return;
90+
91+
WiFi.begin(_ssid, _pass);
92+
_status = AIO_NET_DISCONNECTED;
93+
}
4794
};
4895

4996
#endif // ARDUINO_ARCH_SAMD

0 commit comments

Comments
 (0)