Compare commits
8 Commits
18e6fb3d14
...
4155b9c706
| Author | SHA1 | Date | |
|---|---|---|---|
| 4155b9c706 | |||
| f9f50d7167 | |||
| e21a61232d | |||
| 8d8d3bbae4 | |||
| 1ae661a5e9 | |||
| ffdb27049e | |||
| 38f495e864 | |||
| 85dc6a7e56 |
@@ -6,11 +6,10 @@ import shutil
|
||||
import subprocess
|
||||
from collections import namedtuple
|
||||
from enum import Enum, IntEnum
|
||||
from glob import glob
|
||||
from logging import getLogger
|
||||
from os import X_OK, access
|
||||
from os.path import exists, join
|
||||
from typing import List, Optional
|
||||
from os.path import exists
|
||||
from typing import List
|
||||
|
||||
from pydbus import SystemBus
|
||||
|
||||
@@ -20,7 +19,6 @@ log = getLogger(__name__)
|
||||
|
||||
ConfigVariable = namedtuple("ConfigVariable", ["name", "value", "line_index"])
|
||||
|
||||
LINUX_WIFI_CLASS_PATH = "/sys/class/ieee80211"
|
||||
CONFIG_TXT_LOCATIONS = ("/boot/firmware/config.txt", "/boot/config.txt")
|
||||
|
||||
|
||||
@@ -47,8 +45,6 @@ class RevPiConfig:
|
||||
self._cm_with_wifi = False
|
||||
|
||||
self._revpi_with_con_bridge = False
|
||||
self._wlan_class_path = ""
|
||||
self._wlan_rfkill_index = None
|
||||
|
||||
self.serial = ""
|
||||
self.model = ""
|
||||
@@ -85,26 +81,8 @@ class RevPiConfig:
|
||||
# Detect WiFi on CM module
|
||||
could_have_wifi = self._cm_type in (ComputeModuleTypes.CM4, ComputeModuleTypes.CM5)
|
||||
if could_have_wifi:
|
||||
wifi_interface = join(LINUX_WIFI_CLASS_PATH, "phy0")
|
||||
lst_grep = grep("DRIVER=brcmfmac", join(wifi_interface, "device", "uevent"))
|
||||
self._cm_with_wifi = len(lst_grep) > 0
|
||||
self._wlan_class_path = wifi_interface
|
||||
|
||||
# If no build in Wi-Fi on the CM, detect third party Wi-Fi on RevPi Flat
|
||||
if not self._cm_with_wifi and grep("revpi-flat", "/proc/device-tree/compatible"):
|
||||
lst_wifi_interfaces = glob("/sys/class/ieee80211/*")
|
||||
for wifi_interface in lst_wifi_interfaces:
|
||||
if grep("DRIVER=mwifiex_sdio", join(wifi_interface, "device", "uevent")):
|
||||
self._cm_with_wifi = True
|
||||
self._wlan_class_path = wifi_interface
|
||||
|
||||
# Detect rfkill index of the integrated Wi-Fi device
|
||||
if self._wlan_class_path:
|
||||
for rfkill_path in glob(join(self._wlan_class_path, "rfkill*")):
|
||||
match_index = re.match(r"^/.+/rfkill(?P<index>\d+)$", rfkill_path)
|
||||
if match_index:
|
||||
self._wlan_rfkill_index = int(match_index.group("index"))
|
||||
break
|
||||
lst_grep = grep("DRIVER=brcmfmac", "/sys/class/ieee80211/phy0/device/uevent")
|
||||
self._cm_with_wifi = len(lst_grep) > 0 and self._cm_type in (ComputeModuleTypes)
|
||||
|
||||
# Detect ConBridge
|
||||
could_have_con_bridge = self._cm_type in (ComputeModuleTypes.CM3, ComputeModuleTypes.CM4S)
|
||||
@@ -116,10 +94,6 @@ class RevPiConfig:
|
||||
def cm_type(self) -> ComputeModuleTypes:
|
||||
return self._cm_type
|
||||
|
||||
@property
|
||||
def rfkill_index(self) -> Optional[int]:
|
||||
return self._wlan_rfkill_index
|
||||
|
||||
@property
|
||||
def with_con_bridge(self) -> bool:
|
||||
return self._revpi_with_con_bridge
|
||||
@@ -357,8 +331,6 @@ if __name__ == "__main__":
|
||||
print("Serial: ", rc.serial)
|
||||
print("CM Type: ", rc.cm_type.name)
|
||||
print("With wifi: ", rc.with_wifi)
|
||||
if rc.with_wifi:
|
||||
print(" rfkill index: ", rc.rfkill_index)
|
||||
print("With con-bridge:", rc.with_con_bridge)
|
||||
|
||||
config_txt = ConfigTxt()
|
||||
|
||||
Reference in New Issue
Block a user