Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit d498f14

Browse files
authored
v1.7.1 to use Ethernet_Generic library
### Releases v1.7.1 1. Use new [Ethernet_Generic library](https://github.com/khoih-prog/Ethernet_Generic) as default for W5x00. 2. Support SPI2 for ESP32 3. Add support to SPI1 for RP2040 using [arduino-pico core](https://github.com/earlephilhower/arduino-pico) 4. Use new function `waitForLink()` for Teensy 4.1 QNEthernet library v0.14.0+ 5. Rewrite all the examples to support those new features 6. Update `Packages' Patches`
1 parent 9d5a201 commit d498f14

File tree

45 files changed

+309
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+309
-204
lines changed

examples/QNEthernet/Basic_Insert/Basic_Insert.ino

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,8 @@ String INSERT_SQL = String("INSERT INTO ") + default_database + "." + default_ta
8585

8686
MySQL_Connection conn((Client *)&client);
8787

88-
void setup()
88+
void initEthernet()
8989
{
90-
Serial.begin(115200);
91-
while (!Serial); // wait for serial port to connect
92-
93-
MYSQL_DISPLAY2("\nStarting Basic_Insert on", BOARD_NAME, SHIELD_TYPE);
94-
MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION);
95-
9690
#if USE_NATIVE_ETHERNET
9791
MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========"));
9892
#elif USE_QN_ETHERNET
@@ -113,6 +107,9 @@ void setup()
113107
MYSQL_DISPLAY1("Using mac index =", index);
114108
MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP());
115109

110+
// give the Ethernet shield 2 seconds to initialize:
111+
delay(2000);
112+
116113
#else
117114

118115
#if USING_DHCP
@@ -128,11 +125,11 @@ void setup()
128125

129126
if (!Ethernet.waitForLocalIP(5000))
130127
{
131-
MYSQL_DISPLAY(F("Failed to configure Ethernet"));
128+
Serial.println("Failed to configure Ethernet");
132129

133130
if (!Ethernet.linkStatus())
134131
{
135-
MYSQL_DISPLAY(F("Ethernet cable is not connected."));
132+
Serial.println("Ethernet cable is not connected.");
136133
}
137134

138135
// Stay here forever
@@ -141,12 +138,29 @@ void setup()
141138
delay(1);
142139
}
143140
}
141+
142+
if (!Ethernet.waitForLink(5000))
143+
{
144+
Serial.println(F("Failed to wait for Link"));
145+
}
144146
else
145147
{
146-
MYSQL_DISPLAY1(F("Connected! IP address:"), Ethernet.localIP());
148+
Serial.print("IP Address = ");
149+
Serial.println(Ethernet.localIP());
147150
}
148151

149-
#endif
152+
#endif
153+
}
154+
155+
void setup()
156+
{
157+
Serial.begin(115200);
158+
while (!Serial && millis() < 5000); // wait for serial port to connect
159+
160+
MYSQL_DISPLAY2("\nStarting Basic_Insert on", BOARD_NAME, SHIELD_TYPE);
161+
MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION);
162+
163+
initEthernet();
150164

151165
MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port);
152166
MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database);

examples/QNEthernet/Basic_Insert/defines.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@
3838
#endif
3939

4040
// Only one of the following to be true.
41-
#define USE_ETHERNET false
42-
#define USE_ETHERNET_LARGE false
43-
#define USE_ETHERNET2 false
44-
#define USE_ETHERNET3 false
41+
#define USE_ETHERNET_GENERIC true
4542
#define USE_ETHERNET_ESP8266 false
4643
#define USE_ETHERNET_ENC false
4744
#define USE_ETHERNET_LAN8742A false
48-
#define USE_UIP_ETHERNET false
49-
45+
#define USE_ETHERNET_LAN8720 false
5046
#define USE_CUSTOM_ETHERNET false
47+
#define USE_UIP_ETHERNET false
5148

5249
#if USE_NATIVE_ETHERNET
5350
#include "NativeEthernet.h"

examples/QNEthernet/Basic_Select/Basic_Select.ino

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,9 @@ MySQL_Connection conn((Client *)&client);
7878
// Create an instance of the cursor passing in the connection
7979
MySQL_Query sql_query = MySQL_Query(&conn);
8080

81-
void setup()
81+
void initEthernet()
8282
{
83-
Serial.begin(115200);
84-
while (!Serial); // wait for serial port to connect
85-
86-
MYSQL_DISPLAY2("\nStarting Basic_Select on", BOARD_NAME, SHIELD_TYPE);
87-
MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION);
88-
89-
#if USE_NATIVE_ETHERNET
83+
#if USE_NATIVE_ETHERNET
9084
MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========"));
9185
#elif USE_QN_ETHERNET
9286
MYSQL_DISPLAY(F("=========== USE_QN_ETHERNET ==========="));
@@ -106,6 +100,9 @@ void setup()
106100
MYSQL_DISPLAY1("Using mac index =", index);
107101
MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP());
108102

