Skip to content

Commit

Permalink
Make hostname unique per board.
Browse files Browse the repository at this point in the history
(Attempt to) make the hostname unique per board, by using the last
four chars of the unique ID (flash chip ID) as a suffix.

Fixes #167
  • Loading branch information
Gadgetoid committed Apr 24, 2024
1 parent 4b374bd commit 1754dfc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion enviro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def stop_activity_led():
print(" - -- ---- -----=--==--=== hey enviro, let's go! ===--==--=----- ---- -- - ")
print("")

def reconnect_wifi(ssid, password, country):
def reconnect_wifi(ssid, password, country, hostname=None):
import time
import network
import math
Expand All @@ -165,6 +165,11 @@ def reconnect_wifi(ssid, password, country):
# Set country
rp2.country(country)

# Set hostname
if hostname is None:
hostname = f"EnviroW-{helpers.uid()[-4:]}"
network.hostname(hostname)

# Reference: https://datasheets.raspberrypi.com/picow/connecting-to-the-internet-with-pico-w.pdf
CYW43_LINK_DOWN = 0
CYW43_LINK_JOIN = 1
Expand Down

0 comments on commit 1754dfc

Please sign in to comment.