add ccid to log

This commit is contained in:
2022-03-25 14:16:06 +01:00
parent 3cae7159aa
commit 6f58c95aae
2 changed files with 8 additions and 5 deletions
+4 -3
View File
@@ -199,13 +199,14 @@ def start_book():
try:
modem.get_ccid()
# find the contact with 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]
else:
logger.info("contact not found for this ccid")
error_msg = "slot({}),sim({})".format(i, current_sim_position)
logger.info("contact not found for this ccid:{}".format(modem.ccid))
error_msg = "slot({}):sim({}):ccid({})".format(i, current_sim_position, modem.ccid)
oracle_log_sender.send_contact_not_found(error_msg)
modem.modem.close()
continue
+4 -2
View File
@@ -1,3 +1,4 @@
import logging
from dataclasses import dataclass
from gsmmodem import GsmModem
@@ -13,14 +14,15 @@ class SerialModem():
def __init__(self, modem: GsmModem, ccid: str = None):
self.modem = modem
self.ccid = ccid
self.logger = logging.getLogger("SerialModem")
def get_ccid(self):
cmd = "AT+CCID"
self.modem.connect("0000")
print("try to get ccid")
self.logger.info("try to get ccid")
response = self.modem.write(cmd, True)
self.ccid = response[0].split(" ")[1].replace("\"", "")
print("The SIM card ccid is:" + self.ccid)
self.logger.info("The SIM card ccid is:" + self.ccid)
# print("try to get phone number")
# cmd_phone_number = "AT+CPBS=ON"
# openBook = self.modem.write(cmd_phone_number, True)