@@ -146,11 +146,11 @@ class GsmModem(SerialComms):
146146 CDSI_REGEX = re .compile ('\+CDSI:\s*"([^"]+)",(\d+)$' )
147147 CDS_REGEX = re .compile ('\+CDS:\s*([0-9]+)"$' )
148148
149- def __init__ (self , port , baudrate = 115200 , incomingCallCallbackFunc = None , smsReceivedCallbackFunc = None , smsStatusReportCallback = None , requestDelivery = True , AT_CNMI = "" , * a , ** kw ):
149+ def __init__ (self , port , baudrate = 115200 , incomingCallCallbackFunc = None , smsReceivedCallbackFunc = None , smsStatusReportCallbackFunc = None , requestDelivery = True , AT_CNMI = "" , * a , ** kw ):
150150 super (GsmModem , self ).__init__ (port , baudrate , notifyCallbackFunc = self ._handleModemNotification , * a , ** kw )
151- self .incomingCallCallback = incomingCallCallbackFunc or self . _placeholderCallback
152- self .smsReceivedCallback = smsReceivedCallbackFunc or self . _placeholderCallback
153- self .smsStatusReportCallback = smsStatusReportCallback or self . _placeholderCallback
151+ self .incomingCallCallbackFunc = incomingCallCallbackFunc
152+ self .smsReceivedCallbackFunc = smsReceivedCallbackFunc
153+ self .smsStatusReportCallbackFunc = smsStatusReportCallbackFunc
154154 self .requestDelivery = requestDelivery
155155 self .AT_CNMI = AT_CNMI or "2,1,0,2"
156156 # Flag indicating whether caller ID for incoming call notification has been set up
@@ -377,7 +377,7 @@ def connect(self, pin=None, waitingForModemToStartInSeconds=0):
377377 del cpmsSupport
378378 del cpmsLine
379379
380- if self ._smsReadSupported and (self .smsReceivedCallback or self .smsStatusReportCallback ):
380+ if self ._smsReadSupported and (self .smsReceivedCallbackFunc or self .smsStatusReportCallbackFunc ):
381381 try :
382382 self .write ('AT+CNMI=' + self .AT_CNMI ) # Set message notifications
383383 except CommandError :
@@ -1067,16 +1067,16 @@ def processStoredSms(self, unreadOnly=False):
10671067 :param unreadOnly: If True, only process unread SMS messages
10681068 :type unreadOnly: boolean
10691069 """
1070- if self .smsReceivedCallback :
1070+ if self .smsReceivedCallbackFunc :
10711071 states = [Sms .STATUS_RECEIVED_UNREAD ]
10721072 if not unreadOnly :
10731073 states .insert (0 , Sms .STATUS_RECEIVED_READ )
10741074 for msgStatus in states :
10751075 messages = self .listStoredSms (status = msgStatus , delete = True )
10761076 for sms in messages :
1077- self .smsReceivedCallback (sms )
1077+ self .smsReceivedCallbackFunc (sms )
10781078 else :
1079- raise ValueError ('GsmModem.smsReceivedCallback not set' )
1079+ raise ValueError ('GsmModem.smsReceivedCallbackFunc not set' )
10801080
10811081 def listStoredSms (self , status = Sms .STATUS_ALL , memory = None , delete = False ):
10821082 """ Returns SMS messages currently stored on the device/SIM card.
@@ -1283,7 +1283,9 @@ def _handleIncomingCall(self, lines):
12831283 callId = len (self .activeCalls ) + 1 ;
12841284 call = IncomingCall (self , callerNumber , ton , callerName , callId , callType )
12851285 self .activeCalls [callId ] = call
1286- self .incomingCallCallback (call )
1286+
1287+ if self .incomingCallCallbackFunc (incomingCallCallback ):
1288+ self .incomingCallCallbackFunc (call )
12871289
12881290 def _handleCallInitiated (self , regexMatch , callId = None , callType = 1 ):
12891291 """ Handler for "outgoing call initiated" event notification line """
@@ -1344,16 +1346,16 @@ def _handleCallRejected(self, regexMatch, callId=None):
13441346 def _handleSmsReceived (self , notificationLine ):
13451347 """ Handler for "new SMS" unsolicited notification line """
13461348 self .log .debug ('SMS message received' )
1347- if self .smsReceivedCallback is not None :
1349+ if self .smsReceivedCallbackFunc is not None :
13481350 cmtiMatch = self .CMTI_REGEX .match (notificationLine )
13491351 if cmtiMatch :
13501352 msgMemory = cmtiMatch .group (1 )
13511353 msgIndex = cmtiMatch .group (2 )
13521354 sms = self .readStoredSms (msgIndex , msgMemory )
13531355 try :
1354- self .smsReceivedCallback (sms )
1356+ self .smsReceivedCallbackFunc (sms )
13551357 except Exception :
1356- self .log .error ('error in smsReceivedCallback ' , exc_info = True )
1358+ self .log .error ('error in smsReceivedCallbackFunc ' , exc_info = True )
13571359 else :
13581360 self .deleteStoredSms (msgIndex )
13591361
@@ -1372,12 +1374,12 @@ def _handleSmsStatusReport(self, notificationLine):
13721374 if self ._smsStatusReportEvent :
13731375 # A sendSms() call is waiting for this response - notify waiting thread
13741376 self ._smsStatusReportEvent .set ()
1375- elif self .smsStatusReportCallback :
1377+ elif self .smsStatusReportCallbackFunc :
13761378 # Nothing is waiting for this report directly - use callback
13771379 try :
1378- self .smsStatusReportCallback (report )
1380+ self .smsStatusReportCallbackFunc (report )
13791381 except Exception :
1380- self .log .error ('error in smsStatusReportCallback ' , exc_info = True )
1382+ self .log .error ('error in smsStatusReportCallbackFunc ' , exc_info = True )
13811383
13821384 def _handleSmsStatusReportTe (self , length , notificationLine ):
13831385 """ Handler for TE SMS status reports """
@@ -1400,9 +1402,10 @@ def _handleSmsStatusReportTe(self, length, notificationLine):
14001402 else :
14011403 # Nothing is waiting for this report directly - use callback
14021404 try :
1403- self .smsStatusReportCallback (report )
1405+ self .smsStatusReportCallbackFunc (report )
14041406 except Exception :
1405- self .log .error ('error in smsStatusReportCallback' , exc_info = True )
1407+ self .log .error ('error in smsStatusReportCallbackFunc' , exc_info = True )
1408+
14061409
14071410 def readStoredSms (self , index , memory = None ):
14081411 """ Reads and returns the SMS message at the specified index
@@ -1540,10 +1543,6 @@ def _parseCusdResponse(self, lines):
15401543 message = cusdMatches [0 ].group (2 )
15411544 return Ussd (self , sessionActive , message )
15421545
1543- def _placeHolderCallback (self , * args ):
1544- """ Does nothing """
1545- self .log .debug ('called with args: {0}' .format (args ))
1546-
15471546 def _pollCallStatus (self , expectedState , callId = None , timeout = None ):
15481547 """ Poll the status of outgoing calls.
15491548 This is used for modems that do not have a known set of call status update notifications.
0 commit comments