From 6feb10f49adffaee820deb21191339a6f600cf50 Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Mon, 18 Dec 2023 13:09:57 +0300 Subject: [PATCH] - test script --- src/bt_phone_test.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/bt_phone_test.py diff --git a/src/bt_phone_test.py b/src/bt_phone_test.py new file mode 100644 index 0000000..9e0b172 --- /dev/null +++ b/src/bt_phone_test.py @@ -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) \ No newline at end of file