close modem if the contact not found
This commit is contained in:
@@ -19,7 +19,7 @@ from pojo.serial_modem import SerialModem
|
||||
from logs.AppLogging import init_logger
|
||||
from utils.message_receiver import MessageReceiver
|
||||
|
||||
OTP_TIMEOUT = 60
|
||||
OTP_TIMEOUT = 80
|
||||
is_finished = False
|
||||
commandor = Commandor()
|
||||
contacts = []
|
||||
@@ -50,7 +50,6 @@ def send_command(cmd: str, ser, wait_time_in_s: int = 0) -> bytes:
|
||||
def create_modem_for_port(port: str) -> Union[SerialModem, None]:
|
||||
logger.info('Initializing modem... for ' + port)
|
||||
# Uncomment the following line to see what the modem is doing:
|
||||
init_logger()
|
||||
serial_modem = None
|
||||
try:
|
||||
modem = GsmModem(port)
|
||||
@@ -72,7 +71,7 @@ def start_to_handle_sms(serial_modem: SerialModem):
|
||||
serial_modem.modem.smsReceivedCallback = handle_sms
|
||||
global is_finished
|
||||
is_finished = False
|
||||
serial_modem.modem.smsTextMode = False
|
||||
serial_modem.modem.smsTextMode =False
|
||||
logger.info('Waiting for SMS message, for phone number ' + str(serial_modem.phone_number))
|
||||
listen_at = time.time()
|
||||
while not is_finished:
|
||||
@@ -165,8 +164,8 @@ def read_all_the_phone_number():
|
||||
|
||||
|
||||
def start_book():
|
||||
slot_number = 1
|
||||
slot_sum = 30
|
||||
slot_number = 13
|
||||
slot_sum = 31
|
||||
for i in range(slot_number, slot_sum + 1):
|
||||
card_pool.reset()
|
||||
logger.info("will switch to " + str(i))
|
||||
@@ -191,7 +190,12 @@ def start_book():
|
||||
if len(contact) > 0:
|
||||
modem.phone_number = contact[0].phone
|
||||
modem.contact = contact[0]
|
||||
else:
|
||||
logger.info("contact not found for this ccid")
|
||||
modem.modem.close()
|
||||
continue
|
||||
if modem.contact:
|
||||
logger.info("contact found for this ccid")
|
||||
commandor.start_page(modem.contact)
|
||||
start_to_handle_sms(modem)
|
||||
except Exception as error:
|
||||
|
||||
Reference in New Issue
Block a user