42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
import logging
|
|
import argparse
|
|
from m2m.nbiot import factory
|
|
|
|
# Configure logging
|
|
logging.basicConfig(level=logging.INFO, format='%(name)s - %(levelname)s - %(message)s')
|
|
|
|
def run_simulation(port):
|
|
print(f"Starting Simulation on {port}...")
|
|
|
|
# Initialize with the provided port (e.g. 'MOCK')
|
|
module = factory('BG95', port)
|
|
|
|
with module:
|
|
print("\n--- Basic Checks ---")
|
|
if module.check_state():
|
|
print("Module is responsive (AT -> OK)")
|
|
|
|
print(f"Firmware: {module.read_firmware_version()}")
|
|
print(f"IMEI: {module.read_imei()}")
|
|
print(f"IMSI: {module.read_imsi()}")
|
|
|
|
print("\n--- Network Simulation ---")
|
|
# The mock has default responses for these if 'MOCK' is used
|
|
if module.attach_network():
|
|
print("Attached to network")
|
|
|
|
rssi, ber = module.get_signal_quality()
|
|
print(f"Signal Quality: RSSI={rssi}, BER={ber}")
|
|
|
|
reg_status = module.read_cereg_status()
|
|
print(f"Registration Status: {reg_status}")
|
|
|
|
print("\n--- Extended Info ---")
|
|
print(f"Network Info: {module.get_network_info()}")
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Run simulation.")
|
|
parser.add_argument("port", nargs="?", default="MOCK", help="Serial port (default: MOCK)")
|
|
args = parser.parse_args()
|
|
run_simulation(args.port)
|