zkk f892315588 优化状态栏显示网络图标,优化IP信息更新不及时问题,实现注册码页面
Squashed commit of the following:

commit 69bcfa4bd00fc1af8da8df191b6a4d86309c7d23
Merge: 2dba9f8e 964a81c3
Author: zkk <1007518571@qq.com>
Date:   Mon Mar 3 15:25:49 2025 +0800

    Merge commit '964a81c37cd165b9f8df20db87fd915ba03d10b5' into release

commit 964a81c37cd165b9f8df20db87fd915ba03d10b5
Author: zkk <1007518571@qq.com>
Date:   Fri Feb 28 16:27:57 2025 +0800

    状态栏增加网络连接图标

commit 9c99cd91250c7aeb3d9728e540590299a1caf150
Author: zkk <1007518571@qq.com>
Date:   Fri Feb 28 16:20:52 2025 +0800

    修复网络页面IP更新不及时的问题

commit 842a616c2558757d19b7553d23aee9f1daffdc80
Author: zkk <1007518571@qq.com>
Date:   Tue Feb 25 14:53:31 2025 +0800

    注册码功能的实现

commit 2dba9f8ee2725847f31c891b19df6d9b81e03568
Merge: 03cd3722 18f05cc5
Author: zkk <1007518571@qq.com>
Date:   Fri Feb 14 15:21:36 2025 +0800

    Merge commit '18f05cc52dfb7889853a4f84aad975309ab7dbbe' into release

commit 18f05cc52dfb7889853a4f84aad975309ab7dbbe
Author: zkk <1007518571@qq.com>
Date:   Wed Feb 5 10:59:00 2025 +0800

    修复连接不了未加密网络的旧问题

commit 025a26209cbe15a0b7f5f1aba5166da63d6eaebf
Author: zkk <1007518571@qq.com>
Date:   Fri Jan 24 15:48:52 2025 +0800

    重构网络页面,解决卡顿问题

commit fdc851c4e66e3b872eb2564442f0c67369b9e3e2
Author: zkk <1007518571@qq.com>
Date:   Fri Jan 24 15:13:41 2025 +0800

    优化菜单页面的点击效果和增加列表风格属性

commit e6cfa874208f8d98d0360fb073e4da15c935b202
Author: zkk <1007518571@qq.com>
Date:   Tue Jan 21 15:11:28 2025 +0800

    优化进入工厂模式的方式为10s内点击5次

commit 03cd37229ee6c606e9814af602709d81b2c79bec
Merge: cf7cafef adcbaa17
Author: zkk <1007518571@qq.com>
Date:   Fri Jan 17 14:38:18 2025 +0800

    Merge commit 'adcbaa1795bffedc3000bc9e59eabba04d946dd4' into release

commit adcbaa1795bffedc3000bc9e59eabba04d946dd4
Author: zkk <1007518571@qq.com>
Date:   Tue Jan 14 15:34:10 2025 +0800

    实现探针偏移值校准保存前范围检测,避免保存错误值无法启动问题

commit cf7cafefbcd2274c9a481e58042d11db8cd79961
Merge: dc3478b4 8d259cea
Author: zkk <1007518571@qq.com>
Date:   Tue Jan 7 17:26:59 2025 +0800

    Merge commit '8d259ceadd5026cecc1dc61224d91aef4f3877b4' into release

commit 8d259ceadd5026cecc1dc61224d91aef4f3877b4
Author: zkk <1007518571@qq.com>
Date:   Tue Jan 7 17:15:46 2025 +0800

    实现 打印中恢复喷头温度 提示语的翻译

commit dd11c9683cb5af5407e650eea9b683b1066256c7
Author: zkk <1007518571@qq.com>
Date:   Tue Jan 7 16:52:04 2025 +0800

    优化单个喷头时不显示喷头偏移菜单

commit c3ec7a81bbe1490b76202485d0502a4829a3cee5
Author: zkk <1007518571@qq.com>
Date:   Fri Jan 3 17:52:24 2025 +0800

    修复屏幕耗材检测显示偶尔不准确的问题

commit 413bf6fc4a740f53d265c63abe7c51eaad483cb0
Author: zkk <1007518571@qq.com>
Date:   Fri Jan 3 15:00:54 2025 +0800

    修复耗材检测弹窗异常问题

