SimpleDBus
Architecture
How SimpleDBus models D-Bus interfaces and proxies in C++, including property storage and the automatic handling of org.freedesktop.DBus.Properties.
The following notes provide an overview of the architecture of some of the higher-level classes in the library, as to facilitate their understanding.
Interface
- In order to simplify the routing of messages, all interfaces are assumed to have properties, thus skipping the need to have a special implementation of
org.freedesktop.DBus.Properties. - All properties are stored in the holder in which they came from. This is not the most efficient way of handling properties, but it is the one that minimizes the necessary code for children of the
Interfaceclass.
Proxy
- Messages for
org.freedesktop.DBus.Propertiesare automatically handled by theProxyclass. Proxy::valid()tracks whether the proxy's object path is currently present in the D-Bus object tree. When all interfaces of an object path are removed, the corresponding proxy and all retained descendant proxies are marked invalid. Removing only some of its interfaces leaves it valid. If the path is later added again, the same retained proxy can become valid again.- Interfaces a proxy declares in
on_registration()count as present until the bus removes them, so a proxy only declares interfaces that its remote object always exports. - A retained
Proxyobject should not be treated as proof that the remote D-Bus object still exists. Callers that keep proxy references acrossInterfacesRemovedevents should checkvalid()before issuing methods or refreshing state.
Examples
Where to find the SimpleDBus examples, which show how to use SimpleDBus, the C++ D-Bus library that SimpleBluez builds on, from the SimpleBLE repository.
Usage
Install SimplePyBLE from PyPI or build it locally, and use SimpleBLE from Python with callbacks, error handling, GATT hosting, Dongl and Linux pairing, and asyncio.
