if i flash the 1.9.3 binary the following code runs flawless using the config(dhcp_hostname="hostname")
Code: Select all
from time import sleep_ms
import machine
from Config import Config
Config1 = Config()
def do_connect():
import network
ap = network.WLAN(network.AP_IF)
ap.active(False)
wlan = network.WLAN(network.STA_IF)
wlan.config(dhcp_hostname=Config1.GetValue('DeviceName'))
wlan.active(False)
sleep_ms(2000)
wlan.active(True)
sleep_ms(100)
SSID = Config1.GetValue('SSID')
PASSWORD = Config1.GetValue('PW')
nets = wlan.scan()
bytessid = bytes(SSID, 'utf-8')
rssi = ''
print('searching for access points...')
for net in nets:
if net[0] == bytessid:
print('Access point %s found. RSSI %s' %(net[1], net[3]))
if not rssi:
rssi, BSSID = net[3], net[1]
if net[3] > rssi:
rssi, BSSID = net[3], net[1]
print('Connect to strongest ap %s from net %s with rssi %s and password %s' %(BSSID, SSID, rssi, PASSWORD))
wlan.connect(SSID, PASSWORD, bssid=BSSID)
print('0', end= ' ')
i=0
while not wlan.isconnected():
i+=1
print(i, end= ' ')
if i==61:
print('wlan connection error, restart')
machine.reset()
sleep_ms(1000)
print(' ')
print('Wlan connection succeeded')
print(wlan.ifconfig())
do_connect()
gc.collect()
sleep_ms(10000)
import app.py
Code: Select all
Traceback (most recent call last):
File "main.py", line 43, in <module>
File "main.py", line 10, in do_connect
OSError: can't set STA config
MicroPython v1.9.3-52-gf59c6b4 on 2017-11-26; ESP module with ESP8266