From: Gustavo Padovan <gustavo@padovan.org>
To: linux-bluetooth@vger.kernel.org
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Subject: [PATCH] test: add test-audiosource
Date: Fri, 15 Jun 2012 02:52:37 -0300 [thread overview]
Message-ID: <1339739557-6992-1-git-send-email-gustavo@padovan.org> (raw)
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
Makefile.tools | 2 +-
test/test-audiosource | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletion(-)
create mode 100644 test/test-audiosource
diff --git a/Makefile.tools b/Makefile.tools
index 36b7178..b30c999 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -225,4 +225,4 @@ EXTRA_DIST += test/apitest test/sap-client test/hsplay test/hsmicro \
test/test-serial-proxy test/test-health 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/simple-player test/test-nap test/test-audiosource
diff --git a/test/test-audiosource b/test/test-audiosource
new file mode 100644
index 0000000..c89ff7c
--- /dev/null
+++ b/test/test-audiosource
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+from optparse import OptionParser, make_option
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
+
+option_list = [
+ make_option("-i", "--device", action="store",
+ type="string", dest="dev_id"),
+ ]
+parser = OptionParser(option_list=option_list)
+
+(options, args) = parser.parse_args()
+
+if options.dev_id:
+ adapter_path = manager.FindAdapter(options.dev_id)
+else:
+ adapter_path = manager.DefaultAdapter()
+
+adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
+ "org.bluez.Adapter")
+
+if len(args) < 2:
+ print """Usage: %s <command>
+
+ connect <bdaddr>
+ disconnect <bdaddr>
+ """ % sys.argv[0]
+ sys.exit(1)
+
+device = adapter.FindDevice(args[1])
+audio = dbus.Interface(bus.get_object("org.bluez", device),
+ "org.bluez.AudioSource")
+
+if args[0] == "connect":
+ audio.Connect()
+elif args[0] == "disconnect":
+ audio.Disconnect()
+else:
+ print "Unknown command"
+ sys.exit(1)
+
--
1.7.10.2
next reply other threads:[~2012-06-15 5:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 5:52 Gustavo Padovan [this message]
2012-06-29 11:29 ` [PATCH] test: add test-audiosource Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339739557-6992-1-git-send-email-gustavo@padovan.org \
--to=gustavo@padovan.org \
--cc=gustavo.padovan@collabora.co.uk \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox