Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v3 16/20] doc: Remove Get-/SetProperties from CSC API document
From: Andrzej Kaczmarek @ 2012-12-04 12:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1354625026-29358-1-git-send-email-andrzej.kaczmarek@tieto.com>

cyclingspeed plugin uses DBus.Properties instead of custom methods.
---
 doc/cycling-api.txt | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/doc/cycling-api.txt b/doc/cycling-api.txt
index adbcd33..08e11c8 100644
--- a/doc/cycling-api.txt
+++ b/doc/cycling-api.txt
@@ -28,31 +28,13 @@ Service		org.bluez
 Interface	org.bluez.CyclingSpeed
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
-Methods		void SetProperty(string name, variant value)
-
-			Changes the value of the specified property. Only
-			read-write properties can be changed. On success
-			this will emit a PropertyChanged signal.
-
-			Possible Errors: org.bluez.Error.InvalidArguments
-
-		dict GetProperties()
-
-			Returns all properties for the interface. See the
-			Properties section for the available properties.
-
-		SetCumulativeWheelRevolutions(uint32 value)
+Methods		SetCumulativeWheelRevolutions(uint32 value)
 
 			Sets cumulative wheel revolutions value if
 			Cumulative Wheel Revolutions feature is supported.
 
 			Possible Errors: org.bluez.Error.NotSupported
 
-Signals		PropertyChanged(string name, variant value)
-
-			This signal indicates a changed value of the given
-			property.
-
 Properties	string Location (optional) [readwrite]
 
 			Current sensor location, if supported.
-- 
1.8.0


^ permalink raw reply related

* [PATCH v3 17/20] doc: Rename cycling API to cyclingspeed
From: Andrzej Kaczmarek @ 2012-12-04 12:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1354625026-29358-1-git-send-email-andrzej.kaczmarek@tieto.com>

---
 doc/cycling-api.txt      | 100 -----------------------------------------------
 doc/cyclingspeed-api.txt | 100 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+), 100 deletions(-)
 delete mode 100644 doc/cycling-api.txt
 create mode 100644 doc/cyclingspeed-api.txt

diff --git a/doc/cycling-api.txt b/doc/cycling-api.txt
deleted file mode 100644
index 08e11c8..0000000
--- a/doc/cycling-api.txt
+++ /dev/null
@@ -1,100 +0,0 @@
-Cycling Speed and Cadence API description
-*****************************************
-
-Copyright (C) 2012	Tieto Poland
-
-Cycling Speed and Cadence Manager hierarchy
-===========================================
-
-Service		org.bluez
-Interface	org.bluez.CyclingSpeedManager
-Object path	[variable prefix]/{hci0,hci1,...}
-
-Methods		RegisterWatcher(object agent)
-
-			Registers a watcher to monitor cycling speed and
-			cadence measurements.
-
-			Possible Errors: org.bluez.Error.InvalidArguments
-
-		UnregisterWatcher(object agent)
-
-			Unregisters a watcher.
-
-Cycling Speed and Cadence Profile hierarchy
-===========================================
-
-Service		org.bluez
-Interface	org.bluez.CyclingSpeed
-Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
-
-Methods		SetCumulativeWheelRevolutions(uint32 value)
-
-			Sets cumulative wheel revolutions value if
-			Cumulative Wheel Revolutions feature is supported.
-
-			Possible Errors: org.bluez.Error.NotSupported
-
-Properties	string Location (optional) [readwrite]
-
-			Current sensor location, if supported.
-			If Multiple Sensor Locations feature is supported,
-			this property can be set to one of values read from
-			SupportedLocations property.
-
-			Possible values: "other", "top-of-shoe", "in-shoe",
-					"hip", "front-wheel", "left-crank",
-					"right-crank", "left-pedal",
-					"right-pedal", "front-hub",
-					"rear-dropout", "chainstay",
-					"rear-wheel", "rear-hub"
-
-		array{string} SupportedLocations (optional) [readonly]
-
-			List of locations supported by sensor, only present
-			if Multiple Sensor Locations feature is supported.
-
-		boolean WheelRevolutionDataSupported [readonly]
-
-			true if sensor can read and set Cumulative Wheel
-			Revolutions value, false otherwise.
-
-		boolean MultipleSensorLocationsSupported [readonly]
-
-			true if sensor supports Multiple Sensor Locations
-			feature and can set Location, false otherwise.
-
-Cycling Speed and Cadence Watcher hierarchy
-===========================================
-
-Service		unique name
-Interface	org.bluez.CyclingSpeedWatcher
-Object path	freely definable
-
-Methods		void MeasurementReceived(object device, dict measurement)
-
-			This callback is called whenever wheel and/or crank
-			revolutions measurement is received from sensor.
-
-			Measurement:
-
-				uint32 WheelRevolutions (optional):
-
-					Cumulative number of wheel revolutions.
-
-				uint16 LastWheelEventTime (optional):
-
-					Time of last event from wheel sensor.
-					Value is expressed in 1/1024 second
-					units and can roll over during a ride.
-
-				uint16 CrankRevolutions (optional):
-
-					Cumulative number of crank revolutions.
-					This value can occasionally roll over.
-
-				uint16 LastCrankEventTime (optional):
-
-					Time of last event from crank sensor.
-					Value is expressed in 1/1024 second
-					units and can roll over during a ride.
diff --git a/doc/cyclingspeed-api.txt b/doc/cyclingspeed-api.txt
new file mode 100644
index 0000000..08e11c8
--- /dev/null
+++ b/doc/cyclingspeed-api.txt
@@ -0,0 +1,100 @@
+Cycling Speed and Cadence API description
+*****************************************
+
+Copyright (C) 2012	Tieto Poland
+
+Cycling Speed and Cadence Manager hierarchy
+===========================================
+
+Service		org.bluez
+Interface	org.bluez.CyclingSpeedManager
+Object path	[variable prefix]/{hci0,hci1,...}
+
+Methods		RegisterWatcher(object agent)
+
+			Registers a watcher to monitor cycling speed and
+			cadence measurements.
+
+			Possible Errors: org.bluez.Error.InvalidArguments
+
+		UnregisterWatcher(object agent)
+
+			Unregisters a watcher.
+
+Cycling Speed and Cadence Profile hierarchy
+===========================================
+
+Service		org.bluez
+Interface	org.bluez.CyclingSpeed
+Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
+
+Methods		SetCumulativeWheelRevolutions(uint32 value)
+
+			Sets cumulative wheel revolutions value if
+			Cumulative Wheel Revolutions feature is supported.
+
+			Possible Errors: org.bluez.Error.NotSupported
+
+Properties	string Location (optional) [readwrite]
+
+			Current sensor location, if supported.
+			If Multiple Sensor Locations feature is supported,
+			this property can be set to one of values read from
+			SupportedLocations property.
+
+			Possible values: "other", "top-of-shoe", "in-shoe",
+					"hip", "front-wheel", "left-crank",
+					"right-crank", "left-pedal",
+					"right-pedal", "front-hub",
+					"rear-dropout", "chainstay",
+					"rear-wheel", "rear-hub"
+
+		array{string} SupportedLocations (optional) [readonly]
+
+			List of locations supported by sensor, only present
+			if Multiple Sensor Locations feature is supported.
+
+		boolean WheelRevolutionDataSupported [readonly]
+
+			true if sensor can read and set Cumulative Wheel
+			Revolutions value, false otherwise.
+
+		boolean MultipleSensorLocationsSupported [readonly]
+
+			true if sensor supports Multiple Sensor Locations
+			feature and can set Location, false otherwise.
+
+Cycling Speed and Cadence Watcher hierarchy
+===========================================
+
+Service		unique name
+Interface	org.bluez.CyclingSpeedWatcher
+Object path	freely definable
+
+Methods		void MeasurementReceived(object device, dict measurement)
+
+			This callback is called whenever wheel and/or crank
+			revolutions measurement is received from sensor.
+
+			Measurement:
+
+				uint32 WheelRevolutions (optional):
+
+					Cumulative number of wheel revolutions.
+
+				uint16 LastWheelEventTime (optional):
+
+					Time of last event from wheel sensor.
+					Value is expressed in 1/1024 second
+					units and can roll over during a ride.
+
+				uint16 CrankRevolutions (optional):
+
+					Cumulative number of crank revolutions.
+					This value can occasionally roll over.
+
+				uint16 LastCrankEventTime (optional):
+
+					Time of last event from crank sensor.
+					Value is expressed in 1/1024 second
+					units and can roll over during a ride.
-- 
1.8.0


^ permalink raw reply related

* [PATCH v3 18/20] build: Add CSCP API document to EXTRA_DIST
From: Andrzej Kaczmarek @ 2012-12-04 12:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1354625026-29358-1-git-send-email-andrzej.kaczmarek@tieto.com>

---
 Makefile.am | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index d009828..2e0e9b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -342,7 +342,8 @@ EXTRA_DIST += doc/manager-api.txt \
 		doc/sap-api.txt doc/media-api.txt doc/assigned-numbers.txt \
 		doc/supported-features.txt doc/alert-api.txt doc/mgmt-api.txt \
 		doc/oob-api.txt doc/proximity-api.txt doc/heartrate-api.txt \
-		doc/thermometer-api.txt doc/audio-telephony-design.txt
+		doc/thermometer-api.txt doc/audio-telephony-design.txt \
+		doc/cyclingspeed-api.txt
 
 AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@
 
-- 
1.8.0


^ permalink raw reply related

* [PATCH v3 19/20] test: Add cyclingspeed test script
From: Andrzej Kaczmarek @ 2012-12-04 12:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1354625026-29358-1-git-send-email-andrzej.kaczmarek@tieto.com>

---
 Makefile.tools         |   3 +-
 test/test-cyclingspeed | 124 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 126 insertions(+), 1 deletion(-)
 create mode 100755 test/test-cyclingspeed

diff --git a/Makefile.tools b/Makefile.tools
index 689b4d2..ded9faf 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -209,4 +209,5 @@ EXTRA_DIST += test/sap_client.py test/hsplay test/hsmicro \
 		test/test-health-sink test/service-record.dtd \
 		test/service-did.xml test/service-spp.xml test/service-opp.xml \
 		test/service-ftp.xml test/simple-player test/test-nap \
