Skip to content

Commit 6aeb99f

Browse files
committed
DHCP
1 parent 1d57e3f commit 6aeb99f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

fw/v2/platformio.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ board_build.filesystem_size = 0.5m
1717
[env:rpipico2w]
1818
board = rpipico2w
1919
lib_deps = khoih-prog/Ethernet_Generic@^2.8.1
20+
build_flags =
21+
-DUSE_DHCP

fw/v2/src/main.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
#define LCS 21
2424
#define RCS 13
2525

26+
// DHCP Control Panel
27+
#if (USE_DHCP)
28+
#define DHCP_HOSTNAME "hermes"
29+
#endif
30+
2631
SPISettings spisettings(DEFAULT_BAUDRATE, MSBFIRST, SPI_MODE0);
2732
uint8_t txL[TOTAL_MAX_CHIPS];
2833
uint8_t txR[TOTAL_MAX_CHIPS];
@@ -237,11 +242,22 @@ void setup()
237242
SerialDebug.begin(9600);
238243

239244
Ethernet.init (USE_THIS_SS_PIN);
245+
246+
#if (USE_DHCP)
247+
Ethernet.setHostname(DHCP_HOSTNAME);
248+
#endif
249+
240250
Ethernet.setRstPin(20);
241251
Ethernet.hardreset();
242252

243253
byte mac[6] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 };
244-
Ethernet.begin(mac, ip);
254+
255+
#if (USE_DHCP)
256+
Ethernet.begin(mac);
257+
#else
258+
Ethernet.begin(mac, ip);
259+
#endif
260+
245261
Udp.begin(localPort);
246262

247263
pinMode(LCS, OUTPUT);

0 commit comments

Comments
 (0)