commit dc3478b48c7da1dbae120d1270c9ab64646d6647
Merge: 02c7556c 3bfc1aa7
Author: zkk <1007518571@qq.com>
Date:   Thu Jan 2 11:18:07 2025 +0800

    Merge commit '3bfc1aa714e282d74b801155d830377ca58d8f59' into release

commit 3bfc1aa714e282d74b801155d830377ca58d8f59
Author: zkk <1007518571@qq.com>
Date:   Thu Jan 2 11:17:15 2025 +0800

    修复移轴页面移轴功能失效问题

commit 02c7556cdadf8de1ef3c54d2831920927cadbe30
Merge: 6bfa42e0 991003e6
Author: zkk <1007518571@qq.com>
Date:   Tue Dec 31 15:07:54 2024 +0800

    Merge commit '991003e6cbea335eca73d3783aa1837059614724' into release

commit 991003e6cbea335eca73d3783aa1837059614724
Author: zkk <1007518571@qq.com>
Date:   Tue Dec 31 15:03:34 2024 +0800

    优化完整 简体中文和繁体中文的翻译

commit 1a177e90d09b9b9949bff2a1e3c6b12173420620
Author: zkk <1007518571@qq.com>
Date:   Tue Dec 31 14:10:03 2024 +0800

    优化排除对象的英文语法错误

commit e8d509cb6c2883b1fadb5ab9f9ca658e61849055
Author: zkk <1007518571@qq.com>
Date:   Fri Dec 27 16:40:52 2024 +0800

    优化耗材检测显示内容

commit 1b7670485a918cb334119175777525f768e670be
Author: zkk <1007518571@qq.com>
Date:   Fri Dec 27 14:56:25 2024 +0800

    完善断料自动切头功能描述

commit ecc0c3dd16442497e56f5f8ab3a0c6be00bd180e
Author: zkk <1007518571@qq.com>
Date:   Fri Dec 27 13:40:01 2024 +0800

    实现弹窗翻译功能

commit bc6d60fa183af50b7b16fea685139ca9d5df90ea
Author: zkk <1007518571@qq.com>
Date:   Fri Dec 27 09:53:16 2024 +0800

    优化不合理名称和不合理大小写

commit 2e650926bdba1c65baa506be1b1dd09621e8d8ea
Author: zkk <1007518571@qq.com>
Date:   Thu Dec 26 15:06:11 2024 +0800

    修复10寸屏幕偏移值微调页面出界问题

commit c481b551f777a3a6cadf7be3bfcab38448b51694
Author: zkk <1007518571@qq.com>
Date:   Wed Dec 25 15:28:26 2024 +0800

    优化移轴设置页面没有返回按钮的问题

commit 2b3c9936bd693c8fc265d6352799f382680f4920
Author: zkk <1007518571@qq.com>
Date:   Wed Dec 25 10:05:04 2024 +0800

    删除移动设置页面中轴反转的选项

commit 5e37d59497c54086d3f1e215cbabc03254857a58
Author: zkk <1007518571@qq.com>
Date:   Wed Dec 25 09:05:03 2024 +0800

    优化选择语言标题

commit 5214c3697baac78bd0a465e33d6f4f3c1e30862e
Author: zkk <1007518571@qq.com>
Date:   Tue Dec 24 10:57:41 2024 +0800

    增加设置hostname功能

commit 3709a7465cc2e0d677ecc9979fb18144f7e0ec33
Author: zkk <1007518571@qq.com>
Date:   Tue Dec 24 10:43:46 2024 +0800

    增加工厂设置中打包模式

commit 0c2a2618beb68d50601e433beef06122fb0ffd40
Author: zkk <1007518571@qq.com>
Date:   Mon Dec 23 16:25:37 2024 +0800

    实现恢复出厂设置功能

commit e3a38f85613d53a4a063e835c34c701196010c6e
Author: zkk <1007518571@qq.com>
Date:   Mon Dec 23 15:48:17 2024 +0800

    一点格式化

commit 4e9e452e8bed4b53eaaae8f0a69142de8aa50611
Author: zkk <1007518571@qq.com>
Date:   Sat Dec 21 14:20:22 2024 +0800

    优化探针偏移值校准时如果当前激活为第一个喷头时不会重复激活喷头

commit 3b85e8e8d59b0d4eae75f80d9e637fe9dc272cbe
Merge: 882850db 10ec2029
Author: zkk <1007518571@qq.com>
Date:   Wed Dec 18 17:26:08 2024 +0800

    Merge branch 'develop' of https://server.creatbot.com/Gitea/CreatBot/CreatBotKlipperScreen into develop

