From 3b3fecff99a2ba26c8b618139a5b3b1501f54134 Mon Sep 17 00:00:00 2001 From: Aeluin Chen Date: Fri, 7 Apr 2017 18:30:41 +0800 Subject: [PATCH 1/4] style: fix pylint --- cellular_utility/management.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cellular_utility/management.py b/cellular_utility/management.py index 60c4efa..71b4ab8 100644 --- a/cellular_utility/management.py +++ b/cellular_utility/management.py @@ -457,7 +457,8 @@ def _main_thread(self): 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) + self._update_network_information_callback( + self._network_information) break except Exception: @@ -642,7 +643,8 @@ def _connect(self, pdpc_apn, pdpc_type): 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) + self._update_network_information_callback( + self._network_information) try: pdpc = (item for item in self.pdp_context_list() From 02502b9ad4c6418c101f7c6bcce7d35a47c72be8 Mon Sep 17 00:00:00 2001 From: Aeluin Chen Date: Tue, 11 Apr 2017 17:11:08 +0800 Subject: [PATCH 2/4] docs: Support TAC, NID, BID for LTE and CDMA --- schema/index.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/schema/index.yaml b/schema/index.yaml index 24ba0bb..c454f80 100755 --- a/schema/index.yaml +++ b/schema/index.yaml @@ -120,9 +120,18 @@ definitions: lac: type: string description: Location area code. + tac: + type: string + description: Tracking area code (LTE). + nid: + type: string + description: Network ID (CDMA). cellId: type: string description: Cell ID. + bid: + type: string + description: Base station ID (CDMA). iccId: type: string description: ICC ID of SIM card. @@ -301,7 +310,10 @@ externalDocs: }, "operatorName": "Chunghwa Telecom", "lac": "0xF339", + "tac": "", + "nid": "", "cellId": "0x3194", + "bid": "", "iccId": "", "phoneNumber": "", "imei": "356853050370859", From 0cbb97c19de19acb7849937dbd23398227a3092d Mon Sep 17 00:00:00 2001 From: Aeluin Chen Date: Tue, 11 Apr 2017 17:11:38 +0800 Subject: [PATCH 3/4] feat: TAC for LTE and NID, BID for CDMA --- cellular_utility/cell_mgmt.py | 92 +++++++++++++++++++++++++++++++--- cellular_utility/event.py | 24 ++++++--- cellular_utility/management.py | 24 +++++++++ index.py | 3 ++ 4 files changed, 127 insertions(+), 16 deletions(-) diff --git a/cellular_utility/cell_mgmt.py b/cellular_utility/cell_mgmt.py index f3e65a8..e56535c 100644 --- a/cellular_utility/cell_mgmt.py +++ b/cellular_utility/cell_mgmt.py @@ -253,14 +253,23 @@ def ecio_dbm(self): class CellularLocation(object): def __init__( self, - cell_id=None, - lac=None): + cell_id="", + lac="", + tac="", + bid="", + nid=""): if (not isinstance(cell_id, str) or - not isinstance(lac, str)): + not isinstance(lac, str) or + not isinstance(tac, str) or + not isinstance(bid, str) or + not isinstance(nid, str)): raise ValueError self._cell_id = cell_id self._lac = lac + self._tac = tac + self._bid = bid + self._nid = nid @property def cell_id(self): @@ -270,6 +279,18 @@ def cell_id(self): def lac(self): return self._lac + @property + def tac(self): + return self._tac + + @property + def bid(self): + return self._bid + + @property + def nid(self): + return self._nid + class CellularNumber(object): def __init__( @@ -330,6 +351,22 @@ class CellMgmt(object): r"PS: attached\n" ) + _location_info_lac_regex = re.compile( + r"LAC: ([\S]*)\n" + ) + _location_info_tac_regex = re.compile( + r"TAC: ([\S]*)\n" + ) + _location_info_cellid_regex = re.compile( + r"CellID: ([\S]*)\n" + ) + _location_info_nid_regex = re.compile( + r"NID: ([\S]*)\n" + ) + _location_info_bid_regex = re.compile( + r"BID: ([\S]*)\n" + ) + _number_regex = re.compile( r"^([^\n]*)[\n]{0,1}") @@ -785,13 +822,52 @@ def get_cellular_location(self): """ Return CellularLocation instance. """ + cellid = "" + lac = "" + tac = "" + nid = "" + bid = "" + + _logger.debug("cell_mgmt location_info") + + # [umts] + # LAC: xxx + # CellID: xxx + # + # [lte] + # TAC: xxx + # CellID: xxx + # + # [cdma] + # NID: xxx + # BID: xxx + output = str(self._cell_mgmt("location_info")) + found = self._location_info_lac_regex.search(output) + if found: + lac = found.group(1) + + found = self._location_info_cellid_regex.search(output) + if found: + cellid = found.group(1) + + found = self._location_info_tac_regex.search(output) + if found: + tac = found.group(1) + + found = self._location_info_nid_regex.search(output) + if found: + nid = found.group(1) + + found = self._location_info_bid_regex.search(output) + if found: + bid = found.group(1) - _logger.debug("get_cellular_location") - - minfo = self.m_info() return CellularLocation( - cell_id=minfo.cell_id, - lac=minfo.lac) + cell_id=cellid, + lac=lac, + tac=tac, + bid=bid, + nid=nid) if __name__ == "__main__": diff --git a/cellular_utility/event.py b/cellular_utility/event.py index de76ddf..a81795a 100644 --- a/cellular_utility/event.py +++ b/cellular_utility/event.py @@ -36,14 +36,22 @@ def log_cellular_information( ci should be an instance of cellular_utility.management.CellularInformation """ - self._log( - "mode {}, signal {} dBm, rssi {}, lac {}, cell_id {}".format( - cellular_information.mode, - str(cellular_information.signal_rssi_dbm), - str(cellular_information.signal_csq), - cellular_information.lac, - cellular_information.cell_id) - ) + log = "mode {}, signal {} dBm, rssi {}".format( + cellular_information.mode, + str(cellular_information.signal_rssi_dbm), + str(cellular_information.signal_csq)) + if len(cellular_information.lac): + log += ", lac {}".format(cellular_information.lac) + if len(cellular_information.tac): + log += ", tac {}".format(cellular_information.tac) + if len(cellular_information.nid): + log += ", nid {}".format(cellular_information.nid) + if len(cellular_information.cell_id): + log += ", cell_id {}".format(cellular_information.cell_id) + if len(cellular_information.bid): + log += ", bid {}".format(cellular_information.bid) + + self._log(log) def log_event_connect_begin(self): """ diff --git a/cellular_utility/management.py b/cellular_utility/management.py index 71b4ab8..4abe05c 100644 --- a/cellular_utility/management.py +++ b/cellular_utility/management.py @@ -35,7 +35,10 @@ def __init__( signal_ecio_dbm=None, operator=None, lac=None, + tac=None, + nid=None, cell_id=None, + bid=None, number=None): if (not isinstance(mode, str) or @@ -44,7 +47,10 @@ def __init__( not isinstance(signal_ecio_dbm, float) or not isinstance(operator, str) or not isinstance(lac, str) or + not isinstance(tac, str) or + not isinstance(nid, str) or not isinstance(cell_id, str) or + not isinstance(bid, str) or not isinstance(number, str)): raise ValueError @@ -57,7 +63,10 @@ def __init__( self._signal_ecio_dbm = signal_ecio_dbm self._operator = operator self._lac = lac + self._tac = tac + self._nid = nid self._cell_id = cell_id + self._bid = bid self._number = number @property @@ -84,10 +93,22 @@ def operator(self): def lac(self): return self._lac + @property + def tac(self): + return self._tac + + @property + def nid(self): + return self._nid + @property def cell_id(self): return self._cell_id + @property + def bid(self): + return self._bid + @property def number(self): return self._number @@ -130,7 +151,10 @@ def get(): signal.ecio_dbm, operator, cellular_location.lac, + cellular_location.tac, + cellular_location.nid, cellular_location.cell_id, + cellular_location.bid, number.number) diff --git a/index.py b/index.py index 0f14e71..f343832 100755 --- a/index.py +++ b/index.py @@ -318,7 +318,10 @@ def _get(self): "ecio": cinfo.signal_ecio_dbm}, "operatorName": "n/a" if cinfo is None else cinfo.operator, "lac": "n/a" if cinfo is None else cinfo.lac, + "tac": "n/a" if cinfo is None else cinfo.tac, + "nid": "n/a" if cinfo is None else cinfo.nid, "cellId": "n/a" if cinfo is None else cinfo.cell_id, + "bid": "n/a" if cinfo is None else cinfo.bid, "iccId": "n/a" if sinfo is None else sinfo.icc_id, "imei": "n/a" if sinfo is None else sinfo.imei, "pinRetryRemain": ( From 5e02d46abf2b9d5d4264429124e7dd02456abd02 Mon Sep 17 00:00:00 2001 From: Aeluin Chen Date: Tue, 11 Apr 2017 18:38:20 +0800 Subject: [PATCH 4/4] 3.2.0 --- build-deb/debian/changelog | 6 ++++++ bundle.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build-deb/debian/changelog b/build-deb/debian/changelog index 0f76ef4..53c1097 100644 --- a/build-deb/debian/changelog +++ b/build-deb/debian/changelog @@ -1,3 +1,9 @@ +sanji-bundle-cellular (3.2.0-1) unstable; urgency=low + + * feat: TAC for LTE and NID, BID for CDMA. + + -- Aeluin Chen Tue, 11 Apr 2017 18:29:55 +0800 + sanji-bundle-cellular (3.1.9-1) unstable; urgency=low * fix: Update status after disconnected. diff --git a/bundle.json b/bundle.json index 4bc9c8a..cb9ca06 100644 --- a/bundle.json +++ b/bundle.json @@ -1,6 +1,6 @@ { "name": "cellular", - "version": "3.1.9", + "version": "3.2.0", "author": "Aeluin Chen", "email": "aeluin.chen@moxa.com", "description": "Provides the cellular configuration interface",