Package phones :: Module com_sanyo8300
[hide private]
[frames] | no frames]

Source Code for Module phones.com_sanyo8300

  1  ### BITPIM 
  2  ### 
  3  ### Copyright (C) 2005 Stephen Wood <sawecw@users.sf.net> 
  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_sanyo8300.py 3580 2006-09-23 01:22:17Z sawecw $ 
  9   
 10  """Talk to the Sanyo SCP-8300 cell phone""" 
 11  # standard modules 
 12  import re 
 13  import time 
 14  import sha 
 15   
 16  # my modules 
 17  import common 
 18  import p_brew 
 19  import p_sanyo8300 
 20  import com_brew 
 21  import com_phone 
 22  import com_sanyo 
 23  import com_sanyomedia 
 24  import com_sanyonewer 
 25  import prototypes 
 26  import bpcalendar 
 27   
 28  numbertypetab=( 'cell', 'home', 'office', 'pager', 
 29                      'fax', 'data', 'none' ) 
 30   
31 -class Phone(com_sanyonewer.Phone):
32 "Talk to the Sanyo PM8300 cell phone" 33 34 desc="PM8300" 35 36 FIRST_MEDIA_DIRECTORY=1 37 LAST_MEDIA_DIRECTORY=3 38 39 imagelocations=( 40 # offset, directory #, indexflag, type, maximumentries 41 ) 42 43 protocolclass=p_sanyo8300 44 serialsname='mm8300' 45 46 builtinringtones=( 'None', 'Vibrate', '', '', '', '', '', '', '', 47 'Tone 1', 'Tone 2', 'Tone 3', 'Tone 4', 'Tone 5', 48 'Tone 6', 'Tone 7', 'Tone 8', '', '', '', '', '', 49 '', '', '', '', 50 'Requiem:Dies Irae', 'Minute Waltz', 51 'Hungarian Dance', 'Miltary March', 'Ten Little Indians', 52 'Head,Shoulders,Knees&Toes', 'The Moment', 'Asian Jingle', 53 'Kung-fu','','','','','','','','','','','','','','','','','', 54 '','','','','','', 55 'Voice Alarm') 56 57 # Calendar ringer info 58 # e8 02 Tone 1 744 59 # f9 02 Melody 1 761 60 # fe 02 Melody 6 766 61 # ff 02 Melody 7 767 62 # 00 03 Melody 8 768 63 # 01 03 Melody 9 769 64 # 00 00 Normal 0 65 # f1 ff None 65521 66 # f2 ff Vibrate 65522 67 # 19 03 Voice 793 68 calendar_defaultringtone=0 69 calendar_defaultcaringtone=0 70 calendar_toneoffset=734 71 calendar_tonerange=xrange(744,794) 72
73 - def __init__(self, logtarget, commport):
74 com_sanyonewer.Phone.__init__(self, logtarget, commport) 75 self.mode=self.MODENONE 76 self.numbertypetab=numbertypetab
77
78 - def _setmodebrew(self):
79 req=p_brew.firmwarerequest() 80 respc=p_brew.testing0cresponse 81 82 for baud in 0, 38400,115200: 83 if baud: 84 if not self.comm.setbaudrate(baud): 85 continue 86 try: 87 self.sendbrewcommand(req, respc, callsetmode=False) 88 return True 89 except com_phone.modeignoreerrortypes: 90 pass 91 92 # send AT$QCDMG at various speeds 93 for baud in (0, 115200, 19200, 230400): 94 if baud: 95 if not self.comm.setbaudrate(baud): 96 continue 97 print "Baud="+`baud` 98 99 try: 100 self.comm.write("AT$QCDMG\r\n") 101 except: 102 # some issue during writing such as user pulling cable out 103 self.mode=self.MODENONE 104 self.comm.shouldloop=True 105 raise 106 try: 107 # if we got OK back then it was success 108 if self.comm.readsome().find("OK")>=0: 109 break 110 except com_phone.modeignoreerrortypes: 111 self.log("No response to setting QCDMG mode") 112 113 # verify if we are in DM mode 114 for baud in 0,38400,115200: 115 if baud: 116 if not self.comm.setbaudrate(baud): 117 continue 118 try: 119 self.sendbrewcommand(req, respc, callsetmode=False) 120 return True 121 except com_phone.modeignoreerrortypes: 122 pass 123 return False
124
125 - def getfundamentals(self, results):
126 """Gets information fundamental to interopating with the phone and UI.""" 127 req=self.protocolclass.esnrequest() 128 res=self.sendpbcommand(req, self.protocolclass.esnresponse) 129 results['uniqueserial']=sha.new('%8.8X' % res.esn).hexdigest() 130 self.getmediaindices(results) 131 132 self.log("Fundamentals retrieved") 133 134 return results
135
136 -class Profile(com_sanyonewer.Profile):
137 138 protocolclass=Phone.protocolclass 139 serialsname=Phone.serialsname 140 phone_manufacturer='SANYO' 141 phone_model='SCP-8300/US' 142 # GMR: 1.115SP ,10019 143 144 WALLPAPER_WIDTH=176 145 WALLPAPER_HEIGHT=220 146
147 - def __init__(self):
150