I've received my WiPy + dev board, it is functioning. Just so I can play with it better, I'm trying to achieve the following on boot (in boot.py):
1. On boot, go on my home network and obtain an IP address via DHCP
2. Print the IP address to UART 0 (the serial-to-USB)
3. Duplicate the REPL on the serial port
So far I was able to print to the serial port and use it for REPL, but for some reasons a sequence of commands I'm using interactively successfully isn't working for me when I put it in the boot.py. Here is my boot.py:
Code: Select all
from machine import UART
from network import WLAN
import os
SSID = 'my-home-network-ssid'
AUTH = (WLAN.WPA2, 'hunter2')
# enable the UART on the USB-to-serial port
uart = UART(0, baudrate=115200)
uart.write(b'UART initialised\n')
# login to the local network
uart.write(b'Initialising WLAN in station mode... ')
wlan = WLAN(WLAN.STA)
uart.write(b'done.\nConnecting to WiFi network...')
wlan.connect(ssid=SSID, auth=AUTH)
while not wlan.isconnected():
uart.write(b'.')
uart.write(b'done.\nRequesting an IP from a DHCP server... ')
wlan.ifconfig(config='dhcp')
uart.write(b'done.\n')
# print
ip, mask, gateway, dns = wlan.ifconfig()
uart.write(b'IP address: ' + bytearray(ip) + '\n')
uart.write(b'Netmask: ' + bytearray(mask) + '\n')
uart.write(b'Gateway: ' + bytearray(gateway) + '\n')
uart.write(b'DNS: ' + bytearray(dns) + '\n')
# start the terminal on the UART
os.dupterm(uart)
Also, how can I run the telnet and/or the FTP daemon in station mode?
Thanks,
-- Arik