Skip to content

Commit e032123

Browse files
committed
AVR Ethernet support
1 parent b64a864 commit e032123

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/AudioConfig.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170

171171
#define USE_PWM
172172
#define USE_URL_ARDUINO
173+
#define USE_WIFI
173174
#define USE_WIFI_CLIENT_SECURE
174175
#define USE_I2S
175176
#define USE_AUDIO_SERVER
@@ -230,6 +231,7 @@ typedef uint32_t eps32_i2s_sample_rate_type;
230231

231232
#define USE_PWM
232233
#define USE_URL_ARDUINO
234+
#define USE_WIFI
233235
#define USE_WIFI_CLIENT_SECURE
234236
#define USE_I2S
235237
#define USE_AUDIO_SERVER
@@ -282,6 +284,7 @@ typedef uint32_t eps32_i2s_sample_rate_type;
282284
#define USE_EFFECTS_SUITE
283285
#define USE_TIMER
284286
#define USE_URL_ARDUINO
287+
#define USE_WIFI
285288

286289
#define PIN_PWM_START 12
287290
#define PIN_I2S_BCK -1
@@ -390,6 +393,7 @@ typedef uint32_t eps32_i2s_sample_rate_type;
390393
// The Pico W has WIFI support
391394
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
392395
# define USE_URL_ARDUINO
396+
# define USE_WIFI
393397
# define USE_WIFI_CLIENT_SECURE
394398
# define USE_AUDIO_SERVER
395399
#endif
@@ -399,7 +403,8 @@ typedef uint32_t eps32_i2s_sample_rate_type;
399403
#ifdef __AVR__
400404
#define USE_PWM
401405
#define USE_TIMER
402-
406+
#include <Ethernet.h>
407+
#define USE_URL_ARDUINO
403408
#ifndef assert
404409
#define assert(T)
405410
#endif

src/AudioHttp/URLStream.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class URLStream : public AbstractURLStream {
182182
char* network=nullptr;
183183
char* password=nullptr;
184184
Client *client=nullptr;
185-
WiFiClient *clientInsecure=nullptr;
185+
Client *clientInsecure=nullptr;
186186
#ifdef USE_WIFI_CLIENT_SECURE
187187
WiFiClientSecure *clientSecure=nullptr;
188188
#endif
@@ -250,11 +250,16 @@ class URLStream : public AbstractURLStream {
250250
return *clientSecure;
251251
}
252252
#endif
253+
#ifdef USE_WIFI
253254
if (clientInsecure==nullptr){
254255
clientInsecure = new WiFiClient();
255256
LOGI("WiFiClient");
256257
}
257258
return *clientInsecure;
259+
#else
260+
LOGE("Client not set");
261+
stop();
262+
#endif
258263
}
259264

260265
inline void fillBuffer() {
@@ -270,7 +275,7 @@ class URLStream : public AbstractURLStream {
270275
}
271276

272277
void login(){
273-
#ifndef IS_DESKTOP
278+
#ifdef IS_WIFI
274279
LOGD("connectWiFi");
275280
if (network!=nullptr && password != nullptr && WiFi.status() != WL_CONNECTED){
276281
WiFi.begin(network, password);
@@ -281,6 +286,8 @@ class URLStream : public AbstractURLStream {
281286
Serial.println();
282287
}
283288
delay(500);
289+
#else
290+
LOGE("login not supported");
284291
#endif
285292
}
286293

0 commit comments

Comments
 (0)