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.
This commit is contained in:
@@ -198,6 +198,34 @@ def configure_avahi_daemon(action: ConfigActions):
|
||||
return return_value
|
||||
|
||||
|
||||
def configure_con_can(action: ConfigActions):
|
||||
revpi = RevPiConfig()
|
||||
if action is ConfigActions.AVAILABLE:
|
||||
return revpi.with_con_bridge
|
||||
|
||||
dt_overlay = "revpi-con-can"
|
||||
config_txt = ConfigTxt()
|
||||
|
||||
if action is ConfigActions.ENABLE and revpi.with_con_bridge:
|
||||
config_txt.clear_dtoverlays([dt_overlay])
|
||||
config_txt.add_name_value("dtoverlay", dt_overlay)
|
||||
config_txt.save_config()
|
||||
subprocess.call(["/usr/bin/dtoverlay", dt_overlay])
|
||||
|
||||
elif action is ConfigActions.DISABLE and revpi.with_con_bridge:
|
||||
config_txt.clear_dtoverlays([dt_overlay])
|
||||
config_txt.save_config()
|
||||
subprocess.call(["/usr/bin/dtoverlay", "-r", dt_overlay])
|
||||
|
||||
elif action is ConfigActions.STATUS:
|
||||
return revpi.with_con_bridge and dt_overlay in config_txt.get_values("dtparam")
|
||||
|
||||
else:
|
||||
raise ValueError(f"action {action} not supported")
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def configure_dphys_swapfile(action: ConfigActions):
|
||||
return_value = simple_systemd(action, "dphys-swapfile.service")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user