From 52770d3dc720317b4a3525e59dba4aee03a672b4 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 11 Oct 2015 19:08:10 +1100 Subject: [PATCH] gsmd: use _COPS rather than _OSIMOP to get carrier id. Seems to work better... sometimes. Signed-off-by: NeilBrown --- gsm/gsmd2.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gsm/gsmd2.py b/gsm/gsmd2.py index 2e6a316..75dbb28 100644 --- a/gsm/gsmd2.py +++ b/gsm/gsmd2.py @@ -842,7 +842,9 @@ class Cellid(Engine): if lac != self.lac: self.lac = lac # check we still have correct carrier - at_queue('_OSIMOP', self.got_carrier) + # at_queue('_OSIMOP', self.got_carrier) + at_queue('+COPS=3,2', None) + at_queue('+COPS?', self.got_cops) # Make sure we are getting async cell notifications at_queue('+CSCB=1', None) def got_carrier(self, line): @@ -854,6 +856,22 @@ class Cellid(Engine): record('sid', m.group(2)) record('carrier', m.group(1)) return False + def got_cops(self, line): + if line: + m = re.match('\+COPS: (\d),(\d),"([^"]*)",(\d)', line) + oldsid = recall('sid') + if m and m.group(2) == '2': + record('sid', m.group(3)) + if m.group(3) == 'Limited Service': + record('carrier', m.group(3)) + if oldsid != m.group(3): + at_queue('+COPS=3,1', None) + at_queue('+COPS?', self.got_cops) + elif m and m.group(2) == '1': + record('carrier', m.group(3)) + elif not m: + record('sid', '') + return False add_engine(Cellid()) -- 2.43.0