Skip to content

Commit 6e7d320

Browse files
committed
fix: dynamically detect WiFi interface instead of hardcoding wlan0
On Jetson Orin Nano, the USB WiFi dongle uses predictable interface naming (wlx* prefix) instead of the legacy wlan0 name. This caused the WiFi hardware test to always fail on DB26J robots. - Add _detect_wifi_interface() helper that checks robot hardware type and scans netifaces for wlx*/wlp* interfaces on Orin Nano - Falls back to wlan0 on all other platforms (Jetson Nano, RPi, etc.) - Change wifi_interface default from 'wlan0' to None (auto-detect) - Update test description to show the actual detected interface name DTSW-7683
1 parent 412fde6 commit 6e7d320

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

packages/ros_http_api/include/hardware_test_wifi_dongle/hardware_test_wifi_dongle.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
1-
from typing import Any
1+
from typing import Any, Optional
22

33
import netifaces
4+
from dt_robot_utils import get_robot_hardware, RobotHardware
45
from duckiebot_hardware_test_ros_interface import AbstractHardwareTestROSInterface, HardwareTestJsonParamType
56

67

8+
def _detect_wifi_interface() -> str:
9+
"""Detect the WiFi interface name based on robot hardware.
10+
11+
On Jetson Orin Nano, the USB WiFi dongle uses predictable interface naming
12+
(wlx* for USB, wlp* for PCI) instead of the legacy wlan0 name.
13+
14+
Returns:
15+
The detected WiFi interface name, falling back to 'wlan0'.
16+
"""
17+
if get_robot_hardware() == RobotHardware.JETSON_ORIN_NANO:
18+
interfaces = netifaces.interfaces()
19+
# prefer wlx* (USB WiFi dongles with predictable naming)
20+
for iface in interfaces:
21+
if iface.startswith("wlx"):
22+
return iface
23+
# try wlp* (PCI-based WiFi)
24+
for iface in interfaces:
25+
if iface.startswith("wlp"):
26+
return iface
27+
# default for Jetson Nano, Raspberry Pi, etc.
28+
return "wlan0"
29+
30+
731
class HardwareTestWiFiDongle(AbstractHardwareTestROSInterface):
832
wifi_interface: str
933

10-
def __init__(self, node: Any, test_id: str = "USB WiFi Dongle", wifi_interface: str = "wlan0") -> None:
34+
def __init__(self, node: Any, test_id: str = "USB WiFi Dongle", wifi_interface: Optional[str] = None) -> None:
1135
super().__init__(node, test_id, service_identifier="tests/wifi")
12-
self.wifi_interface = wifi_interface
36+
self.wifi_interface = wifi_interface if wifi_interface is not None else _detect_wifi_interface()
1337

1438
def get_test_data(self, _: dict) -> dict:
1539
return {}
1640

1741
def test_description_expectation(self) -> str:
1842
return self.html_util_ul(
1943
[
20-
"The IP address of the <code>wlan0</code> network interface should be displayed below.",
44+
f"The IP address of the <code>{self.wifi_interface}</code> network interface should be displayed below.",
2145
]
2246
)
2347

0 commit comments

Comments
 (0)