add position to sim info

This commit is contained in:
2022-03-02 09:54:15 +01:00
parent 54287f70c9
commit 4563929881
4 changed files with 23 additions and 11 deletions
+3 -1
View File
@@ -65,8 +65,10 @@ class ModemPool:
response = str(self._send_command(cmd, ser)) response = str(self._send_command(cmd, ser))
ccid_group = re.search("[0-9F]+", response) ccid_group = re.search("[0-9F]+", response)
ccid = ccid_group.group(0) ccid = ccid_group.group(0)
sim_position = index + 1
position = (slot_position - 1) * 15 + sim_position
if phone_number: if phone_number:
self._db_manager.save_sim_info(SimInfoPojo(phone=phone_number, ccid=ccid)) self._db_manager.save_sim_info(SimInfoPojo(phone=phone_number, ccid=ccid, position=position))
# write the number to sim card's phonebook # write the number to sim card's phonebook
cmd = f'AT+CPBW={self.phone_number_position},\"{phone_number}\"\r' cmd = f'AT+CPBW={self.phone_number_position},\"{phone_number}\"\r'
self._send_command(cmd, ser, wait_time_in_s=2) self._send_command(cmd, ser, wait_time_in_s=2)
+6 -6
View File
@@ -82,7 +82,7 @@ def create_modem_for_port(port: str) -> SerialModem:
def timeout_occurred(serial_modem: SerialModem): def timeout_occurred(serial_modem: SerialModem):
firebase_store_manager.save_timeout_contact(serial_modem.contact) firebase_store_manager.save_timeout_contact(serial_modem.contact)
oracle_log_sender.send_log(str(serial_modem.contact.phone_number), type=LOG_APPOINTMENT_TIMEOUT) oracle_log_sender.send_log(str(serial_modem.phone_number), type=LOG_APPOINTMENT_TIMEOUT)
def start_to_handle_sms(serial_modem: SerialModem): def start_to_handle_sms(serial_modem: SerialModem):
@@ -165,8 +165,8 @@ def start_listen():
def read_all_the_phone_number(): def read_all_the_phone_number():
slot_number = 3 slot_number = 1
slot_sum = 32 slot_sum = 31
# card_pool.switch_to_slot(3) # card_pool.switch_to_slot(3)
for i in range(slot_number, slot_sum + 1): for i in range(slot_number, slot_sum + 1):
@@ -199,6 +199,6 @@ if __name__ == '__main__':
init_logger() init_logger()
logger = logging.getLogger() logger = logging.getLogger()
logger.addHandler(logging.StreamHandler(stream=sys.stdout)) logger.addHandler(logging.StreamHandler(stream=sys.stdout))
# read_all_the_phone_number() read_all_the_phone_number()
start_listen() # start_listen()
start_book() # start_book()
+14 -2
View File
@@ -1,16 +1,26 @@
import datetime
import time
class SimInfoPojo: class SimInfoPojo:
phone: str phone: str
ccid: str ccid: str
update_at: int
position: int
def __init__(self, phone: str, ccid: str): def __init__(self, phone: str, ccid: str, position, update_at: int = int(time.time())):
self.phone = phone self.phone = phone
self.ccid = ccid self.ccid = ccid
self.update_at = update_at
self.position = position
@staticmethod @staticmethod
def from_firestore_dict(source): def from_firestore_dict(source):
phone = source['phone'] phone = source['phone']
ccid = source['ccid'] ccid = source['ccid']
result = SimInfoPojo(phone=phone, ccid=ccid) update_at = source['update_at']
position = source['position']
result = SimInfoPojo(phone=phone, ccid=ccid, update_at=update_at, position=position)
result.id = id result.id = id
return result return result
@@ -18,6 +28,8 @@ class SimInfoPojo:
dest = { dest = {
u'phone': self.phone, u'phone': self.phone,
u'ccid': self.ccid, u'ccid': self.ccid,
u'update_at': self.update_at,
u'position': self.position,
} }
return dest return dest
-2
View File
@@ -2,8 +2,6 @@ from dataclasses import dataclass
from gsmmodem import GsmModem from gsmmodem import GsmModem
from pojo.contact_pojo import ContactPojo
@dataclass @dataclass
class SerialModem(): class SerialModem():