When I turn on the wifi station and wifi AP at the same time in esp32, the newly created thread cannot run.
When I turn on the wifi station and wifi AP at the same time in esp32, the newly created thread cannot run. It is tested in multiple versions of firmware. What is the reason?
boot.py:
import network
import jsondb
import gc
import json
import machine
import time
import _thread
import urequests
machine.freq(240000000)
jsondb.read()
sta_if = network.WLAN(network.STA_IF);
sta_if.active(True)
sta_if.connect(jsondb.data["sta_ssid"],jsondb.data["sta_pass"])
ap_if = network.WLAN(network.AP_IF)
ap_if.active(True)
ap_if.config(essid=jsondb.data["ap_ssid"], authmode=network.AUTH_WPA_WPA2_PSK, password=jsondb.data["ap_pass"])
def th_ota() :
print("[ OTA ] task start.")
while True :
if sta_if.isconnected() :
break
time.sleep(1)
print("[ OTA ] Checking OTA update...")
base = "http://192.168.1.1/ota/"
updatelist = urequests.get(base + "uplist.json")
info = json.loads(updatelist.text)
version = jsondb.data["version"]
print("[ OTA ] local version : {} , cloud version : {}".format(version,info["version"]))
if info["version"] != version:
jsondb.data.update({"version":info["version"]})
jsondb.write()
print("[ OTA ] new version detect {}".format(info["version"]))
for i in info["files"] :
resp = urequests.get(url=base + i, stream=True)
print("OTA update {}...".format(i))
if type(resp.raw) != None :
f = open(i,"wb")
while True :
gc.collect()
content = resp.raw.read(8192)
if content == b"" :
f.close()
break
f.write(content)
print("[ OTA ] Reset machine.")
machine.reset()
else:
print("[ OTA ] version not change.")
_thread.start_new_thread(th_ota,())
[ ESP32 ] How to change the Maximum simultaneously WiFi connection on the softAP?
Hello.
I tested and the Maximum is 4, right?
How I tested:
- I configured my ESP32 to AP mode.
- I want to have 10 other ESP32 STA connected simultaneously in the ESP32 AP.
- I have error in the ESP AP when the ESP STA number 5 tried to connect to AP, with error: wifi: max connection, deauth
Follow the sequence error in the AP:
MicroPython v1.11 on 2019-05-29; ESP32 module with ESP32
Type "help()" for more information.
import network
ap = network.WLAN(network.AP_IF)
I (1342589) wifi: wifi driver task: 3ffc4830, prio:23, stack:3584, core=0
I (1342589) wifi: wifi firmware version: 38e2484
I (1342589) wifi: config NVS flash: enabled
I (1342599) wifi: config nano formating: disabled
I (1342599) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1342609) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1342639) wifi: Init dynamic tx buffer num: 32
I (1342639) wifi: Init data frame dynamic rx buffer num: 32
I (1342639) wifi: Init management frame dynamic rx buffer num: 32
I (1342639) wifi: Init static rx buffer size: 1600
I (1342649) wifi: Init static rx buffer num: 10
I (1342649) wifi: Init dynamic rx buffer num: 32
ap.config(essid='esp', password='esp')
ap.active(True)
I (1353999) phy: phy_version: 4007, 9c6b43b, Jan 11 2019, 16:45:07, 0, 0
I (1354009) wifi: mode : softAP (24:6f:28:de:40:85)
I (1354009) wifi: Init max length of beacon: 752/752
I (1354009) wifi: Init max length of beacon: 752/752
True
I (1354019) network: event 13
print(ap.ifconfig())
('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
I (1540579) wifi: new:<1,0>, old:<1,0>, ap:<1,1>, sta:<255,255>, prof:1
I (1540579) wifi: station: 0c:cb:85:3e:15:c1 join, AID=1, bgn, 20
I (1540579) network: event 15
dhcps: send_offer>>udp_sendto result 0
I (1540959) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2
I (1540959) network: event 17
I (1551259) wifi: station: 0c:cb:85:3e:15:c1 leave, AID = 1, bss_flags is 134259
I (1551259) wifi: new:<1,0>, old:<1,0>, ap:<1,1>, sta:<255,255>, prof:1
I (1551259) network: event 16
I (1556339) wifi: new:<1,0>, old:<1,0>, ap:<1,1>, sta:<255,255>, prof:1
I (1556339) wifi: station: 0c:cb:85:3e:15:c1 join, AID=1, bgn, 20
I (1556339) network: event 15
dhcps: send_offer>>udp_sendto result 0
I (1556949) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2
I (1556949) network: event 17
I (1638929) wifi: new:<1,0>, old:<1,0>, ap:<1,1>, sta:<255,255>, prof:1
I (1638929) wifi: station: b4:ef:39:84:80:50 join, AID=2, bgn, 20
I (1638929) network: event 15
dhcps: send_offer>>udp_sendto result 0
I (1639649) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.3
I (1639659) network: event 17
I (1677649) wifi: new:<1,0>, old:<1,0>, ap:<1,1>, sta:<255,255>, prof:1
I (1677649) wifi: station: 08:c5:e1:c4:c5:5a join, AID=3, bgn, 20
I (1677649) network: event 15
dhcps: send_offer>>udp_sendto result 0
I (1678469) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.4
I (1678469) network: event 17
I (1801719) wifi: new:<1,0>, old:<1,0>, ap:<1,1>, sta:<255,255>, prof:1
I (1801719) wifi: station: 70:fd:46:ab:86:3c join, AID=4, bgn, 20
I (1801729) network: event 15
dhcps: send_offer>>udp_sendto result 0
I (1802339) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.5
I (1802339) network: event 17
I (1923569) wifi: max connection, deauth!
I (1923879) wifi: max connection, deauth!
I (1924189) wifi: max connection, deauth!
I (1924499) wifi: max connection, deauth!
I (1924819) wifi: max connection, deauth!
I (1925129) wifi: max connection, deauth!
I (1925439) wifi: max connection, deauth!
I (1927019) wifi: max connection, deauth!
I (1927329) wifi: max connection, deauth!
I (1927649) wifi: max connection, deauth!
I (1927959) wifi: max connection, deauth!
I (1928269) wifi: max connection, deauth!
I (1928589) wifi: max connection, deauth!