From 1754dfce9e2f8de63c3fc9d8e4db9d6ef6e95da6 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 23 Apr 2024 17:07:57 +0100 Subject: [PATCH] Make hostname unique per board. (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 --- enviro/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/enviro/__init__.py b/enviro/__init__.py index 72d6df8..17fa3a4 100644 --- a/enviro/__init__.py +++ b/enviro/__init__.py @@ -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 @@ -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