QUERY · ISSUE
esp32 cannot create thread after opening ap
why esp32 cannot create thread after opening ap.
CANDIDATE · ISSUE
When I turn on the wifi station and wifi AP at the same time in esp32, the newly created thread cannot run.
port-esp32
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,())