wait 40s for sms
This commit is contained in:
+11
-13
@@ -1,4 +1,3 @@
|
||||
import datetime
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
@@ -11,13 +10,11 @@ from commandor_page import CommandorPage
|
||||
from logs.AppLogging import init_logger
|
||||
from modems.ModemPool import ModemPool
|
||||
from modems.card_pool import CardPool
|
||||
from params import MODEM_POOL_PORTS, CARD_POOL_PORT, firebase_store_manager, oracle_log_sender
|
||||
from pojo.ReserveResultPojo import ReserveResultPojo
|
||||
from params import MODEM_POOL_PORTS, CARD_POOL_PORT
|
||||
from pojo.serial_modem import SerialModem
|
||||
from utils.excel_reader import ExcelHelper
|
||||
|
||||
OTP_TIMEOUT = 120
|
||||
is_finished = False
|
||||
OTP_TIMEOUT = 40
|
||||
commandor = CommandorPage()
|
||||
thread_event = None
|
||||
current_gsm_modem = None
|
||||
@@ -30,6 +27,7 @@ current_sim_position = 1
|
||||
def get_devices_ports() -> list:
|
||||
return MODEM_POOL_PORTS
|
||||
|
||||
|
||||
def create_modem_for_port(port: str) -> Union[SerialModem, None]:
|
||||
logger.info('Initializing modem... for ' + port)
|
||||
serial_modem = None
|
||||
@@ -50,14 +48,14 @@ def timeout_occurred(serial_modem: SerialModem):
|
||||
def start_to_handle_sms(serial_modem: SerialModem):
|
||||
global current_gsm_modem
|
||||
current_gsm_modem = serial_modem.modem
|
||||
# current_gsm_modem.deleteMultipleStoredSms(memory="MT")
|
||||
if "893313" in serial_modem.ccid:
|
||||
# lycamobile
|
||||
current_gsm_modem.deleteMultipleStoredSms(memory="SM")
|
||||
serial_modem.modem.smsReceivedCallback = handle_sms
|
||||
global is_finished
|
||||
is_finished = 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:
|
||||
while True:
|
||||
time.sleep(2)
|
||||
# check whether timeout
|
||||
now = time.time()
|
||||
@@ -67,7 +65,6 @@ def start_to_handle_sms(serial_modem: SerialModem):
|
||||
timeout_occurred(serial_modem)
|
||||
current_gsm_modem.close()
|
||||
return
|
||||
return
|
||||
|
||||
|
||||
def handle_sms(sms):
|
||||
@@ -85,9 +82,10 @@ def init_modems() -> list:
|
||||
modems.append(serial_modem)
|
||||
return modems
|
||||
|
||||
|
||||
def start_book():
|
||||
slot_number = 1
|
||||
slot_sum = 2
|
||||
slot_sum = 27
|
||||
for i in range(slot_number, slot_sum + 1):
|
||||
card_pool.reset()
|
||||
logger.info("will switch to " + str(i))
|
||||
@@ -106,7 +104,8 @@ def start_book():
|
||||
try:
|
||||
# get contact for current modem
|
||||
modem.get_ccid()
|
||||
contact = [contact for contact in contacts if contact.ccid.replace("F","") == modem.ccid.replace("F","")]
|
||||
contact = [contact for contact in contacts if
|
||||
contact.ccid.replace("F", "") == modem.ccid.replace("F", "")]
|
||||
if len(contact) > 0:
|
||||
modem.phone_number = contact[0].phone
|
||||
modem.contact = contact[0]
|
||||
@@ -121,4 +120,3 @@ if __name__ == '__main__':
|
||||
logger = logging.getLogger()
|
||||
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
||||
start_book()
|
||||
# card_pool.switch_to_slot(12)
|
||||
|
||||
Reference in New Issue
Block a user