add position to sim info
This commit is contained in:
+3
-1
@@ -65,8 +65,10 @@ class ModemPool:
|
||||
response = str(self._send_command(cmd, ser))
|
||||
ccid_group = re.search("[0-9F]+", response)
|
||||
ccid = ccid_group.group(0)
|
||||
sim_position = index + 1
|
||||
position = (slot_position - 1) * 15 + sim_position
|
||||
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
|
||||
cmd = f'AT+CPBW={self.phone_number_position},\"{phone_number}\"\r'
|
||||
self._send_command(cmd, ser, wait_time_in_s=2)
|
||||
|
||||
@@ -82,7 +82,7 @@ def create_modem_for_port(port: str) -> SerialModem:
|
||||
|
||||
def timeout_occurred(serial_modem: SerialModem):
|
||||
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):
|
||||
@@ -165,8 +165,8 @@ def start_listen():
|
||||
|
||||
|
||||
def read_all_the_phone_number():
|
||||
slot_number = 3
|
||||
slot_sum = 32
|
||||
slot_number = 1
|
||||
slot_sum = 31
|
||||
# card_pool.switch_to_slot(3)
|
||||
|
||||
for i in range(slot_number, slot_sum + 1):
|
||||
@@ -199,6 +199,6 @@ if __name__ == '__main__':
|
||||
init_logger()
|
||||
logger = logging.getLogger()
|
||||
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
||||
# read_all_the_phone_number()
|
||||
start_listen()
|
||||
start_book()
|
||||
read_all_the_phone_number()
|
||||
# start_listen()
|
||||
# start_book()
|
||||
|
||||
+14
-2
@@ -1,16 +1,26 @@
|
||||
import datetime
|
||||
import time
|
||||
|
||||
|
||||
class SimInfoPojo:
|
||||
phone: 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.ccid = ccid
|
||||
self.update_at = update_at
|
||||
self.position = position
|
||||
|
||||
@staticmethod
|
||||
def from_firestore_dict(source):
|
||||
phone = source['phone']
|
||||
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
|
||||
return result
|
||||
|
||||
@@ -18,6 +28,8 @@ class SimInfoPojo:
|
||||
dest = {
|
||||
u'phone': self.phone,
|
||||
u'ccid': self.ccid,
|
||||
u'update_at': self.update_at,
|
||||
u'position': self.position,
|
||||
}
|
||||
|
||||
return dest
|
||||
|
||||
@@ -2,8 +2,6 @@ from dataclasses import dataclass
|
||||
|
||||
from gsmmodem import GsmModem
|
||||
|
||||
from pojo.contact_pojo import ContactPojo
|
||||
|
||||
|
||||
@dataclass
|
||||
class SerialModem():
|
||||
|
||||
Reference in New Issue
Block a user