Skip to content

Commit a98ee76

Browse files
brentrubrentru
authored andcommitted
add pins to io constructor instead
1 parent d6a6af0 commit a98ee76

File tree

5 files changed

+22
-37
lines changed

5 files changed

+22
-37
lines changed

src/AdafruitIO.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ 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-
3530
void errorCallback(char *err, uint16_t len)
3631
{
3732
AIO_ERROR_PRINTLN();

src/AdafruitIO.h

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

6868
protected:
6969
virtual void _connect() = 0;
70-
virtual void _setAirLiftPins(uint16_t ss, uint16_t ack, uint16_t rst) = 0;
7170
aio_status_t _status = AIO_IDLE;
7271
uint32_t _last_ping = 0;
7372

src/AdafruitIO_Definitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ 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
4747
#define AIO_ERROR
4848

src/AdafruitIO_AIRLIFT.h renamed to src/wifi/AdafruitIO_AIRLIFT.h

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@
2626
#include "Adafruit_MQTT.h"
2727
#include "Adafruit_MQTT_Client.h"
2828

29-
// Configure some pins used for the ESP32 connection
30-
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
31-
#define SPIWIFI SPI
32-
#define ESP32_GPIO0 -1 // Not connected
33-
#endif
34-
29+
#define SPIWIFI SPI
3530
#define NINAFWVER "1.0.0"
3631

3732
/****************************************************************************/
@@ -55,8 +50,12 @@ class AdafruitIO_AIRLIFT : public AdafruitIO {
5550
A reference to the WiFi network password.
5651
*/
5752
/**************************************************************************/
58-
AdafruitIO_AIRLIFT(const char *user, const char *key, const char *ssid, const char *pass) : AdafruitIO(user, key)
53+
AdafruitIO_AIRLIFT(const char *user, const char *key, const char *ssid, const char *pass, int ssPin, int ackPin, int rstPin, int gpio0Pin) : AdafruitIO(user, key)
5954
{
55+
_ssPin = ssPin;
56+
_ackPin = ackPin;
57+
_rstPin = rstPin;
58+
_gpio0Pin = gpio0Pin;
6059
_ssid = ssid;
6160
_pass = pass;
6261
_mqtt_client = new WiFiSSLClient;
@@ -130,30 +129,11 @@ class AdafruitIO_AIRLIFT : public AdafruitIO {
130129
return "AIRLIFT";
131130
}
132131

133-
/**************************************************************************/
134-
/*!
135-
@brief Defines pins for the ESP32's chip select, busy pin and reset pin.
136-
GPIO0 is not defined as it is disconnected by default.
137-
@param ss
138-
ESP32 chip select pin.
139-
@param ack
140-
ESP32 BUSY/READY pin.
141-
@param rst
142-
ESP32 RESET pin.
143-
*/
144-
/**************************************************************************/
145-
void _setAirLiftPins(uint16_t ss, uint16_t ack, uint16_t rst)
146-
{
147-
_ssPin = ss;
148-
_ackPin = ack;
149-
_rstPin = rst;
150-
}
151-
152132
protected:
153133
const char *_ssid;
154134
const char *_pass;
155135
String _fv = "0.0.0";
156-
uint16_t _ssPin, _ackPin, _rstPin = 0;
136+
int _ssPin, _ackPin, _rstPin, _gpio0Pin = 0;
157137

158138
WiFiSSLClient *_http_client;
159139
WiFiSSLClient *_mqtt_client;
@@ -168,7 +148,13 @@ class AdafruitIO_AIRLIFT : public AdafruitIO {
168148
{
169149
// setup ESP32 pins
170150
if (_ssPin != 0) {
171-
WiFi.setPins(10, 9, 6, ESP32_GPIO0, &SPIWIFI);
151+
AIO_DEBUG_PRINTLN("Pins: ");
152+
AIO_DEBUG_PRINT(_ssPin);
153+
AIO_DEBUG_PRINT(_ackPin);
154+
AIO_DEBUG_PRINT(_rstPin);
155+
AIO_DEBUG_PRINT(_gpio0Pin);
156+
AIO_DEBUG_PRINTLN("");
157+
WiFi.setPins(_ssPin, _ackPin, _rstPin, _gpio0Pin, &SPIWIFI);
172158
}
173159

174160
// check esp32 module version against NINAFWVER

src/wifi/AdafruitIO_WINC1500.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@
3030
class AdafruitIO_WINC1500 : public AdafruitIO {
3131

3232
public:
33-
AdafruitIO_WINC1500(const char *user, const char *key, const char *ssid, const char *pass) : AdafruitIO(user, key)
33+
AdafruitIO_WINC1500(const char *user, const char *key, const char *ssid, const char *pass, int winc_en, int winc_cs, int winc_irq, int winc_rst) : AdafruitIO(user, key)
3434
{
35+
_winc_en = winc_en;
36+
_winc_cs = winc_cs;
37+
_winc_irq = winc_irq;
38+
_winc_rst = winc_rst;
3539
_ssid = ssid;
3640
_pass = pass;
3741
_mqtt_client = new WiFiSSLClient;
@@ -75,14 +79,15 @@ class AdafruitIO_WINC1500 : public AdafruitIO {
7579
protected:
7680
const char *_ssid;
7781
const char *_pass;
82+
int _winc_cs, _winc_irq, _winc_rst, _winc_en = 0;
7883

7984
WiFiSSLClient *_http_client;
8085
WiFiSSLClient *_mqtt_client;
8186

8287
void _connect()
8388
{
8489

85-
WiFi.setPins(WINC_CS, WINC_IRQ, WINC_RST, WINC_EN);
90+
WiFi.setPins(_winc_cs, _winc_irq, _winc_rst, _winc_en);
8691

8792
// no shield? bail
8893
if (WiFi.status() == WL_NO_SHIELD)

0 commit comments

Comments
 (0)