Skip to content

Commit

Permalink
Merge pull request #126 from lwindg/develop
Browse files Browse the repository at this point in the history
3.2.0
  • Loading branch information
taotao authored Apr 11, 2017
2 parents 3577296 + 5e02d46 commit d7bc9eb
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 19 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.2.0-1) unstable; urgency=low

* feat: TAC for LTE and NID, BID for CDMA.

-- Aeluin Chen <[email protected]> Tue, 11 Apr 2017 18:29:55 +0800

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

* fix: Update status after disconnected.
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.9",
"version": "3.2.0",
"author": "Aeluin Chen",
"email": "[email protected]",
"description": "Provides the cellular configuration interface",
Expand Down
92 changes: 84 additions & 8 deletions cellular_utility/cell_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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__(
Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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__":
Expand Down
24 changes: 16 additions & 8 deletions cellular_utility/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
30 changes: 28 additions & 2 deletions cellular_utility/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -457,7 +481,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:
Expand Down Expand Up @@ -642,7 +667,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()
Expand Down
3 changes: 3 additions & 0 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": (
Expand Down
12 changes: 12 additions & 0 deletions schema/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -301,7 +310,10 @@ externalDocs:
},
"operatorName": "Chunghwa Telecom",
"lac": "0xF339",
"tac": "",
"nid": "",
"cellId": "0x3194",
"bid": "",
"iccId": "",
"phoneNumber": "",
"imei": "356853050370859",
Expand Down

0 comments on commit d7bc9eb

Please sign in to comment.