Skip to content

Commit 3758a2d

Browse files
committed
modules/startup: WLAN supports static protocol.
Signed-off-by: lbuque <[email protected]>
1 parent 1d242d7 commit 3758a2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+511
-105
lines changed

m5stack/modules/startup/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,21 @@ def connect_network(
3030
ssid: str = "",
3131
pswd: str = "",
3232
lan_if: "network.LAN" = None,
33-
eth_mode: str = "DHCP",
33+
protocol: str = "DHCP",
3434
ip: str = "",
3535
netmask: str = "",
3636
gateway: str = "",
3737
dns: str = "",
3838
) -> bool:
3939
if self.network_type == "WIFI" and len(ssid) > 0:
4040
self.network.connect(ssid, pswd)
41+
if protocol == "STATIC":
42+
self.network.ifconfig((ip, netmask, gateway, dns))
4143
return True
4244
elif self.network_type == "ETH":
4345
self.network = lan_if
4446
self.network.active(True)
45-
if eth_mode == "STATIC":
47+
if protocol == "STATIC":
4648
self.network.ifconfig((ip, netmask, gateway, dns))
4749
return True
4850
else:
@@ -82,7 +84,7 @@ def startup(boot_opt, timeout: int = 60) -> None:
8284
net_mode = nvs.get_str("net_mode")
8385
ssid = nvs.get_str("ssid0")
8486
pswd = nvs.get_str("pswd0")
85-
eth_mode = nvs.get_str("eth_mode")
87+
protocol = nvs.get_str("protocol")
8688
ip = nvs.get_str("ip_addr")
8789
netmask = nvs.get_str("netmask")
8890
gateway = nvs.get_str("gateway")
@@ -291,7 +293,7 @@ def startup(boot_opt, timeout: int = 60) -> None:
291293
from .stamplc import StampPLC_Startup
292294

293295
plc = StampPLC_Startup()
294-
plc.startup(net_mode, ssid, pswd, eth_mode, ip, netmask, gateway, dns, timeout)
296+
plc.startup(net_mode, ssid, pswd, protocol, ip, netmask, gateway, dns, timeout)
295297

296298
elif board_id == M5.BOARD.M5Tab5:
297299
from .tab5 import Tab5_Startup

m5stack/modules/startup/airq.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,28 @@ class AirQ_Startup:
493493
def __init__(self) -> None:
494494
self._wifi = Startup()
495495

496-
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
496+
def startup(
497+
self,
498+
ssid: str,
499+
pswd: str,
500+
protocol: str = "",
501+
ip: str = "",
502+
netmask: str = "",
503+
gateway: str = "",
504+
dns: str = "",
505+
timeout: int = 60,
506+
) -> None:
497507
DEBUG and print("Corink startup")
498508
# DEBUG and M5.Lcd.drawCenterString("Corink startup2", 100, 100)
499-
self._wifi.connect_network(ssid, pswd)
509+
self._wifi.connect_network(
510+
ssid,
511+
pswd,
512+
protocol=protocol,
513+
ip=ip,
514+
netmask=netmask,
515+
gateway=gateway,
516+
dns=dns,
517+
)
500518

501519
sprite = M5.Lcd.newCanvas(200, 200, 1, False)
502520
sprite.drawBmp(STARTUP_BG_IMG, 0, 0)

m5stack/modules/startup/atom_echos3r.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,28 @@ def show_error(self, ssid: str, error: str) -> None:
3939
self.show_mac()
4040
print("SSID: " + ssid + "\r\nNotice: " + error)
4141

42-
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
42+
def startup(
43+
self,
44+
ssid: str,
45+
pswd: str,
46+
protocol: str = "",
47+
ip: str = "",
48+
netmask: str = "",
49+
gateway: str = "",
50+
dns: str = "",
51+
timeout: int = 60,
52+
) -> None:
4353
self.show_mac()
4454

45-
if super().connect_network(ssid=ssid, pswd=pswd):
55+
if super().connect_network(
56+
ssid=ssid,
57+
pswd=pswd,
58+
protocol=protocol,
59+
ip=ip,
60+
netmask=netmask,
61+
gateway=gateway,
62+
dns=dns,
63+
):
4664
self.show_ssid(ssid)
4765
count = 1
4866
status = super().connect_status()

m5stack/modules/startup/atommatrix.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,28 @@ def show_mac(self) -> None:
3838
def show_error(self, ssid: str, error: str) -> None:
3939
print("SSID: " + ssid + "\r\nNotice: " + error)
4040

41-
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
41+
def startup(
42+
self,
43+
ssid: str,
44+
pswd: str,
45+
protocol: str = "",
46+
ip: str = "",
47+
netmask: str = "",
48+
gateway: str = "",
49+
dns: str = "",
50+
timeout: int = 60,
51+
) -> None:
4252
self.show_mac()
4353

44-
if super().connect_network(ssid=ssid, pswd=pswd):
54+
if super().connect_network(
55+
ssid=ssid,
56+
pswd=pswd,
57+
protocol=protocol,
58+
ip=ip,
59+
netmask=netmask,
60+
gateway=gateway,
61+
dns=dns,
62+
):
4563
print("Connecting to " + ssid + " ", end="")
4664
status = super().connect_status()
4765
self.rgb.set_brightness(60)

m5stack/modules/startup/atoms3.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,30 @@ def show_error(self, ssid: str, error: str) -> None:
5050
self.show_mac()
5151
print("SSID: " + ssid + "\r\nNotice: " + error)
5252

