- try to finish answering nodes properly

This commit is contained in:
2023-09-05 17:24:21 +03:00
parent b3f87c97f0
commit efd763d055
2 changed files with 14 additions and 3 deletions

View File

@@ -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,13 +95,17 @@ 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()