From: NeilBrown Date: Sun, 17 Feb 2013 03:51:12 +0000 (+1100) Subject: gsm: differentiate between different styles of reset. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=c7f7c0017860fdf28fe03bfe1af0c777545d3a01;p=plato.git gsm: differentiate between different styles of reset. A CFUN error only requires a soft reset. And EOF requires a harder reset. In each case, reopen devices just in case. Also make sure status information is cleared until we are up and running again. Signed-off-by: NeilBrown --- diff --git a/gsm/gsmd.py b/gsm/gsmd.py index ccd30a0..04ec2ca 100644 --- a/gsm/gsmd.py +++ b/gsm/gsmd.py @@ -205,10 +205,17 @@ class PowerAction(Task): elif self.cmd == "off": record('carrier', '') record('cell', '') - record('signal_strength','0/32') + record('signal_strength','-/32') channel.disconnect() channel.altchan.disconnect() elif self.cmd == 'reopen': + record('status','') + record('incoming','') + record('carrier', '') + record('cell', '') + record('signal_strength','-/32') + calllog_end('incoming') + calllog_end('outgoing') channel.disconnect() channel.altchan.disconnect() channel.connect() @@ -457,7 +464,7 @@ def check_cfun(channel, line, m): if channel.last_reset + 100 < time.time(): channel.last_reset = time.time() - channel.set_state('reset') + channel.set_state('refresh') return def data_handle(channel, line, m): @@ -511,7 +518,7 @@ def data_hungup(channel, failed): if channel.data_APN: # We still want a connection if failed: - channel.set_state('reset') + channel.set_state('refresh') return elif channel.next_data_call <= time.time(): channel.next_data_call = (time.time() + @@ -580,12 +587,25 @@ control['flight'] = [ BlockSuspendAction(False), ] +control['refresh'] = [ + # Soft reset: just use CFUN to turn off/on + # also reopen to clear status and just in case. + AtAction(at='+CFUN=0',critical=False, retries=0), + BlockSuspendAction(False), + PowerAction('reopen'), + BlockSuspendAction(True), + AtAction(at='E0', timeout=30000), + ChangeStateAction('init1'), + ] + control['reset'] = [ - # turning power off just kills everything!!! - #AtAction(at='_ORESET', critical = False), - AtAction(at='$QCPWRDN', critical = False, retries = 0), + # Harder reset - use _ORESET and re-open devices. + # Don't block suspend if we cannot re-open. + AtAction(at='_ORESET', critical = False), + #AtAction(at='$QCPWRDN', critical = False, retries = 0), + BlockSuspendAction(False), PowerAction('reopen'), - #PowerAction('off'), + BlockSuspendAction(True), AtAction(at='E0', timeout=30000), ChangeStateAction('init1'), ]