mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-17 17:24:32 +08:00
Add service test scripts
This commit is contained in:
parent
89aa5447d1
commit
fcba5ddbba
@ -23,6 +23,6 @@ AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @HAL_CFLAGS@ @GLIB_CFLAGS@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/common
|
||||
|
||||
EXTRA_DIST = network.service network-api.txt
|
||||
EXTRA_DIST = network.service network-api.txt test-network
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
27
network/test-network
Executable file
27
network/test-network
Executable 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
|
@ -20,6 +20,6 @@ AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/common
|
||||
|
||||
EXTRA_DIST = serial.service serial-api.txt
|
||||
EXTRA_DIST = serial.service serial-api.txt test-serial
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
48
serial/test-serial
Executable file
48
serial/test-serial
Executable 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)
|
Loading…
Reference in New Issue
Block a user