def __init__(self, gsm_mod, db, gsm_id): print("<< Imported User SMS") today = dt.today() self.gsm_mod = gsm_mod self.db = db self.gsm_id = gsm_id self.error_logger = err_log.ErrorLogger(self.gsm_id, 'User') csq = gsm_mod.get_csq() db.write_csq(self.gsm_id, today, csq) print(">> CSQ:", csq)
def __init__(self, ser_port='/dev/ttyUSB1', ser_baud=57600, pow_pin=33, ring_pin=15): self.defaults = DefaultSettings() self.ser_port = ser_port self.ser_baud = ser_baud self.gsm = self.initialize_serial() GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(pow_pin, GPIO.OUT) GPIO.output(pow_pin, 0) GPIO.setup(ring_pin, GPIO.IN) self.pow_pin = pow_pin self.ring_pin = ring_pin self.error_logger = err_log.ErrorLogger(0, 'Gsm Module')
def __init__(self, host, gsm_id): self.db_cred = DatabaseCredentials(host) self.error_logger = err_log.ErrorLogger(gsm_id, 'Database')
print('>> Error in parsing arguments') error = parser.format_help() print(error) sys.exit() if __name__ == "__main__": start_time = time.time() initialize_gsm = GsmServer() args = initialize_gsm.get_arguments() os.makedirs(os.path.abspath('./gsm_logs/'), exist_ok=True) if args.dbhost is not None: dbhost = args.dbhost else: dbhost = None error_logger = err_log.ErrorLogger(args.gsm_id, 'Runner') db = dbLib.DatabaseConnection(dbhost, args.gsm_id) gsm_modules = db.get_gsm_info(args.gsm_id) config = configparser.ConfigParser() config.read( '/home/pi/updews-pycodes/gsm/gsmserver_dewsl3/utils/config.cnf') if args.gsm_id not in gsm_modules.keys(): print(">> Error in gsm module selection (", args.gsm_id, ")") sys.exit() if gsm_modules[args.gsm_id]["port"] is None: print(">> Error: missing information on gsm_module") sys.exit() gsm_info = gsm_modules[args.gsm_id]