|
@@ -0,0 +1,27 @@
|
|
|
+from machine import Pin, Signal
|
|
|
+LED_PIN = Signal(13, Pin.OUT, invert=False)
|
|
|
+BUTTON_PIN = Signal(0, Pin.IN, invert=True)
|
|
|
+
|
|
|
+# Turn off "ready" LED
|
|
|
+LED_PIN.off()
|
|
|
+
|
|
|
+# Read configuration from JSON file
|
|
|
+with open('config.json') as fd:
|
|
|
+ import ujson
|
|
|
+ config = ujson.load(fd)
|
|
|
+
|
|
|
+# Configure wireless networking
|
|
|
+import network
|
|
|
+wifi_host = network.WLAN(network.AP_IF)
|
|
|
+wifi_host.active(False)
|
|
|
+
|
|
|
+wifi_guest = network.WLAN(network.STA_IF)
|
|
|
+wifi_guest.active(True)
|
|
|
+if not wifi_guest.isconnected():
|
|
|
+ wifi_guest.connect(config.wifi.ssid, config.wifi.password)
|
|
|
+ while not wifi_guest.isconnected():
|
|
|
+ pass
|
|
|
+print(wifi_guest.ifconfig())
|
|
|
+
|
|
|
+# Turn on "ready" LED
|
|
|
+LED_PIN.on()
|