summaryrefslogtreecommitdiffstats
path: root/hcid/test-device
blob: 034a9c6fef7c902db695f53cb8f2fd6968cf3e87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python

import sys
import dbus

bus = dbus.SystemBus()

manager = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'),
							'org.bluez.Manager')

adapter = dbus.Interface(bus.get_object('org.bluez', manager.DefaultAdapter()),
							'org.bluez.Adapter')

if (len(sys.argv) < 2):
	print "Usage: %s <command>" % (sys.argv[0])
	print ""
	print "  create <address>"
	print "  remove <path>"
	print "  list"
	sys.exit(1)

if (sys.argv[1] == "list"):
	list = adapter.ListDevices()
	print list
	sys.exit(0)

if (len(sys.argv) < 3):
	print "Need parameter"
	sys.exit(1)

if (sys.argv[1] == "create"):
	address = sys.argv[2]
	device = adapter.CreateDevice(address)
	print device
	sys.exit(0)

if (sys.argv[1] == "remove"):
	path = sys.argv[2]
	adapter.RemoveDevice(path)
	sys.exit(0)

print "Unknown command"
sys.exit(1)