Skip to content

Commit a99642c

Browse files
committed
Add support for newer SIMCom devices
This patch adds support to event driven calls for newer SIMCom devices such as the SIM7100, SIM7500, and SIM7600. These devices support the command "AT+CLCC=1" which sets the modem to print the CLCC output on every call status change. I made an effort to to probe modem upport for automatic reporting by trying setting AT+CLCC to 1. The untested assumption is that the command will fail if the modem does not support it. The regular expressions used for _handleCallAnswered, _handleCallInitiated, and _handleCallEnded are simply a copy and paste from the regular expression used for CLCC, replacing what was on the third group by a fixed number representing the call status. For example, using the number 6 to indicate that the call was disconnected. To detect the newer devices I used the availability of the +SIMCOMATI command but I am not really sure how reliable this is. My concern is of false positives for devices that could support the +SIMCOMATI and not support the automatic reporting of "AT+CLCC=1". This was tested on an SIM7600G. Signed-off-by: Peter Senna Tschudin <[email protected]>
1 parent ea7db39 commit a99642c

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

gsmmodem/modem.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ def connect(self, pin=None, waitingForModemToStartInSeconds=0):
255255
enableWind = True
256256
elif '+ZPAS' in commands:
257257
callUpdateTableHint = 3 # ZTE
258+
if '+SIMCOMATI' in commands:
259+
callUpdateTableHint = 4 # SIMCom
258260
else:
259261
# Try to enable general notifications on Wavecom-like device
260262
enableWind = True
@@ -323,6 +325,39 @@ def connect(self, pin=None, waitingForModemToStartInSeconds=0):
323325
self._waitForCallInitUpdate = False # ZTE modems do not provide "call initiated" updates
324326
if commands == None: # ZTE uses standard +VTS for DTMF
325327
Call.dtmfSupport = True
328+
elif callUpdateTableHint == 4: # SIMCom (Tested on SIM7600)
329+
self.log.info('Loading SIMCOM call state update table')
330+
self._mustPollCallStatus = False
331+
Call.dtmfSupport = True
332+
try:
333+
# Enables automatic reporting of the list of current calls
334+
# when the call status changes
335+
self.write('AT+CLCC=1')
336+
except CommandError:
337+
# Modem does not support automatic reporting of the list of
338+
# current calls when the call status changes
339+
self.log.info('Will use polling for call state updates')
340+
self._mustPollCallStatus = True
341+
342+
# This works well with the SIM7600G for example
343+
if not self._mustPollCallStatus:
344+
# Using the field <stat> of the AT+CLCC command. Notice the
345+
# numbers between groups 1 and 2 on the following regexes
346+
#
347+
# The possible values are:
348+
# 0 – active
349+
# 1 – held
350+
# 2 – dialing (MO call)
351+
# 3 – alerting (MO call)
352+
# 4 – incoming (MT call)
353+
# 5 – waiting (MT call)
354+
# 6 – disconnect
355+
self._callStatusUpdates = (
356+
(re.compile('^\+CLCC:\s+(\d+),(\d),0,(\d),([^,]),"([^,]*)",(\d+)$'), self._handleCallAnswered),
357+
(re.compile('^\+CLCC:\s+(\d+),(\d),2,(\d),([^,]),"([^,]*)",(\d+)$'), self._handleCallInitiated),
358+
(re.compile('^\+CLCC:\s+(\d+),(\d),6,(\d),([^,]),"([^,]*)",(\d+)$'), self._handleCallEnded),
359+
(re.compile('^BUSY$'), self._handleCallRejected))
360+
#self._waitForAtdResponse = True
326361
else:
327362
# Unknown modem - we do not know what its call updates look like. Use polling instead
328363
self.log.info('Unknown/generic modem type - will use polling for call state updates')
@@ -567,7 +602,7 @@ def supportedCommands(self):
567602
except (TimeoutException, CommandError):
568603
# Try interactive command recognition
569604
commands = []
570-
checkable_commands = ['^CVOICE', '+VTS', '^DTMF', '^USSDMODE', '+WIND', '+ZPAS', '+CSCS', '+CNUM']
605+
checkable_commands = ['^CVOICE', '+VTS', '^DTMF', '^USSDMODE', '+WIND', '+ZPAS', '+CSCS', '+CNUM', '+SIMCOMATI']
571606

572607
# Check if modem is still alive
573608
try:

0 commit comments

Comments
 (0)