thermometer: Append version to Thermometer interfaces

This commit is contained in:
Luiz Augusto von Dentz 2012-12-14 11:12:59 +02:00 committed by Johan Hedberg
parent 942fe3bb79
commit ce25879be4
4 changed files with 17 additions and 12 deletions

View File

@ -7,7 +7,7 @@ Health Thermometer Manager hierarchy
====================================
Service org.bluez
Interface org.bluez.ThermometerManager
Interface org.bluez.ThermometerManager1
Object path [variable prefix]/{hci0,hci1,...}
Methods RegisterWatcher(object agent)
@ -44,7 +44,7 @@ Health Thermometer Profile hierarchy
====================================
Service org.bluez
Interface org.bluez.Thermometer
Interface org.bluez.Thermometer1
Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
@ -77,7 +77,7 @@ Health Thermometer Watcher hierarchy
====================================
Service unique name
Interface org.bluez.ThermometerWatcher
Interface org.bluez.ThermometerWatcher1
Object path freely definable
Methods void MeasurementReceived(dict measurement)

View File

@ -42,9 +42,9 @@
#include "attrib/gatt.h"
#include "thermometer.h"
#define THERMOMETER_INTERFACE "org.bluez.Thermometer"
#define THERMOMETER_MANAGER_INTERFACE "org.bluez.ThermometerManager"
#define THERMOMETER_WATCHER_INTERFACE "org.bluez.ThermometerWatcher"
#define THERMOMETER_INTERFACE "org.bluez.Thermometer1"
#define THERMOMETER_MANAGER_INTERFACE "org.bluez.ThermometerManager1"
#define THERMOMETER_WATCHER_INTERFACE "org.bluez.ThermometerWatcher1"
/* Temperature measurement flag fields */
#define TEMP_UNITS 0x01

View File

@ -15,7 +15,7 @@
<allow send_interface="org.bluez.MediaEndpoint1"/>
<allow send_interface="org.bluez.MediaPlayer1"/>
<allow send_interface="org.bluez.Watcher"/>
<allow send_interface="org.bluez.ThermometerWatcher"/>
<allow send_interface="org.bluez.ThermometerWatcher1"/>
<allow send_interface="org.bluez.AlertAgent"/>
<allow send_interface="org.bluez.Profile1"/>
<allow send_interface="org.bluez.HeartRateWatcher1"/>

View File

@ -15,8 +15,13 @@ import dbus.mainloop.glib
from optparse import OptionParser, make_option
import bluezutils
BUS_NAME = 'org.bluez'
THERMOMETER_MANAGER_INTERFACE = 'org.bluez.ThermometerManager1'
THERMOMETER_WATCHER_INTERFACE = 'org.bluez.ThermometerWatcher1'
THERMOMETER_INTERFACE = 'org.bluez.Thermometer1'
class Watcher(dbus.service.Object):
@dbus.service.method("org.bluez.ThermometerWatcher",
@dbus.service.method(THERMOMETER_WATCHER_INTERFACE,
in_signature="oa{sv}", out_signature="")
def MeasurementReceived(self, device, measure):
print("%s measurement received from %s" % (measure["Measurement"], device))
@ -31,7 +36,7 @@ class Watcher(dbus.service.Object):
print("Type: ", measure["Type"])
def properties_changed(interface, changed, invalidated):
if interface != "org.bluez.Thermometer":
if interface != THERMOMETER_INTERFACE:
return
for name, value in changed.iteritems():
print("Property %s changed: %s" % (name, str(value)))
@ -63,15 +68,15 @@ if __name__ == "__main__":
options.adapter)
adapter_path = adapter.object_path
thermometer_manager = dbus.Interface(bus.get_object("org.bluez",
adapter_path), "org.bluez.ThermometerManager")
thermometer_manager = dbus.Interface(bus.get_object(BUS_NAME,
adapter_path), THERMOMETER_MANAGER_INTERFACE)
device = bluezutils.find_device_in_objects(managed_objects,
options.address,
options.adapter)
device_path = device.object_path
bus.add_signal_receiver(properties_changed, bus_name="org.bluez",
bus.add_signal_receiver(properties_changed, bus_name=BUS_NAME,
path=device_path,
dbus_interface="org.freedesktop.DBus.Properties",
signal_name="PropertiesChanged")