Browse Source

Wifi wrapper

master
Elis Hirwing 1 year ago
parent
commit
f7a5675bb3
Signed by: etu <elis@hirwing.se> GPG Key ID: D57EFA625C9A925F
2 changed files with 17 additions and 1 deletions
  1. +2
    -1
      Makefile
  2. +15
    -0
      src/wifi.py

+ 2
- 1
Makefile View File

@@ -1,9 +1,10 @@
DEVICE := /dev/ttyUSB3

copy:
ampy --port $(DEVICE) put src/pinouts.py
ampy --port $(DEVICE) put src/csms12.py
ampy --port $(DEVICE) put src/main.py
ampy --port $(DEVICE) put src/pinouts.py
ampy --port $(DEVICE) put src/wifi.py

connect:
picocom $(DEVICE) -b115200

+ 15
- 0
src/wifi.py View File

@@ -0,0 +1,15 @@
import network

def connect():
sta_if = network.WLAN(network.STA_IF)

if not sta_if.isconnected():
print('connecting to network...')

sta_if.active(True)
sta_if.connect('<ssid>', '<psk>')

while not sta_if.isconnected():
pass

print('network config:', sta_if.ifconfig())

Loading…
Cancel
Save