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