9 Commits

Author SHA1 Message Date
18e6fb3d14 feat(revpiconfig): Enhance Wi-Fi detection and add rfkill index support
Improved logic to detect built-in and third-party Wi-Fi interfaces,
including integration of `rfkill` index retrieval for Wi-Fi devices.
This enhances support for various hardware setups and allows better
control over Wi-Fi functionality.
2025-04-21 09:05:47 +02:00
fe614d026a feat(dbus): Add support for configuring 'revpi-con-can' feature
Introduce the `configure_con_can` function to manage enabling,
disabling, status checking, and availability of the 'revpi-con-can'
feature. Update the `AVAILABLE_FEATURES` dictionary to integrate
'revpi-con-can' as a configurable feature.
2025-04-21 09:05:47 +02:00
870a55042e feat(dbus): Add support for configuring the external antenna
Introduce the `configure_external_antenna` function to manage external
antenna settings, including enable, disable, and status checks. Update
the feature configuration in `interface_config` to include this
functionality. This enhances WiFi-related configuration options.
2025-04-21 09:05:47 +02:00
2848fdcf54 feat(revpiconfig): Add ConfigTxt class for managing config.txt file
Introduced the ConfigTxt class to handle parsing, editing, and saving of
config.txt files. This includes methods for adding, clearing, and
retrieving configuration values, as well as handling dtoverlays and
dtparams. Enhanced system configuration capabilities by providing
structured support for config file operations.
2025-04-21 09:05:47 +02:00
d0f641f2b5 feat(dbus): Add dphys-swapfile configuration functionality
Implemented `configure_dphys_swapfile` to manage the dphys-swapfile
service, including automatic swapfile removal when the service is
disabled. Updated feature registry to support dphys-swapfile
configuration.
2025-04-21 09:05:47 +02:00
e8eba43647 feat(dbus): Add avahi-daemon configuration to system services
Introduce a `configure_avahi_daemon` function to manage the avahi-daemon
service and socket with proper post actions. Update the interface
configuration to enable avahi management using the new function.
2025-04-21 09:05:47 +02:00
0d601f623c feat(dbus): Remove 'var-log.mount' feature
The 'var-log.mount' feature was dropped and has been removed from
the AVAILABLE_FEATURES dictionary.
2025-04-21 09:05:47 +02:00
66735a9eba refactor(dbus): Move system configuration methods to revpi_config.py
Centralized `ConfigActions`, `configure_gui`, and `simple_systemd` into
`revpi_config.py` to eliminate duplication and improve maintainability.
Updated `interface_config.py` to import these methods, ensuring
consistent functionality across modules.
2025-04-21 09:05:47 +02:00
7525c9f653 feat(revpiconfig): Add RevPiConfig class for device information handling
This commit introduces a new `RevPiConfig` class to manage RevPi device
configuration details, such as model, serial, compute module type, WiFi,
and ConBridge detection. It parses CPU info from `/proc/cpuinfo` and
leverages helper methods for hardware-specific checks, enhancing the
middleware's ability to identify and manage hardware features.
2025-04-21 09:05:46 +02:00

View File

@@ -6,10 +6,11 @@ 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
from typing import List
from os.path import exists, join
from typing import List, Optional
from pydbus import SystemBus
@@ -19,6 +20,7 @@ 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")
@@ -45,6 +47,8 @@ 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 = ""
@@ -81,8 +85,26 @@ class RevPiConfig:
# Detect WiFi on CM module
could_have_wifi = self._cm_type in (ComputeModuleTypes.CM4, ComputeModuleTypes.CM5)
if could_have_wifi:
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)
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
# Detect ConBridge
could_have_con_bridge = self._cm_type in (ComputeModuleTypes.CM3, ComputeModuleTypes.CM4S)
@@ -94,6 +116,10 @@ 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
@@ -331,6 +357,8 @@ 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()