commit 882850dbde648598e5f91281101d0ea01fd56d56
Author: zkk <1007518571@qq.com>
Date:   Wed Dec 18 17:21:16 2024 +0800

    补充双喷头偏移校准页面二维码图片

commit 10ec2029eb73e66874d5a0ec492c016480641110
Author: ruipeng <1041589370@qq.com>
Date:   Wed Dec 18 17:17:18 2024 +0800

    增加自动切换喷头开关选项

commit 3d6eed9d9526b77472ba7df29014b5768c594026
Author: zkk <1007518571@qq.com>
Date:   Mon Dec 16 16:33:34 2024 +0800

    喷头偏移值校准功能的实现

commit 40ecbb3ea4827c9bac1aa271cccc958c94c1114a
Author: zkk <1007518571@qq.com>
Date:   Fri Dec 13 09:20:00 2024 +0800

    z探针校准时指定默认激活工具头为第一个头

commit bce3caa409618ef5bc2067865940d14a1441c0f8
Author: zkk <1007518571@qq.com>
Date:   Fri Dec 13 09:19:19 2024 +0800

    优化z探针校准时候移动过慢问题

commit 6bfa42e036a521c8ff7db1bf8ccb65500eabb6ea
Merge: 1a87ced3 4f3aa9aa
Author: zkk <1007518571@qq.com>
Date:   Thu Dec 12 10:33:58 2024 +0800

    Merge commit '4f3aa9aa4c581ae9e7a740bd37f9e80ba064c27f' into release

commit 4f3aa9aa4c581ae9e7a740bd37f9e80ba064c27f
Merge: e3fd413d 1a69b518
Author: zkk <1007518571@qq.com>
Date:   Thu Dec 12 10:30:00 2024 +0800

    Merge branch 'develop' of https://server.creatbot.com/Gitea/CreatBot/CreatBotKlipperScreen into develop

commit 1a69b5180de733f15550a1294a7221d6070306a0
Author: ruipeng <1041589370@qq.com>
Date:   Wed Dec 11 11:44:36 2024 +0800

    新增D600pro2、D1000的V0版机型

commit e3fd413d6256414441e9fe653c1132b1799a5cb2
Author: zkk <1007518571@qq.com>
Date:   Tue Dec 10 14:34:13 2024 +0800

    修复打印时没有修改z偏移值 仍提示保存z偏移的按钮的bug

commit 594fb668fe94fe907c028bf65ecced43ea8660cb
Author: zkk <1007518571@qq.com>
Date:   Tue Dec 10 14:25:04 2024 +0800

    设置自适应调平选项默认为关闭状态

commit 1a87ced3f5725569a6b9a7ee5f5250044d01d852
Merge: 629416d1 6064a6e1
Author: zkk <1007518571@qq.com>
Date:   Fri Nov 29 10:18:32 2024 +0800

    Merge branch 'develop' into release

# Conflicts:
#	ks_includes/locales/KlipperScreen.pot   resolved by 69bcfa4bd00fc1af8da8df191b6a4d86309c7d23 version
#	ks_includes/locales/zh_CN/LC_MESSAGES/KlipperScreen.mo   resolved by 69bcfa4bd00fc1af8da8df191b6a4d86309c7d23 version
#	ks_includes/locales/zh_CN/LC_MESSAGES/KlipperScreen.po   resolved by 69bcfa4bd00fc1af8da8df191b6a4d86309c7d23 version
#	ks_includes/locales/zh_TW/LC_MESSAGES/KlipperScreen.mo   resolved by 69bcfa4bd00fc1af8da8df191b6a4d86309c7d23 version
#	ks_includes/locales/zh_TW/LC_MESSAGES/KlipperScreen.po   resolved by 69bcfa4bd00fc1af8da8df191b6a4d86309c7d23 version
#	panels/factory_settings.py   resolved by 69bcfa4bd00fc1af8da8df191b6a4d86309c7d23 version
#	panels/network.py   resolved by 69bcfa4bd00fc1af8da8df191b6a4d86309c7d23 version
2025-03-03 15:28:36 +08:00

418 lines
15 KiB
Python

