Skip to content

Commit 1e5e032

Browse files
committed
Arduino Bootstrapper (v1.17.0)
1 parent e741201 commit 1e5e032

7 files changed

+103
-69
lines changed

library.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "git",
77
"url": "https://github.com/sblantipodi/arduino_bootstrapper.git"
88
},
9-
"version": "1.16.3",
9+
"version": "1.17.0",
1010
"examples": "examples/*.cpp",
1111
"exclude": "tests",
1212
"frameworks": "arduino",

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Bootstrapper
2-
version=1.16.3
2+
version=1.17.0
33
author=Davide Perini <perini.davide@dpsoftware.org>
44
maintainer=Davide Perini <perini.davide@dpsoftware.org>
55
sentence=A client library for MQTT messaging.

src/BootstrapManager.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,25 @@ void BootstrapManager::bootstrapSetup(void (*manageDisconnections)(), void (*man
6060
}
6161

6262
#if defined(ARDUINO_ARCH_ESP32)
63-
void WT32_ETH01_event(WiFiEvent_t event) {
63+
void eth_event(WiFiEvent_t event) {
6464
switch (event) {
6565
case ARDUINO_EVENT_ETH_START:
66+
ethConnected = true;
6667
break;
6768
case ARDUINO_EVENT_ETH_CONNECTED:
6869
MAC = WiFi.macAddress();
70+
ethConnected = true;
6971
break;
7072
case ARDUINO_EVENT_ETH_GOT_IP:
7173
MAC = WiFi.macAddress();
7274
microcontrollerIP = ETH.localIP().toString();
75+
ethConnected = true;
7376
break;
7477
case ARDUINO_EVENT_ETH_DISCONNECTED:
78+
ethConnected = false;
7579
break;
7680
case ARDUINO_EVENT_ETH_STOP:
81+
ethConnected = false;
7782
break;
7883
default:
7984
break;
@@ -98,7 +103,7 @@ void BootstrapManager::bootstrapSetup(void (*manageDisconnections)(), void (*man
98103
#if defined(ARDUINO_ARCH_ESP32)
99104
isConfigFileOk = true;
100105
ETH.setHostname(Helpers::string2char(deviceName));
101-
WiFi.onEvent(WT32_ETH01_event);
106+
WiFi.onEvent(eth_event);
102107
EthManager::connectToEthernet(ethd);
103108
Serial.println(F("Ethernet connected."));
104109
initMqttOta(callback);

src/EthManager.cpp

+91-65
Original file line numberDiff line numberDiff line change
@@ -20,77 +20,103 @@
2020

2121

2222
#if defined(ARDUINO_ARCH_ESP32)
23+
/**
24+
* Supported ethernet devices
25+
*/
2326
const ethernet_config ethernetDevices[] = {
24-
// No Ethernet
25-
{
26-
},
27-
// QuinLed-ESP32-Ethernet
28-
{
29-
0,
30-
5,
31-
23,
32-
18,
33-
ETH_PHY_LAN8720,
34-
ETH_CLOCK_GPIO17_OUT
35-
},
36-
// QuinLed-Dig-Octa Brainboard-32-8L and LilyGO-T-ETH-POE
37-
{
38-
0,
39-
-1,
40-
23,
41-
18,
42-
ETH_PHY_LAN8720,
43-
ETH_CLOCK_GPIO17_OUT
44-
},
45-
// WT32-EHT01
46-
// These pins works well: IO2, IO4, IO12, IO14, IO15
47-
// These not: IO35, IO36, IO39
48-
{
49-
1,
50-
16,
51-
23,
52-
18,
53-
ETH_PHY_LAN8720,
54-
ETH_CLOCK_GPIO0_IN
55-
},
56-
// ESP32-ETHERNET-KIT-VE
57-
{
58-
0,
59-
5,
60-
23,
61-
18,
62-
ETH_PHY_IP101,
63-
ETH_CLOCK_GPIO0_IN
64-
},
65-
// ESP32-POE
66-
{
67-
0,
68-
12,
69-
23,
70-
18,
71-
ETH_PHY_LAN8720,
72-
ETH_CLOCK_GPIO17_OUT
73-
},
74-
// WESP32
75-
{
76-
0,
77-
-1,
78-
16,
79-
17,
80-
ETH_PHY_LAN8720,
81-
ETH_CLOCK_GPIO0_IN
82-
}
27+
// No Ethernet
28+
{
29+
},
30+
// QuinLed-ESP32-Ethernet
31+
{
32+
33+
0,
34+
5,
35+
23,
36+
18,
37+
ETH_PHY_LAN8720,
38+
ETH_CLOCK_GPIO17_OUT
39+
},
40+
// QuinLed-Dig-Octa Brainboard-32-8L and LilyGO-T-ETH-POE
41+
{
42+
0,
43+
-1,
44+
23,
45+
18,
46+
ETH_PHY_LAN8720,
47+
ETH_CLOCK_GPIO17_OUT
48+
},
49+
// WT32-EHT01
50+
// These pins works well: IO2, IO4, IO12, IO14, IO15
51+
// These not: IO35, IO36, IO39
52+
{
53+
1,
54+
16,
55+
23,
56+
18,
57+
ETH_PHY_LAN8720,
58+
ETH_CLOCK_GPIO0_IN
59+
},
60+
// ESP32-ETHERNET-KIT-VE
61+
{
62+
0,
63+
5,
64+
23,
65+
18,
66+
ETH_PHY_IP101,
67+
ETH_CLOCK_GPIO0_IN
68+
},
69+
// ESP32-POE
70+
{
71+
0,
72+
12,
73+
23,
74+
18,
75+
ETH_PHY_LAN8720,
76+
ETH_CLOCK_GPIO17_OUT
77+
},
78+
// WESP32
79+
{
80+
0,
81+
-1,
82+
16,
83+
17,
84+
ETH_PHY_LAN8720,
85+
ETH_CLOCK_GPIO0_IN
86+
}
8387
};
8488

89+
/**
90+
* Connect to ethernet
91+
* @param deviceNumber to use
92+
*/
8593
void EthManager::connectToEthernet(int8_t deviceNumber) {
8694
ETH.begin(
87-
ethernetDevices[deviceNumber].address,
88-
ethernetDevices[deviceNumber].power,
89-
ethernetDevices[deviceNumber].mdc,
90-
ethernetDevices[deviceNumber].mdio,
91-
ethernetDevices[deviceNumber].type,
92-
ethernetDevices[deviceNumber].clk_mode
95+
ethernetDevices[deviceNumber].address,
96+
ethernetDevices[deviceNumber].power,
97+
ethernetDevices[deviceNumber].mdc,
98+
ethernetDevices[deviceNumber].mdio,
99+
ethernetDevices[deviceNumber].type,
100+
ethernetDevices[deviceNumber].clk_mode
93101
);
94102
}
95103

104+
/**
105+
* Deallocate ethernet pins
106+
* @param deviceNumber to deallocate
107+
*/
108+
void EthManager::deallocateEthernetPins(int8_t deviceNumber) {
109+
const uint32_t MATRIX_DETACH_OUT_SIG = 0x100;
110+
gpio_matrix_out(ethernetDevices[deviceNumber].address, MATRIX_DETACH_OUT_SIG, false, false);
111+
gpio_matrix_out(ethernetDevices[deviceNumber].power, MATRIX_DETACH_OUT_SIG, false, false);
112+
gpio_matrix_out(ethernetDevices[deviceNumber].mdc, MATRIX_DETACH_OUT_SIG, false, false);
113+
gpio_matrix_out(ethernetDevices[deviceNumber].mdio, MATRIX_DETACH_OUT_SIG, false, false);
114+
gpio_matrix_out(ethernetDevices[deviceNumber].clk_mode, MATRIX_DETACH_OUT_SIG, false, false);
115+
pinMode(ethernetDevices[deviceNumber].address, INPUT);
116+
pinMode(ethernetDevices[deviceNumber].power, INPUT);
117+
pinMode(ethernetDevices[deviceNumber].mdc, INPUT);
118+
pinMode(ethernetDevices[deviceNumber].mdio, INPUT);
119+
pinMode(ethernetDevices[deviceNumber].clk_mode, INPUT);
120+
}
121+
96122
#endif

src/EthManager.h

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class EthManager {
4444

4545
public:
4646
static void connectToEthernet(int8_t deviceNumber);
47+
static void deallocateEthernetPins(int8_t deviceNumber);
4748
};
4849

4950
#endif

src/Helpers.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ int mqttWillQOS = 1;
5353
bool mqttWillRetain = 0;
5454
bool mqttCleanSession = 1;
5555
String additionalParam = "XXX";
56+
bool ethConnected = false;
5657

5758
unsigned long previousMillis = 0;
5859
const unsigned long interval = 200;

src/Helpers.h

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extern int mqttWillQOS;
5454
extern bool mqttWillRetain;
5555
extern bool mqttCleanSession;
5656
extern String additionalParam;
57+
extern bool ethConnected;
5758

5859
// Blink LED vars
5960
extern unsigned long previousMillis; // will store last time LED was updated

0 commit comments

Comments
 (0)