close modem if the contact not found

This commit is contained in:
2022-03-15 15:14:41 +01:00
parent cae27e2e7c
commit 556d8c7d7f
+8 -4
View File
@@ -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)
@@ -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: