Files
sunnypilot/system/ui/lib/networkmanager.py
T
Shane Smiskol 612c518dd6 WifiManager: signal-driven connection status (#37258)
* signal driven wifi state

* copy exactly

* copy signal handler

* remove is_connected

* Revert "remove is_connected"

This reverts commit f2246a70f4a29e9f3405947ca43d9404578c9d2d.

* do 3 network

* missing reason

* do wifiui

* clean up mici updater

* rest

* or not connecting

* clean up is_connected

* clean up wifiui

* match wifiui state more exactly in network panel for wifi button

* update active connection info after activation (used to do in _update_networks)

* clean up prints

* more

* rm

* not needed

* clean up state machine a bit

* more

* more

* indent

* final clean up

* debug

* debug

* wait for ip?

* more

* revert

* just to see

* ensure we emit activated even if we fail to get conn path from dbus

* hmm

* fine

* back

* back

* Revert "back"

This reverts commit 6464abe243c2a3bbf62b8f9a109b72ec3ddb3817.

* debug flickering on forget then connect to another. commit before this is good

* fix rare flicker when forgetting network and immediately connecting to
another

* clean up

* clean up router stuff now

* ugh wtf

* stash -- wtf

* Revert "stash -- wtf"

This reverts commit 756a92a9c0530a16917303424e26447f258f17e4.

* Revert "fix rare flicker when forgetting network and immediately connecting to"

This reverts commit 90c5fc14551726765ab2524e7866ee8b3c5dee7c.

* remove debug

* fix

* add issues

* add flow

* match previous behavior

* it doesn't fix the flikcer

* more atomic

* Revert "more atomic"

This reverts commit ead87c5a7a4030719b64138c12b9154ec82e73d9.

* last test!

last test!

* really the race is here?

* atomic wifi_state replace

* not slow

* clean up
2026-02-18 22:42:05 -08:00

61 lines
1.9 KiB
Python

from enum import IntEnum
# NetworkManager device states
class NMDeviceState(IntEnum):
# https://networkmanager.dev/docs/api/1.46/nm-dbus-types.html#NMDeviceState
UNKNOWN = 0
UNMANAGED = 10
UNAVAILABLE = 20
DISCONNECTED = 30
PREPARE = 40
CONFIG = 50
NEED_AUTH = 60
IP_CONFIG = 70
IP_CHECK = 80
SECONDARIES = 90
ACTIVATED = 100
DEACTIVATING = 110
FAILED = 120
class NMDeviceStateReason(IntEnum):
# https://networkmanager.dev/docs/api/1.46/nm-dbus-types.html#NMDeviceStateReason
NONE = 0
UNKNOWN = 1
NO_SECRETS = 7
SUPPLICANT_DISCONNECT = 8
CONNECTION_REMOVED = 38
NEW_ACTIVATION = 60
# NetworkManager constants
NM = "org.freedesktop.NetworkManager"
NM_PATH = '/org/freedesktop/NetworkManager'
NM_IFACE = 'org.freedesktop.NetworkManager'
NM_ACCESS_POINT_IFACE = 'org.freedesktop.NetworkManager.AccessPoint'
NM_SETTINGS_PATH = '/org/freedesktop/NetworkManager/Settings'
NM_SETTINGS_IFACE = 'org.freedesktop.NetworkManager.Settings'
NM_CONNECTION_IFACE = 'org.freedesktop.NetworkManager.Settings.Connection'
NM_ACTIVE_CONNECTION_IFACE = 'org.freedesktop.NetworkManager.Connection.Active'
NM_WIRELESS_IFACE = 'org.freedesktop.NetworkManager.Device.Wireless'
NM_PROPERTIES_IFACE = 'org.freedesktop.DBus.Properties'
NM_DEVICE_IFACE = 'org.freedesktop.NetworkManager.Device'
NM_IP4_CONFIG_IFACE = 'org.freedesktop.NetworkManager.IP4Config'
NM_DEVICE_TYPE_WIFI = 2
NM_DEVICE_TYPE_MODEM = 8
# https://developer.gnome.org/NetworkManager/1.26/nm-dbus-types.html#NM80211ApFlags
NM_802_11_AP_FLAGS_NONE = 0x0
NM_802_11_AP_FLAGS_PRIVACY = 0x1
NM_802_11_AP_FLAGS_WPS = 0x2
# https://developer.gnome.org/NetworkManager/1.26/nm-dbus-types.html#NM80211ApSecurityFlags
NM_802_11_AP_SEC_PAIR_WEP40 = 0x00000001
NM_802_11_AP_SEC_PAIR_WEP104 = 0x00000002
NM_802_11_AP_SEC_GROUP_WEP40 = 0x00000010
NM_802_11_AP_SEC_GROUP_WEP104 = 0x00000020
NM_802_11_AP_SEC_KEY_MGMT_PSK = 0x00000100
NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200