@@ -21,7 +21,7 @@
#include "mesh/error.h"
#include "mesh/dbus.h"
-static struct l_dbus *dbus;
+static struct l_dbus *dbus = NULL;
struct error_entry {
const char *dbus_err;
@@ -75,6 +75,11 @@ struct l_dbus_message *dbus_error(struct l_dbus_message *msg, int err,
"%s", error_table[err].default_desc);
}
+void dbus_set_bus(struct l_dbus *bus)
+{
+ dbus = bus;
+}
+
struct l_dbus *dbus_get_bus(void)
{
return dbus;
@@ -82,6 +87,9 @@ struct l_dbus *dbus_get_bus(void)
bool dbus_init(struct l_dbus *bus)
{
+ if (dbus != bus)
+ return false;
+
/* Network interface */
if (!mesh_dbus_init(bus))
return false;
@@ -14,6 +14,7 @@
#define DEFAULT_DBUS_TIMEOUT 30
bool dbus_init(struct l_dbus *dbus);
+void dbus_set_bus(struct l_dbus *bus);
struct l_dbus *dbus_get_bus(void);
void dbus_append_byte_array(struct l_dbus_message_builder *builder,
const uint8_t *data, int len);
@@ -278,6 +278,8 @@ int main(int argc, char *argv[])
goto done;
}
+ dbus_set_bus(dbus);
+
if (dbus_debug)
l_dbus_set_debug(dbus, do_debug, "[DBUS] ", NULL);
l_dbus_set_ready_handler(dbus, ready_callback, dbus, NULL);