faucamp / python-gsmmodem

Python module to control a GSM modem attached to the system: send/receive SMS messages, handle calls, etc
GNU Lesser General Public License v3.0
384 stars 302 forks source link

Incoming SMS and Incoming Call in same Port #46

Open sah-anshu opened 9 years ago

sah-anshu commented 9 years ago

INFO: Connecting to modem on port /dev/ttyUSB1 at 115200bps DEBUG: write: ATZ DEBUG: response: ['OK'] DEBUG: write: ATE0 DEBUG: response: ['OK'] DEBUG: write: AT+CFUN? DEBUG: response: ['+CFUN: 1', 'OK'] DEBUG: write: AT+CMEE=1 DEBUG: response: ['OK'] DEBUG: write: AT+CPIN? DEBUG: response: ['+CPIN: READY', 'OK'] DEBUG: write: AT+CLAC DEBUG: response: ['ERROR'] DEBUG: write: AT+WIND? DEBUG: response: ['ERROR'] DEBUG: write: AT+CGMI DEBUG: response: ['SIEMENS', 'OK'] DEBUG: write: AT+ZPAS? DEBUG: response: ['ERROR'] INFO: Unknown/generic modem type - will use polling for call state updates DEBUG: write: AT+COPS=3,0 DEBUG: response: ['OK'] DEBUG: write: AT+CMGF=0 DEBUG: response: ['OK'] DEBUG: write: AT+CSCA? DEBUG: response: ['+CSCA: "+919894051914",145', 'OK'] DEBUG: write: AT+CSMP=49,167,0,0 DEBUG: response: ['OK'] DEBUG: write: AT+CSCA? DEBUG: response: ['+CSCA: "+919894051914",145', 'OK'] DEBUG: write: AT+CPMS=? DEBUG: response: ['+CPMS: ("MT","SM","ME"),("MT","SM","ME"),("MT","SM")', 'OK'] DEBUG: write: AT+CPMS="ME","ME","SM" DEBUG: response: ['+CPMS: 9,25,9,25,0,20', 'OK'] DEBUG: write: AT+CNMI=2,1,0,2 DEBUG: response: ['OK'] DEBUG: write: AT+CLIP=1 DEBUG: response: ['OK'] DEBUG: write: AT+CRC=1 DEBUG: response: ['OK'] DEBUG: write: AT+CVHU=0 DEBUG: response: ['ERROR'] Checking for network coverage... DEBUG: write: AT+CREG? DEBUG: response: ['+CREG: 0,5', 'OK'] DEBUG: write: AT+CSQ DEBUG: response: ['+CSQ: 23,99', 'OK'] Waiting ... DEBUG: notification: ['+CIEV: call,0', '+CRING: VOICE', '+CLIP: "+91XXXXXXXX",145,,,,0'] DEBUG: Handling incoming call Exception in thread Thread-3: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 551, in *bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 504, in run self.__target(_self.__args, _self.kwargs) File "build/bdist.linux-i686/egg/gsmmodem/modem.py", line 865, in threadedHandleModemNotification self._handleIncomingCall(lines) File "build/bdist.linux-i686/egg/gsmmodem/modem.py", line 931, in _handleIncomingCall call = IncomingCall(self, callerNumber, ton, callerName, callId, callType) File "build/bdist.linux-i686/egg/gsmmodem/modem.py", line 1298, in __init** callType = self.CALL_TYPE_MAP[callType] KeyError: 'call,0'

sah-anshu commented 9 years ago

Also When I Send SMS then i am facing similar problem

DEBUG: notification: ['+CIEV: call,0', '+CMTI: "ME",11'] DEBUG: SMS message received DEBUG: write: AT+CPMS="ME" DEBUG: response: ['+CPMS: 11,25,11,25,0,20', 'OK'] DEBUG: write: AT+CMGR=11 DEBUG: response: ['+CMGR: 0,,29', '0791198904100161240C911979099137640000512091413402220BC8B4421174CFD175D014', 'OK'] DEBUG: write: AT+CMGD=11,0 DEBUG: response: ['+CMS ERROR: 500'] Exception in thread Thread-3: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 551, in bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 504, in run self.__target(_self.args, *_self.kwargs) File "build/bdist.linux-i686/egg/gsmmodem/modem.py", line 869, in threadedHandleModemNotification self._handleSmsReceived(line) File "build/bdist.linux-i686/egg/gsmmodem/modem.py", line 999, in _handleSmsReceived self.deleteStoredSms(msgIndex) File "build/bdist.linux-i686/egg/gsmmodem/modem.py", line 1086, in deleteStoredSms self.write('AT+CMGD={0},0'.format(index)) File "build/bdist.linux-i686/egg/gsmmodem/modem.py", line 441, in write raise CmsError(data, int(errorCode)) CmsError: CMS 500

Code

modem = GsmModem(args.port, args.baud, incomingCallCallbackFunc=handleIncomingCall, smsReceivedCallbackFunc=handleSms)
    modem.smsTextMode = False 
    modem.connect(args.pin)

    print('Checking for network coverage...')
    try:
        modem.waitForNetworkCoverage(5)
    except TimeoutException:
        print('Network signal strength is not sufficient, please adjust modem position/antenna and try again.')
        modem.close()
        sys.exit(1)
    else:    
        print('Waiting ...')
        modem.rxThread.join(2**31)    
    finally:
        modem.close();