exitProgram() if email_from == "": print "Error: No from e-mail address has been defined." exitProgram() if email_gateway == "": print "Error: No e-mail gateway has been defined." exitProgram() # Setup the modem print "Information: Connecting to GSM modem..." gsm = GSMDevice(gsm_port, gsm_speed, gsm_bits, gsm_parity, gsm_stop_bits, 1) # Connect to modem and ensure it's responding gsm.sendATCommand(skipcheck = True) frc = gsm.receiveSingleResult() if frc == "OK": # Modem is ready, re-setup... print "Information: GSM modem responded." if gsm.sendATCommand("E0", skipcheck = True): print "Information: Checking if we need a PIN..." if gsm.sendATCommand("+CPIN?"): ir, frc = gsm.receiveDualResult()
if sms_method < 0 or sms_method > 1: print "Error: Unknown SMS sending method." exitProgram() # Setup any directories if not os.path.exists(QUEUE_DIRECTORY): os.mkdir(QUEUE_DIRECTORY) # OK, now determine what are doing if server_mode: # Setup the modem audit("Information: Connecting to GSM modem...") gsm = GSMDevice(gsm_port, gsm_speed, gsm_bits, gsm_parity, gsm_stop_bits, 1) # Connect to modem and ensure it's responding gsm.sendATCommand(skipcheck = True) frc = gsm.receiveSingleResult() if frc == "OK": # Modem is ready, re-setup... audit("Information: GSM modem responded.") if gsm.sendATCommand("E0", skipcheck = True): audit("Information: Checking if we need a PIN...") if gsm.sendATCommand("+CPIN?"): ir, frc = gsm.receiveDualResult()
exitProgram() if sms_to.startswith("+"): sms_to_method = 0 print "Information: Number identified as ISDN ITU E.164/E.163." else: sms_to_method = 1 print "Information: Number identified NOT as ISDN ITU E.164/E.163." # Setup the modem print "Information: Connecting to GSM modem..." gsm = GSMDevice(gsm_port, gsm_speed, gsm_bits, gsm_parity, gsm_stop_bits, 1) # Connect to modem and ensure it's responding gsm.sendATCommand(skipcheck=True) frc = gsm.receiveSingleResult() if frc == "OK": # Modem is ready, re-setup... print "Information: GSM modem responded." if gsm.sendATCommand("E0", skipcheck=True): print "Information: Checking if we need a PIN..." if gsm.sendATCommand("+CPIN?"): ir, frc = gsm.receiveDualResult()