Add service test scripts

This commit is contained in:
Marcel Holtmann 2007-05-08 14:08:54 +00:00
parent 89aa5447d1
commit fcba5ddbba
4 changed files with 77 additions and 2 deletions

View File

@ -23,6 +23,6 @@ AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @HAL_CFLAGS@ @GLIB_CFLAGS@
INCLUDES = -I$(top_srcdir)/common INCLUDES = -I$(top_srcdir)/common
EXTRA_DIST = network.service network-api.txt EXTRA_DIST = network.service network-api.txt test-network
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in

27
network/test-network Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/python
import dbus
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'),
'org.bluez.Manager')
conn = manager.ActivateService('network')
network = dbus.Interface(bus.get_object(conn, '/org/bluez/network'),
'org.bluez.network.Manager')
try:
nap = dbus.Interface(bus.get_object('org.bluez.network',
network.FindAdapter('nap')),
'org.bluez.network.Server')
except:
pass
try:
gn = dbus.Interface(bus.get_object('org.bluez.network',
network.FindAdapter('gn')),
'org.bluez.network.Server')
except:
pass

View File

@ -20,6 +20,6 @@ AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@
INCLUDES = -I$(top_srcdir)/common INCLUDES = -I$(top_srcdir)/common
EXTRA_DIST = serial.service serial-api.txt EXTRA_DIST = serial.service serial-api.txt test-serial
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in

48
serial/test-serial Executable file
View File

@ -0,0 +1,48 @@
#!/usr/bin/python
import sys
import time
import dbus
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'),
'org.bluez.Manager')
conn = manager.ActivateService('serial')
serial = dbus.Interface(bus.get_object(conn, '/org/bluez/serial'),
'org.bluez.serial.Manager')
if (len(sys.argv) < 2):
print "Usage: %s <address> [service]" % (sys.argv[0])
sys.exit(1)
address = sys.argv[1]
if (len(sys.argv) < 3):
service = "spp"
else:
service = sys.argv[2]
uuidbase = "-0000-1000-8000-00805F9B34FB"
if (service == "spp"):
service = "00001101" + uuidbase
if (service == "dun"):
service = "00001103" + uuidbase
device = serial.ConnectService(address, service)
print "Connected %s to %s" % (device, address)
print "Press CTRL-C to disconnect"
try:
time.sleep(1000)
print "Terminating connection"
except:
pass
serial.DisconnectService(device)