Trees | Indices | Help |
|
---|
|
1 ### BITPIM 2 ### 3 ### Copyright (C) 2005 Joe Pham <djpham@bitpim.org> 4 ### 5 ### This program is free software; you can redistribute it and/or modify 6 ### it under the terms of the BitPim license as detailed in the LICENSE file. 7 ### 8 ### $Id: com_etsi.py 3927 2007-01-22 03:15:22Z rogerb $ 9 10 """Communicate with a GSM phones using AT commands""" 11 12 # system modules 13 14 # BitPim modules 15 import com_phone 16 import commport 17 import prototypes 18 import p_etsi 1921 """ Talk to generic GSM phones 22 """ 23 desc='GSM' 24 protocolclass=p_etsi 25 29114 115 #------------------------------------------------------------------------------- 11631 """Similar to the sendpbcommand in com_sanyo and com_lg, except that 32 a list of responses is returned, one per line of information returned 33 from the phone""" 34 35 buffer=prototypes.buffer() 36 37 request.writetobuffer(buffer, logtitle="GSM sendATcommand") 38 data=buffer.getvalue() 39 40 try: 41 response_lines=self.comm.sendatcommand(data, ignoreerror=ignoreerror) 42 except commport.ATError: 43 raise 44 except: 45 self.comm.success=False 46 self.mode=self.MODENONE 47 self.raisecommsdnaexception("sending AT command") 48 49 self.comm.success=True 50 51 if responseclass is None: 52 return response_lines 53 54 reslist=[] 55 for line in response_lines: 56 res=responseclass() 57 buffer=prototypes.buffer(line) 58 res.readfrombuffer(buffer, logtitle="GSM receive AT response") 59 reslist.append(res) 60 return reslist6163 self.log("_setmodemodem") 64 65 # Just try waking phone up first 66 try: 67 self.comm.sendatcommand("Z") 68 self.comm.sendatcommand('E0V1') 69 return True 70 except: 71 pass 72 73 # Should be in modem mode. Wake up the interface 74 for baud in (0, 115200, 19200, 230400): 75 self.log("Baud="+`baud`) 76 if baud: 77 if not self.comm.setbaudrate(baud): 78 continue 79 try: 80 self.comm.sendatcommand("Z") 81 self.comm.sendatcommand('E0V1') 82 return True 83 except: 84 pass 85 return False8688 req=self.protocolclass.esnrequest() 89 res=self.sendATcommand(req, self.protocolclass.esnresponse) 90 try: 91 return res[0].esn 92 except: 93 return ''9496 req=self.protocolclass.SIM_ID_Req() 97 try: 98 res=self.sendATcommand(req, self.protocolclass.single_value_resp) 99 return res[0].value 100 except: 101 return None102104 return self.sendATcommand(self.protocolclass.manufacturer_id_req(), 105 self.protocolclass.single_value_resp)[0].value106108 return self.sendATcommand(self.protocolclass.model_id_req(), 109 self.protocolclass.single_value_resp)[0].value110112 return self.sendATcommand(self.protocolclass.firmware_version_req(), 113 self.protocolclass.single_value_resp)[0].value118 BP_Calendar_Version=3119
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Jan 24 16:24:09 2010 | http://epydoc.sourceforge.net |