introduce function prepare_lowmem to remove big buffers
This commit is contained in:
parent
76693b97d7
commit
9eabcacd16
1 changed files with 11 additions and 12 deletions
23
main.py
23
main.py
|
|
@ -215,21 +215,25 @@ def network_connect(cmd):
|
||||||
pass
|
pass
|
||||||
debug("wlan connected")
|
debug("wlan connected")
|
||||||
|
|
||||||
|
def prepare_lowmem():
|
||||||
|
global BUFFER
|
||||||
|
del BUFFER # delete buffer to free some memory for upload process
|
||||||
|
global UART0
|
||||||
|
UART0.deinit()
|
||||||
|
del UART0
|
||||||
|
gc.collect()
|
||||||
|
|
||||||
|
|
||||||
def exec_upload(cmd):
|
def exec_upload(cmd):
|
||||||
# options:
|
# options:
|
||||||
# wlan_ssid
|
# wlan_ssid
|
||||||
# wlan_password - optional
|
# wlan_password - optional
|
||||||
# upload_server
|
# upload_server
|
||||||
# router_mac - MACaddress of the router
|
# router_mac - MACaddress of the router
|
||||||
global BUFFER
|
|
||||||
global URL_ACCESS_TOKEN
|
global URL_ACCESS_TOKEN
|
||||||
global LOG_FOLDER
|
global LOG_FOLDER
|
||||||
global OLD_LOG_FOLDER
|
global OLD_LOG_FOLDER
|
||||||
del BUFFER # delete buffer to free some memory for upload process
|
prepare_lowmem()
|
||||||
global UART0
|
|
||||||
UART0.deinit()
|
|
||||||
del UART0
|
|
||||||
gc.collect()
|
|
||||||
debug(f"free memory before network connect: {gc.mem_free()}")
|
debug(f"free memory before network connect: {gc.mem_free()}")
|
||||||
network_connect(cmd)
|
network_connect(cmd)
|
||||||
# upload file to server
|
# upload file to server
|
||||||
|
|
@ -268,12 +272,7 @@ def exec_uota(cmd):
|
||||||
# options:
|
# options:
|
||||||
# wlan_ssid
|
# wlan_ssid
|
||||||
# wlan_password - optional
|
# wlan_password - optional
|
||||||
global BUFFER
|
prepare_lowmem()
|
||||||
del BUFFER
|
|
||||||
global UART0
|
|
||||||
UART0.deinit()
|
|
||||||
del UART0
|
|
||||||
gc.collect()
|
|
||||||
import uota
|
import uota
|
||||||
network_connect(cmd)
|
network_connect(cmd)
|
||||||
if uota.check_for_updates():
|
if uota.check_for_updates():
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue