optimisation for otp

This commit is contained in:
2022-03-21 22:39:47 +01:00
parent 1a60ba3a1d
commit ea0aed7caa
2 changed files with 55 additions and 66 deletions
+17 -10
View File
@@ -3,27 +3,27 @@ import logging
import re
import sys
import time
from threading import Event
from typing import Union
from gsmmodem import GsmModem
import params
from commandor_page import CommandorPage
from logs.AppLogging import init_logger
from logs.LogSender import LOG_APPOINTMENT_TIMEOUT
from modems.ModemPool import ModemPool
from modems.card_pool import CardPool
from commandor import Commandor
from logs.LogSender import LOG_APPOINTMENT_TIMEOUT, LOG_SUBJECT_EVENT, TYPE_EVENT_RESET_ALL_SIM_CARDS, LOG_SUBJECT_SMS, \
TYPE_SMS_RECEIVED
from params import MODEM_POOL_PORTS, CARD_POOL_PORT, firebase_store_manager, oracle_log_sender
from pojo.ReserveResultPojo import ReserveResultPojo
from utils.excel_reader import ExcelHelper
from pojo.serial_modem import SerialModem
from logs.AppLogging import init_logger
from utils.excel_reader import ExcelHelper
from utils.message_receiver import MessageReceiver
OTP_TIMEOUT = 600
is_finished = False
commandor = Commandor()
contacts = []
commandor = CommandorPage()
thread_event = None
current_gsm_modem = None
card_pool = CardPool(CARD_POOL_PORT)
# used to save the current slot position
@@ -104,7 +104,10 @@ def handle_sms(sms):
match = re.search(pattern, sms.text)
otp = match.group(0)
logger.info("otp is " + otp)
commandor.send_otp(otp)
global thread_event
commandor.otp_value = otp
thread_event.set()
# commandor.send_otp(otp)
# wait for the sms for 20 seconds
global is_finished
while not is_finished:
@@ -150,6 +153,11 @@ def start_listen():
receiver.start_listener(on_message_received)
def on_ready_for_otp(e: Event, commandor: CommandorPage):
global thread_event
thread_event = e
def start_book():
slot_number = 1
slot_sum = 22
@@ -163,7 +171,6 @@ def start_book():
# create listeners for chaque modem
# read the contact, and contact the 2 objects together
excel_reader = ExcelHelper()
global contacts
contacts = excel_reader.read_contacts()
global current_sim_position
current_sim_position = 1
@@ -185,7 +192,7 @@ def start_book():
logger.info("contact found for this ccid")
signal = modem.modem.signalStrength
logger.info("信号强度: " + str(signal))
commandor.start_page(modem.contact)
commandor.start_page(modem.contact, on_ready_for_otp=on_ready_for_otp)
start_to_handle_sms(modem)
except Exception as error:
print(error)