Skip to content

Commit

Permalink
Disable power saving on wifi only on USB power
Browse files Browse the repository at this point in the history
  • Loading branch information
sjefferson99 authored and Stephen Jefferson committed Jan 16, 2024
1 parent 2c09833 commit 7a665b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions enviro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def dump_status():
wlog(f"active: {1 if wlan.active() else 0}, status: {status} ({status_names[status]})")
return status

# Return True on expected status, exception on error status (negative) and False on timeout
def wait_status(expected_status, *, timeout=10, tick_sleep=0.5):
for i in range(math.ceil(timeout / tick_sleep)):
time.sleep(tick_sleep)
Expand All @@ -205,8 +206,9 @@ def wait_status(expected_status, *, timeout=10, tick_sleep=0.5):
return False

wlan.active(True)
# Disable power saving mode - TODO only do this on USB power/config option
wlan.config(pm=0xa11140)
# Disable power saving mode if on USB power
if vbus_present:
wlan.config(pm=0xa11140)

# Print MAC
mac = ubinascii.hexlify(wlan.config('mac'),':').decode()
Expand Down

0 comments on commit 7a665b8

Please sign in to comment.