# This is the backend of the UI panel that communicates to sdbus-networkmanager
# TODO device selection/swtichability
# Alfredo Monclus (alfrix) 2024
import subprocess
import logging
import sdbus
from sdbus_block.networkmanager import (
NetworkManager,
NetworkDeviceGeneric,
NetworkDeviceWireless,
NetworkConnectionSettings,
NetworkManagerSettings,
AccessPoint,
NetworkManagerConnectionProperties,
IPv4Config,
ActiveConnection,
enums,
exceptions,
)
from gi.repository import GLib
from uuid import uuid4
NONE = 0 # The access point has no special security requirements.
PAIR_WEP40 = 1 # 40/64-bit WEP is supported for pairwise/unicast encryption.
PAIR_WEP104 = 2 # 104/128-bit WEP is supported for pairwise/unicast encryption.
PAIR_TKIP = 4 # TKIP is supported for pairwise/unicast encryption.
PAIR_CCMP = 8 # AES/CCMP is supported for pairwise/unicast encryption.
GROUP_WEP40 = 16 # 40/64-bit WEP is supported for group/broadcast encryption.
GROUP_WEP104 = 32 # 104/128-bit WEP is supported for group/broadcast encryption.
GROUP_TKIP = 64 # TKIP is supported for group/broadcast encryption.
GROUP_CCMP = 128 # AES/CCMP is supported for group/broadcast encryption.
KEY_MGMT_PSK = 256 # WPA/RSN Pre-Shared Key encryption
KEY_MGMT_802_1X = 512 # 802.1x authentication and key management
KEY_MGMT_SAE = 1024 # WPA/RSN Simultaneous Authentication of Equals
KEY_MGMT_OWE = 2048 # WPA/RSN Opportunistic Wireless Encryption
KEY_MGMT_OWE_TM = 4096 # WPA/RSN Opportunistic Wireless Encryption transition mode
KEY_MGMT_EAP_SUITE_B_192 = 8192 # WPA3 Enterprise Suite-B 192
def get_encryption(flags):
if flags == 0:
return "Open"
encryption_mapping = {
PAIR_WEP40: "WEP",
PAIR_WEP104: "WEP",
PAIR_TKIP: "TKIP",
PAIR_CCMP: "AES",
GROUP_WEP40: "WEP",
GROUP_WEP104: "WEP",
GROUP_TKIP: "TKIP",
GROUP_CCMP: "AES",
KEY_MGMT_PSK: "WPA-PSK",
KEY_MGMT_802_1X: "802.1x",
KEY_MGMT_SAE: "WPA-SAE",
KEY_MGMT_OWE: "OWE",
KEY_MGMT_OWE_TM: "OWE-TM",
KEY_MGMT_EAP_SUITE_B_192: "WPA3-B192",
}
encryption_methods = []
for flag, method_name in encryption_mapping.items():
if flags & flag and method_name not in encryption_methods:
encryption_methods.append(method_name)
return " ".join(encryption_methods)
def WifiChannels(freq: str):
if freq == "2484":
return "2.4", "14"
try:
freq = float(freq)
except ValueError:
return "?", "?"
if 2412 <= freq <= 2472:
return "2.4", str(int((freq - 2407) / 5))
elif 3657.5 <= freq <= 3692.5:
return "3", str(int((freq - 3000) / 5))
elif 4915 <= freq <= 4980:
return "5", str(int((freq - 4000) / 5))
elif 5035 <= freq <= 5885:
return "5", str(int((freq - 5000) / 5))
elif 6455 <= freq <= 7115:
return "6", str(int((freq - 5950) / 5))
else:
return "?", "?"
class SdbusNm:
def __init__(self, popup_callback):
self.ensure_nm_running()
self.system_bus = sdbus.sd_bus_open_system() # We need system bus
if self.system_bus is None:
return None
sdbus.set_default_bus(self.system_bus)
self.nm = NetworkManager()
self.wlan_device = (
self.get_wireless_interfaces()[0]
if self.get_wireless_interfaces()
else None
)
self.wifi = self.wlan_device is not None
self.monitor_connection = False
self.wifi_state = -1
self.popup = popup_callback
def ensure_nm_running(self):
try:
status = subprocess.run(
["systemctl", "is-active", "--quiet", "NetworkManager"]
)
if status.returncode != 0:
raise RuntimeError("Failed to detect NetworkManager service")
except FileNotFoundError as e:
logging.exception(f"{e}")
raise RuntimeError(f"{e}") from e
def is_wifi_enabled(self):
return self.nm.wireless_enabled
def get_interfaces(self):
return [
NetworkDeviceGeneric(device).interface for device in self.nm.get_devices()
]
def get_wireless_interfaces(self):
devices = {path: NetworkDeviceGeneric(path) for path in self.nm.get_devices()}
return [
NetworkDeviceWireless(path)
for path, device in devices.items()
if device.device_type == enums.DeviceType.WIFI
]
def get_primary_interface(self):
if self.nm.primary_connection == "/":
if self.wlan_device:
return self.wlan_device.interface
return next(
(interface for interface in self.get_interfaces() if interface != "lo"),
None,
)
gateway = ActiveConnection(self.nm.primary_connection).devices[0]
return NetworkDeviceGeneric(gateway).interface
@staticmethod
def get_known_networks():
known_networks = []
saved_network_paths = NetworkManagerSettings().list_connections()
for netpath in saved_network_paths:
saved_con = NetworkConnectionSettings(netpath)
con_settings = saved_con.get_settings()
if con_settings["connection"]["type"][1] == "802-11-wireless":
known_networks.append(
{
"SSID": con_settings["802-11-wireless"]["ssid"][1].decode(),
"UUID": con_settings["connection"]["uuid"][1],
}
)
return known_networks
def is_known(self, ssid):
return any(net["SSID"] == ssid for net in self.get_known_networks())
def get_ip_address(self):
active_connection_path = self.nm.primary_connection
if not active_connection_path or active_connection_path == "/":
return "?"
active_connection = ActiveConnection(active_connection_path)
ip_info = IPv4Config(active_connection.ip4_config)
return ip_info.address_data[0]["address"][1]
def get_networks(self):
networks = []
try:
if self.wlan_device:
seen_networks = {}
all_aps = [AccessPoint(result) for result in self.wlan_device.access_points]
for ap in all_aps:
if not ap.ssid:
continue
ssid = ap.ssid.decode("utf-8")
signal_level = ap.strength
if ssid in seen_networks:
if signal_level > seen_networks[ssid]["signal_level"]:
seen_networks[ssid] = {
"SSID": ssid,
"known": self.is_known(ssid),
"security": get_encryption(ap.rsn_flags or ap.wpa_flags or ap.flags),
"signal_level": signal_level,
"BSSID": ap.hw_address,
}
else:
seen_networks[ssid] = {
"SSID": ssid,
"known": self.is_known(ssid),
"security": get_encryption(ap.rsn_flags or ap.wpa_flags or ap.flags),
"signal_level": signal_level,
"BSSID": ap.hw_address,
}
networks = list(seen_networks.values())
return sorted(networks, key=lambda i: i["signal_level"], reverse=True)
return networks
except Exception as e:
return networks
def get_bssid_from_ssid(self, ssid):
return next(net["BSSID"] for net in self.get_networks() if ssid == net["SSID"])
def get_is_connected(self):
state = self.wlan_device.state
if state in [
enums.DeviceState.ACTIVATED,
]:
return True
else:
return False
def get_connected_ap(self):
if self.wlan_device.active_access_point == "/":
return None
return AccessPoint(self.wlan_device.active_access_point)
def get_connected_bssid(self):
return (
self.get_connected_ap().hw_address
if self.get_connected_ap() is not None
else None
)
def get_signal_strength(self):
ap = self.get_connected_ap()
return ap.strength if ap else None
def get_security_type(self, ssid):
return next(
(
network["security"]
for network in self.get_networks()
if network["SSID"] == ssid
),
None,
)
def add_network(self, ssid, psk, eap_method, identity="", phase2=None):
security_type = self.get_security_type(ssid)
logging.debug(f"Adding network of type: {security_type}")
if security_type is None:
return {"error": "network_not_found", "message": _("Network not found")}
if self.is_known(ssid):
self.delete_network(ssid)
properties: NetworkManagerConnectionProperties = {
"connection": {
"id": ("s", ssid),
"uuid": ("s", str(uuid4())),
"type": ("s", "802-11-wireless"),
"interface-name": ("s", self.wlan_device.interface),
},
"802-11-wireless": {
"mode": ("s", "infrastructure"),
"ssid": ("ay", ssid.encode("utf-8")),
"security": ("s", "802-11-wireless-security"),
},
"ipv4": {"method": ("s", "auto")},
"ipv6": {"method": ("s", "auto")},
}
if security_type == "Open":
properties["802-11-wireless"]["security"] = ("s", "none")
elif "WPA-PSK" in security_type:
properties["802-11-wireless-security"] = {
"key-mgmt": ("s", "wpa-psk"),
"psk": ("s", psk),
}
elif "SAE" in security_type:
properties["802-11-wireless-security"] = {
"key-mgmt": ("s", "sae"),
"psk": ("s", psk),
}
elif "WPA3-B192" in security_type:
properties["802-11-wireless-security"] = {
"key-mgmt": ("s", "wpa-eap-suite-b-192"),
"psk": ("s", psk),
}
elif "OWE" in security_type:
properties["802-11-wireless-security"] = {
"key-mgmt": ("s", "owe"),
}
elif "802.1x" in security_type:
properties["802-11-wireless-security"] = {
"key-mgmt": ("s", "wpa-eap"),
"eap": ("as", [eap_method]),
"identity": ("s", identity),
"password": ("s", psk),
}
if phase2:
properties["802-11-wireless-security"]["phase2_auth"] = ("s", phase2)
elif "WEP" in security_type:
properties["802-11-wireless-security"] = {
"key-mgmt": ("s", "none"),
"wep-key-type": ("u", 2),
"wep-key0": ("s", psk),
"auth-alg": ("s", "shared"),
}
else:
return {
"error": "unknown_security_type",
"message": _("Unknown security type"),
}
try:
NetworkManagerSettings().add_connection(properties)
return {"status": "success"}
except exceptions.NmSettingsPermissionDeniedError:
logging.exception("Insufficient privileges")
return {
"error": "insufficient_privileges",
"message": _("Insufficient privileges"),
}
except exceptions.NmConnectionInvalidPropertyError:
logging.exception("Invalid property")
return {"error": "psk_invalid", "message": _("Invalid password")}
except Exception as e:
logging.exception("Couldn't add network")
return {"error": "unknown", "message": _("Couldn't add network") + f"\n{e}"}
def disconnect_network(self):
self.wlan_device.disconnect()
def delete_network(self, ssid):
if path := self.get_connection_path_by_ssid(ssid):
self.delete_connection_path(path)
else:
logging.debug(f"SSID '{ssid}' not found among saved connections")
def delete_connection_path(self, path):
try:
NetworkConnectionSettings(path).delete()
logging.info(f"Deleted connection path: {path}")
except Exception as e:
logging.exception(f"Failed to delete connection path: {path} - {e}")
return {
"error": "deletion_failed",
"message": _("Failed to delete connection") + f"\n{e}",
}
def rescan(self):
try:
return self.wlan_device.request_scan({})
except Exception as e:
self.popup(f"Unexpected error: {e}")
def get_connection_path_by_ssid(self, ssid):
existing_networks = NetworkManagerSettings().list_connections()
for connection_path in existing_networks:
connection_settings = NetworkConnectionSettings(
connection_path
).get_settings()
if (
connection_settings.get("802-11-wireless")
and connection_settings["802-11-wireless"].get("ssid")
and connection_settings["802-11-wireless"]["ssid"][1].decode() == ssid
):
return connection_path
return None
def connect(self, ssid):
if target_connection := self.get_connection_path_by_ssid(ssid):
try:
active_connection = self.nm.activate_connection(target_connection)
return target_connection
except Exception as e:
logging.exception("Unexpected error")
self.popup(f"Unexpected error: {e}")
else:
self.popup(f"SSID '{ssid}' not found among saved connections")
def toggle_wifi(self, enable):
self.nm.wireless_enabled = enable
def monitor_connection_status(self):
state = self.wlan_device.state
if self.wifi_state != state:
logging.debug(f"State changed: {state} {self.wlan_device.state_reason}")
if self.wifi_state == -1:
logging.debug("Starting to monitor state")
elif state in [
enums.DeviceState.PREPARE,
enums.DeviceState.CONFIG,
]:
self.popup(_("Connecting"), 1)
elif state in [
enums.DeviceState.IP_CONFIG,
enums.DeviceState.IP_CHECK,
enums.DeviceState.SECONDARIES,
]:
self.popup(_("Getting IP address"), 1)
elif state in [
enums.DeviceState.ACTIVATED,
]:
self.popup(_("Network connected"), 1)
elif state in [
enums.DeviceState.DISCONNECTED,
enums.DeviceState.DEACTIVATING,
]:
self.popup(_("Network disconnected"))
elif state == enums.DeviceState.FAILED:
self.popup(_("Connection failed"))
self.wifi_state = state
return self.monitor_connection
def enable_monitoring(self, enable):
self.monitor_connection = enable