PyXR

c:\projects\bitpim\src \ phones \ com_sanyo8300.py



0001 ### BITPIM
0002 ###
0003 ### Copyright (C) 2005 Stephen Wood <sawecw@users.sf.net>
0004 ###
0005 ### This program is free software; you can redistribute it and/or modify
0006 ### it under the terms of the BitPim license as detailed in the LICENSE file.
0007 ###
0008 ### $Id: com_sanyo8300.py 3580 2006-09-23 01:22:17Z sawecw $
0009 
0010 """Talk to the Sanyo SCP-8300 cell phone"""
0011 # standard modules
0012 import re
0013 import time
0014 import sha
0015 
0016 # my modules
0017 import common
0018 import p_brew
0019 import p_sanyo8300
0020 import com_brew
0021 import com_phone
0022 import com_sanyo
0023 import com_sanyomedia
0024 import com_sanyonewer
0025 import prototypes
0026 import bpcalendar
0027 
0028 numbertypetab=( 'cell', 'home', 'office', 'pager',
0029                     'fax', 'data', 'none' )
0030 
0031 class Phone(com_sanyonewer.Phone):
0032     "Talk to the Sanyo PM8300 cell phone"
0033 
0034     desc="PM8300"
0035 
0036     FIRST_MEDIA_DIRECTORY=1
0037     LAST_MEDIA_DIRECTORY=3
0038 
0039     imagelocations=(
0040         # offset, directory #, indexflag, type, maximumentries
0041         )    
0042 
0043     protocolclass=p_sanyo8300
0044     serialsname='mm8300'
0045 
0046     builtinringtones=( 'None', 'Vibrate', '', '', '', '', '', '', '', 
0047                        'Tone 1', 'Tone 2', 'Tone 3', 'Tone 4', 'Tone 5',
0048                        'Tone 6', 'Tone 7', 'Tone 8', '', '', '', '', '',
0049                        '', '', '', '', 
0050                        'Requiem:Dies Irae', 'Minute Waltz',
0051                        'Hungarian Dance', 'Miltary March', 'Ten Little Indians',
0052                        'Head,Shoulders,Knees&Toes', 'The Moment', 'Asian Jingle',
0053                        'Kung-fu','','','','','','','','','','','','','','','','','',
0054                        '','','','','','',
0055                        'Voice Alarm')
0056 
0057     # Calendar ringer info
0058     # e8 02 Tone 1  744
0059     # f9 02 Melody 1  761
0060     # fe 02 Melody 6  766
0061     # ff 02 Melody 7  767
0062     # 00 03 Melody 8  768
0063     # 01 03 Melody 9  769
0064     # 00 00 Normal      0
0065     # f1 ff None    65521
0066     # f2 ff Vibrate 65522
0067     # 19 03 Voice     793
0068     calendar_defaultringtone=0
0069     calendar_defaultcaringtone=0
0070     calendar_toneoffset=734
0071     calendar_tonerange=xrange(744,794)
0072 
0073     def __init__(self, logtarget, commport):
0074         com_sanyonewer.Phone.__init__(self, logtarget, commport)
0075         self.mode=self.MODENONE
0076         self.numbertypetab=numbertypetab
0077 
0078     def _setmodebrew(self):
0079         req=p_brew.firmwarerequest()
0080         respc=p_brew.testing0cresponse
0081         
0082         for baud in 0, 38400,115200:
0083             if baud:
0084                 if not self.comm.setbaudrate(baud):
0085                     continue
0086             try:
0087                 self.sendbrewcommand(req, respc, callsetmode=False)
0088                 return True
0089             except com_phone.modeignoreerrortypes:
0090                 pass
0091 
0092         # send AT$QCDMG at various speeds
0093         for baud in (0, 115200, 19200, 230400):
0094             if baud:
0095                 if not self.comm.setbaudrate(baud):
0096                     continue
0097             print "Baud="+`baud`
0098 
0099             try:
0100                 self.comm.write("AT$QCDMG\r\n")
0101             except:
0102                 # some issue during writing such as user pulling cable out
0103                 self.mode=self.MODENONE
0104                 self.comm.shouldloop=True
0105                 raise
0106             try:
0107                 # if we got OK back then it was success
0108                 if self.comm.readsome().find("OK")>=0:
0109                     break
0110             except com_phone.modeignoreerrortypes:
0111                 self.log("No response to setting QCDMG mode")
0112 
0113         # verify if we are in DM mode
0114         for baud in 0,38400,115200:
0115             if baud:
0116                 if not self.comm.setbaudrate(baud):
0117                     continue
0118             try:
0119                 self.sendbrewcommand(req, respc, callsetmode=False)
0120                 return True
0121             except com_phone.modeignoreerrortypes:
0122                 pass
0123         return False
0124 
0125     def getfundamentals(self, results):
0126         """Gets information fundamental to interopating with the phone and UI."""
0127         req=self.protocolclass.esnrequest()
0128         res=self.sendpbcommand(req, self.protocolclass.esnresponse)
0129         results['uniqueserial']=sha.new('%8.8X' % res.esn).hexdigest()
0130         self.getmediaindices(results)
0131 
0132         self.log("Fundamentals retrieved")
0133 
0134         return results
0135 
0136 class Profile(com_sanyonewer.Profile):
0137 
0138     protocolclass=Phone.protocolclass
0139     serialsname=Phone.serialsname
0140     phone_manufacturer='SANYO'
0141     phone_model='SCP-8300/US'
0142     # GMR: 1.115SP   ,10019
0143 
0144     WALLPAPER_WIDTH=176
0145     WALLPAPER_HEIGHT=220
0146 
0147     def __init__(self):
0148         com_sanyonewer.Profile.__init__(self)
0149         self.numbertypetab=numbertypetab
0150 
0151 

Generated by PyXR 0.9.4