Skip to content

Commit

Permalink
Merge pull request #124 from lwindg/develop
Browse files Browse the repository at this point in the history
3.1.9
  • Loading branch information
taotao authored Apr 5, 2017
2 parents a5f970d + 44cfd34 commit 3577296
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
6 changes: 6 additions & 0 deletions build-deb/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
sanji-bundle-cellular (3.1.9-1) unstable; urgency=low

* fix: Update status after disconnected.

-- Aeluin Chen <[email protected]> Wed, 05 Apr 2017 17:59:31 +0800

sanji-bundle-cellular (3.1.8-1) unstable; urgency=low

* fix: Keepalive reboot should include "interface".
Expand Down
2 changes: 1 addition & 1 deletion bundle.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cellular",
"version": "3.1.8",
"version": "3.1.9",
"author": "Aeluin Chen",
"email": "[email protected]",
"description": "Provides the cellular configuration interface",
Expand Down
16 changes: 15 additions & 1 deletion cellular_utility/cell_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ def _sh_default_timeout(*args, **kwargs):
class NetworkInformation(object):
def __init__(
self,
status,
ip,
netmask,
gateway,
dns_list):
if (not isinstance(ip, str) or
if (not isinstance(status, bool) or
not isinstance(ip, str) or
not isinstance(netmask, str) or
not isinstance(gateway, str)):
raise ValueError
Expand All @@ -138,11 +140,16 @@ def __init__(
if not isinstance(dns, str):
raise ValueError

self._status = status
self._ip = ip
self._netmask = netmask
self._gateway = gateway
self._dns_list = dns_list

@property
def status(self):
return self._status

@property
def ip(self):
return self._ip
Expand Down Expand Up @@ -458,6 +465,7 @@ def start(self, apn):
dns = match.group(1).split(" ")

return NetworkInformation(
status=True,
ip=ip_,
netmask=netmask,
gateway=gateway,
Expand All @@ -477,6 +485,12 @@ def stop(self):
self._cell_mgmt("stop")
except ErrorReturnCode:
_logger.warning(format_exc() + ", ignored")
return NetworkInformation(
status=False,
ip="",
netmask="",
gateway="",
dns_list=[])

@critical_section
@handle_error_return_code
Expand Down
10 changes: 8 additions & 2 deletions cellular_utility/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,10 @@ def _main_thread(self):
self._observer = None

self._log.log_event_cellular_disconnect()
self._cell_mgmt.stop()
self._network_information = self._cell_mgmt.stop()
# update nwk_info
if self._update_network_information_callback is not None:
self._update_network_information_callback(self._network_information)
break

except Exception:
Expand Down Expand Up @@ -636,7 +639,10 @@ def _connect(self, pdpc_apn, pdpc_type):
try:
self._log.log_event_connect_begin()

self._cell_mgmt.stop()
self._network_information = self._cell_mgmt.stop()
# update nwk_info
if self._update_network_information_callback is not None:
self._update_network_information_callback(self._network_information)

try:
pdpc = (item for item in self.pdp_context_list()
Expand Down
1 change: 1 addition & 0 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ def _publish_network_info(
"wan": True,
"type": "cellular",
"mode": "dhcp",
"status": nwk_info.status,
"ip": nwk_info.ip,
"netmask": nwk_info.netmask,
"gateway": nwk_info.gateway,
Expand Down

0 comments on commit 3577296

Please sign in to comment.