-		test/test-heartrate test/test-alert test/test-hfp
+		test/test-heartrate test/test-alert test/test-hfp \
+		test/test-cycling
diff --git a/test/test-cyclingspeed b/test/test-cyclingspeed
new file mode 100755
index 0000000..92fe935
--- /dev/null
+++ b/test/test-cyclingspeed
@@ -0,0 +1,124 @@
+#!/usr/bin/python
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+'''
+Cycling Speed and Cadence test script
+'''
+
+import gobject
+
+import sys
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+from optparse import OptionParser, make_option
+
+class Watcher(dbus.service.Object):
+	@dbus.service.method("org.bluez.CyclingSpeedWatcher",
+					in_signature="oa{sv}", out_signature="")
+	def MeasurementReceived(self, device, measure):
+		print("Measurement received from %s" % device)
+
+		if "WheelRevolutions" in measure:
+			print("WheelRevolutions: ", measure["WheelRevolutions"])
+
+		if "LastWheelEventTime" in measure:
+			print("LastWheelEventTime: ", measure["LastWheelEventTime"])
+
+		if "CrankRevolutions" in measure:
+			print("CrankRevolutions: ", measure["CrankRevolutions"])
+
+		if "LastCrankEventTime" in measure:
+			print("LastCrankEventTime: ", measure["LastCrankEventTime"])
+
+def properties_changed(interface, changed, invalidated):
+	if "Location" in changed:
+		print("Sensor location: %s" % changed["Location"])
+
+if __name__ == "__main__":
+	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+	bus = dbus.SystemBus()
+
+	option_list = [
+		make_option("-i", "--adapter", action="store",
+			type="string", dest="adapter"),
+		make_option("-b", "--device", action="store",
+			type="string", dest="address"),
+		]
+
+	parser = OptionParser(option_list=option_list)
+
+	(options, args) = parser.parse_args()
+
+	if not options.address:
+		print("Usage: %s [-i <adapter>] -b <bdaddr> [-c <value>] [cmd]" % (sys.argv[0]))
+		print("Possible commands:")
+		print("\tShowSupportedLocations")
+		print("\tSetLocation <location>")
+		print("\tSetCumulativeWheelRevolutions <value>")
+		sys.exit(1)
+
+	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
+					"org.bluez.Manager")
+	if options.adapter:
+		adapter_path = manager.FindAdapter(options.adapter)
+	else:
+		adapter_path = manager.DefaultAdapter()
+
+	adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
+							"org.bluez.Adapter")
+
+	device_path = adapter.FindDevice(options.address)
+
+	cscmanager = dbus.Interface(bus.get_object("org.bluez", adapter_path),
+						"org.bluez.CyclingSpeedManager")
+
+	watcher_path = "/test/watcher"
+	watcher = Watcher(bus, watcher_path)
+	cscmanager.RegisterWatcher(watcher_path)
+
+	csc = dbus.Interface(bus.get_object("org.bluez", device_path),
+						"org.bluez.CyclingSpeed")
+
+	bus.add_signal_receiver(properties_changed, bus_name="org.bluez",
+				path=device_path,
+				dbus_interface="org.freedesktop.DBus.Properties",
+				signal_name="PropertiesChanged")
+
+	device_prop = dbus.Interface(bus.get_object("org.bluez", device_path),
+					"org.freedesktop.DBus.Properties")
+
+	properties = device_prop.GetAll("org.bluez.CyclingSpeed")
+
+	if "Location" in properties:
+		print("Sensor location: %s" % properties["Location"])
+	else:
+		print("Sensor location is not supported")
+
+	if len(args) > 0:
+		if args[0] == "ShowSupportedLocations":
+			if properties["MultipleSensorLocationsSupported"]:
+				print("Supported locations: ", properties["SupportedLocations"])
+			else:
+				print("Multiple sensor locations not supported")
+
+		elif args[0] == "SetLocation":
+			if properties["MultipleSensorLocationsSupported"]:
+				device_prop.Set("org.bluez.CyclingSpeed", "Location", args[1])
+			else:
+				print("Multiple sensor locations not supported")
+
+		elif args[0] == "SetCumulativeWheelRevolutions":
+			if properties["WheelRevolutionDataSupported"]:
+				csc.SetCumulativeWheelRevolutions(dbus.UInt32(args[1]))
+			else:
+				print("Wheel revolution data not supported")
+
+		else:
+			print("Unknown command")
+			sys.exit(1)
+
+	mainloop = gobject.MainLoop()
+	mainloop.run()
-- 
1.8.0


^ permalink raw reply related

* [PATCH v3 20/20] test: Enable speed and cadence calculation in test-cyclingspeed
From: Andrzej Kaczmarek @ 2012-12-04 12:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1354625026-29358-1-git-send-email-andrzej.kaczmarek@tieto.com>

This patch allows to enable instantenous speed and cadence calculation
based on measurement received from remote device.

To enable calculations additional parameter "--circumference <value>"
needs to be used when calling script which sets wheel circumference in mm.

Both speed and cadence are enabled at the same time. Speed is calculated
in km/h and cadence in rpm.
---
 test/test-cyclingspeed | 71 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 69 insertions(+), 2 deletions(-)

diff --git a/test/test-cyclingspeed b/test/test-cyclingspeed
index 92fe935..841456c 100755
--- a/test/test-cyclingspeed
+++ b/test/test-cyclingspeed
@@ -14,23 +14,86 @@ import dbus.service
 import dbus.mainloop.glib
 from optparse import OptionParser, make_option
 
+class MeasurementQ:
+	def __init__(self, wrap_v):
+		self._now = [None, None]
+		self._prev = [None, None]
+		self._wrap_v = wrap_v
+
+	def can_calc(self):
+		return ((self._now[0] is not None)
+			and (self._now[1] is not None)
+			and (self._prev[0] is not None)
+			and (self._prev[1] is not None))
+
+	def delta_v(self):
+		delta = self._now[0] - self._prev[0]
+		if (delta < 0) and (self._wrap_v):
+			delta = delta + 65536
+		return delta
+
+	def delta_t(self):
+		delta = self._now[1] - self._prev[1]
+		if delta < 0:
+			delta = delta + 65536
+		return delta
+
+	def put(self, data):
+		self._prev = self._now
+		self._now = data
+
 class Watcher(dbus.service.Object):
+	_wheel = MeasurementQ(False)
+	_crank = MeasurementQ(True)
+	_circumference = None
+
+	def enable_calc(self, v):
+		self._circumference = v
+
 	@dbus.service.method("org.bluez.CyclingSpeedWatcher",
 					in_signature="oa{sv}", out_signature="")
 	def MeasurementReceived(self, device, measure):
 		print("Measurement received from %s" % device)
 
+		rev = None
+		evt = None
 		if "WheelRevolutions" in measure:
+			rev = measure["WheelRevolutions"]
 			print("WheelRevolutions: ", measure["WheelRevolutions"])
-
 		if "LastWheelEventTime" in measure:
+			evt = measure["LastWheelEventTime"]
 			print("LastWheelEventTime: ", measure["LastWheelEventTime"])
+		self._wheel.put( [rev, evt] )
 
+		rev = None
+		evt = None
 		if "CrankRevolutions" in measure:
+			rev = measure["CrankRevolutions"]
 			print("CrankRevolutions: ", measure["CrankRevolutions"])
-
 		if "LastCrankEventTime" in measure:
+			evt = measure["LastCrankEventTime"]
 			print("LastCrankEventTime: ", measure["LastCrankEventTime"])
+		self._crank.put( [rev, evt] )
+
+		if self._circumference is None:
+			return
+
+		if self._wheel.can_calc():
+			delta_v = self._wheel.delta_v()
+			delta_t = self._wheel.delta_t()
+
+			if (delta_v >= 0) and (delta_t > 0):
+				speed = delta_v * self._circumference * 1024 / delta_t # mm/s
+				speed = speed * 0.0036 # mm/s -> km/h
+				print("(calculated) Speed: %.2f km/h" % speed)
+
+		if self._crank.can_calc():
+			delta_v = self._crank.delta_v()
+			delta_t = self._crank.delta_t()
+
+			if delta_t > 0:
+				cadence = delta_v * 1024 / delta_t
+				print("(calculated) Cadence: %d rpm" % cadence)
 
 def properties_changed(interface, changed, invalidated):
 	if "Location" in changed:
@@ -46,6 +109,8 @@ if __name__ == "__main__":
 			type="string", dest="adapter"),
 		make_option("-b", "--device", action="store",
 			type="string", dest="address"),
+		make_option("-c", "--circumference", action="store",
+			type="int", dest="circumference"),
 		]
 
 	parser = OptionParser(option_list=option_list)
@@ -77,6 +142,8 @@ if __name__ == "__main__":
 
 	watcher_path = "/test/watcher"
 	watcher = Watcher(bus, watcher_path)
