- try to finish answering nodes properly
This commit is contained in:
parent
b3f87c97f0
commit
efd763d055
|
|
@ -21,6 +21,7 @@ from agent_config import AgentConfig
|
||||||
from bt_controller import Bluetoothctl
|
from bt_controller import Bluetoothctl
|
||||||
import bt_signal
|
import bt_signal
|
||||||
from bt_signal import SignalBoundaries
|
from bt_signal import SignalBoundaries
|
||||||
|
from bt_call_controller import INTERRUPT_SIGNAL
|
||||||
import bt_call_controller
|
import bt_call_controller
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -424,12 +425,17 @@ def remove_pid_on_exit():
|
||||||
|
|
||||||
|
|
||||||
def receive_signal(signal_number, frame):
|
def receive_signal(signal_number, frame):
|
||||||
|
global INTERRUPT_SIGNAL
|
||||||
|
|
||||||
# Delete PID file
|
# Delete PID file
|
||||||
remove_pid_on_exit()
|
remove_pid_on_exit()
|
||||||
|
|
||||||
# Debugging info
|
# Debugging info
|
||||||
print(f'Got signal {signal_number} from {frame}')
|
print(f'Got signal {signal_number} from {frame}')
|
||||||
|
|
||||||
|
# This it to break BT play controller
|
||||||
|
INTERRUPT_SIGNAL = True
|
||||||
|
|
||||||
# Exit
|
# Exit
|
||||||
raise SystemExit('Exiting')
|
raise SystemExit('Exiting')
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ CALL_ADDED = multiprocessing.Value('b', False)
|
||||||
CALL_REMOVED = multiprocessing.Value('b', False)
|
CALL_REMOVED = multiprocessing.Value('b', False)
|
||||||
CALL_LOCK = threading.Lock()
|
CALL_LOCK = threading.Lock()
|
||||||
|
|
||||||
|
INTERRUPT_SIGNAL = multiprocessing.Value('b', False)
|
||||||
|
|
||||||
# Call state change event
|
# Call state change event
|
||||||
class CallState(bt_phone.Observer):
|
class CallState(bt_phone.Observer):
|
||||||
|
|
@ -94,13 +95,17 @@ def dial_number(number: str, play_file: str):
|
||||||
|
|
||||||
# Answer the call
|
# Answer the call
|
||||||
def answer_call(play_file: str):
|
def answer_call(play_file: str):
|
||||||
global CALL_PATH, CALL_LOCK, CALL_ADDED
|
global CALL_PATH, CALL_LOCK, CALL_ADDED, INTERRUPT_SIGNAL
|
||||||
utils.log('Waiting for incoming call...')
|
utils.log('Waiting for incoming call...')
|
||||||
|
|
||||||
# Wait for incoming call
|
# Wait for incoming call
|
||||||
while not CALL_ADDED.value:
|
while not CALL_ADDED.value and not INTERRUPT_SIGNAL.value():
|
||||||
time.sleep(0.1)
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
if INTERRUPT_SIGNAL.value():
|
||||||
|
utils.log(f'Interrupt signal detected, exiting.')
|
||||||
|
return
|
||||||
|
|
||||||
utils.log(f'Found incoming call {CALL_PATH}')
|
utils.log(f'Found incoming call {CALL_PATH}')
|
||||||
# CALL_LOCK.release()
|
# CALL_LOCK.release()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue