[PATCH RFC BlueZ 5/5] Add testing API to dummy Time Server provider

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The new TimeUpdated() is useful to test Current Time Characteristic
value notifications.
---
 time/provider-dummy.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/time/provider-dummy.c b/time/provider-dummy.c
index ba0744f..ab90f7b 100644
--- a/time/provider-dummy.c
+++ b/time/provider-dummy.c
@@ -23,20 +23,59 @@
  */
 
 #include <stdint.h>
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <gdbus.h>
 
 #include "server.h"
 #include "log.h"
 
+#define TIME_DUMMY_IFACE "org.bluez.TimeProviderTest"
+#define TIME_DUMMY_PATH "/org/bluez/test"
+
+static DBusConnection *connection = NULL;
+
+static DBusMessage *time_updated(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+	DBG("");
+
+	current_time_updated();
+
+	return dbus_message_new_method_return(msg);
+}
+
+static GDBusMethodTable dummy_methods[] = {
+	{ "TimeUpdated",	"",	"",	time_updated	},
+};
+
 int time_provider_init(void)
 {
 	DBG("");
 
+	connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+	if (g_dbus_register_interface(connection, TIME_DUMMY_PATH,
+					TIME_DUMMY_IFACE, dummy_methods, NULL,
+					NULL, NULL, NULL) == FALSE) {
+		error("time-dummy interface %s init failed on path %s",
+					TIME_DUMMY_IFACE, TIME_DUMMY_PATH);
+		dbus_connection_unref(connection);
+
+		return -1;
+	}
+
 	return 0;
 }
 
 void time_provider_exit(void)
 {
 	DBG("");
+
+	g_dbus_unregister_interface(connection, TIME_DUMMY_PATH,
+							TIME_DUMMY_IFACE);
+	dbus_connection_unref(connection);
+	connection = NULL;
 }
 
 void time_provider_status(uint8_t *state, uint8_t *result)
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux