- preconnect phone before checking BT modem

This commit is contained in:
Dmytro Bogovych 2023-09-06 20:03:50 +03:00
parent 1256f3ad21
commit eccf8d1934
3 changed files with 17 additions and 6 deletions

View File

@ -472,6 +472,12 @@ if __name__ == '__main__':
bt_ctl = Bluetoothctl() bt_ctl = Bluetoothctl()
bt_ctl.connect(CONFIG.BT_MAC) bt_ctl.connect(CONFIG.BT_MAC)
utils.log(f' Done.') utils.log(f' Done.')
else:
utils.log_error(f'No BT MAC specified, cannot connect. Exiting.')
raise SystemExit(EXIT_ERROR)
# Init BT modem
bt_call_controller.init()
# Logging settings # Logging settings
utils.verbose_logging = CONFIG.Verbose utils.verbose_logging = CONFIG.Verbose

View File

@ -42,13 +42,18 @@ class CallState(bt_phone.Observer):
# Listen to call changes # Listen to call changes
CALL_STATE_EVENT = CallState() CALL_STATE_EVENT = None
PHONE = bt_phone.Phone() PHONE = None
PHONE.addObserver(CALL_STATE_EVENT)
# virtualmic module # virtualmic module
PA_MODULE_IDX = -1 PA_MODULE_IDX = -1
def init():
global CALL_STATE_EVENT, PHONE
CALL_STATE_EVENT = CallState()
PHONE = bt_phone.Phone()
PHONE.addObserver(CALL_STATE_EVENT)
# Set volume 0..100% # Set volume 0..100%
def set_headset_spk_volume(vol: float): def set_headset_spk_volume(vol: float):

View File

@ -59,7 +59,7 @@ class Phone(Observable):
model_serial = properties['Serial'] model_serial = properties['Serial']
modem_online = properties['Online'] modem_online = properties['Online']
utils.log(f'Found modem: {path} name: {modem_name} serial: {model_serial} online: {modem_online}') # utils.log(f'Found modem: {path} name: {modem_name} serial: {model_serial} online: {modem_online}')
if modem_online == 1: if modem_online == 1:
return path return path