Trees | Indices | Help |
|
---|
|
1 ### BITPIM 2 ### 3 ### Copyright (C) 2006 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_moto.py 3641 2006-11-08 02:43:05Z sawecw $ 9 10 """Communicate with Motorola CDMA phones using AT commands""" 11 12 import commport 13 import com_moto 14 import com_brew 1517 _switch_mode_cmd='\x44\x58\xf4\x7e' 18 22 27136 13929 self.log('Switching from modem to BREW') 30 try: 31 self.comm.sendatcommand('$QCDMG') 32 return True 33 except: 34 pass 35 # give it another try 36 self.log('Retry switching from modem to BREW') 37 try: 38 self.comm.sendatcommand('$QCDMG') 39 return True 40 except commport.ATError: 41 return False 42 except: 43 if __debug__: 44 self.log('Got an excepetion') 45 return False4648 # switch from None to BREW 49 self.log('Switching from None to BREW') 50 # do it the long, but sure, way: 1st try to switch to modem 51 if not self._setmodemodem(): 52 # can't switch to modem, give up 53 return False 54 # then switch from modem to BREW 55 return self._setmodemodemtobrew()5658 self.log('Switching from BREW to modem') 59 try: 60 self.comm.write(self._switch_mode_cmd, False) 61 self.comm.readsome(numchars=5, log=False) 62 return True 63 except: 64 pass 65 # give it a 2nd try 66 try: 67 self.comm.write(self._switch_mode_cmd, False) 68 self.comm.readsome(numchars=5, log=False) 69 return True 70 except: 71 return False7274 # ask parent to do it 75 if super(Phone,self)._setmodemodem(): 76 return True 77 # could be in BREW mode, try switch over 78 self.log('trying to switch from BREW mode') 79 if not self._setmodebrewtomodem(): 80 return False 81 try: 82 self.comm.sendatcommand('E0V1') 83 self.set_mode(self.protocolclass.MODE_MODEM) 84 return True 85 except: 86 return False87 88 # Ringtones & wallpaper sutff------------------------------------------------------------90 """Read the contents of media files and return""" 91 _media={} 92 for _key,_entry in fundamentals.get(index_key, {}).items(): 93 if _entry.get('filename', None): 94 # this one associates with a file, try to read it 95 try: 96 _media[_entry['name']]=self.getfilecontents(_entry['filename'], 97 True) 98 except (com_brew.BrewNoSuchFileException, 99 com_brew.BrewBadPathnameException, 100 com_brew.BrewNameTooLongException, 101 com_brew.BrewAccessDeniedException): 102 self.log("Failed to read media file: %s"%_entry['name']) 103 except: 104 self.log('Failed to read media file.') 105 if __debug__: 106 raise 107 return _media108110 """Retrieve ringtones data""" 111 self.log('Reading ringtones') 112 self.setmode(self.MODEPHONEBOOK) 113 self.setmode(self.MODEBREW) 114 try: 115 fundamentals['ringtone']=self._read_media('ringtone-index', 116 fundamentals) 117 except: 118 if __debug__: 119 raise 120 self.setmode(self.MODEMODEM) 121 return fundamentals122124 """Retrieve wallpaper data""" 125 self.log('Reading wallpapers') 126 self.setmode(self.MODEPHONEBOOK) 127 self.setmode(self.MODEBREW) 128 try: 129 fundamentals['wallpapers']=self._read_media('wallpaper-index', 130 fundamentals) 131 except: 132 if __debug__: 133 raise 134 self.setmode(self.MODEMODEM) 135 return fundamentals
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Jan 24 16:22:25 2010 | http://epydoc.sourceforge.net |