Skip to content

Commit f0ee919

Browse files
Copilotnetmindz
andcommitted
Add enhanced DHCP/network diagnostics and ping tests
Enhanced network connectivity diagnostics in QEMU E2E tests: Network Logging Improvements (wled.cpp): - Added verbose DHCP client initialization logging - Log DHCP start result and error codes - Wait 2 seconds after DHCP start and check IP assignment status - Display assigned IP, gateway, and netmask when available - Log when DHCP is still negotiating - Added logging for static IP configuration path Connectivity Testing Improvements (workflow): - Added ping tests before HTTP tests for basic connectivity verification - Test localhost ping first - Attempt to detect and ping guest IP (10.0.2.x) from QEMU logs - More verbose output showing each connectivity test attempt - Helps diagnose if issue is network layer vs HTTP server This addresses the request to: 1. Indicate when DHCP requests are being made and if replies are received 2. Use ping as well as HTTP requests to verify connectivity The enhanced logging helps differentiate between: - Network stack initialization issues - DHCP negotiation problems - IP assignment failures - HTTP server startup delays Co-authored-by: netmindz <[email protected]>
1 parent db57333 commit f0ee919

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

.github/workflows/qemu-e2e-test.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,28 @@ jobs:
159159
fi
160160
161161
echo ""
162-
echo "=== Testing HTTP Server Connectivity ==="
162+
echo "=== Testing Network Connectivity ==="
163163
164-
# Wait up to 1 minute for HTTP server to respond
164+
# Wait up to 1 minute for network connectivity
165165
for i in {1..30}; do
166+
# Test ping connectivity first
167+
echo "Attempt $i/30: Testing connectivity..."
168+
if ping -c 1 -W 2 localhost > /dev/null 2>&1; then
169+
echo "✓ Localhost ping successful"
170+
171+
# Try pinging the QEMU guest IP if we can detect it
172+
GUEST_IP=$(grep -o "10\.0\.2\.[0-9]\+" qemu-output.log | tail -1 || echo "")
173+
if [ -n "$GUEST_IP" ]; then
174+
echo "Detected guest IP: $GUEST_IP"
175+
if ping -c 1 -W 2 "$GUEST_IP" > /dev/null 2>&1; then
176+
echo "✓ Guest IP ($GUEST_IP) ping successful"
177+
else
178+
echo "⚠ Guest IP ($GUEST_IP) not responding to ping"
179+
fi
180+
fi
181+
fi
182+
183+
# Test HTTP connectivity
166184
if curl -f -m 5 http://localhost:8080/ > /dev/null 2>&1; then
167185
echo "✓ SUCCESS: WLED HTTP server is responding!"
168186
@@ -189,7 +207,6 @@ jobs:
189207
190208
exit 0
191209
fi
192-
echo "Attempt $i/30: Waiting for HTTP server..."
193210
sleep 2
194211
done
195212

wled00/wled.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,21 +1081,47 @@ bool WLED::initEthernet()
10811081
// QEMU: Skip hardware initialization - QEMU's open_eth doesn't fully emulate MAC registers
10821082
// The ethernet hardware init crashes with LoadStorePIFAddrError in emac_ll_clock_enable_rmii_output
10831083
// espressif example on how to init open_eth:
1084-
// https://github.com/espressif/esp-afr-sdk/blob/release/v4.4/examples/common_components/protocol_examples_common/connect.c - look for esp_eth_mac_new_openeth()
1084+
// https://github.com/esp-afr-sdk/blob/release/v4.4/examples/common_components/protocol_examples_common/connect.c - look for esp_eth_mac_new_openeth()
10851085

10861086
// Don't call ETH.begin() - avoids MAC register crash
10871087
// But manually initialize lwIP and DHCP for QEMU
1088+
USER_PRINTLN(F("initC: QEMU mode - initializing network stack"));
10881089
tcpip_adapter_init();
1090+
10891091
#if !defined(WLED_STATIC_IP_DEFAULT_1)
1090-
tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_ETH);
1092+
USER_PRINTLN(F("initC: QEMU - Starting DHCP client on ethernet interface"));
1093+
esp_err_t dhcp_result = tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_ETH);
1094+
if (dhcp_result == ESP_OK) {
1095+
USER_PRINTLN(F("initC: QEMU - DHCP client started successfully"));
1096+
} else {
1097+
USER_PRINTF("initC: QEMU - DHCP client start failed with error: %d\n", dhcp_result);
1098+
}
1099+
1100+
// Give DHCP some time and check status
1101+
delay(2000);
1102+
tcpip_adapter_ip_info_t ip_info_check;
1103+
if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip_info_check) == ESP_OK) {
1104+
if (ip_info_check.ip.addr != 0) {
1105+
USER_PRINTF("initC: QEMU - Got IP address: %d.%d.%d.%d\n",
1106+
IP2STR(&ip_info_check.ip));
1107+
USER_PRINTF("initC: QEMU - Gateway: %d.%d.%d.%d\n",
1108+
IP2STR(&ip_info_check.gw));
1109+
USER_PRINTF("initC: QEMU - Netmask: %d.%d.%d.%d\n",
1110+
IP2STR(&ip_info_check.netmask));
1111+
} else {
1112+
USER_PRINTLN(F("initC: QEMU - No IP address assigned yet (DHCP may still be negotiating)"));
1113+
}
1114+
}
10911115
#else
10921116
// Or set static IP:
1117+
USER_PRINTLN(F("initC: QEMU - Configuring static IP address"));
10931118
tcpip_adapter_ip_info_t ip_info;
10941119
IP4_ADDR(&ip_info.ip, 10, 0, 2, 15);
10951120
IP4_ADDR(&ip_info.gw, 10, 0, 2, 2);
10961121
IP4_ADDR(&ip_info.netmask, 255, 255, 255, 0);
10971122
tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &ip_info);
1098-
#endif // hack
1123+
USER_PRINTF("initC: QEMU - Static IP: %d.%d.%d.%d\n", IP2STR(&ip_info.ip));
1124+
#endif
10991125

11001126
// Network stack will still work via QEMU's user-mode networking (slirp)
11011127
DEBUG_PRINTLN(F("initC: QEMU mode - skipping ETH.begin() hardware initialization"));

0 commit comments

Comments
 (0)