~ubuntu-branches/ubuntu/wily/bluez/wily

« back to all changes in this revision

Viewing changes to test/test-serial

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello
  • Date: 2008-10-07 12:10:29 UTC
  • Revision ID: james.westby@ubuntu.com-20081007121029-4gup4fmmh2vfo5nh
Tags: upstream-4.12
ImportĀ upstreamĀ versionĀ 4.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import sys
 
4
import time
 
5
import dbus
 
6
 
 
7
bus = dbus.SystemBus()
 
8
 
 
9
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
 
10
                                                "org.bluez.Manager")
 
11
 
 
12
adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()),
 
13
                                                        "org.bluez.Adapter")
 
14
 
 
15
if (len(sys.argv) < 2):
 
16
        print "Usage: %s <address> [service]" % (sys.argv[0])
 
17
        sys.exit(1)
 
18
 
 
19
address = sys.argv[1]
 
20
 
 
21
if (len(sys.argv) < 3):
 
22
        service = "spp"
 
23
else:
 
24
        service = sys.argv[2]
 
25
 
 
26
path = adapter.FindDevice(address)
 
27
 
 
28
serial = dbus.Interface(bus.get_object("org.bluez", path),
 
29
                                                "org.bluez.Serial")
 
30
 
 
31
node = serial.Connect(service)
 
32
 
 
33
print "Connected %s to %s" % (device, address)
 
34
 
 
35
print "Press CTRL-C to disconnect"
 
36
 
 
37
try:
 
38
        time.sleep(1000)
 
39
        print "Terminating connection"
 
40
except:
 
41
        pass
 
42
 
 
43
serial.Disconnect(node)