Yeah, it’s complicated because D-Bus is complex.
Proxy and peer are D-Bus entities. You can get yourself familiar with them in the d-bus tutorial.
As for how to use a d-bus object:
let main () =
(* Create a bus *)
let bus = OBus_bus.system () in
(* Create a proxy for your object *)
let proxy = OBus_proxy.make ~peer:(...) ~path:["org"; "path"; "to"; "object"] in
(* Call methods via OBus_method *)
let _ = OBus_method.call m_MethodName proxy argument
(* Get or set the property values via OBus_property *)
let property = OBus_property.make p_PropName proxy in
let _ = OBus_property.get property in
(* Attach callbacks to signalls using OBus_signal *)
let signal = OBus_signal.make s_SignalName proxy in
OBus_signal.connect signal >>= fun react_signal ->
(* here you have a React signal which you can attach to *)
All you need is to generate OCaml interface out of D-Bus’s XML description using
obus-gen-interface, it’ll generate an
ml file representing D-Bus object’s interface and containing fields lime
p_PropertyName for each method, property, signal etc.
Then you can call these using interfaces from this set of modules. These contains comments, you mostly need only OBus_method, OBus_signal and OBus_property.
What is the difference between
The former is the type representing signal you can attach to and work with, the latter represents a member of the D-Bus object’s interface encapsulating information needed to work with the signal (address, arguments’ types etc).
OBus_member types are representing various members of object’s interface: methods, signals, properties. You work with these members using corresponding modules from
protocol. I.e. you use
OBus_method module to would with a field of type
make_any seems very similar to
make but a
OBus_peer.t is its second argument… and it creates an
(OBus_proxy.t * 'a) t .
Proxy represents an object. Peer represents an application, which can have various objects.
OBus_signal.make_any create a signal not for an object, but for all objects of the Peer. Signal returns then not only a value, but also an object which signaled it.