103+
// give the Ethernet shield 2 seconds to initialize:
104+
delay(2000);
105+
109106
#else
110107

111108
#if USING_DHCP
@@ -121,11 +118,11 @@ void setup()
121118

122119
if (!Ethernet.waitForLocalIP(5000))
123120
{
124-
MYSQL_DISPLAY(F("Failed to configure Ethernet"));
121+
Serial.println("Failed to configure Ethernet");
125122

126123
if (!Ethernet.linkStatus())
127124
{
128-
MYSQL_DISPLAY(F("Ethernet cable is not connected."));
125+
Serial.println("Ethernet cable is not connected.");
129126
}
130127

131128
// Stay here forever
@@ -134,12 +131,29 @@ void setup()
134131
delay(1);
135132
}
136133
}
134+
135+
if (!Ethernet.waitForLink(5000))
136+
{
137+
Serial.println(F("Failed to wait for Link"));
138+
}
137139
else
138140
{
139-
MYSQL_DISPLAY1(F("Connected! IP address:"), Ethernet.localIP());
141+
Serial.print("IP Address = ");
142+
Serial.println(Ethernet.localIP());
140143
}
141144

142-
#endif
145+
#endif
146+
}
147+
148+
void setup()
149+
{
150+
Serial.begin(115200);
151+
while (!Serial && millis() < 5000); // wait for serial port to connect
152+
153+
MYSQL_DISPLAY2("\nStarting Basic_Select on", BOARD_NAME, SHIELD_TYPE);
154+
MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION);
155+
156+
initEthernet();
143157

144158
MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port);
145159
MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database);

examples/QNEthernet/Basic_Select/defines.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@
3838
#endif
3939

4040
// Only one of the following to be true.
41-
#define USE_ETHERNET false
42-
#define USE_ETHERNET_LARGE false
43-
#define USE_ETHERNET2 false
44-
#define USE_ETHERNET3 false
41+
#define USE_ETHERNET_GENERIC true
4542
#define USE_ETHERNET_ESP8266 false
4643
#define USE_ETHERNET_ENC false
4744
#define USE_ETHERNET_LAN8742A false
48-
#define USE_UIP_ETHERNET false
49-
45+
#define USE_ETHERNET_LAN8720 false
5046
#define USE_CUSTOM_ETHERNET false
47+
#define USE_UIP_ETHERNET false
5148

5249
#if USE_NATIVE_ETHERNET
5350
#include "NativeEthernet.h"

examples/QNEthernet/Complex_Insert/Complex_Insert.ino

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
IPAddress server(192, 168, 2, 112);
7979
#endif
8080

81-
8281
uint16_t server_port = 5698; //3306;
8382

8483
char user[] = "invited-guest"; // MySQL user login username
@@ -106,14 +105,8 @@ char *dtostrf(double val, signed char width, unsigned char prec, char *sout)
106105
}
107106
#endif
108107

109-
void setup()
108+
void initEthernet()
110109
{
111-
Serial.begin(115200);
112-
while (!Serial); // wait for serial port to connect
113-
114-
MYSQL_DISPLAY2("\nStarting Complex_Insert on", BOARD_NAME, SHIELD_TYPE);
115-
MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION);
116-
117110
#if USE_NATIVE_ETHERNET
118111
MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========"));
119112
#elif USE_QN_ETHERNET
@@ -134,6 +127,9 @@ void setup()
134127
MYSQL_DISPLAY1("Using mac index =", index);
135128
MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP());
136129

130+
// give the Ethernet shield 2 seconds to initialize:
131+
delay(2000);
132+
137133
#else
138134

139135
#if USING_DHCP
@@ -149,11 +145,11 @@ void setup()
149145

150146
if (!Ethernet.waitForLocalIP(5000))
151147
{
152-
MYSQL_DISPLAY(F("Failed to configure Ethernet"));
148+
Serial.println("Failed to configure Ethernet");
153149

154150
if (!Ethernet.linkStatus())
155151
{
156-
MYSQL_DISPLAY(F("Ethernet cable is not connected."));
152+
Serial.println("Ethernet cable is not connected.");
157153
}
158154

159155
// Stay here forever
@@ -162,12 +158,29 @@ void setup()
162158
delay(1);
163159
}
164160
}
161+
162+
if (!Ethernet.waitForLink(5000))
163+
{
164+
Serial.println(F("Failed to wait for Link"));
165+
}
165166
else
166167
{
167-
MYSQL_DISPLAY1(F("Connected! IP address:"), Ethernet.localIP());
168+
Serial.print("IP Address = ");
169+
Serial.println(Ethernet.localIP());
168170
}
169171

170-
#endif
172+
#endif
173+
}
174+
175+
void setup()
176+
{
177+
Serial.begin(115200);
178+
while (!Serial && millis() < 5000); // wait for serial port to connect
179+
180+
MYSQL_DISPLAY2("\nStarting Complex_Insert on", BOARD_NAME, SHIELD_TYPE);
181+
MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION);
182+
183+
initEthernet();
171184

