can restart modemPool and detected disabled sim card
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import logging
|
||||
|
||||
import serial
|
||||
|
||||
PORT = "/dev/tty.usbmodem11301"
|
||||
|
||||
BAUDRATE = 115200
|
||||
|
||||
|
||||
class CardPool:
|
||||
|
||||
def __init__(self, port):
|
||||
self.logger = logging.getLogger("CardPool")
|
||||
self._serial = serial.Serial(port, BAUDRATE, timeout=1)
|
||||
|
||||
def _send_command(self, cmd: str) -> bytes:
|
||||
print("send command {}".format(cmd))
|
||||
self._serial.write(cmd.encode())
|
||||
msg = self._serial.read(100)
|
||||
self.logger.info(msg)
|
||||
return msg
|
||||
|
||||
# info: after reset, we need to restart modem pool
|
||||
def reset(self):
|
||||
self._send_command("AT+NEXT00\r")
|
||||
|
||||
def switch_to_next(self):
|
||||
self._send_command("AT+NEXT11\r")
|
||||
|
||||
def switch_to_slot(self, slot_number: int):
|
||||
if slot_number < 10:
|
||||
self._send_command("AT+SWIT00-000{}\r".format(slot_number))
|
||||
else:
|
||||
self._send_command("AT+SWIT00-0{}\r".format(slot_number))
|
||||
|
||||
# not work for the pool
|
||||
def find_current_slot(self):
|
||||
self._send_command("AT+USIM\r")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
card_pool = CardPool(PORT)
|
||||
# print(card_pool.find_current_slot())
|
||||
card_pool.reset()
|
||||
# card_pool.switch_to_next()
|
||||
# reset modem pool
|
||||
# for port in get_devices_ports():
|
||||
# ser = serial.Serial(port, BAUDRATE, timeout=1)
|
||||
# send_command("AT+RESET\r", ser)
|
||||
# ser.close()
|
||||
# card_pool.switch_to_slot(12)
|
||||
Reference in New Issue
Block a user