Skip to content

Commit fdf0b8c

Browse files
committed
Hologram Python SDK v0.7.1 release
1 parent 7a75b6a commit fdf0b8c

File tree

7 files changed

+58
-54
lines changed

7 files changed

+58
-54
lines changed

Hologram/Cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from Network import NetworkManager
1414
from Authentication import *
1515

16-
__version__ = '0.7.0'
16+
__version__ = '0.7.1'
1717

1818
class Cloud(object):
1919

Hologram/Network/Cellular.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def connect(self, timeout = DEFAULT_CELLULAR_TIMEOUT):
6868

6969
if success:
7070
self.logger.info('Successfully connected to cell network')
71+
# Disable at sockets mode since we're already establishing PPP.
72+
# This call is needed in certain modems that have limited interfaces to work with.
73+
self.disable_at_sockets_mode()
7174
self._connection_status = CLOUD_CONNECTED
7275
self.event.broadcast('cellular.connected')
7376
super(Cellular, self).connect()

Hologram/Network/Modem/Modem.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def close_socket(self, socket_identifier=None):
319319

320320
ok, r = self.set('+USOCL', "%s" % socket_identifier)
321321
if ok != ModemResult.OK:
322-
self.logger.error('Failed to close socket')
322+
self.logger.info('Failed to close socket')
323323

324324
def debugwrite(self, x, hide=False):
325325
if not hide:
@@ -381,6 +381,8 @@ def handleURC(self, urc):
381381
self._handle_listen_urc(urc)
382382
self.last_read_payload_length = 0
383383
next_urc_state = Modem.SOCKET_RECEIVE_READ
384+
else:
385+
self.logger.debug("URC was not handled. \'%s\'", urc)
384386

385387
self.urc_state = next_urc_state
386388

@@ -565,15 +567,28 @@ def _parsePDU(self, header, pdu):
565567
def is_connected(self):
566568
return self.is_registered()
567569

568-
#EXPECTS: '+CREG' or '+CGREG'
570+
@staticmethod
571+
def _check_registered_helper(cmd, result):
572+
r = None
573+
if isinstance(result, list) and len(result) > 0:
574+
# If more than one response is provided, assume that only
575+
# the last response is of interest and that the
576+
# rest are uncaught URCs that we should disregard.
577+
r = result[-1]
578+
else:
579+
r = result
580+
581+
regstatus = int(r.lstrip(cmd).lstrip(': ').split(',')[1])
582+
# 1: registered home network
583+
# 5: registered roaming
584+
return regstatus == 1 or regstatus == 5
585+
586+
#EXPECTS: '+CREG', '+CGREG', or '+CEREG'
569587
def check_registered(self, cmd):
570588
ok, r = self.read(cmd)
571589
if ok == ModemResult.OK:
572590
try:
573-
regstatus = int(r.lstrip(cmd).lstrip(': ').split(',')[1])
574-
# 1: registered home network
575-
# 5: registered roaming
576-
return regstatus == 1 or regstatus == 5
591+
return Modem._check_registered_helper(cmd, r)
577592
except (IndexError, ValueError) as e:
578593
self.logger.error(repr(e))
579594
return False

sftp-config.json

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/MessageMode/test_Cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ def test_invalid_send_sms(self):
4040
def test_sdk_version(self):
4141
cloud = Cloud(None, send_host = '127.0.0.1', send_port = 9999)
4242

43-
assert cloud.version == '0.7.0'
43+
assert cloud.version == '0.7.1'

tests/Modem/test_Modem.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,34 @@ def test_get_result_string(self):
3030
assert modem.getResultString(-2) == 'Modem error'
3131
assert modem.getResultString(-3) == 'Modem response doesn\'t match expected return value'
3232
assert modem.getResultString(-99) == 'Unknown response code'
33+
34+
35+
# pylint: disable=W0212
36+
from Hologram.Network.Modem.Modem import Modem
37+
class TestModemProtectedMethods(object):
38+
def test_check_registered_string(self):
39+
result = '+CREG: 2,5,"5585","404C790",6'
40+
registered = Modem._check_registered_helper('+CREG', result)
41+
assert registered == True
42+
43+
def test_check_registered_short_list(self):
44+
result = ['+CREG: 5,"5585","404C78A",6',
45+
'+CREG: 5,"5585","404C790",6',
46+
'+CREG: 2,5,"5585","404C790",6']
47+
registered = Modem._check_registered_helper('+CREG', result)
48+
assert registered == True
49+
50+
def test_check_registered_long_list(self):
51+
result = ['+CREG: 5,"5585","404EF4D",6',
52+
'+CREG: 5,"5585","404C816",6',
53+
'+CREG: 5,"5585","404C790",6',
54+
'+CREG: 5,"5585","404C816",6',
55+
'+CREG: 5,"5585","404EF4D",6',
56+
'+CREG: 5,"5585","404C78A",6',
57+
'+CREG: 5,"5585","404C790",6',
58+
'+CREG: 5,"5585","404C816",6',
59+
'+CREG: 2',
60+
'+CREG: 5,"5585","404C790",6',
61+
'+CREG: 2,5,"5585","404C790",6']
62+
registered = Modem._check_registered_helper('+CREG', result)
63+
assert registered == True

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.7.0
1+
0.7.1

0 commit comments

Comments
 (0)