]> git.neil.brown.name Git - plato.git/commitdiff
gsmd2: use +CLCC in place of +CPAS
authorNeilBrown <neilb@suse.de>
Mon, 16 Dec 2013 05:41:55 +0000 (16:41 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 17 Dec 2013 09:29:54 +0000 (20:29 +1100)
We poll the status while a call is incoming so we can know
when the called hangs up.
CPAS isn't reliable as it reports any connection including data.
So use +CLCC.

gsm/gsmd2.py

index dd27063b09fba46276c3c595d910a412d731d20e..a30156a2e78ee4f032dfd5f20454d65dccdcffea 100644 (file)
@@ -1124,10 +1124,7 @@ add_engine(config())
 #  'incoming' is "-" for private, or "number" of incoming (or empty)
 #  'status' is "INCOMING" or 'BUSY' or 'on-call' (or empty)
 #
-# While 'on-call' we poll with +CPAS
-# 0=ready 1=unavailable 2=unknown 3=ringing 4=call-in-progress 5=asleep
-# need 4 '0' in a row before assume hang-up
-# Could use AT+CLCC ??
+# While 'on-call' we poll with +CLCC
 # ringing:
 #    +CLCC: 1,1,4,0,0,"0403463349",128
 # answered:
@@ -1158,6 +1155,7 @@ class voice(Engine):
         request_async('+CLIP:', self.incoming_number)
         request_async('NO CARRIER', self.hangup)
         request_async('BUSY', self.busy)
+        request_async('_OLCC', self.async_activity)
         watch('/run/gsm-state', 'call', self.check_call)
         watch('/run/gsm-state', 'dtmf', self.check_dtmf)
         self.f = EvDev('/dev/input/incoming', self.incoming_wake)
@@ -1179,23 +1177,35 @@ class voice(Engine):
             self.zero_cnt = 0
             self.retry(0)
     def do_retry(self):
-        at_queue('+CPAS', self.get_activity)
+        at_queue('+CLCC', self.get_activity)
     def get_activity(self, line):
-        if line == None:
-            return False
-        m = re.match('\+CPAS: (\d)', line)
+        m = re.match('\+CLCC: \d+,(\d+),(\d+),\d+,\d+,"([^"]*)".*', line)
         if m:
-            n = m.group(1)
-            if n == '0' or (n == '4' and self.state == 'idle'):
-                self.zero_cnt += 1
-                if self.zero_cnt >= 4 or self.state == 'idle':
+            n1 = m.group(1)
+            n2 = m.group(2)
+            num = m.group(3)
+            if n1 == '1':
+                if n2 == '30':
                     self.to_idle()
-            else:
-                self.zero_cnt = 0
-            if n == '3':
-                if self.state != 'incoming':
-                    self.to_incoming()
+                else:
+                    self.to_incoming(num)
             self.retry()
+        else:
+            self.to_idle()
+        return False
+
+    def async_activity(self, line):
+        m = re.match('_OLCC: \d+,(\d+),(\d+),\d+,\d+,"([^"]*)".*', line)
+        if m:
+            n1 = m.group(1)
+            n2 = m.group(2)
+            num = m.group(3)
+            if n1 == '1':
+                if n2 == '30':
+                    self.to_idle()
+                else:
+                    self.to_incoming(num)
+            return True
         return False
 
     def incoming(self, line):