summaryrefslogtreecommitdiffstats
path: root/test/test-telephony
blob: eb695117cea34a1a015bdbd91139ee8f94fae6cf (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/python

import sys
import dbus

bus = dbus.SystemBus()

manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()),
				"org.bluez.Adapter")
test = dbus.Interface(bus.get_object("org.bluez", "/org/bluez/test"),
			"org.bluez.TelephonyTest")

if len(sys.argv) < 2:
	print """Usage: %s <command>

	connect <bdaddr>
	disconnect <bdaddr>
	outgoing <number>
	incoming <number>
	cancel
	signal <level>
	battery <level>
	roaming <yes|no>
	registration <status>
	subscriber <number>
	speakergain <bdaddr> [level]
	microphonegain <bdaddr> [level]
	play <bdaddr>
	stop <bdaddr>
	""" % sys.argv[0]
	sys.exit(1)

if sys.argv[1] == "connect":
	if len(sys.argv) < 3:
		print "Need device address parameter"
		sys.exit(1)
	device = adapter.FindDevice(sys.argv[2])
	headset = dbus.Interface(bus.get_object("org.bluez", device),
					"org.bluez.Headset")
	headset.Connect()
	sys.exit(0)

if sys.argv[1] == "disconnect":
	if len(sys.argv) < 3:
		print "Need device address parameter"
		sys.exit(1)
	device = adapter.FindDevice(sys.argv[2])
	headset = dbus.Interface(bus.get_object("org.bluez", device),
					"org.bluez.Headset")
	headset.Disconnect()
	sys.exit(0)

if sys.argv[1] == "speakergain":
	if len(sys.argv) < 3:
		print "Need device address parameter"
		sys.exit(1)
	device = adapter.FindDevice(sys.argv[2])
	headset = dbus.Interface(bus.get_object("org.bluez", device),
					"org.bluez.Headset")
	if len(sys.argv) > 3:
		headset.SetProperty('SpeakerGain', dbus.UInt16(sys.argv[3]))
	else:
		props = headset.GetProperties()
		print props['SpeakerGain']

	sys.exit(0)

if sys.argv[1] == "microphonegain":
	if len(sys.argv) < 3:
		print "Need device address parameter"
		sys.exit(1)
	device = adapter.FindDevice(sys.argv[2])
	headset = dbus.Interface(bus.get_object("org.bluez", device),
					"org.bluez.Headset")
	if len(sys.argv) > 3:
		headset.SetProperty('MicrophoneGain', dbus.UInt16(sys.argv[3]))
	else:
		props = headset.GetProperties()
		print props['MicrophoneGain']

	sys.exit(0)

if sys.argv[1] == "play":
	if len(sys.argv) < 3:
		print "Need device address parameter"
		sys.exit(1)
	device = adapter.FindDevice(sys.argv[2])
	headset = dbus.Interface(bus.get_object("org.bluez", device),
					"org.bluez.Headset")
	headset.Play()

	sys.exit(0)

if sys.argv[1] == "stop":
	if len(sys.argv) < 3:
		print "Need device address parameter"
		sys.exit(1)
	device = adapter.FindDevice(sys.argv[2])
	headset = dbus.Interface(bus.get_object("org.bluez", device),
					"org.bluez.Headset")
	headset.Stop()

	sys.exit(0)

if sys.argv[1] == "outgoing":
	if len(sys.argv) > 2:
		test.OutgoingCall(sys.argv[2])
	else:
		print "Need number parameter"
	sys.exit(0)

if sys.argv[1] == "incoming":
	if len(sys.argv) > 2:
		test.IncomingCall(sys.argv[2])
	else:
		print "Need number parameter"
	sys.exit(0)

if sys.argv[1] == "cancel":
	test.CancelCall()
	sys.exit(0)

if sys.argv[1] == "signal":
	if len(sys.argv) > 2:
		test.SignalStrength(sys.argv[2])
	else:
		print "Need signal strength parameter"
	sys.exit(0)

if sys.argv[1] == "battery":
	if len(sys.argv) > 2:
		test.BatteryLevel(sys.argv[2])
	else:
		print "Need battery level parameter"
	sys.exit(0)

if sys.argv[1] == "roaming":
	if len(sys.argv) > 2:
		test.RoamingStatus(sys.argv[2] == "yes" or False)
	else:
		print "Need yes/no parameter"
	sys.exit(0)

if sys.argv[1] == "registration":
	if len(sys.argv) > 2:
		test.RegistrationStatus(sys.argv[2] == "yes" or False)
	else:
		print "Need yes/no parameter"
	sys.exit(0)

if sys.argv[1] == "subscriber":
	if len(sys.argv) > 2:
		test.SetSubscriberNumber(sys.argv[2])
	else:
		print "Need number parameter"
	sys.exit(0)

print "Unknown command"
sys.exit(1)