feat(dbus): Add initial D-Bus middleware implementation

Introduce a D-Bus middleware module for revpi_middleware, including an
interface definition and a `BusProvider` class to handle D-Bus
communication. This forms the foundation for middleware interactions
using D-Bus.
This commit is contained in:
2025-04-18 14:12:14 +02:00
parent 11b68a0c15
commit b442369b42
2 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH
# SPDX-License-Identifier: GPL-2.0-or-later
"""D-Bus middleware version 1 of revpi_middleware."""
from ..__about__ import __author__, __copyright__, __license__, __version__
REVPI_DBUS_NAME = "com.revolutionpi.middleware1"
REVPI_DBUS_BASE_PATH = "/com/revolutionpi/middleware1"

View File

@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH
# SPDX-License-Identifier: GPL-2.0-or-later
"""D-Bus bus provider for revpi_middleware."""
from logging import getLogger
from threading import Thread
from gi.repository import GLib
from pydbus import SystemBus
from . import REVPI_DBUS_NAME
from .process_image import InterfacePiControl
log = getLogger(__name__)
class BusProvider(Thread):
def __init__(self):
log.debug("enter BusProvider.__init__")
super().__init__()
self._bus = SystemBus()
self._loop = GLib.MainLoop()
def run(self):
log.debug("enter BusProvider.run")
self._bus.publish(
REVPI_DBUS_NAME,
InterfacePiControl(),
)
self._loop.run()
log.debug("leave BusProvider.run")
def stop(self):
log.debug("enter BusProvider.stop")
self._loop.quit()
log.debug("leave BusProvider.stop")