def __init__(self, name, debug = 0): self.name = name self.debug = debug if self.debug: print (self.name + " init") self.gsm_ser = xcmodem_ser.xcModemSer('/dev/ttyACM3', debug = 0) self.gsm_ser.send('AT#GPIO=1,0,2\r') self.off()
def __init__(self, sdebug=0, debug=0, tear_off=0): self.name = 'gsm_app' self.debug = debug self.sdebug = sdebug if self.debug: print(self.name + " init") self.gsm_ser = xcmodem_ser.xcModemSer('/dev/ttyACM3', self.sdebug) self.gsm_ser.set_speed('115200', '8N1') self.led_ctl = boardid_inquiry() > 0 if self.led_ctl: self.gsm_led = xcModemLed('gsm_led', led_path['gsm'][self.led_ctl]) self.gsm_led.off() else: self.gsm_led = gsmLed('gsm_led') self.gsm_led.default() self.start_once = 0 self.tear_off = tear_off self.csq_thread = None modem_state[self.name] = app_state.IDLE
def __init__(self, sdebug = 0, debug = 0, tear_off = 0): self.name = 'gsm_app' self.debug = debug self.sdebug = sdebug if self.debug: print (self.name + " init") self.gsm_ser = xcmodem_ser.xcModemSer('/dev/ttyACM3', self.sdebug) self.gsm_ser.set_speed('115200','8N1') self.led_ctl = boardid_inquiry() > 0 if self.led_ctl: self.gsm_led = xcModemLed('gsm_led', led_path['gsm'][self.led_ctl]) self.gsm_led.off() else: self.gsm_led = gsmLed('gsm_led') self.gsm_led.default() self.start_once = 0 self.tear_off = tear_off self.csq_thread = None modem_state[self.name] = app_state.IDLE
def __init__(self, name, sdebug=0, debug=0): self.name = name self.debug = debug self.ser = xcmodem_ser.xcModemSer('/dev/ttyACM0', sdebug) self.save_once = 0 self.tick_bk = 0
def __init__(self, name, sdebug = 0, debug = 0): self.name = name self.debug = debug self.ser = xcmodem_ser.xcModemSer('/dev/ttyACM0', sdebug) self.save_once = 0 self.tick_bk = 0
def prep(self, apn): if self.led_ctl: self.gsm_led.on() # only prep once if modem_state[self.name] == app_state.PENDING: LOG.debug("Skip preparing " + self.name) return True LOG.debug("Preparing " + self.name) if self.debug: lstdout = None lstderr = None else: lstdout = subprocess.PIPE lstderr = subprocess.PIPE # clean up lingering pppd process if exist subprocess.call('killall -q pppd', shell=True, \ stdout=lstdout, stderr=lstderr) # Since main gsm channel will be locked during PPP connection, # alternative channel (which is also used by GPS) is needed for signal quality monitor # Hence, signal quality monitor thread should be started only if gps is not enable; # otherwise, GPS task will monitor signal qualilty if not conf_options['gps_enable']: self.gsm_ser1 = xcmodem_ser.xcModemSer('/dev/ttyACM0', self.sdebug) self.gsm_ser1.set_speed('115200', '8N1') self.gsm_ser1.cmd_check('ATE0\r', 'OK') self.csq_thread, self.stop_csq = loop_timer(1 - SERIAL_INTERFACE_TIMEOUT, \ gsm_csq_inquiry, self.gsm_ser1, self.debug) apn = conf_options['web_scp_apn'] attempt = 1 cmd = 'AT+CGDCONT=1,"IP","%s"\r' % apn while (attempt <= xcModemGsm.MAX_ATTEMPT): if self.gsm_ser.cmd_check('ATE0\r', 'OK') is not None: if self.gsm_ser.cmd_check('AT#QSS?\r', 'QSS: 2') is None: # default QSS mode to 2 per Telit's suggestion self.gsm_ser.cmd_check('AT#QSS=2\r', 'OK') # default to mode 2 self.gsm_ser.cmd_check('AT&W0\r', 'OK') # store into profile0 self.gsm_ser.cmd_check( 'AT&P0\r', 'OK') # full profile0 reset in next boot if self.gsm_ser.cmd_check('AT#QSS?\r', 'QSS: 2,0') is not None: LOG.error("SIM not inserted " + self.name) if self.led_ctl: self.gsm_led.blink(1) # different blink mode return False if self.gsm_ser.cmd_check(cmd, 'OK') is not None: if self.gsm_ser.cmd_check('AT#SGACT?\r', 'SGACT: 1,0') is not None: break elif self.gsm_ser.cmd_check('AT#SGACT=1,0\r', 'OK') is not None: if self.gsm_ser.cmd_check('AT#SGACT?\r', 'SGACT: 1,0') is not None: break attempt += 1 if attempt > xcModemGsm.MAX_ATTEMPT: LOG.error("fail to prepare " + self.name) return False else: # For GSM 850Mhz + PCS 1900Mhz self.gsm_ser.cmd_check('AT#BND=3,4\r', 'OK') # Telit real-time clock sync; however, it's not guarantee the timestamp is correct self.clk_sync() modem_state[self.name] = app_state.PENDING return True
def prep(self, apn): if self.led_ctl: self.gsm_led.on() # only prep once if modem_state[self.name] == app_state.PENDING: LOG.debug("Skip preparing " + self.name) return True LOG.debug("Preparing " + self.name) if self.debug: lstdout = None lstderr = None else: lstdout = subprocess.PIPE lstderr = subprocess.PIPE # clean up lingering pppd process if exist subprocess.call('killall -q pppd', shell=True, \ stdout=lstdout, stderr=lstderr) # Since main gsm channel will be locked during PPP connection, # alternative channel (which is also used by GPS) is needed for signal quality monitor # Hence, signal quality monitor thread should be started only if gps is not enable; # otherwise, GPS task will monitor signal qualilty if not conf_options['gps_enable']: self.gsm_ser1 = xcmodem_ser.xcModemSer('/dev/ttyACM0', self.sdebug) self.gsm_ser1.set_speed('115200','8N1') self.gsm_ser1.cmd_check('ATE0\r','OK') self.csq_thread, self.stop_csq = loop_timer(1 - SERIAL_INTERFACE_TIMEOUT, \ gsm_csq_inquiry, self.gsm_ser1, self.debug) apn = conf_options['web_scp_apn'] attempt = 1 cmd = 'AT+CGDCONT=1,"IP","%s"\r' % apn while (attempt <= xcModemGsm.MAX_ATTEMPT): if self.gsm_ser.cmd_check('ATE0\r','OK') is not None: if self.gsm_ser.cmd_check('AT#QSS?\r','QSS: 2') is None: # default QSS mode to 2 per Telit's suggestion self.gsm_ser.cmd_check('AT#QSS=2\r','OK') # default to mode 2 self.gsm_ser.cmd_check('AT&W0\r','OK') # store into profile0 self.gsm_ser.cmd_check('AT&P0\r','OK') # full profile0 reset in next boot if self.gsm_ser.cmd_check('AT#QSS?\r','QSS: 2,0') is not None: LOG.error("SIM not inserted " + self.name) if self.led_ctl: self.gsm_led.blink(1) # different blink mode return False if self.gsm_ser.cmd_check(cmd, 'OK') is not None: if self.gsm_ser.cmd_check('AT#SGACT?\r','SGACT: 1,0') is not None: break elif self.gsm_ser.cmd_check('AT#SGACT=1,0\r','OK') is not None: if self.gsm_ser.cmd_check('AT#SGACT?\r','SGACT: 1,0') is not None: break; attempt += 1 if attempt > xcModemGsm.MAX_ATTEMPT: LOG.error("fail to prepare " + self.name) return False else: # For GSM 850Mhz + PCS 1900Mhz self.gsm_ser.cmd_check('AT#BND=3,4\r','OK') # Telit real-time clock sync; however, it's not guarantee the timestamp is correct self.clk_sync() modem_state[self.name] = app_state.PENDING return True