172185
MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port);
173186
MYSQL_DISPLAY3("User =", user, ", PW =", password);

examples/QNEthernet/Complex_Insert/defines.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@
3838
#endif
3939

4040
// Only one of the following to be true.
41-
#define USE_ETHERNET false
42-
#define USE_ETHERNET_LARGE false
43-
#define USE_ETHERNET2 false
44-
#define USE_ETHERNET3 false
41+
#define USE_ETHERNET_GENERIC true
4542
#define USE_ETHERNET_ESP8266 false
4643
#define USE_ETHERNET_ENC false
4744
#define USE_ETHERNET_LAN8742A false
48-
#define USE_UIP_ETHERNET false
49-
45+
#define USE_ETHERNET_LAN8720 false
5046
#define USE_CUSTOM_ETHERNET false
47+
#define USE_UIP_ETHERNET false
5148

5249
#if USE_NATIVE_ETHERNET
5350
#include "NativeEthernet.h"

examples/QNEthernet/Complex_Select/Complex_Select.ino

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
#include <MySQL_Generic.h>
5050

51-
#define USING_HOST_NAME true
51+
#define USING_HOST_NAME false //true
5252

5353
#if USING_HOST_NAME
5454
// Optional using hostname, and Ethernet built-in DNS lookup
@@ -78,14 +78,8 @@ char query[128];
7878

7979
MySQL_Connection conn((Client *)&client);
8080

81-
void setup()
81+
void initEthernet()
8282
{
83-
Serial.begin(115200);
84-
while (!Serial); // wait for serial port to connect
85-
86-
MYSQL_DISPLAY2("\nStarting Complex_Select on", BOARD_NAME, SHIELD_TYPE);
87-
MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION);
88-
8983
#if USE_NATIVE_ETHERNET
9084
MYSQL_DISPLAY(F("======== USE_NATIVE_ETHERNET ========"));
9185
#elif USE_QN_ETHERNET
@@ -106,6 +100,9 @@ void setup()
106100
MYSQL_DISPLAY1("Using mac index =", index);
107101
MYSQL_DISPLAY1("Connected! IP address:", Ethernet.localIP());
108102

103+
// give the Ethernet shield 2 seconds to initialize:
104+
delay(2000);
105+
109106
#else
110107

111108
#if USING_DHCP
@@ -121,11 +118,11 @@ void setup()
121118

122119
if (!Ethernet.waitForLocalIP(5000))
123120
{
124-
MYSQL_DISPLAY(F("Failed to configure Ethernet"));
121+
Serial.println("Failed to configure Ethernet");
125122

126123
if (!Ethernet.linkStatus())
127124
{
128-
MYSQL_DISPLAY(F("Ethernet cable is not connected."));
125+
Serial.println("Ethernet cable is not connected.");
129126
}
130127

131128
// Stay here forever
@@ -134,12 +131,29 @@ void setup()
134131
delay(1);
135132
}
136133
}
134+
135+
if (!Ethernet.waitForLink(5000))
136+
{
137+
Serial.println(F("Failed to wait for Link"));
138+
}
137139
else
138140
{
139-
MYSQL_DISPLAY1(F("Connected! IP address:"), Ethernet.localIP());
141+
Serial.print("IP Address = ");
142+
Serial.println(Ethernet.localIP());
140143
}
141144

142-
#endif
145+
#endif
146+
}
147+
148+
void setup()
149+
{
150+
Serial.begin(115200);
151+
while (!Serial && millis() < 5000); // wait for serial port to connect
152+
153+
MYSQL_DISPLAY2("\nStarting Complex_Select on", BOARD_NAME, SHIELD_TYPE);
154+
MYSQL_DISPLAY(MYSQL_MARIADB_GENERIC_VERSION);
155+
156+
initEthernet();
143157

144158
MYSQL_DISPLAY3("Connecting to SQL Server @", server, ", Port =", server_port);
145159
MYSQL_DISPLAY5("User =", user, ", PW =", password, ", DB =", default_database);

examples/QNEthernet/Complex_Select/defines.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@
3838
#endif
3939

4040
// Only one of the following to be true.
41-
#define USE_ETHERNET false
42-
#define USE_ETHERNET_LARGE false
43-
#define USE_ETHERNET2 false
44-
#define USE_ETHERNET3 false
41+
#define USE_ETHERNET_GENERIC true
4542
#define USE_ETHERNET_ESP8266 false
4643
#define USE_ETHERNET_ENC false
4744
#define USE_ETHERNET_LAN8742A false
48-
#define USE_UIP_ETHERNET false
49-
45+
#define USE_ETHERNET_LAN8720 false
5046
#define USE_CUSTOM_ETHERNET false
47+
#define USE_UIP_ETHERNET false
5148

5249
#if USE_NATIVE_ETHERNET
5350
#include "NativeEthernet.h"

0 commit comments

Comments
 (0)