From 05663142a11648f0115dead818e3361819e51885 Mon Sep 17 00:00:00 2001 From: Dominic Amato Date: Fri, 5 Jun 2020 20:28:25 -0500 Subject: [PATCH] make it possible to renable at sockets (#36) --- Hologram/Network/Cellular.py | 4 ++++ Hologram/Network/Modem/E303.py | 4 ---- Hologram/Network/Modem/MS2131.py | 4 ---- Hologram/Network/Modem/Modem.py | 5 ++++- Hologram/Network/Modem/Nova.py | 3 +++ 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Hologram/Network/Cellular.py b/Hologram/Network/Cellular.py index 0aa8dcb..b02ed45 100644 --- a/Hologram/Network/Cellular.py +++ b/Hologram/Network/Cellular.py @@ -91,6 +91,7 @@ def disconnect(self): success = self.modem.disconnect() if success: self.logger.info('Successfully disconnected from cell network') + self.enable_at_sockets_mode() self._connection_status = CLOUD_DISCONNECTED self.event.broadcast('cellular.disconnected') super().disconnect() @@ -140,6 +141,9 @@ def pop_received_message(self): def disable_at_sockets_mode(self): self.modem.disable_at_sockets_mode() + def enable_at_sockets_mode(self): + self.modem.enable_at_sockets_mode() + def enableSMS(self): return self.modem.enableSMS() diff --git a/Hologram/Network/Modem/E303.py b/Hologram/Network/Modem/E303.py index b726494..2f066e9 100644 --- a/Hologram/Network/Modem/E303.py +++ b/Hologram/Network/Modem/E303.py @@ -37,10 +37,6 @@ def init_serial_commands(self): self.command("+CREG", "2") self.command("+CGREG", "2") - # AT sockets mode is always disabled for E303. - def disable_at_sockets_mode(self): - pass - @property def iccid(self): return self._basic_command('^ICCID?').lstrip('^ICCID: ')[:-1] diff --git a/Hologram/Network/Modem/MS2131.py b/Hologram/Network/Modem/MS2131.py index a3b5e34..ecc80e2 100644 --- a/Hologram/Network/Modem/MS2131.py +++ b/Hologram/Network/Modem/MS2131.py @@ -38,10 +38,6 @@ def init_serial_commands(self): self.command("+CREG", "2") self.command("+CGREG", "2") - # AT sockets mode is always disabled for MS2131. - def disable_at_sockets_mode(self): - pass - @property def iccid(self): return self._basic_command('^ICCID?').lstrip('^ICCID: ')[:-1] diff --git a/Hologram/Network/Modem/Modem.py b/Hologram/Network/Modem/Modem.py index 63d3429..9416ada 100644 --- a/Hologram/Network/Modem/Modem.py +++ b/Hologram/Network/Modem/Modem.py @@ -809,7 +809,10 @@ def _read_from_serial_port(self, timeout=None, size=DEFAULT_SERIAL_READ_SIZE): return r def disable_at_sockets_mode(self): - raise HologramError('Cannot disable AT command sockets on this Modem type') + pass + + def enable_at_sockets_mode(self): + pass def enable_hex_mode(self): self.__set_hex_mode(1) diff --git a/Hologram/Network/Modem/Nova.py b/Hologram/Network/Modem/Nova.py index eddd77e..c3ddd03 100644 --- a/Hologram/Network/Modem/Nova.py +++ b/Hologram/Network/Modem/Nova.py @@ -24,6 +24,9 @@ def __init__(self, device_name=None, baud_rate='9600', def disable_at_sockets_mode(self): self._at_sockets_available = False + def enable_at_sockets_mode(self): + self._at_sockets_available = True + @property def version(self): return self._basic_command('I9')