- test script

This commit is contained in:
Dmytro Bogovych 2023-12-18 13:09:57 +03:00
parent 2f67aec5bb
commit 6feb10f49a
1 changed files with 42 additions and 0 deletions

42
src/bt_phone_test.py Normal file
View File

@ -0,0 +1,42 @@
#!/usr/bin/python3
import bt_phone
import bt_controller
import time
EXIT_OK = 0
EXIT_ERROR = 1
PHONE_BT_MAC = '40:B0:76:B4:36:98'
# Connection to phone
bluetooth_ctl = bt_controller.Bluetoothctl()
devices = bt_controller.get_paired_devices()
print(f'Paired devices: {devices}')
# disconnect before connect
bluetooth_ctl.disconnect( PHONE_BT_MAC )
ret = bluetooth_ctl.connect( PHONE_BT_MAC )
if ret == False:
print(f'Connect to {PHONE_BT_MAC} failed')
exit(EXIT_ERROR)
print(f'Connect to {PHONE_BT_MAC} success')
# Call
# Initialize phone - this brings Ofono via D-Bus
phone = bt_phone.Phone()
phone.setup_dbus_loop()
phone.call_number('111222')
# Wait 5 seconds
time.sleep(5)
# Just to be sure
phone.hangup_call()
phone.quit_dbus_loop()
exit(EXIT_OK)