53-
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
53+
def startup(
54+
self,
55+
ssid: str,
56+
pswd: str,
57+
protocol: str = "",
58+
ip: str = "",
59+
netmask: str = "",
60+
gateway: str = "",
61+
dns: str = "",
62+
timeout: int = 60,
63+
) -> None:
5464
M5.Lcd.drawImage(self.WIFI_OK, 0, 0)
5565
M5.Lcd.drawImage(self.MODE_DEV, 0, 98)
5666
self.show_mac()
5767

58-
if super().connect_network(ssid=ssid, pswd=pswd):
68+
if super().connect_network(
69+
ssid=ssid,
70+
pswd=pswd,
71+
protocol=protocol,
72+
ip=ip,
73+
netmask=netmask,
74+
gateway=gateway,
75+
dns=dns,
76+
):
5977
self.show_ssid(ssid)
6078
count = 1
6179
status = super().connect_status()

m5stack/modules/startup/atoms3r.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,30 @@ def show_error(self, ssid: str, error: str) -> None:
5151
self.show_mac()
5252
print("SSID: " + ssid + "\r\nNotice: " + error)
5353

54-
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
54+
def startup(
55+
self,
56+
ssid: str,
57+
pswd: str,
58+
protocol: str = "",
59+
ip: str = "",
60+
netmask: str = "",
61+
gateway: str = "",
62+
dns: str = "",
63+
timeout: int = 60,
64+
) -> None:
5565
M5.Lcd.drawImage(self.WIFI_OK, 0, 0)
5666
M5.Lcd.drawImage(self.MODE_DEV, 0, 98)
5767
self.show_mac()
5868

59-
if super().connect_network(ssid=ssid, pswd=pswd):
69+
if super().connect_network(
70+
ssid=ssid,
71+
pswd=pswd,
72+
protocol=protocol,
73+
ip=ip,
74+
netmask=netmask,
75+
gateway=gateway,
76+
dns=dns,
77+
):
6078
self.show_ssid(ssid)
6179
count = 1
6280
status = super().connect_status()

m5stack/modules/startup/atoms3r_cam.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,28 @@ def show_error(self, ssid: str, error: str) -> None:
3838
self.show_mac()
3939
print("SSID: " + ssid + "\r\nNotice: " + error)
4040

41-
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
41+
def startup(
42+
self,
43+
ssid: str,
44+
pswd: str,
45+
protocol: str = "",
46+
ip: str = "",
47+
netmask: str = "",
48+
gateway: str = "",
49+
dns: str = "",
50+
timeout: int = 60,
51+
) -> None:
4252
self.show_mac()
4353

44-
if super().connect_network(ssid=ssid, pswd=pswd):
54+
if super().connect_network(
55+
ssid=ssid,
56+
pswd=pswd,
57+
protocol=protocol,
58+
ip=ip,
59+
netmask=netmask,
60+
gateway=gateway,
61+
dns=dns,
62+
):
4563
self.show_ssid(ssid)
4664
count = 1
4765
status = super().connect_status()

m5stack/modules/startup/basic/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,20 @@ class Basic_Startup:
2828
def __init__(self) -> None:
2929
self._wlan = Startup()
3030

31-
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
32-
self._wlan.connect_network(ssid, pswd)
31+
def startup(
32+
self,
33+
ssid: str,
34+
pswd: str,
35+
protocol: str = "",
36+
ip: str = "",
37+
netmask: str = "",
38+
gateway: str = "",
39+
dns: str = "",
40+
timeout: int = 60,
41+
) -> None:
42+
self._wlan.connect_network(
43+
ssid, pswd, protocol=protocol, ip=ip, netmask=netmask, gateway=gateway, dns=dns
44+
)
3345
M5.Speaker.setVolume(80)
3446
M5.Speaker.tone(4000, 50)
3547

m5stack/modules/startup/basic/apps/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ def get_data(self):
242242

243243
# if is_save is True:
244244
# self.nvs.commit()
245-
# self._wifi.wlan.disconnect()
246-
# self._wifi.wlan.active(False)
247-
# self._wifi.wlan.active(True)
245+
# self._wifi.network.disconnect()
246+
# self._wifi.network.active(False)
247+
# self._wifi.network.active(True)
248248
# self._wifi.connect_network(self.ssid, self.psk)
249249

250250

m5stack/modules/startup/capsule.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,29 @@ class Capsule_Startup(StampS3_Startup):
1414
def __init__(self) -> None:
1515
super().__init__()
1616

17-
def startup(self, ssid: str, pswd: str, timeout: int = 60) -> None:
17+
def startup(
18+
self,
19+
ssid: str,
20+
pswd: str,
21+
protocol: str = "",
22+
ip: str = "",
23+
netmask: str = "",
24+
gateway: str = "",
25+
dns: str = "",
26+
timeout: int = 60,
27+
) -> None:
1828
self.show_mac()
1929
M5.Speaker.setVolumePercentage(1.0)
2030

21-
if super().connect_network(ssid=ssid, pswd=pswd):
31+
if super().connect_network(
32+
ssid=ssid,
33+
pswd=pswd,
34+
protocol=protocol,
35+
ip=ip,
36+
netmask=netmask,
37+
gateway=gateway,
38+
dns=dns,
39+
):
2240
print("Connecting to " + ssid + " ", end="")
2341
status = super().connect_status()
2442
self.rgb.set_brightness(60)

0 commit comments

Comments
 (0)