43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
import argparse
|
|
import logging
|
|
from m2m.nbiot import factory
|
|
|
|
# Configure logging
|
|
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
|
|
|
|
def disable_psm(port, module_type='BG95'):
|
|
module = factory(module_type, port)
|
|
|
|
with module:
|
|
print(f"--- PSM Deactivation Utility for {module_type} ---")
|
|
|
|
# 1. Read current status
|
|
print("Reading current PSM status...")
|
|
status = module.read_psm_status()
|
|
print(f"Current Status: {status if status else 'Not set or error'}")
|
|
|
|
# 2. Deactivate PSM
|
|
print("Sending deactivation command (AT+CPSMS=0)...")
|
|
if module.disable_psm():
|
|
print("OK: PSM has been successfully deactivated.")
|
|
else:
|
|
print("ERROR: Failed to deactivate PSM.")
|
|
|
|
# 3. Verify final status
|
|
print("Verifying final status...")
|
|
final_status = module.read_psm_status()
|
|
print(f"Final Status: {final_status}")
|
|
|
|
if "+CPSMS: 0" in final_status:
|
|
print("SUCCESS: PSM is confirmed OFF.")
|
|
else:
|
|
print("WARNING: PSM status might still be active or returned unexpected response.")
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Deactivate PSM (Power Saving Mode) on the modem.")
|
|
parser.add_argument("port", help="Serial port (e.g. /dev/ttyUSB0, socket://host:port, or MOCK)")
|
|
parser.add_argument("--type", default="BG95", help="Module type (BG95, BG96, BC66)")
|
|
args = parser.parse_args()
|
|
|
|
disable_psm(args.port, args.type)
|