--- pygsmd.py 2008-03-28 20:04:04.000000000 +0100 +++ pysmsd.py 2008-03-29 00:40:16.000000000 +0100 @@ -32,33 +32,46 @@ # see http://www.ctiforum.com/standard/standard/etsi/0710.pdf init_commands = ( # base settings - # AT-Command Interpreter ready # expect this after hw reset 'Z', # soft reset 'E0V1', # echo off, verbose result on - '+CMEE=2', # report mobile equipment error - #'+CSCS=8859-1', # character set - '+CRC=1', # cellular result codes - '+CLIP=1', # calling line identification presentation enable - '+COLP=1', # connected line identification presentation enable - '+CMOD=0', # call modes supported: single mode - '+CMGF=0', # pdu mode sms enable - #'+CSTA=145', # select type of address: allow international access code character "+" - #'+CVHU=0', # hangup control / not implemented by neo1973, uses ATH - #'+CCFC=', # call forwarding number and conditions - #'+CBST=7,0,1', # select bearer service type - #'+CSNS=0', # single numbering scheme - '+CREG=2', # enable network registration and location information unsolicited result code - #'+CFUN=0', # limited phone functionality on + # AT-Command Interpreter ready # expect this after hw reset + '+CMEE=2', # report mobile equipment error + #'+CSCS=8859-1', # character set + '+CRC=1', # cellular result codes + '+CLIP=1', # calling line identification presentation enable + '+COLP=1', # connected line identification presentation enable + '+CMOD=0', # call modes supported: single mode + #'+CMGF=0', # pdu mode sms enable + #'+CSTA=145', # select type of address: allow international access code character "+" + #'+CVHU=0', # hangup control / not implemented by neo1973, uses ATH + #'+CCFC=', # call forwarding number and conditions + #'+CBST=7,0,1', # select bearer service type + #'+CSNS=0', # single numbering scheme + '+CREG=2', # enable network registration and location information unsolicited result code + '+CFUN=1', # limited phone functionality on + #'+CPIN="1111"', # limited phone functionality on + #'+CMGL=4', # List all SMS +# '+CPIN?;+CPAS;+CSQ;+CREG?;+WS46?;+COPS?;+CFUN?', # Set UCS-2 charset + '+CSMS=0', # enables SMS support? + '+CMGF=1', # pdu mode sms disable (enable text mode) + '+CSCS="UCS2"', # Set UCS-2 charset + '+CNMI=2,1,2,1,0', # Set the New Message Indications properties +# '+CSCA?', # GSMD_SMS_GET_SERVICE_CENTRE +# '+CPMS?', # GSMD_SMS_GET_MSG_STORAGE + '+CMGL="ALL"', # List all SMS ) statuscommand = ';'.join(( - '+CPIN?', # Pin state - '+CPAS', # phone activity status - '+CSQ', # signal quality - #'+CCLK?', # clock - TODO: does not work on neo1973 - '+CREG?', # network registration - '+WS46?', # wireless network - '+COPS?', # operator selection - '+CFUN?' # function + '+CPIN?', # Pin state + '+CPAS', # phone activity status + #'+CCLK?', # clock - TODO: does not work on neo1973 + '+CSCA?', # GSMD_SMS_GET_SERVICE_CENTRE + '+CPMS?', # GSMD_SMS_GET_MSG_STORAGE +# '+CMGF=0', # pdu mode sms ensable +# '+CMGL', # List all SMS + '+CMGF=1', # text mode sms enable + #'+CSCS="UCS2"', # Set UCS-2 charset + '+CSCS="IRA"', # Set UCS-2 charset + '+CMGL="ALL"', # List all SMS )) class GsmPhone(serial.Serial, NotifyObject): @@ -78,6 +91,7 @@ ''' def __init__(self, bus): self.bus = bus + self.waitforok = False # glib's waiters self.tow = None self.iow = None @@ -104,6 +118,9 @@ self.rtscts = True self.silence = 0 self._sim_auth_status = dict() + self._sms = dict() + self._sms_indices = [] + self._sms_indices_new = [] self.timeout = 7 self.writeTimeout = 1 self.xonxoff = False @@ -225,9 +242,14 @@ self.silence = 0 if line: # ignore empty lines LOG(LOG_DEBUG, __name__, 'read', line.__repr__()) - if line == 'AT%s'% self.command: # ignore my echo... + if self.waitforok and line != 'OK': + print line + elif line == 'AT%s'% self.command: # ignore my echo... pass elif line in ('NO CARRIER', 'BUSY', 'ERROR', 'OK', ): + self.waitforok= False # All SMS are printed, we are done + self._sms_indices = self._sms_indices_new; # New SMS indices + self._sms_indices_new = []; # New SMS indices name = 'gsm%s'% line name = name.replace(' ', '_') fnctn = getattr(self, name, None) @@ -369,6 +391,30 @@ ) if sim_status != self._sim_auth_status: self.SimAuthStatus(sim_status) + def gsmCSCA(self, sca, num): + LOG(LOG_INFO, __name__, 'service centre:', sca) + def gsmCPMS(self, s1,s2,s3,s4,s5,s6,s7,s8,s9): + LOG(LOG_INFO, __name__, 'sms storage:', s1,s2,s3,s4,s5,s6,s7,s8,s9) +# gsmCMGL [\'5\', \'"REC READ"\', \'"436644490292"\', \'\', \'"08/03/23\', \'11:45:18+04"\', \'145\', \'91\']' + def gsmCMGL(self, idx,status,sender,s4,date,time,s7,s8): + LOG(LOG_INFO, __name__, 'sms:', idx,status,sender,s4,date,time,s7,s8) + self.waitforok= True + sms = dict(self._sms, + idx=idx, + sender=sender, + date=date, + time=time, + ) + self._sms = sms + self._sms_indices_new.append(int(idx)); + print "current new indices:", self._sms_indices_new + @method(DIN_PHONE, '', 'ai') + def ListMessages(self): + print "current indices:", self._sms_indices + return self._sms_indices + @method(DIN_PHONE, '', 'a{sv}') + def GetSMS(self): + return self._sms ### network @method(DIN_PHONE, '', '') def NetworkRegister(self):