Letting the wifi run is as easy as:
Code: Select all
def ww(arg):
wifi.write(arg+'\r')
print(wifi.read().decode("utf-8"))
wifi=pyb.UART(3,9600)
wifi.write('$$$') # start command mode
wifi.any()
wifi.read()
ww('set wlan ssid MySSID')
ww('set wlan passphrase MyWifiPassword')
# 4=WPA2 PSK
ww('set wlan auth 4')
# DHCP client 0=static IP 1=dhcp client 2=autoIP 3=DHCP cached 4=DHCP server AP
ww('set ip dhcp 1')
ww('join MySSID_network')
ww('get ip')
ww('get ip')
You can actually open a remote wifi socket to the wifi with telnet on default port 2000:
I would rather not poll for wifi.any() in a while True loop.telnet 10.1.1.13 2000
Trying 10.1.1.13...
Connected to 10.1.1.13.
Escape character is '^]'.
*HELLO*
$$$
CMD
get ip
get ip
IF=UP
DHCP=ON
IP=10.1.1.13:2000
NM=255.255.255.0
GW=10.1.1.1
HOST=0.0.0.0:2000
PROTO=TCP,
MTU=1524
FLAGS=0x7
TCPMODE=0x0
BACKUP=0.0.0.0
<4.00>
Thank you for any hints.