Skip to content

Commit

Permalink
make it possible to renable at sockets (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
DomAmato authored Jun 6, 2020
1 parent cfef0f5 commit 0566314
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Hologram/Network/Cellular.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down
4 changes: 0 additions & 4 deletions Hologram/Network/Modem/E303.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
4 changes: 0 additions & 4 deletions Hologram/Network/Modem/MS2131.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
5 changes: 4 additions & 1 deletion Hologram/Network/Modem/Modem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions Hologram/Network/Modem/Nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 0566314

Please sign in to comment.