test(led-driver): add espnow peer and ap pm0 scripts
Made-with: Cursor
This commit is contained in:
41
tests/test_ap_pm0.py
Normal file
41
tests/test_ap_pm0.py
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
"""MicroPython AP example with power management disabled (pm=0).
|
||||
|
||||
Run on device:
|
||||
mpremote connect /dev/ttyACM0 run tests/test_ap_pm0.py
|
||||
"""
|
||||
|
||||
import network
|
||||
import time
|
||||
|
||||
AP_SSID = "led-ap"
|
||||
AP_PASSWORD = "ledpass123"
|
||||
AP_CHANNEL = 6
|
||||
|
||||
|
||||
def main():
|
||||
ap = network.WLAN(network.AP_IF)
|
||||
ap.active(True)
|
||||
|
||||
# Explicitly disable Wi-Fi power save for AP mode.
|
||||
try:
|
||||
ap.config(pm=0)
|
||||
except (AttributeError, ValueError, TypeError):
|
||||
try:
|
||||
ap.config(pm=network.WLAN.PM_NONE)
|
||||
except (AttributeError, ValueError, TypeError):
|
||||
pass
|
||||
|
||||
ap.config(essid=AP_SSID, password=AP_PASSWORD, channel=AP_CHANNEL, authmode=3)
|
||||
|
||||
print("[ap-pm0] AP active:", ap.active())
|
||||
print("[ap-pm0] SSID:", AP_SSID)
|
||||
print("[ap-pm0] IFCONFIG:", ap.ifconfig())
|
||||
print("[ap-pm0] Waiting for clients. Ctrl+C to stop.")
|
||||
|
||||
while True:
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user