+	if options.circumference:
+		watcher.enable_calc(options.circumference)
 	cscmanager.RegisterWatcher(watcher_path)
 
 	csc = dbus.Interface(bus.get_object("org.bluez", device_path),
-- 
1.8.0


^ permalink raw reply related

* Bluez 4.99 - Connection/Authentification keeps pending
From: Mario Premke @ 2012-12-04 13:50 UTC (permalink / raw)
  To: linux-bluetooth

Hello,
I am running: Bluez-4.99 ; Kernel 3.6.8; connecting a mouse (Logitech V470) 
with simple-agent was no problem.
Trying (for hours) to connect a Keysonic ACK-595BT keyboard - to no avail.

The pin somehow gets exchanged, but then it gets stuck:

... simple-agent hci0 00:18:00:00:D0:88
RequestPinCode (/org/bluez/1644/hci0/dev_00_18_00_00_D0_88)
Enter PIN Code: 123456
Release exit: False <- this is my debug print "Release exit: %s" % 
self.exit_on_release in simple-agent
Creating device failed: org.freedesktop.DBus.Error.NoReply: Did not receive 
a reply. Possible causes include: the remote application did not send a 
reply, the message bus security policy blocked the reply, the reply timeout 
expired, or the network connection was broken.

and the connection/authentification keeps pending (snip from hcidump):

< HCI Command: Create Connection (0x01|0x0005) plen 13
    bdaddr 00:18:00:00:D0:88 ptype 0xcc18 rswitch 0x01 clkoffset 0x0000
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5
> HCI Event: Command Status (0x0f) plen 4
    Create Connection (0x01|0x0005) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 37 bdaddr 00:18:00:00:D0:88 type ACL encrypt 0x00
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
    handle 37
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 0
> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7
    bdaddr 00:18:00:00:D0:88 mode 1
> HCI Event: Max Slots Change (0x1b) plen 3
    handle 37 slots 5
> HCI Event: Command Status (0x0f) plen 4
    Unknown (0x00|0x0000) status 0x00 ncmd 1
> HCI Event: Read Remote Supported Features (0x0b) plen 11
    status 0x00 handle 37
    Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
    bdaddr 00:18:00:00:D0:88 mode 2 clkoffset 0x0000
> HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr 00:18:00:00:D0:88 name 'BTKB-D088'
< HCI Command: Authentication Requested (0x01|0x0011) plen 2
    handle 37
> HCI Event: Command Status (0x0f) plen 4
    Authentication Requested (0x01|0x0011) status 0x00 ncmd 1
> HCI Event: Link Key Request (0x17) plen 6
    bdaddr 00:18:00:00:D0:88
< HCI Command: Link Key Request Negative Reply (0x01|0x000c) plen 6
    bdaddr 00:18:00:00:D0:88
> HCI Event: Command Complete (0x0e) plen 10
    Link Key Request Negative Reply (0x01|0x000c) ncmd 1
    status 0x00 bdaddr 00:18:00:00:D0:88
> HCI Event: PIN Code Request (0x16) plen 6
    bdaddr 00:18:00:00:D0:88
< HCI Command: PIN Code Request Reply (0x01|0x000d) plen 23
    bdaddr 00:18:00:00:D0:88 len 6 pin '123456'
> HCI Event: Command Complete (0x0e) plen 10
    PIN Code Request Reply (0x01|0x000d) ncmd 1
    status 0x00 bdaddr 00:18:00:00:D0:88
> HCI Event: Link Key Notification (0x18) plen 23
    bdaddr 00:18:00:00:D0:88 key 86B9BE88F30AF1481F03C2D69894AD4C type 0
    Type: Combination Key
> HCI Event: Auth Complete (0x06) plen 3
    status 0x00 handle 37
< HCI Command: Authentication Requested (0x01|0x0011) plen 2
    handle 37
< ACL data: handle 37 flags 0x00 dlen 10
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Command Status (0x0f) plen 4
    Authentication Requested (0x01|0x0011) status 0x00 ncmd 1
> HCI Event: Link Key Request (0x17) plen 6
    bdaddr 00:18:00:00:D0:88
< HCI Command: Link Key Request Reply (0x01|0x000b) plen 22
    bdaddr 00:18:00:00:D0:88 key 86B9BE88F30AF1481F03C2D69894AD4C
> HCI Event: Command Complete (0x0e) plen 10
    Link Key Request Reply (0x01|0x000b) ncmd 1
    status 0x00 bdaddr 00:18:00:00:D0:88
> ACL data: handle 37 flags 0x02 dlen 16
      Extended feature mask 0x0007
        Flow control mode
        Retransmission mode
        Bi-directional QoS
< ACL data: handle 37 flags 0x00 dlen 12
> HCI Event: Auth Complete (0x06) plen 3
    status 0x00 handle 37
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> ACL data: handle 37 flags 0x02 dlen 16
      Connection pending - Authorization pending
> ACL data: handle 37 flags 0x02 dlen 16
      Connection successful
< ACL data: handle 37 flags 0x00 dlen 12
> ACL data: handle 37 flags 0x02 dlen 12
< ACL data: handle 37 flags 0x00 dlen 18
      MTU 672
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> ACL data: handle 37 flags 0x02 dlen 14
      Success
< ACL data: handle 37 flags 0x00 dlen 24
        SDP SSA Req: tid 0x0 len 0xf
          max 65535
          aid(s) 0x0000 - 0xffff
          cont 00
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Mode Change (0x14) plen 6
    Mode: Active
> HCI Event: Mode Change (0x14) plen 6
    Mode: Sniff
< ACL data: handle 37 flags 0x00 dlen 12
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 37 reason 0x08
    Reason: Connection Timeout
< HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7
    bdaddr 00:18:00:00:D0:88 all 0
> HCI Event: Command Complete (0x0e) plen 6
    Delete Stored Link Key (0x03|0x0012) ncmd 1
    status 0x00 deleted 0

When I then struck a key at the BT keyboard hcidump shows the following:

> HCI Event: Mode Change (0x14) plen 6
    Mode: Active
> HCI Event: Mode Change (0x14) plen 6
    Mode: Sniff
> HCI Event: Connect Request (0x04) plen 10
    bdaddr 00:18:00:00:D0:88 class 0x002540 type ACL
< HCI Command: Accept Connection Request (0x01|0x0009) plen 7
    bdaddr 00:18:00:00:D0:88 role 0x00
    Role: Master
> HCI Event: Command Status (0x0f) plen 4
    Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
> HCI Event: Role Change (0x12) plen 8
    status 0x00 bdaddr 00:18:00:00:D0:88 role 0x00
    Role: Master
> HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 37 bdaddr 00:18:00:00:D0:88 type ACL encrypt 0x00
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
    handle 37
> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7
    bdaddr 00:18:00:00:D0:88 mode 1
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 0
> HCI Event: Max Slots Change (0x1b) plen 3
    handle 37 slots 5
> HCI Event: Command Status (0x0f) plen 4
    Unknown (0x00|0x0000) status 0x00 ncmd 1
> ACL data: handle 37 flags 0x02 dlen 12
< ACL data: handle 37 flags 0x00 dlen 16
      Connection pending - No futher information available
< ACL data: handle 37 flags 0x00 dlen 10
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Read Remote Supported Features (0x0b) plen 11
    status 0x00 handle 37
    Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
    bdaddr 00:18:00:00:D0:88 mode 2 clkoffset 0x0000
> HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> ACL data: handle 37 flags 0x02 dlen 16
      Extended feature mask 0x0007
        Flow control mode
        Retransmission mode
        Bi-directional QoS
< ACL data: handle 37 flags 0x00 dlen 16
      Connection successful
< ACL data: handle 37 flags 0x00 dlen 12
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> ACL data: handle 37 flags 0x02 dlen 12
< ACL data: handle 37 flags 0x00 dlen 18
      MTU 672
> ACL data: handle 37 flags 0x02 dlen 14
      Success
< ACL data: handle 37 flags 0x00 dlen 5
      HIDP: Control: Virtual cable unplug
< ACL data: handle 37 flags 0x00 dlen 12
> HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr 00:18:00:00:D0:88 name 'BTKB-D088'
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> ACL data: handle 37 flags 0x02 dlen 12
> ACL data: handle 37 flags 0x02 dlen 12
< ACL data: handle 37 flags 0x00 dlen 16
      Connection pending - Authorization pending
< ACL data: handle 37 flags 0x00 dlen 16
      Connection refused - security block
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 37 packets 1
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 37 reason 0x13
    Reason: Remote User Terminated Connection


This is what /var/log/messages says:

dbus[1631]: [system] Rejected send message, 1 matched rules; 
type="method_return", sender=":1.31" (uid=0 pid=3009 comm="/usr/bin/python2 
/usr/bin/simple-agent hci0 00:18:") interface="(unset)" member="(unset)" 
error name="(unset)" requested_reply="0" destination=":1.0" (uid=0 pid=1644 
comm="/usr/sbin/bluetoothd --udev ")

My policies at /etc/dbus-1/system.d/bluetooth.conf are:

<policy user="root">
<allow own="org.bluez"/>
<allow send_destination="org.bluez"/>
<allow send_interface="org.bluez.Agent"/>
<allow send_interface="org.bluez.HandsfreeAgent"/>
<allow send_interface="org.bluez.MediaEndpoint"/>
<allow send_interface="org.bluez.MediaPlayer"/>
<allow send_interface="org.bluez.Watcher"/>
<allow send_interface="org.bluez.ThermometerWatcher"/>

<allow send_type="method_call"/>
<allow send_type="method_return"/>
</policy>

I am fiddling around with the allowance for the send_types, but it always 
runs into the rejected message type as can be seen in the syslog, probably 
because of the "unset" interface (see syslog), since I have (not 
surprisingly) no rule for this interface.

So it seems to get stuck in the authentification process, but I have no clue 
why?
In Bluez-3.x there was a programm 'passkey-agent', is it obsolete that it's 
not included in Bluez-4.x any more?
I once connected the keyboard to another linux system, but that was with 
Bluez-3.x ...

Thanks in advance
Mario 


^ permalink raw reply

* Re: [PATCH BlueZ 2/2 v1] l2test: Add support to test auto select PSM
From: Syam Sidhardhan @ 2012-12-04 14:36 UTC (permalink / raw)
  To: Gustavo Padovan, Syam Sidhardhan, linux-bluetooth
In-Reply-To: <20121120175213.GH14006@joana>

Hi Gustavo,

On Tue, Nov 20, 2012 at 11:22 PM, Gustavo Padovan <gustavo@padovan.org> wrote:
> Hi Syam,
>
> * Syam Sidhardhan <s.syam@samsung.com> [2012-11-20 21:45:51 +0530]:
>
>> This patch enable us to test the auto select PSM for server by passing
>> PSM value as 0.
>>
>> Ex: l2test -d -P 0
>> l2test[2585]: Waiting for connection on psm 4097 ...
>> ---
>> v1-> Corrected the misplaced code
>>
>>  test/l2test.c |    4 +---
>>  1 files changed, 1 insertions(+), 3 deletions(-)
>>
>> diff --git a/test/l2test.c b/test/l2test.c
>> index 7645681..485887f 100644
>> --- a/test/l2test.c
>> +++ b/test/l2test.c
>> @@ -87,7 +87,7 @@ static long buffer_size = 2048;
>>
>>  /* Default addr and psm and cid */
>>  static bdaddr_t bdaddr;
>> -static unsigned short psm = 0x1011;
>> +static unsigned short psm = 0;
>
> Your patch makes the client side to always pass the psm option and I don't
> think this is a good approach. I think we need something smarter here to not
> break things.

True, I assumed that for initiating or listening a connection, the PSM
or CID is mandatory.
I think, we should not change the psm initialization
"static unsigned short psm = 0x1011;"  in the previous patch.
If the user want to test the auto select psm, then he should
explicitly pass the "-P 0" option in the argument.

I'll send an updated version.

Regards,
Syam.

^ permalink raw reply

* [PATCH v0 0/3] Remove access rights from MediaTransport
From: Mikel Astiz @ 2012-12-04 17:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

The accessrights used in the Acquire() method are not very useful and can thus be removed. This simplifies both the D-Bus API and the internal implementation significantly.

Mikel Astiz (3):
  media: Remove transport access type from D-Bus API
  media: Remove internal transport locks
  media: Remove transport owner list

 doc/media-api.txt          |  30 ++----
 profiles/audio/transport.c | 238 ++++++++++-----------------------------------
 2 files changed, 59 insertions(+), 209 deletions(-)

-- 
1.7.11.7


^ permalink raw reply

* [PATCH v0 1/3] media: Remove transport access type from D-Bus API
From: Mikel Astiz @ 2012-12-04 17:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1354641230-3667-1-git-send-email-mikel.astiz.oss@gmail.com>

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

There is no known use-case making use of these access types and
therefore the Media API can be simplified.

>From now on, the transport will always be acquired with read and write
access rights.
---
 doc/media-api.txt          | 30 ++++++++----------------------
 profiles/audio/transport.c | 44 +++++++++-----------------------------------
 2 files changed, 17 insertions(+), 57 deletions(-)

diff --git a/doc/media-api.txt b/doc/media-api.txt
index cf69efa..cb5d9a3 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -261,31 +261,17 @@ Service		org.bluez
 Interface	org.bluez.MediaTransport
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/fdX
 
-Methods		fd, uint16, uint16 Acquire(string accesstype)
+Methods		fd, uint16, uint16 Acquire(boolean optional)
 
-			Acquire transport file descriptor and the MTU for read
-			and write respectively.
+			Acquire transport (with read and write rights) and
+			return the file descriptor and the MTU.
 
-			possible accesstype:
+			The optional flag specifies that the transport will be
+			acquired only if it's in "pending" state, and will
+			otherwise fail. This means no request will be sent to
+			the remote side.
 
-				"r" : Read only access
-
-				"w" : Write only access
-
-				"rw": Read and write access
-
-			The accesstype string can also be combined with a "?"
-			suffix, which will make the request optional. This
-			typically means the transport will only be acquired if
-			it is already available (remote-initiated), but
-			otherwise no request will be sent to the remote side.
-			In this last case the function will fail. Note that,
-			due to compatibility issues with older versions of
-			BlueZ, clients are encouraged to use exactly the same
-			accesstype for Release(), matching the string provided
-			to Acquire().
-
-		void Release(string accesstype)
+		void Release()
 
 			Releases file descriptor.
 
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 610aca3..5924f73 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -127,19 +127,6 @@ static const char *lock2str(transport_lock_t lock)
 		return "rw";
 }
 
-static transport_lock_t str2lock(const char *str)
-{
-	transport_lock_t lock = 0;
-
-	if (g_strstr_len(str, -1, "r") != NULL)
-		lock |= TRANSPORT_LOCK_READ;
-
-	if (g_strstr_len(str, -1, "w") != NULL)
-		lock |= TRANSPORT_LOCK_WRITE;
-
-	return lock;
-}
-
 static const char *state2str(transport_state_t state)
 {
 	switch (state) {
@@ -532,12 +519,13 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
 	struct media_transport *transport = data;
 	struct media_owner *owner;
 	struct media_request *req;
-	const char *accesstype, *sender;
-	transport_lock_t lock;
+	const char *sender;
+	dbus_bool_t optional;
 	guint id;
+	transport_lock_t lock = TRANSPORT_LOCK_READ | TRANSPORT_LOCK_WRITE;
 
 	if (!dbus_message_get_args(msg, NULL,
-				DBUS_TYPE_STRING, &accesstype,
+				DBUS_TYPE_BOOLEAN, &optional,
 				DBUS_TYPE_INVALID))
 		return btd_error_invalid_args(msg);
 
@@ -547,12 +535,7 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
 	if (owner != NULL)
 		return btd_error_not_authorized(msg);
 
-	lock = str2lock(accesstype);
-	if (lock == 0)
-		return btd_error_invalid_args(msg);
-
-	if (transport->state != TRANSPORT_STATE_PENDING &&
-				g_strstr_len(accesstype, -1, "?") != NULL)
+	if (transport->state != TRANSPORT_STATE_PENDING && optional)
 		return btd_error_failed(msg, "Transport not playing");
 
 	if (media_transport_acquire(transport, lock) == FALSE)
@@ -578,14 +561,9 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 {
 	struct media_transport *transport = data;
 	struct media_owner *owner;
-	const char *accesstype, *sender;
-	transport_lock_t lock;
+	const char *sender;
 	struct media_request *req;
-
-	if (!dbus_message_get_args(msg, NULL,
-				DBUS_TYPE_STRING, &accesstype,
-				DBUS_TYPE_INVALID))
-		return btd_error_invalid_args(msg);
+	transport_lock_t lock = TRANSPORT_LOCK_READ | TRANSPORT_LOCK_WRITE;
 
 	sender = dbus_message_get_sender(msg);
 
@@ -593,8 +571,6 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 	if (owner == NULL)
 		return btd_error_not_authorized(msg);
 
-	lock = str2lock(accesstype);
-
 	if (owner->lock == lock) {
 		guint id;
 
@@ -764,13 +740,11 @@ static void set_volume(const GDBusPropertyTable *property,
 
 static const GDBusMethodTable transport_methods[] = {
 	{ GDBUS_ASYNC_METHOD("Acquire",
-			GDBUS_ARGS({ "access_type", "s" }),
+			GDBUS_ARGS({ "optional", "b" }),
 			GDBUS_ARGS({ "fd", "h" }, { "mtu_r", "q" },
 							{ "mtu_w", "q" } ),
 			acquire) },
-	{ GDBUS_ASYNC_METHOD("Release",
-			GDBUS_ARGS({ "access_type", "s" }), NULL,
-			release ) },
+	{ GDBUS_ASYNC_METHOD("Release", NULL, NULL, release) },
 	{ },
 };
 
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH v0 2/3] media: Remove internal transport locks
From: Mikel Astiz @ 2012-12-04 17:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1354641230-3667-1-git-send-email-mikel.astiz.oss@gmail.com>

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

The internal transport_lock_t is not needed any more since transports
are now always acquired with read and write permissions.
---
 profiles/audio/transport.c | 134 ++++++++++-----------------------------------
 1 file changed, 30 insertions(+), 104 deletions(-)

diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 5924f73..ad9270e 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -51,11 +51,6 @@
 #define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport"
 
 typedef enum {
-	TRANSPORT_LOCK_READ = 1,
-	TRANSPORT_LOCK_WRITE = 1 << 1,
-} transport_lock_t;
-
-typedef enum {
 	TRANSPORT_STATE_IDLE,		/* Not acquired and suspended */
 	TRANSPORT_STATE_PENDING,	/* Playing but not acquired */
 	TRANSPORT_STATE_REQUESTING,	/* Acquire in progress */
@@ -80,7 +75,6 @@ struct media_owner {
 	struct media_transport	*transport;
 	struct media_request	*pending;
 	char			*name;
-	transport_lock_t	lock;
 	guint			watch;
 };
 
@@ -100,7 +94,6 @@ struct media_transport {
 	int			fd;		/* Transport file descriptor */
 	uint16_t		imtu;		/* Transport input mtu */
 	uint16_t		omtu;		/* Transport output mtu */
-	transport_lock_t	lock;
 	transport_state_t	state;
 	guint			hs_watch;
 	guint			source_watch;
@@ -115,18 +108,6 @@ struct media_transport {
 	void			*data;
 };
 
-static const char *lock2str(transport_lock_t lock)
-{
-	if (lock == 0)
-		return "";
-	else if (lock == TRANSPORT_LOCK_READ)
-		return "r";
-	else if (lock == TRANSPORT_LOCK_WRITE)
-		return "w";
-	else
-		return "rw";
-}
-
 static const char *state2str(transport_state_t state)
 {
 	switch (state) {
@@ -229,20 +210,6 @@ static void media_request_reply(struct media_request *req, int err)
 	g_dbus_send_message(btd_get_dbus_connection(), reply);
 }
 
-static gboolean media_transport_release(struct media_transport *transport,
-							transport_lock_t lock)
-{
-	transport->lock &= ~lock;
-
-	if (lock & TRANSPORT_LOCK_READ)
-		DBG("Transport %s: read lock released", transport->path);
-
-	if (lock & TRANSPORT_LOCK_WRITE)
-		DBG("Transport %s: write lock released", transport->path);
-
-	return TRUE;
-}
-
 static void media_owner_remove(struct media_owner *owner)
 {
 	struct media_transport *transport = owner->transport;
@@ -279,8 +246,6 @@ static void media_transport_remove(struct media_transport *transport,
 {
 	DBG("Transport %s Owner %s", transport->path, owner->name);
 
-	media_transport_release(transport, owner->lock);
-
 	/* Reply if owner has a pending request */
 	if (owner->pending)
 		media_request_reply(owner->pending, EIO);
@@ -339,12 +304,6 @@ static void a2dp_resume_complete(struct avdtp *session,
 
 	media_transport_set_fd(transport, fd, imtu, omtu);
 
-	if ((owner->lock & TRANSPORT_LOCK_READ) == 0)
-		imtu = 0;
-
-	if ((owner->lock & TRANSPORT_LOCK_WRITE) == 0)
-		omtu = 0;
-
 	ret = g_dbus_send_reply(btd_get_dbus_connection(), req->msg,
 						DBUS_TYPE_UNIX_FD, &fd,
 						DBUS_TYPE_UINT16, &imtu,
@@ -443,24 +402,6 @@ static void media_owner_exit(DBusConnection *connection, void *user_data)
 	media_transport_remove(owner->transport, owner);
 }
 
-static gboolean media_transport_acquire(struct media_transport *transport,
-							transport_lock_t lock)
-{
-	if (transport->lock & lock)
-		return FALSE;
-
-	transport->lock |= lock;
-
-	if (lock & TRANSPORT_LOCK_READ)
-		DBG("Transport %s: read lock acquired", transport->path);
-
-	if (lock & TRANSPORT_LOCK_WRITE)
-		DBG("Transport %s: write lock acquired", transport->path);
-
-
-	return TRUE;
-}
-
 static void media_transport_add(struct media_transport *transport,
 					struct media_owner *owner)
 {
@@ -473,17 +414,14 @@ static void media_transport_add(struct media_transport *transport,
 							owner, NULL);
 }
 
-static struct media_owner *media_owner_create(DBusMessage *msg,
-						transport_lock_t lock)
+static struct media_owner *media_owner_create(DBusMessage *msg)
 {
 	struct media_owner *owner;
 
 	owner = g_new0(struct media_owner, 1);
 	owner->name = g_strdup(dbus_message_get_sender(msg));
-	owner->lock = lock;
 
-	DBG("Owner created: sender=%s accesstype=%s", owner->name,
-							lock2str(lock));
+	DBG("Owner created: sender=%s", owner->name);
 
 	return owner;
 }
@@ -522,7 +460,6 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
 	const char *sender;
 	dbus_bool_t optional;
 	guint id;
-	transport_lock_t lock = TRANSPORT_LOCK_READ | TRANSPORT_LOCK_WRITE;
 
 	if (!dbus_message_get_args(msg, NULL,
 				DBUS_TYPE_BOOLEAN, &optional,
@@ -535,16 +472,15 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
 	if (owner != NULL)
 		return btd_error_not_authorized(msg);
 
+	if (transport->state >= TRANSPORT_STATE_REQUESTING)
+		return btd_error_not_authorized(msg);
+
 	if (transport->state != TRANSPORT_STATE_PENDING && optional)
 		return btd_error_failed(msg, "Transport not playing");
 
-	if (media_transport_acquire(transport, lock) == FALSE)
-		return btd_error_not_authorized(msg);
-
-	owner = media_owner_create(msg, lock);
+	owner = media_owner_create(msg);
 	id = transport->resume(transport, owner);
 	if (id == 0) {
-		media_transport_release(transport, lock);
 		media_owner_free(owner);
 		return btd_error_not_authorized(msg);
 	}
@@ -563,7 +499,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 	struct media_owner *owner;
 	const char *sender;
 	struct media_request *req;
-	transport_lock_t lock = TRANSPORT_LOCK_READ | TRANSPORT_LOCK_WRITE;
+	guint id;
 
 	sender = dbus_message_get_sender(msg);
 
@@ -571,45 +507,35 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 	if (owner == NULL)
 		return btd_error_not_authorized(msg);
 
-	if (owner->lock == lock) {
-		guint id;
-
-		/* Not the last owner, no need to suspend */
-		if (g_slist_length(transport->owners) != 1) {
-			media_transport_remove(transport, owner);
-			return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-		}
-
-		if (owner->pending) {
-			const char *member;
+	/* Not the last owner, no need to suspend */
+	if (g_slist_length(transport->owners) != 1) {
+		media_transport_remove(transport, owner);
+		return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+	}
 
-			member = dbus_message_get_member(owner->pending->msg);
-			/* Cancel Acquire request if that exist */
-			if (g_str_equal(member, "Acquire"))
-				media_owner_remove(owner);
-			else
-				return btd_error_in_progress(msg);
-		}
+	if (owner->pending) {
+		const char *member;
 
-		transport_set_state(transport, TRANSPORT_STATE_SUSPENDING);
+		member = dbus_message_get_member(owner->pending->msg);
+		/* Cancel Acquire request if that exist */
+		if (g_str_equal(member, "Acquire"))
+			media_owner_remove(owner);
+		else
+			return btd_error_in_progress(msg);
+	}
 
-		id = transport->suspend(transport, owner);
-		if (id == 0) {
-			media_transport_remove(transport, owner);
-			return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-		}
+	transport_set_state(transport, TRANSPORT_STATE_SUSPENDING);
 
-		req = media_request_create(msg, id);
-		media_owner_add(owner, req);
+	id = transport->suspend(transport, owner);
+	if (id == 0) {
+		media_transport_remove(transport, owner);
+		return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+	}
 
-		return NULL;
-	} else if ((owner->lock & lock) == lock) {
-		media_transport_release(transport, lock);
-		owner->lock &= ~lock;
-	} else
-		return btd_error_not_authorized(msg);
+	req = media_request_create(msg, id);
+	media_owner_add(owner, req);
 
-	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+	return NULL;
 }
 
 static gboolean get_device(const GDBusPropertyTable *property,
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH v0 3/3] media: Remove transport owner list
From: Mikel Astiz @ 2012-12-04 17:13 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1354641230-3667-1-git-send-email-mikel.astiz.oss@gmail.com>

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Transports now have zero or one owners, so there is no need to maintain
a list any more.
---
 profiles/audio/transport.c | 80 +++++++++++++---------------------------------
 1 file changed, 22 insertions(+), 58 deletions(-)

diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index ad9270e..2075894 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -88,7 +88,7 @@ struct media_transport {
 	char			*path;		/* Transport object path */
 	struct audio_device	*device;	/* Transport device */
 	struct media_endpoint	*endpoint;	/* Transport endpoint */
-	GSList			*owners;	/* Transport owners */
+	struct media_owner	*owner;		/* Transport owner */
 	uint8_t			*configuration; /* Transport configuration */
 	int			size;		/* Transport configuration size */
 	int			fd;		/* Transport file descriptor */
@@ -241,24 +241,25 @@ static void media_owner_free(struct media_owner *owner)
 	g_free(owner);
 }
 
-static void media_transport_remove(struct media_transport *transport,
-						struct media_owner *owner)
+static void media_transport_remove_owner(struct media_transport *transport)
 {
+	struct media_owner *owner = transport->owner;
+
 	DBG("Transport %s Owner %s", transport->path, owner->name);
 
 	/* Reply if owner has a pending request */
 	if (owner->pending)
 		media_request_reply(owner->pending, EIO);
 
-	transport->owners = g_slist_remove(transport->owners, owner);
+	if (transport->owner == owner)
+		transport->owner = NULL;
 
 	if (owner->watch)
 		g_dbus_remove_watch(btd_get_dbus_connection(), owner->watch);
 
 	media_owner_free(owner);
 
-	/* Suspend if there is no longer any owner */
-	if (transport->owners == NULL && state_in_use(transport->state))
+	if (state_in_use(transport->state))
 		transport->suspend(transport, NULL);
 }
 
@@ -319,7 +320,7 @@ static void a2dp_resume_complete(struct avdtp *session,
 	return;
 
 fail:
-	media_transport_remove(transport, owner);
+	media_transport_remove_owner(transport);
 }
 
 static guint resume_a2dp(struct media_transport *transport,
@@ -366,7 +367,7 @@ static void a2dp_suspend_complete(struct avdtp *session,
 
 	a2dp_sep_unlock(sep, a2dp->session);
 	transport_set_state(transport, TRANSPORT_STATE_IDLE);
-	media_transport_remove(transport, owner);
+	media_transport_remove_owner(transport);
 }
 
 static guint suspend_a2dp(struct media_transport *transport,
@@ -399,14 +400,14 @@ static void media_owner_exit(DBusConnection *connection, void *user_data)
 
 	media_owner_remove(owner);
 
-	media_transport_remove(owner->transport, owner);
+	media_transport_remove_owner(owner->transport);
 }
 
-static void media_transport_add(struct media_transport *transport,
+static void media_transport_set_owner(struct media_transport *transport,
 					struct media_owner *owner)
 {
 	DBG("Transport %s Owner %s", transport->path, owner->name);
-	transport->owners = g_slist_append(transport->owners, owner);
+	transport->owner = owner;
 	owner->transport = transport;
 	owner->watch = g_dbus_add_disconnect_watch(btd_get_dbus_connection(),
 							owner->name,
@@ -435,29 +436,12 @@ static void media_owner_add(struct media_owner *owner,
 	owner->pending = req;
 }
 
-static struct media_owner *media_transport_find_owner(
-					struct media_transport *transport,
-					const char *name)
-{
-	GSList *l;
-
-	for (l = transport->owners; l; l = l->next) {
-		struct media_owner *owner = l->data;
-
-		if (g_strcmp0(owner->name, name) == 0)
-			return owner;
-	}
-
-	return NULL;
-}
-
 static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
 					void *data)
 {
 	struct media_transport *transport = data;
 	struct media_owner *owner;
 	struct media_request *req;
-	const char *sender;
 	dbus_bool_t optional;
 	guint id;
 
@@ -466,10 +450,7 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
 				DBUS_TYPE_INVALID))
 		return btd_error_invalid_args(msg);
 
-	sender = dbus_message_get_sender(msg);
-
-	owner = media_transport_find_owner(transport, sender);
-	if (owner != NULL)
+	if (transport->owner != NULL)
 		return btd_error_not_authorized(msg);
 
 	if (transport->state >= TRANSPORT_STATE_REQUESTING)
@@ -487,7 +468,7 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
 
 	req = media_request_create(msg, id);
 	media_owner_add(owner, req);
-	media_transport_add(transport, owner);
+	media_transport_set_owner(transport, owner);
 
 	return NULL;
 }
@@ -496,23 +477,16 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 					void *data)
 {
 	struct media_transport *transport = data;
-	struct media_owner *owner;
+	struct media_owner *owner = transport->owner;
 	const char *sender;
 	struct media_request *req;
 	guint id;
 
 	sender = dbus_message_get_sender(msg);
 
-	owner = media_transport_find_owner(transport, sender);
-	if (owner == NULL)
+	if (owner == NULL || g_strcmp0(owner->name, sender) != 0)
 		return btd_error_not_authorized(msg);
 
-	/* Not the last owner, no need to suspend */
-	if (g_slist_length(transport->owners) != 1) {
-		media_transport_remove(transport, owner);
-		return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-	}
-
 	if (owner->pending) {
 		const char *member;
 
@@ -528,7 +502,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 
 	id = transport->suspend(transport, owner);
 	if (id == 0) {
-		media_transport_remove(transport, owner);
+		media_transport_remove_owner(transport);
 		return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 	}
 
@@ -698,15 +672,9 @@ static void destroy_a2dp(void *data)
 static void media_transport_free(void *data)
 {
 	struct media_transport *transport = data;
-	GSList *l = transport->owners;
 
-	while (l) {
-		struct media_owner *owner = l->data;
-		l = l->next;
-		media_transport_remove(transport, owner);
-	}
-
-	g_slist_free(transport->owners);
+	if (transport->owner)
+		media_transport_remove_owner(transport);
 
 	if (transport->destroy != NULL)
 		transport->destroy(transport->data);
@@ -726,13 +694,9 @@ static void transport_update_playing(struct media_transport *transport,
 		if (transport->state == TRANSPORT_STATE_PENDING)
 			transport_set_state(transport, TRANSPORT_STATE_IDLE);
 		else if (transport->state == TRANSPORT_STATE_ACTIVE) {
-			/* Remove all owners */
-			while (transport->owners != NULL) {
-				struct media_owner *owner;
-
-				owner = transport->owners->data;
-				media_transport_remove(transport, owner);
-			}
+			/* Remove owner */
+			if (transport->owner != NULL)
+				media_transport_remove_owner(transport);
 		}
 	} else if (transport->state == TRANSPORT_STATE_IDLE)
 		transport_set_state(transport, TRANSPORT_STATE_PENDING);
-- 
1.7.11.7


^ permalink raw reply related

* Re: BLE issue: Start_LE_Encryption fails
From: Ajay @ 2012-12-04 18:49 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <CAJdJm_PLSAZBc+ef_YXsmQ+VE5aW3aD_CPs3x2Y7gY+8zY19Bw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 6467 bytes --]

On Sun, Oct 28, 2012 at 1:08 PM, Ajay <ajay.kv@globaledgesoft.com> wrote:
 > Hi,
 >         I am getting le_long_term_key_negative reply  from the remote 
device
 > , on sending le_start_encryption . I am testing this with 2 ubuntu
 > machines(3.2.5) with IOGEAR dual mode dongles .

To connect to a dual mode dongle, you need to set LE Adv. flags to
0x06 (which means general discoverable + BR/EDR not supported) on the
acceptor side. You can use this command (on the acceptor/slave side):

sudo hcitool -i hci0 cmd 0x08 0x0008 03 02 01 06 \
     $(perl -e 'print "00 " x 28')

Next, enable LE advertising:

sudo hciconfig hci0 leadv

On the initiator/master side, run "hcitool lescan" and try pairing again.





Hi Ajay,

On Sun, Oct 28, 2012 at 8:30 PM, Ajay <ajay.kv@globaledgesoft.com> wrote:
 > Thanks, but "sudo hcitool -i hci0 cmd 0x08 0x0008 03 02 01 06 " ,   this
 > command only sets the advertising data to zero right . so how do i 
set the
 > adv flag as 0x06 . Which hci command is used for this  purpose .

No, this sets adv. data to have "Flags" AD set to 0x06. But you missed
the second line of the command:

sudo hcitool -i hci0 cmd 0x08 0x0008 03 02 01 06 \
     $(perl -e 'print "00 " x 28')

The second line is important because it fills the other bytes with
zero (which some controllers require).





On Tuesday 30 October 2012 07:45 PM, Anderson Lizardo wrote:
> Hi Ajay,
>
> On Sun, Oct 28, 2012 at 9:33 PM, Ajay <ajay.kv@globaledgesoft.com> wrote:
>>   ya , i got your point ,advertiser is informing the remote device  , that it
>> is not BR/EDR capable .That is done and device is connecting now.
>>          But  still i dont know, how to do le specific pairing and
>> start_encryption enable(part of le pairing) . Is there any tool in bluez
>> providing LE pairing before connecting the devices (want to try with 2
>> ubuntu pc's ).
>
> We use the "simple-agent" script from test/ directory in BlueZ for pairing.
>
> On the slave side run:
>
> test/simple-agent hci0
>
> on the master side, after "hcitool lescan", run:
>
> test/simple-agent hci0 <slave-address>
>
> This should trigger Just Works SMP pairing.
>
> Regards,
>


Hi,
     I have included some of our previous conversations  related to this 
issue.

I got some error while testing the above case for LE pairing using 
simple_agent . kindly find a solution



MASTER side
Steps followed
root@test:/home# hcitool lescan

root@test:/home# ./simple-agent  hci0 00:02:72:D6:A1:0D

Creating device failed: org.freedesktop.DBus.Error.NoReply: Did not 
receive a reply. Possible causes include: the remote application did not 
send a reply, the message bus security policy blocked the reply, the 
reply timeout expired, or the network connection was broken.

hcidump on master side
********************************************************************************
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7
     type 0x01 (active)
     interval 10.000ms window 10.000ms
     own address: 0x00 (Public) policy: All
 > HCI Event: Command Complete (0x0e) plen 4
     LE Set Scan Parameters (0x08|0x000b) ncmd 1
     status 0x00
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
     value 0x01 (scanning enabled)
     filter duplicates 0x00 (disabled)
 > HCI Event: Command Complete (0x0e) plen 4
     LE Set Scan Enable (0x08|0x000c) ncmd 1
     status 0x00

       RSSI: -71
 > HCI Event: LE Meta Event (0x3e) plen 12
     LE Advertising Report
       SCAN_RSP - Scan Response (4)
       bdaddr 00:02:72:D6:A1:0D (Public)
       RSSI: -70
 > HCI Event: LE Meta Event (0x3e) plen 15
     LE Advertising Report
       ADV_IND - Connectable undirected advertising (0)
       bdaddr 00:02:72:D6:A1:0D (Public)
       Flags: 0x06
       RSSI: -69

 > HCI Event: LE Meta Event (0x3e) plen 12
     LE Advertising Report
       SCAN_RSP - Scan Response (4)
       bdaddr 00:02:72:D6:A1:0D (Public)

< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
     value 0x00 (scanning disabled)
     filter duplicates 0x00 (disabled)
 > HCI Event: Command Complete (0x0e) plen 4
     LE Set Scan Enable (0x08|0x000c) ncmd 1
     status 0x00
< HCI Command: LE Create Connection (0x08|0x000d) plen 25
     bdaddr 00:02:72:D6:A1:0D type 0
 > HCI Event: Command Status (0x0f) plen 4
     LE Create Connection (0x08|0x000d) status 0x00 ncmd 1
 > HCI Event: LE Meta Event (0x3e) plen 19
     LE Connection Complete
       status 0x00 handle 64, role master
< ACL data: handle 64 flags 0x00 dlen 11
     ATT: Read By Group req (0x10)
       start 0x0001, end 0xffff
       type-uuid 0x2800
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 64 packets 1
< HCI Command: Read Remote Version Information (0x01|0x001d) plen 2
     handle 64
 > HCI Event: Command Status (0x0f) plen 4
     Read Remote Version Information (0x01|0x001d) status 0x00 ncmd 1
 > HCI Event: Read Remote Ver Info Complete (0x0c) plen 8
     status 0x00 handle 64
     LMP Version: 4.0 (0x6) LMP Subversion: 0x220e
     Manufacturer: Broadcom Corporation (15)
< HCI Command: Disconnect (0x01|0x0006) plen 3
     handle 64 reason 0x13
     Reason: Remote User Terminated Connection
 > HCI Event: Command Status (0x0f) plen 4
     Disconnect (0x01|0x0006) status 0x00 ncmd 1
 > HCI Event: Disconn Complete (0x05) plen 4
     status 0x00 handle 64 reason 0x16
     Reason: Connection Terminated by Local Host


SLAVE side

root@test:/home#  hcitool -i hci0 cmd 0x08 0x0008 03 02 01 06 \
     			$(perl -e 'print "00 " x 28')
root@test:/home# hciconfig hci0  leadv


Hcidump shows ..

< HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32
 > HCI Event: Command Complete (0x0e) plen 4
     LE Set Advertising Data (0x08|0x0008) ncmd 1
     status 0x00
< HCI Command: LE Set Advertise Enable (0x08|0x000a) plen 1
 > HCI Event: Command Complete (0x0e) plen 4
     LE Set Advertise Enable (0x08|0x000a) ncmd 1
     status 0x00

 > HCI Event: LE Meta Event (0x3e) plen 19
     LE Connection Complete
       status 0x00 handle 64, role slave
       bdaddr 00:02:72:D6:AB:AD (Public)
 > ACL data: handle 64 flags 0x02 dlen 11
     ATT: Read By Group req (0x10)
       start 0x0001, end 0xffff
       type-uuid 0x2800
 > HCI Event: Disconn Complete (0x05) plen 4
     status 0x00 handle 64 reason 0x13
     Reason: Remote User Terminated Connection

***************************************************************************


-- 
Thanks & Regards

  AJAY KV
  GlobalEdge software Ltd
  8892753703

[-- Attachment #2: ajay_kv.vcf --]
[-- Type: text/x-vcard, Size: 74 bytes --]

begin:vcard
fn:AJAY KV
n:;AJAY
tel;cell:8892753703
version:2.1
end:vcard


^ permalink raw reply

* [PATCH 1/2] audio: Remove left over of HFP removal
From: chanyeol.park @ 2012-12-05  2:27 UTC (permalink / raw)
  To: linux-bluetooth

From: Chan-yeol Park <chanyeol.park@samsung.com>

---
 profiles/audio/main.c |    8 --------
 1 file changed, 8 deletions(-)

diff --git a/profiles/audio/main.c b/profiles/audio/main.c
index ce060fc..c5d1426 100644
--- a/profiles/audio/main.c
+++ b/profiles/audio/main.c
@@ -44,8 +44,6 @@
 #include "device.h"
 #include "manager.h"
 
-static GIOChannel *sco_server = NULL;
-
 static GKeyFile *load_config_file(const char *file)
 {
 	GError *err = NULL;
@@ -81,12 +79,6 @@ static int audio_init(void)
 
 static void audio_exit(void)
 {
-	if (sco_server) {
-		g_io_channel_shutdown(sco_server, TRUE, NULL);
-		g_io_channel_unref(sco_server);
-		sco_server = NULL;
-	}
-
 	audio_manager_exit();
 }
 
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 2/2] build: Include bluetooth lib folder for obexd
From: chanyeol.park @ 2012-12-05  2:27 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1354674477-25835-1-git-send-email-chanyeol.park@samsung.com>

From: Chan-yeol Park <chanyeol.park@samsung.com>

Because obexd is included in bluez repo, obexd should refer to local
lib folder before system's one.
---
 Makefile.obexd |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile.obexd b/Makefile.obexd
index 1ed423b..cbcd65d 100644
--- a/Makefile.obexd
+++ b/Makefile.obexd
@@ -29,7 +29,7 @@ obexd_src_obexd_CFLAGS = @GLIB_CFLAGS@ @DBUS_CFLAGS@ \
 					-DPLUGINDIR=\""$(obex_plugindir)"\" \
 					-fPIC -D_FILE_OFFSET_BITS=64
 
-obexd_src_obexd_CPPFLAGS = -I$(builddir)/obexd/src \
+obexd_src_obexd_CPPFLAGS = -I$(builddir)/lib -I$(builddir)/obexd/src  \
 				-I$(srcdir)/obexd/src -I$(srcdir)/btio \
 				-I$(srcdir)/gobex -I$(srcdir)/gdbus
 
@@ -76,7 +76,8 @@ obexd_client_obex_client_LDADD = lib/libbluetooth-private.la \
 obexd_client_obex_client_CFLAGS = @GLIB_CFLAGS@ @DBUS_CFLAGS@ \
 						-fPIC -D_FILE_OFFSET_BITS=64
 
-obexd_client_obex_client_CPPFLAGS = -I$(srcdir)/obexd/src -I$(srcdir)/btio \
-					-I$(srcdir)/gobex -I$(srcdir)/gdbus
+obexd_client_obex_client_CPPFLAGS = -I$(builddir)/lib -I$(srcdir)/obexd/src \
+				-I$(srcdir)/btio -I$(srcdir)/gobex \
+				-I$(srcdir)/gdbus
 
 obexd_client_obex_client_SHORTNAME = obex-client
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH v3 00/20] CSCP plugin
From: Johan Hedberg @ 2012-12-05  8:23 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1354625026-29358-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Tue, Dec 04, 2012, Andrzej Kaczmarek wrote:
> Changes since v2:
> - rebased to latest upstream master
> - moved all code to cyclingspeed.c to avoid "empty" calls across files
> 
> No changes in functionality.
> 
> 
> Andrzej Kaczmarek (20):
>   cyclingspeed: Add CSC profile plugin skeleton
>   cyclingspeed: Add attio callbacks
>   cyclingspeed: Discover CSCS characteristics
>   cyclingspeed: Discover characteristics CCC
>   cyclingspeed: Read CSC Feature characteristic value
>   cyclingspeed: Read Sensor Location characteristic value
>   cyclingspeed: Add CyclingSpeedManager interface
>   cyclingspeed: Add support to enable measurement notifications
>   cyclingspeed: Process measurement notifications
>   cyclingspeed: Add DBus.Properties for org.bluez.CyclingSpeed
>     interface
>   cyclingspeed: Add stub to use SC Control Point
>   cyclingspeed: Add support for Request Supported Sensor Locations
>   cyclingspeed: Add support for Update Sensor Location
>   cyclingspeed: Add support for Set Cumulative Value
>   core: Add CyclingSpeedWatcher interface to default policy
>   doc: Remove Get-/SetProperties from CSC API document
>   doc: Rename cycling API to cyclingspeed
>   build: Add CSCP API document to EXTRA_DIST
>   test: Add cyclingspeed test script
>   test: Enable speed and cadence calculation in test-cyclingspeed
> 
>  Makefile.am                          |    8 +-
>  Makefile.tools                       |    3 +-
>  doc/cycling-api.txt                  |  118 ----
>  doc/cyclingspeed-api.txt             |  100 +++
>  lib/uuid.h                           |    6 +
>  profiles/cyclingspeed/cyclingspeed.c | 1285 ++++++++++++++++++++++++++++++++++
>  src/bluetooth.conf                   |    1 +
>  test/test-cyclingspeed               |  191 +++++
>  8 files changed, 1590 insertions(+), 122 deletions(-)
>  delete mode 100644 doc/cycling-api.txt
>  create mode 100644 doc/cyclingspeed-api.txt
>  create mode 100644 profiles/cyclingspeed/cyclingspeed.c
>  create mode 100755 test/test-cyclingspeed

All patches in this set have been applied. Thanks.

I also pushed an additional coding style cleanup patch, so if you have
further patches to this code queued up please rebase first to the
upstream tree.

Johan

^ permalink raw reply

* Re: [PATCH 1/2] audio: Remove left over of HFP removal
From: Johan Hedberg @ 2012-12-05  8:43 UTC (permalink / raw)
  To: chanyeol.park; +Cc: linux-bluetooth
In-Reply-To: <1354674477-25835-1-git-send-email-chanyeol.park@samsung.com>

Hi Chan-yeol,

On Wed, Dec 05, 2012, chanyeol.park@samsung.com wrote:
> ---
>  profiles/audio/main.c |    8 --------
>  1 file changed, 8 deletions(-)

Both patches have been applied. Thanks!

Johan

^ permalink raw reply

* [PATCH] adapter: Fix compilation on some architectures
From: Szymon Janc @ 2012-12-05 10:02 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

plain char may be treated as signed or unsigned depending on compiler
(as oposite to other integer types). Use signed char explicitly when
signed type is needed.

This fix following compilation error on ARM:

  CC     src/bluetoothd-adapter.o
src/adapter.c: In function ‘convert_entry’:
src/adapter.c:2710:2: error: comparison is always true due to limited
	range of data type [-Werror=type-limits]
cc1: all warnings being treated as errors
make[1]: *** [src/bluetoothd-adapter.o] Error 1
---
 src/adapter.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/adapter.c b/src/adapter.c
index 3c5d277..0cbce78 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2673,7 +2673,7 @@ static void convert_ltk_entry(GKeyFile *key_file, void *value)
 static void convert_entry(char *key, char *value, void *user_data)
 {
 	struct device_converter *converter = user_data;
-	char device_type = -1;
+	signed char device_type = -1;
 	char filename[PATH_MAX + 1];
 	GKeyFile *key_file;
 	char *data;
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 0/9] Remove redundant struct audio_device members
From: Szymon Janc @ 2012-12-05 10:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Both src and dst addresses can be obtained from struct btd_device
reference and used when needed.

Szymon Janc (9):
  avdtp: Convert avdtp_get to accept audio_device
  avdtp: Convert avdtp_is_connected to accept audio_device
  avctp: Convert avctp_connect to accept audio_device
  avctp: Convert avctp_get to accept audio_device
  avctp: Don't use audio_device src and dst in avctp_control_confirm
  avdtp: Don't use audio_device src and dst fields in avdtp_confirm_cb
  audio: Don't use audio_device src and dst in manager_find_devices
  avrcp: Don't use audio_device src field
  audio: Remove src and dst from struct audio_device

 profiles/audio/avctp.c     |   23 ++++++++++++++++++++---
 profiles/audio/avctp.h     |    4 ++--
 profiles/audio/avdtp.c     |   16 +++++++++++++---
 profiles/audio/avdtp.h     |    4 ++--
 profiles/audio/avrcp.c     |   16 +++++++++++-----
 profiles/audio/control.c   |    4 ++--
 profiles/audio/device.c    |   13 ++++---------
 profiles/audio/device.h    |    7 +------
 profiles/audio/manager.c   |   11 ++++++++---
 profiles/audio/sink.c      |    2 +-
 profiles/audio/source.c    |    2 +-
 profiles/audio/transport.c |    3 +--
 12 files changed, 66 insertions(+), 39 deletions(-)

-- 
1.7.9.5


^ permalink raw reply

* [PATCH 1/9] avdtp: Convert avdtp_get to accept audio_device
From: Szymon Janc @ 2012-12-05 10:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354702224-15895-1-git-send-email-szymon.janc@tieto.com>

Use addresses taken from btd_dev reference in audio_device to get
session source and destination.
---
 profiles/audio/avdtp.c     |    7 ++++++-
 profiles/audio/avdtp.h     |    2 +-
 profiles/audio/sink.c      |    2 +-
 profiles/audio/source.c    |    2 +-
 profiles/audio/transport.c |    3 +--
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index e38c95b..9ff2168 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2363,9 +2363,14 @@ static struct avdtp *avdtp_get_internal(const bdaddr_t *src, const bdaddr_t *dst
 	return session;
 }
 
-struct avdtp *avdtp_get(bdaddr_t *src, bdaddr_t *dst)
+struct avdtp *avdtp_get(struct audio_device *device)
 {
 	struct avdtp *session;
+	const bdaddr_t *src;
+	const bdaddr_t *dst;
+
+	src = adapter_get_address(device_get_adapter(device->btd_dev));
+	dst = device_get_address(device->btd_dev);
 
 	session = avdtp_get_internal(src, dst);
 
diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h
index cdf39bf..9117e89 100644
--- a/profiles/audio/avdtp.h
+++ b/profiles/audio/avdtp.h
@@ -213,7 +213,7 @@ struct avdtp_sep_ind {
 typedef void (*avdtp_discover_cb_t) (struct avdtp *session, GSList *seps,
 					struct avdtp_error *err, void *user_data);
 
-struct avdtp *avdtp_get(bdaddr_t *src, bdaddr_t *dst);
+struct avdtp *avdtp_get(struct audio_device *device);
 
 void avdtp_unref(struct avdtp *session);
 struct avdtp *avdtp_ref(struct avdtp *session);
diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c
index 466c0a8..d964c3c 100644
--- a/profiles/audio/sink.c
+++ b/profiles/audio/sink.c
@@ -348,7 +348,7 @@ int sink_connect(struct audio_device *dev, audio_device_cb cb, void *data)
 	struct pending_request *pending;
 
 	if (!sink->session)
-		sink->session = avdtp_get(&dev->src, &dev->dst);
+		sink->session = avdtp_get(dev);
 
 	if (!sink->session) {
 		DBG("Unable to get a session");
diff --git a/profiles/audio/source.c b/profiles/audio/source.c
index 157a4e8..eea2661 100644
--- a/profiles/audio/source.c
+++ b/profiles/audio/source.c
@@ -348,7 +348,7 @@ int source_connect(struct audio_device *dev, audio_device_cb cb, void *data)
 	struct pending_request *pending;
 
 	if (!source->session)
-		source->session = avdtp_get(&dev->src, &dev->dst);
+		source->session = avdtp_get(dev);
 
 	if (!source->session) {
 		DBG("Unable to get a session");
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index 610aca3..859900d 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -381,11 +381,10 @@ static guint resume_a2dp(struct media_transport *transport,
 {
 	struct a2dp_transport *a2dp = transport->data;
 	struct media_endpoint *endpoint = transport->endpoint;
-	struct audio_device *device = transport->device;
 	struct a2dp_sep *sep = media_endpoint_get_sep(endpoint);
 
 	if (a2dp->session == NULL) {
-		a2dp->session = avdtp_get(&device->src, &device->dst);
+		a2dp->session = avdtp_get(transport->device);
 		if (a2dp->session == NULL)
 			return 0;
 	}
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 2/9] avdtp: Convert avdtp_is_connected to accept audio_device
From: Szymon Janc @ 2012-12-05 10:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354702224-15895-1-git-send-email-szymon.janc@tieto.com>

Use addresses taken from btd_dev reference in audio_device to get
session source and destination.
---
 profiles/audio/avdtp.c  |    7 ++++++-
 profiles/audio/avdtp.h  |    2 +-
 profiles/audio/device.c |    7 +++----
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 9ff2168..deb8d26 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -3201,10 +3201,15 @@ static gboolean avdtp_parse_rej(struct avdtp *session,
 	}
 }
 
-gboolean avdtp_is_connected(const bdaddr_t *src, const bdaddr_t *dst)
+gboolean avdtp_is_connected(struct audio_device *device)
 {
 	struct avdtp_server *server;
 	struct avdtp *session;
+	const bdaddr_t *src;
+	const bdaddr_t *dst;
+
+	src = adapter_get_address(device_get_adapter(device->btd_dev));
+	dst = device_get_address(device->btd_dev);
 
 	server = find_server(servers, src);
 	if (!server)
diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h
index 9117e89..e014623 100644
--- a/profiles/audio/avdtp.h
+++ b/profiles/audio/avdtp.h
@@ -218,7 +218,7 @@ struct avdtp *avdtp_get(struct audio_device *device);
 void avdtp_unref(struct avdtp *session);
 struct avdtp *avdtp_ref(struct avdtp *session);
 
-gboolean avdtp_is_connected(const bdaddr_t *src, const bdaddr_t *dst);
+gboolean avdtp_is_connected(struct audio_device *device);
 
 struct avdtp_service_capability *avdtp_service_cap_new(uint8_t category,
 							void *data, int size);
diff --git a/profiles/audio/device.c b/profiles/audio/device.c
index fef2bea..ba1efec 100644
--- a/profiles/audio/device.c
+++ b/profiles/audio/device.c
@@ -323,14 +323,13 @@ gboolean audio_device_is_active(struct audio_device *dev,
 						const char *interface)
 {
 	if (!interface) {
-		if ((dev->sink || dev->source) &&
-				avdtp_is_connected(&dev->src, &dev->dst))
+		if ((dev->sink || dev->source) && avdtp_is_connected(dev))
 			return TRUE;
 	} else if (!strcmp(interface, AUDIO_SINK_INTERFACE) && dev->sink &&
-				avdtp_is_connected(&dev->src, &dev->dst))
+				avdtp_is_connected(dev))
 		return TRUE;
 	else if (!strcmp(interface, AUDIO_SOURCE_INTERFACE) && dev->source &&
-				avdtp_is_connected(&dev->src, &dev->dst))
+				avdtp_is_connected(dev))
 		return TRUE;
 	else if (!strcmp(interface, AUDIO_CONTROL_INTERFACE) && dev->control &&
 				control_is_active(dev))
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 3/9] avctp: Convert avctp_connect to accept audio_device
From: Szymon Janc @ 2012-12-05 10:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354702224-15895-1-git-send-email-szymon.janc@tieto.com>

Use addresses taken from btd_dev reference in audio_device to get
session source and destination.
---
 profiles/audio/avctp.c   |    7 ++++++-
 profiles/audio/avctp.h   |    2 +-
 profiles/audio/avrcp.c   |    4 ++--
 profiles/audio/control.c |    2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index dcffb05..6752cef 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1594,11 +1594,16 @@ gboolean avctp_unregister_browsing_pdu_handler(unsigned int id)
 	return FALSE;
 }
 
-struct avctp *avctp_connect(const bdaddr_t *src, const bdaddr_t *dst)
+struct avctp *avctp_connect(struct audio_device *device)
 {
 	struct avctp *session;
 	GError *err = NULL;
 	GIOChannel *io;
+	const bdaddr_t *src;
+	const bdaddr_t *dst;
+
+	src = adapter_get_address(device_get_adapter(device->btd_dev));
+	dst = device_get_address(device->btd_dev);
 
 	session = avctp_get_internal(src, dst);
 	if (!session)
diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h
index c00a3fc..7314a04 100644
--- a/profiles/audio/avctp.h
+++ b/profiles/audio/avctp.h
@@ -93,7 +93,7 @@ gboolean avctp_remove_state_cb(unsigned int id);
 int avctp_register(const bdaddr_t *src, gboolean master);
 void avctp_unregister(const bdaddr_t *src);
 
-struct avctp *avctp_connect(const bdaddr_t *src, const bdaddr_t *dst);
+struct avctp *avctp_connect(struct audio_device *device);
 struct avctp *avctp_get(const bdaddr_t *src, const bdaddr_t *dst);
 int avctp_connect_browsing(struct avctp *session);
 void avctp_disconnect(struct avctp *session);
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 2517df8..f6a5ac9 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -2173,7 +2173,7 @@ static struct avrcp *session_create(struct avrcp_server *server,
 
 	session = g_new0(struct avrcp, 1);
 	session->server = server;
-	session->conn = avctp_connect(&dev->src, &dev->dst);
+	session->conn = avctp_connect(dev);
 	session->dev = dev;
 
 	server->sessions = g_slist_append(server->sessions, session);
@@ -2254,7 +2254,7 @@ gboolean avrcp_connect(struct audio_device *dev)
 {
 	struct avctp *session;
 
-	session = avctp_connect(&dev->src, &dev->dst);
+	session = avctp_connect(dev);
 	if (session)
 		return FALSE;
 
diff --git a/profiles/audio/control.c b/profiles/audio/control.c
index 7299b7e..5b16e17 100644
--- a/profiles/audio/control.c
+++ b/profiles/audio/control.c
@@ -141,7 +141,7 @@ int control_connect(struct audio_device *dev, audio_device_cb cb, void *data)
 	if (control->connect)
 		return -EINPROGRESS;
 
-	control->session = avctp_connect(&dev->src, &dev->dst);
+	control->session = avctp_connect(dev);
 	if (!control->session)
 		return -EIO;
 
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 4/9] avctp: Convert avctp_get to accept audio_device
From: Szymon Janc @ 2012-12-05 10:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354702224-15895-1-git-send-email-szymon.janc@tieto.com>

Use addresses taken from btd_dev reference in audio_device to get
session source and destination.
---
 profiles/audio/avctp.c   |    8 +++++++-
 profiles/audio/avctp.h   |    2 +-
 profiles/audio/avrcp.c   |    2 +-
 profiles/audio/control.c |    2 +-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 6752cef..a7daef3 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1671,7 +1671,13 @@ void avctp_disconnect(struct avctp *session)
 	avctp_set_state(session, AVCTP_STATE_DISCONNECTED);
 }
 
-struct avctp *avctp_get(const bdaddr_t *src, const bdaddr_t *dst)
+struct avctp *avctp_get(struct audio_device *device)
 {
+	const bdaddr_t *src;
+	const bdaddr_t *dst;
+
+	src = adapter_get_address(device_get_adapter(device->btd_dev));
+	dst = device_get_address(device->btd_dev);
+
 	return avctp_get_internal(src, dst);
 }
diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h
index 7314a04..2597e6e 100644
--- a/profiles/audio/avctp.h
+++ b/profiles/audio/avctp.h
@@ -94,7 +94,7 @@ int avctp_register(const bdaddr_t *src, gboolean master);
 void avctp_unregister(const bdaddr_t *src);
 
 struct avctp *avctp_connect(struct audio_device *device);
-struct avctp *avctp_get(const bdaddr_t *src, const bdaddr_t *dst);
+struct avctp *avctp_get(struct audio_device *device);
 int avctp_connect_browsing(struct avctp *session);
 void avctp_disconnect(struct avctp *session);
 
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index f6a5ac9..d5f23da 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -2265,7 +2265,7 @@ void avrcp_disconnect(struct audio_device *dev)
 {
 	struct avctp *session;
 
-	session = avctp_get(&dev->src, &dev->dst);
+	session = avctp_get(dev);
 	if (!session)
 		return;
 
diff --git a/profiles/audio/control.c b/profiles/audio/control.c
index 5b16e17..fea49b6 100644
--- a/profiles/audio/control.c
+++ b/profiles/audio/control.c
@@ -110,7 +110,7 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 		if (control->session)
 			break;
 
-		control->session = avctp_get(&dev->src, &dev->dst);
+		control->session = avctp_get(dev);
 
 		break;
 	case AVCTP_STATE_CONNECTED:
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 5/9] avctp: Don't use audio_device src and dst in avctp_control_confirm
From: Szymon Janc @ 2012-12-05 10:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354702224-15895-1-git-send-email-szymon.janc@tieto.com>

Use src and dst addresses from btd_dev reference.
---
 profiles/audio/avctp.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index a7daef3..e29527f 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1055,6 +1055,9 @@ static struct avctp *avctp_get_internal(const bdaddr_t *src,
 static void avctp_control_confirm(struct avctp *session, GIOChannel *chan,
 						struct audio_device *dev)
 {
+	const bdaddr_t *src;
+	const bdaddr_t *dst;
+
 	if (session->control != NULL) {
 		error("Control: Refusing unexpected connect");
 		g_io_channel_shutdown(chan, TRUE, NULL);
@@ -1064,7 +1067,10 @@ static void avctp_control_confirm(struct avctp *session, GIOChannel *chan,
 	avctp_set_state(session, AVCTP_STATE_CONNECTING);
 	session->control = avctp_channel_create(session, chan);
 
-	session->auth_id = btd_request_authorization(&dev->src, &dev->dst,
+	src = adapter_get_address(device_get_adapter(dev->btd_dev));
+	dst = device_get_address(dev->btd_dev);
+
+	session->auth_id = btd_request_authorization(src, dst,
 							AVRCP_TARGET_UUID,
 							auth_cb, session);
 	if (session->auth_id == 0)
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 6/9] avdtp: Don't use audio_device src and dst fields in avdtp_confirm_cb
From: Szymon Janc @ 2012-12-05 10:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354702224-15895-1-git-send-email-szymon.janc@tieto.com>

There is already src and dst available from bt_io.
---
 profiles/audio/avdtp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index deb8d26..9f7bea2 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2546,7 +2546,7 @@ static void avdtp_confirm_cb(GIOChannel *chan, gpointer data)
 	session->io_id = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
 					(GIOFunc) session_cb, session);
 
-	session->auth_id = btd_request_authorization(&dev->src, &dev->dst,
+	session->auth_id = btd_request_authorization(&src, &dst,
 							ADVANCED_AUDIO_UUID,
 							auth_cb, session);
 	if (session->auth_id == 0) {
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 7/9] audio: Don't use audio_device src and dst in manager_find_devices
From: Szymon Janc @ 2012-12-05 10:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1354702224-15895-1-git-send-email-szymon.janc@tieto.com>

Use addresses taken from btd_dev reference in audio_device to get
device source and destination.
---
 profiles/audio/manager.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index 714489a..98ae694 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
@@ -673,15 +673,20 @@ GSList *manager_find_devices(const char *path,
 
 	for (l = devices; l != NULL; l = l->next) {
 		struct audio_device *dev = l->data;
+		const bdaddr_t *dev_src;
+		const bdaddr_t *dev_dst;
+
+		dev_src = adapter_get_address(device_get_adapter(dev->btd_dev));
+		dev_dst = device_get_address(dev->btd_dev);
 
 		if ((path && (strcmp(path, "")) &&
 				strcmp(device_get_path(dev->btd_dev), path)))
 			continue;
 
-		if ((src && bacmp(src, BDADDR_ANY)) && bacmp(&dev->src, src))
+		if ((src && bacmp(src, BDADDR_ANY)) && bacmp(dev_src, src))
 			continue;
 
-		if ((dst && bacmp(dst, BDADDR_ANY)) && bacmp(&dev->dst, dst))
+		if ((dst && bacmp(dst, BDADDR_ANY)) && bacmp(dev_dst, dst))
 			continue;
 
 		if (interface && !strcmp(AUDIO_SINK_INTERFACE, interface)
-- 
1.7.9.5


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox