@@ -32,26 +32,26 @@ void initEthernet()
3232#elif USE_NATIVE_ETHERNET
3333 ET_LOGWARN (F (" ======== USE_NATIVE_ETHERNET ========" ));
3434#elif USE_ETHERNET_GENERIC
35- ET_LOGWARN (F (" =========== USE_ETHERNET_GENERIC ===========" ));
35+ ET_LOGWARN (F (" =========== USE_ETHERNET_GENERIC ===========" ));
3636#elif USE_ETHERNET_ESP8266
3737 ET_LOGWARN (F (" =========== USE_ETHERNET_ESP8266 ===========" ));
3838#elif USE_ETHERNET_ENC
39- ET_LOGWARN (F (" =========== USE_ETHERNET_ENC ===========" ));
39+ ET_LOGWARN (F (" =========== USE_ETHERNET_ENC ===========" ));
4040#else
4141 ET_LOGWARN (F (" =========================" ));
4242#endif
4343
4444#if !(USE_NATIVE_ETHERNET || USE_ETHERNET_PORTENTA_H7)
4545
4646#if (USING_SPI2)
47- #if defined(CUR_PIN_MISO)
48- ET_LOGWARN (F (" Default SPI pinout:" ));
49- ET_LOGWARN1 (F (" MOSI:" ), CUR_PIN_MOSI);
50- ET_LOGWARN1 (F (" MISO:" ), CUR_PIN_MISO);
51- ET_LOGWARN1 (F (" SCK:" ), CUR_PIN_SCK);
52- ET_LOGWARN1 (F (" SS:" ), CUR_PIN_SS);
53- ET_LOGWARN (F (" =========================" ));
54- #endif
47+ #if defined(CUR_PIN_MISO)
48+ ET_LOGWARN (F (" Default SPI pinout:" ));
49+ ET_LOGWARN1 (F (" MOSI:" ), CUR_PIN_MOSI);
50+ ET_LOGWARN1 (F (" MISO:" ), CUR_PIN_MISO);
51+ ET_LOGWARN1 (F (" SCK:" ), CUR_PIN_SCK);
52+ ET_LOGWARN1 (F (" SS:" ), CUR_PIN_SS);
53+ ET_LOGWARN (F (" =========================" ));
54+ #endif
5555#else
5656 ET_LOGWARN (F (" Default SPI pinout:" ));
5757 ET_LOGWARN1 (F (" MOSI:" ), MOSI);
@@ -63,28 +63,28 @@ void initEthernet()
6363
6464#if defined(ESP8266)
6565 // For ESP8266, change for other boards if necessary
66- #ifndef USE_THIS_SS_PIN
67- #define USE_THIS_SS_PIN D2 // For ESP8266
68- #endif
66+ #ifndef USE_THIS_SS_PIN
67+ #define USE_THIS_SS_PIN D2 // For ESP8266
68+ #endif
6969
7070 ET_LOGWARN1 (F (" ESP8266 setCsPin:" ), USE_THIS_SS_PIN);
7171
72- #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
73- // For ESP8266
74- // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8
75- // EthernetGeneric X X X X X 0
76- // Ethernet_ESP8266 0 0 0 0 0 0
77- // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs
78- // Must use library patch for Ethernet, EthernetLarge libraries
79- Ethernet.init (USE_THIS_SS_PIN);
80-
81- #elif USE_CUSTOM_ETHERNET
82-
83- // You have to add initialization for your Custom Ethernet here
84- // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
85- Ethernet.init (USE_THIS_SS_PIN);
86-
87- #endif // ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
72+ #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
73+ // For ESP8266
74+ // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8
75+ // EthernetGeneric X X X X X 0
76+ // Ethernet_ESP8266 0 0 0 0 0 0
77+ // D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs
78+ // Must use library patch for Ethernet, EthernetLarge libraries
79+ Ethernet.init (USE_THIS_SS_PIN);
80+
81+ #elif USE_CUSTOM_ETHERNET
82+
83+ // You have to add initialization for your Custom Ethernet here
84+ // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
85+ Ethernet.init (USE_THIS_SS_PIN);
86+
87+ #endif // ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
8888
8989#elif defined(ESP32)
9090
@@ -96,84 +96,84 @@ void initEthernet()
9696 // Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
9797 // Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
9898
99- #ifndef USE_THIS_SS_PIN
100- #define USE_THIS_SS_PIN 5 // 22 // For ESP32
101- #endif
99+ #ifndef USE_THIS_SS_PIN
100+ #define USE_THIS_SS_PIN 5 // 22 // For ESP32
101+ #endif
102102
103103 ET_LOGWARN1 (F (" ESP32 setCsPin:" ), USE_THIS_SS_PIN);
104104
105105 // For other boards, to change if necessary
106- #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
107- // Must use library patch for Ethernet, EthernetLarge libraries
108- // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge
109- // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3
110-
111- // Ethernet.setCsPin (USE_THIS_SS_PIN);
112- Ethernet.init (USE_THIS_SS_PIN);
113-
114- #elif USE_CUSTOM_ETHERNET
115-
116- // You have to add initialization for your Custom Ethernet here
117- // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
118- Ethernet.init (USE_THIS_SS_PIN);
119-
120- #endif // ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
106+ #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
107+ // Must use library patch for Ethernet, EthernetLarge libraries
108+ // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge
109+ // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3
110+
111+ // Ethernet.setCsPin (USE_THIS_SS_PIN);
112+ Ethernet.init (USE_THIS_SS_PIN);
113+
114+ #elif USE_CUSTOM_ETHERNET
115+
116+ // You have to add initialization for your Custom Ethernet here
117+ // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
118+ Ethernet.init (USE_THIS_SS_PIN);
119+
120+ #endif // ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
121121
122122#elif ETHERNET_USE_RPIPICO
123123
124124 pinMode (USE_THIS_SS_PIN, OUTPUT);
125125 digitalWrite (USE_THIS_SS_PIN, HIGH);
126-
126+
127127 // ETHERNET_USE_RPIPICO, use default SS = 5 or 17
128- #ifndef USE_THIS_SS_PIN
129- #if defined(ARDUINO_ARCH_MBED)
130- #define USE_THIS_SS_PIN 5 // For Arduino Mbed core
131- #else
132- #define USE_THIS_SS_PIN 17 // For E.Philhower core
133- #endif
134- #endif
128+ #ifndef USE_THIS_SS_PIN
129+ #if defined(ARDUINO_ARCH_MBED)
130+ #define USE_THIS_SS_PIN 5 // For Arduino Mbed core
131+ #else
132+ #define USE_THIS_SS_PIN 17 // For E.Philhower core
133+ #endif
134+ #endif
135135
136136 ET_LOGWARN1 (F (" RPIPICO setCsPin:" ), USE_THIS_SS_PIN);
137137
138138 // For other boards, to change if necessary
139- #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
140- // Must use library patch for Ethernet, EthernetLarge libraries
141- // For RPI Pico using Arduino Mbed RP2040 core
142- // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5
143- // For RPI Pico using E. Philhower RP2040 core
144- // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
145- // Default pin 5/17 to SS/CS
146-
147- // Ethernet.setCsPin (USE_THIS_SS_PIN);
148- Ethernet.init (USE_THIS_SS_PIN);
149-
150- #endif // ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
139+ #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
140+ // Must use library patch for Ethernet, EthernetLarge libraries
141+ // For RPI Pico using Arduino Mbed RP2040 core
142+ // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5
143+ // For RPI Pico using E. Philhower RP2040 core
144+ // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
145+ // Default pin 5/17 to SS/CS
146+
147+ // Ethernet.setCsPin (USE_THIS_SS_PIN);
148+ Ethernet.init (USE_THIS_SS_PIN);
149+
150+ #endif // ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
151151
152152#else // defined(ESP8266)
153153 // unknown board, do nothing, use default SS = 10
154- #ifndef USE_THIS_SS_PIN
155- #define USE_THIS_SS_PIN 10 // For other boards
156- #endif
154+ #ifndef USE_THIS_SS_PIN
155+ #define USE_THIS_SS_PIN 10 // For other boards
156+ #endif
157157
158- #if defined(BOARD_NAME)
159- ET_LOGWARN3 (F (" Board :" ), BOARD_NAME, F (" , setCsPin:" ), USE_THIS_SS_PIN);
160- #else
161- ET_LOGWARN1 (F (" Unknown board setCsPin:" ), USE_THIS_SS_PIN);
162- #endif
158+ #if defined(BOARD_NAME)
159+ ET_LOGWARN3 (F (" Board :" ), BOARD_NAME, F (" , setCsPin:" ), USE_THIS_SS_PIN);
160+ #else
161+ ET_LOGWARN1 (F (" Unknown board setCsPin:" ), USE_THIS_SS_PIN);
162+ #endif
163163
164164 // For other boards, to change if necessary
165- #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET )
166- // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
167-
168- Ethernet.init (USE_THIS_SS_PIN);
169-
170- #elif USE_CUSTOM_ETHERNET
171-
172- // You have to add initialization for your Custom Ethernet here
173- // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
174- Ethernet.init (USE_THIS_SS_PIN);
175-
176- #endif // ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
165+ #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET )
166+ // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
167+
168+ Ethernet.init (USE_THIS_SS_PIN);
169+
170+ #elif USE_CUSTOM_ETHERNET
171+
172+ // You have to add initialization for your Custom Ethernet here
173+ // This is just an example to setCSPin to USE_THIS_SS_PIN, and can be not correct and enough
174+ Ethernet.init (USE_THIS_SS_PIN);
175+
176+ #endif // ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC )
177177
178178#endif // defined(ESP8266)
179179
@@ -188,48 +188,50 @@ void initEthernet()
188188
189189#if !(USE_NATIVE_ETHERNET || USE_ETHERNET_PORTENTA_H7)
190190 ET_LOGWARN (F (" =========================" ));
191-
192- #if defined( ESP32 )
193- // Just info to know how to connect correctly
194- // To change for other SPI
195- ET_LOGWARN (F (" Currently Used SPI pinout:" ));
196- ET_LOGWARN1 (F (" MOSI:" ), PIN_MOSI);
197- ET_LOGWARN1 (F (" MISO:" ), PIN_MISO);
198- ET_LOGWARN1 (F (" SCK:" ), PIN_SCK);
199- ET_LOGWARN1 (F (" SS:" ), PIN_SS);
200- #else
201- #if defined(CUR_PIN_MISO)
202- ET_LOGWARN (F (" Currently Used SPI pinout:" ));
203- ET_LOGWARN1 (F (" MOSI:" ), CUR_PIN_MOSI);
204- ET_LOGWARN1 (F (" MISO:" ), CUR_PIN_MISO);
205- ET_LOGWARN1 (F (" SCK:" ), CUR_PIN_SCK);
206- ET_LOGWARN1 (F (" SS:" ), CUR_PIN_SS);
207- #else
208- ET_LOGWARN (F (" Currently Used SPI pinout:" ));
209- ET_LOGWARN1 (F (" MOSI:" ), MOSI);
210- ET_LOGWARN1 (F (" MISO:" ), MISO);
211- ET_LOGWARN1 (F (" SCK:" ), SCK);
212- ET_LOGWARN1 (F (" SS:" ), SS);
213- #endif
214- #endif
215-
191+
192+ #if defined( ESP32 )
193+ // Just info to know how to connect correctly
194+ // To change for other SPI
195+ ET_LOGWARN (F (" Currently Used SPI pinout:" ));
196+ ET_LOGWARN1 (F (" MOSI:" ), PIN_MOSI);
197+ ET_LOGWARN1 (F (" MISO:" ), PIN_MISO);
198+ ET_LOGWARN1 (F (" SCK:" ), PIN_SCK);
199+ ET_LOGWARN1 (F (" SS:" ), PIN_SS);
200+ #else
201+ #if defined(CUR_PIN_MISO)
202+ ET_LOGWARN (F (" Currently Used SPI pinout:" ));
203+ ET_LOGWARN1 (F (" MOSI:" ), CUR_PIN_MOSI);
204+ ET_LOGWARN1 (F (" MISO:" ), CUR_PIN_MISO);
205+ ET_LOGWARN1 (F (" SCK:" ), CUR_PIN_SCK);
206+ ET_LOGWARN1 (F (" SS:" ), CUR_PIN_SS);
207+ #else
208+ ET_LOGWARN (F (" Currently Used SPI pinout:" ));
209+ ET_LOGWARN1 (F (" MOSI:" ), MOSI);
210+ ET_LOGWARN1 (F (" MISO:" ), MISO);
211+ ET_LOGWARN1 (F (" SCK:" ), SCK);
212+ ET_LOGWARN1 (F (" SS:" ), SS);
213+ #endif
214+ #endif
215+
216216 ET_LOGWARN (F (" =========================" ));
217217
218218#elif (USE_ETHERNET_PORTENTA_H7)
219- if (Ethernet.hardwareStatus () == EthernetNoHardware)
219+
220+ if (Ethernet.hardwareStatus () == EthernetNoHardware)
220221 {
221222 Serial.println (" No Ethernet found. Stay here forever" );
222-
223- while (true )
223+
224+ while (true )
224225 {
225226 delay (1 ); // do nothing, no point running without Ethernet hardware
226227 }
227228 }
228-
229- if (Ethernet.linkStatus () == LinkOFF)
229+
230+ if (Ethernet.linkStatus () == LinkOFF)
230231 {
231232 Serial.println (" Not connected Ethernet cable" );
232233 }
234+
233235#endif
234236
235237 Serial.print (F (" Using mac index = " ));
@@ -242,6 +244,7 @@ void initEthernet()
242244void setup ()
243245{
244246 Serial.begin (115200 );
247+
245248 while (!Serial);
246249
247250 Serial.print (" \n Starting BasicAuthGet on " + String (BOARD_NAME));
@@ -251,7 +254,7 @@ void setup()
251254 initEthernet ();
252255}
253256
254- void loop ()
257+ void loop ()
255258{
256259 Serial.println (" making GET request with HTTP basic authentication" );
257260 httpClient.beginRequest ();
@@ -267,7 +270,7 @@ void loop()
267270 Serial.println (statusCode);
268271 Serial.print (" Response: " );
269272 Serial.println (response);
270-
273+
271274 Serial.println (" Wait five seconds" );
272275 delay (5000 );
273276}
0 commit comments