]> git.neil.brown.name Git - plato.git/commitdiff
gsmd: use _COPS rather than _OSIMOP to get carrier id.
authorNeilBrown <neilb@suse.com>
Sun, 11 Oct 2015 08:08:10 +0000 (19:08 +1100)
committerNeilBrown <neilb@suse.com>
Sun, 11 Oct 2015 08:08:10 +0000 (19:08 +1100)
Seems to work better... sometimes.

Signed-off-by: NeilBrown <neil@brown.name>
gsm/gsmd2.py

index 2e6a316014cf3b9d8e00b7d35965968d66903442..75dbb2875d94e7abbfb96a95bcf13685dca96f00 100644 (file)
@@ -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())