if sms_to <> "" and sms_message <> "": # Get the signal strength, if it's too low we may not want to send it audit("Information: Determining signal strength...") if gsm.sendATCommand("+CSQ", dualcheck = True): ir, frc = gsm.receiveDualResult() if frc == "OK": csq = ir.split(": ")[1].split(",") dbm = int(csq[0]) ber = int(csq[1]) audit("Information: Signal strength is %ddBm with a BER of '%s'." % (dbm, gsm.getBERPercentage(ber).lower())) if dbm < minimum_signal_strength: audit("Warning: Signal strength is NOT acceptable (needed >= %ddBm), will try again later..." % minimum_signal_strength) else: if sms_to.startswith("+"): sms_to_method = 0 audit("Information: Number identified as ISDN ITU E.164/E.163.") else: sms_to_method = 1 audit("Information: Number identified NOT as ISDN ITU E.164/E.163.")
print "Warning: +COPS command not recognised, unable to get the network." # Get the signal strength, if it's too low we may not want to send it print "Information: Determining signal strength..." if gsm.sendATCommand("+CSQ", dualcheck=True): ir, frc = gsm.receiveDualResult() if frc == "OK": csq = ir.split(": ")[1].split(",") dbm = int(csq[0]) ber = int(csq[1]) print "Information: Signal strength is %ddBm with a BER of '%s'." % ( dbm, gsm.getBERPercentage(ber).lower(), ) if dbm < minimum_signal_strength: print "Error: Signal strength is NOT acceptable (needed >= %ddBm), aborting..." % minimum_signal_strength exitProgram() else: print "Warning: Unable to get the signal strength, command may not be supported." else: print "Warning: +CSQ command not recognised, unable to get the signal strength." # Make sure we have SMS commands available print "Information: Determining SMS capabilities..."