40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
import logging
|
|
import argparse
|
|
from m2m.nbiot import factory
|
|
|
|
# Setup logging
|
|
logging.basicConfig(level=logging.INFO, format='%(name)s - %(levelname)s - %(message)s')
|
|
|
|
def run_diagnostics(port):
|
|
# Instantiate a BG96 module (works the same for BG95)
|
|
module = factory('BG96', port, baudrate=115200)
|
|
|
|
with module:
|
|
print("--- Module Info ---")
|
|
print(f"Firmware: {module.read_firmware_version()}")
|
|
print(f"IMEI: {module.read_imei()}")
|
|
print(f"ICCID: {module.read_iccid()}")
|
|
|
|
print("\n--- SIM Status ---")
|
|
# Check if PIN is needed
|
|
if module.unlock_sim("1234"):
|
|
print("SIM Unlocked/Ready")
|
|
|
|
print(f"Registered PLMN: {module.get_registered_plmn()}")
|
|
print(f"Forbidden PLMNs: {module.read_forbidden_plmns()}")
|
|
|
|
print("\n--- Network Info ---")
|
|
rssi, ber = module.get_signal_quality()
|
|
print(f"Signal: RSSI {rssi}, BER {ber}")
|
|
print(f"Registration: {module.read_cereg_status()}")
|
|
|
|
# Deep engineering info
|
|
cell_info = module.get_serving_cell_info()
|
|
print(f"Serving Cell: {cell_info}")
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Run module diagnostics.")
|
|
parser.add_argument("port", nargs="?", default="/dev/ttyUSB0", help="Serial port (e.g. /dev/ttyUSB0 or MOCK)")
|
|
args = parser.parse_args()
|
|
run_diagnostics(args.port)
|