Skip to content

Commit 10d0e15

Browse files
committed
Add black hook, switch to loading with a command
1 parent a710e48 commit 10d0e15

File tree

7 files changed

+47
-3
lines changed

7 files changed

+47
-3
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 23.7.0
4+
hooks:
5+
- id: black

files/Manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"JPKG_minimum_version": 2,
33
"package_name": "netutils",
4-
"version": [1, 1, 1],
4+
"version": [1, 2, 0],
55
"dependencies": [],
66
"conflicts": [],
77
"install": "installer.py",

files/installer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"telnet.py",
2323
"timesync.lja",
2424
"timesync.py",
25+
"load_networking.lja",
26+
"load_wifi.py",
2527
]:
2628
be.based.run("cp " + vr("f") + " /bin/" + vr("f"))
2729

files/load_networking.lja

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pexec term.dmtex_suppress = False
2+
fpexec /bin/load_wifi.py
3+
telnet setup -q
4+
timesync
5+
pexec term.dmtex_suppress = True

files/load_wifi.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
rename_process("load_wifi")
2+
if "network" not in be.devices.keys():
3+
be.based.run("modprobe driver_wifi as network")
4+
be.based.run("iwctl station wifi disconnect")
5+
6+
def _autocon() -> None:
7+
if not (
8+
be.devices["network"][0].connected or be.devices["network"][0].ap_connected
9+
):
10+
systemprints(2, "Connecting wifi")
11+
be.based.run(
12+
"iwctl station wifi auto"
13+
) # Configure connections in &/settings.toml
14+
systemprints(1, "Connecting wifi")
15+
if "ttyTELNET0" in pv[0]["consoles"]:
16+
be.based.run("telnet deinit")
17+
be.based.run("telnet setup -q")
18+
vr("tm", time.monotonic())
19+
20+
def _checker() -> bool:
21+
return time.monotonic() - vr("tm") > 10
22+
23+
vr("task", be.api.tasks.add("wifi_scheduler", 30, _checker, _autocon))
24+
pid_activate(vr("task")) # Now running under the wifi scheduler task
25+
_autocon()
26+
pid_deactivate() # back to our task
27+
del _checker, _autocon
28+
else:
29+
term.write("Wifi already initialized.")

files/strap.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"telnet.py",
2727
"timesync.lja",
2828
"timesync.py",
29+
"load_networking.lja",
30+
"load_wifi.py",
2931
]:
3032
shutil.copyfile(i, path.join(root, "bin", i))
31-

files/uninstaller.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
be.based.run("rm /lib/telnet_console.mpy /lib/adafruit_connection_manager.mpy /lib/adafruit_ntp.mpy /lib/adafruit_requests.mpy /bin/iwctl/headless.py /bin/iwctl/interactive.py /bin/iwctl/main.py /bin/ping.lja /bin/ping.py /bin/iwctl.lja /bin/telnet.lja /bin/telnet.py /bin/timesync.lja /bin/timesync.py")
1+
be.based.run(
2+
"rm /lib/telnet_console.mpy /lib/adafruit_connection_manager.mpy /lib/adafruit_ntp.mpy /lib/adafruit_requests.mpy /bin/iwctl/headless.py /bin/iwctl/interactive.py /bin/iwctl/main.py /bin/ping.lja /bin/ping.py /bin/iwctl.lja /bin/telnet.lja /bin/telnet.py /bin/timesync.lja /bin/timesync.py /bin/load_networking.lja /bin/load_wifi.py"
3+
)
24

35
be.api.setvar("return", "0")

0 commit comments

Comments
 (0)