Currently is possible enable webrepl daemon with CLI (import webrepl_setup -> (E)nable and set pwd), but i want to do this with script.
The basic activities, what i want to do:
1. erase_flash
2. write new fw
3. connect to wifi # done in boot.py
4. if web_repl disabled, enable web_repl and set password
5. webrepl.start()
I'm stuck with the step 4.
Yes, i can do this once and manually, but developing my skills and knowledge would be nice, if i understand how to do it.
Enable webrepl daemon with script
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Enable webrepl daemon with script
I do this in my project:
Code: Select all
if config.WEBREPL_ACTIVE:
try:
import webrepl_cfg
except ImportError:
try:
with open("webrepl_cfg.py", "w") as f:
f.write("PASS = %r\n" % config.WEBREPL_PASSWORD)
except Exception as e:
_log.critical("Can't start webrepl: {!s}".format(e), local_only=True)
try:
import webrepl
webrepl.start()
except Exception as e:
_log.critical("Can't start webrepl: {!s}".format(e))
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
-
- Posts: 169
- Joined: Fri Aug 19, 2016 11:55 am
Re: Enable webrepl daemon with script
The easiest way to achieve the same state as if you had configured it manually is to copy the boot.py and webrepl_cfg.py files that are generated by the manual configuration to the board.
Check the source to see what import webrepl_setup does.
Check the source to see what import webrepl_setup does.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Enable webrepl daemon with script
That is actually not the easiest way because you have to keep different file versions or modify those files.
It's easier to use my approach that will create the webrepl_cfg.py according to how webrepl.py does it (at least as long as it doesn't exist) and starts the webrepl without modifying the boot.py
It's easier to use my approach that will create the webrepl_cfg.py according to how webrepl.py does it (at least as long as it doesn't exist) and starts the webrepl without modifying the boot.py
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: Enable webrepl daemon with script
check if this works for you
https://github.com/kr-g/mpyconfigbase
or on pypi
https://pypi.org/project/mpyconfigbase/
https://github.com/kr-g/mpyconfigbase
or on pypi
https://pypi.org/project/mpyconfigbase/
Re: Enable webrepl daemon with script
to whom it may concern (little bit of topic here since the inital post was just regarding web repl)
there is a new version v0.0.4 of mpyconfigbase
- supports now setting time from NTP automatically during startup when wlan is configured and connected
https://github.com/kr-g/mpyconfigbase
there is a new version v0.0.4 of mpyconfigbase
- supports now setting time from NTP automatically during startup when wlan is configured and connected
https://github.com/kr-g/mpyconfigbase