/usr/bin/bluez-test-telephony is in bluez 4.101-0ubuntu13.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | #!/usr/bin/python
from __future__ import absolute_import, print_function, unicode_literals
import sys
import dbus
from optparse import OptionParser, make_option
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
option_list = [
make_option("-i", "--device", action="store",
type="string", dest="dev_id"),
]
parser = OptionParser(option_list=option_list)
(options, args) = parser.parse_args()
if options.dev_id:
adapter_path = manager.FindAdapter(options.dev_id)
else:
adapter_path = manager.DefaultAdapter()
adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
"org.bluez.Adapter")
test = dbus.Interface(bus.get_object("org.bluez", "/org/bluez/test"),
"org.bluez.TelephonyTest")
if len(args) < 1:
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 args[0] == "connect":
if len(args) < 2:
print("Need device address parameter")
sys.exit(1)
device = adapter.FindDevice(args[1])
headset = dbus.Interface(bus.get_object("org.bluez", device),
"org.bluez.Headset")
headset.Connect()
sys.exit(0)
if args[0] == "disconnect":
if len(args) < 2:
print("Need device address parameter")
sys.exit(1)
device = adapter.FindDevice(args[1])
headset = dbus.Interface(bus.get_object("org.bluez", device),
"org.bluez.Headset")
headset.Disconnect()
sys.exit(0)
if args[0] == "speakergain":
if len(args) < 2:
print("Need device address parameter")
sys.exit(1)
device = adapter.FindDevice(args[1])
headset = dbus.Interface(bus.get_object("org.bluez", device),
"org.bluez.Headset")
if len(args) > 2:
headset.SetProperty('SpeakerGain', dbus.UInt16(args[2]))
else:
props = headset.GetProperties()
print(props['SpeakerGain'])
sys.exit(0)
if args[0] == "microphonegain":
if len(args) < 2:
print("Need device address parameter")
sys.exit(1)
device = adapter.FindDevice(args[1])
headset = dbus.Interface(bus.get_object("org.bluez", device),
"org.bluez.Headset")
if len(args) > 2:
headset.SetProperty('MicrophoneGain', dbus.UInt16(args[2]))
else:
props = headset.GetProperties()
print(props['MicrophoneGain'])
sys.exit(0)
if args[0] == "play":
if len(args) < 2:
print("Need device address parameter")
sys.exit(1)
device = adapter.FindDevice(args[1])
headset = dbus.Interface(bus.get_object("org.bluez", device),
"org.bluez.Headset")
headset.Play()
sys.exit(0)
if args[0] == "stop":
if len(args) < 2:
print("Need device address parameter")
sys.exit(1)
device = adapter.FindDevice(args[1])
headset = dbus.Interface(bus.get_object("org.bluez", device),
"org.bluez.Headset")
headset.Stop()
sys.exit(0)
if args[0] == "outgoing":
if len(args) > 1:
test.OutgoingCall(args[1])
else:
print("Need number parameter")
sys.exit(0)
if args[0] == "incoming":
if len(args) > 1:
test.IncomingCall(args[1])
else:
print("Need number parameter")
sys.exit(0)
if args[0] == "cancel":
test.CancelCall()
sys.exit(0)
if args[0] == "signal":
if len(args) > 1:
test.SignalStrength(args[1])
else:
print("Need signal strength parameter")
sys.exit(0)
if args[0] == "battery":
if len(args) > 1:
test.BatteryLevel(args[1])
else:
print("Need battery level parameter")
sys.exit(0)
if args[0] == "roaming":
if len(args) > 1:
test.RoamingStatus(args[1] == "yes" or False)
else:
print("Need yes/no parameter")
sys.exit(0)
if args[0] == "registration":
if len(args) > 1:
test.RegistrationStatus(args[1] == "yes" or False)
else:
print("Need yes/no parameter")
sys.exit(0)
if args[0] == "subscriber":
if len(args) > 1:
test.SetSubscriberNumber(args[1])
else:
print("Need number parameter")
sys.exit(0)
print("Unknown command")
sys.exit(1)
|