Discussion:
[BitPim-devel] Telus SPH-A840 phone module help
Denis Tonn
2006-09-23 04:59:12 UTC
Permalink
Stephen suggested I post what I have done for the Telus SPH-A840 to this list and perhaps
I can get some assist (and cleanup) for building a proper module for this phone.

I have a file system dump with a variety of data and a semi-working module for phonebook
mode. There are a lot of limitations and quirks of phonebook mode that I discovered when
working with this phone, so I suspect that eventually the best way to handle it will be
100% through BREW mode if possible.

If anyone wants to take a look at the file dump, or the code I have already built then
just let me know and I'll drop you a copy.. I'd appreciate any help or comments you can
supply. Be gentle, Python and BitPim are brand new to me <grin>, although I do have a fair
bit of background in programming.. The results so far are very much a hack to get the
numbers back into the phone, although I would like to eventually get access to everything
this phone has.


Some background:
I recently had an urgent need to transfer a bunch of phone numbers into a new phone. Telus
Canada had discontinued my previous phone, which had bit the dust - it wouldn't even power
up anymore.

I had the phone numbers from the old phone backed up on my computer in CVS format (another
program) but no way of writing these numbers to the new phone. I did a bit of digging and
could not find support for this phone anywhere. Then I discovered BitPim and brought the
source in. I could have developed it under Linux or Windows, but ended up doing the dev
under Windows (my laptop - I was in and out)..

I have never worked in Python before, but have had a fair bit of experience in a variety
of languages. A long weekend of phone hacking and python learning and blatent borrowing of
code from existing modules and I had the phone data transfered back into the new phone.
Getting the phone number data working was the biggest hurdle, and as an afterthought I
dropped in the Calendar stuff - which was relatively easy. It does not handle uploading
and downloading ringtones or images, but it does work.

The phone has problems coming out of BREW mode, so I had to do everything through ATxxxxx
type commands. When coming out of BREW mode, the phone shuts itself off and you have to
manually restart it. Eventually I discovered that a phone reset will bring it out of BREW
mode without manual intervention. But by then I was well on down the road of getting my
phone numbers restored to the phone through phonebook mode.


There were a few hurdles I encountered while building a module for this phone. Here are
some of the things I found.

---------
Samsung SPH-A840 from Telus Canada

Not really a SPH-A840, but a hybrid of the SCH-A850 with SPH-A840 code and further adapted
for Telus.

---------

specs (per Telus and Samsung)
500 phone book entries .
640x480 camera
email and web browsing
web downloadable ring tones and images.

---------
sample command responses:

at+GMI
+GMI: SAMSUNG ELECTRONICS CO.,LTD.

at+GMM
+GMM: SCH-A850 /180

at+GMR
+GMR: S/W VER: ES.A840YL01 SPH-A840 

at+GSN
+GSN: XXXXXXXX

at+GCAP
+GCAP: +CIS707-A, +MS, +ES, +DS, +FCLASS

at+IPR=?
+IPR: (0, 19200, 38400, 57600, 115200, 230400)

at#pmode=1
OK

at#pbgrr=?
#PBGRR: (0-4),31

at#pbgrr=0
#PBGRR: 0,"Friends",0,S,19800106T000000

at#pbgrr=1
#PBGRR: 1,"ral",0,S,19800106T000000

at#pbgrr=2
#PBGRR: 2,"",0,S,19800106T000000

at#pbsel?
#PBSEL: 0,0,""

at#pidyr=?
#PIDYR: (0-19),16

at#pishr=?
#PISHR: (0-19),(0-4),32
100
0
10
30
60

at#pishr=0
#PISHR: 0,20060920T160000,20060920T160000,20060919T232701,3,S,"t.no alarm"

NUMCALENDAREVENTS=20

PACKET eventresponse:
* CSVSTRING {'quotechar': None, 'terminator': ord(' '), 'constant': '#PISHR:'} command
* CSVINT slot
* CSVTIME start
* CSVTIME end
* CSVTIME timestamp
* CSVINT alarm "0: No Alarm, 1: On Time, 2: 10 minutes, 3: 30 minutes, 4: 60 minutes"
* CSVSTRING {'quotechar': None} status
* CSVSTRING {'terminator': None} eventname

at#pssel?
#PSSEL: 10,0,0

at#pitdr=?
#PITDR: (0-19),32

at#pbokr=?
#PBOKR: (1-525),(0-4),32,48,48,0

at#pbokr=500
OK
at#pbokr=501
ERROR

at#pugsn? - hangs

at#pbokr=65
#PBOKR: 65,66,0,8,"g general",0,0,,,,,5553333,0,,,,,"","","",8,0,"",20060921T021756

Breakdown of the fields:

NUMPHONEBOOKENTRIES=500
NUMEMAILS=1
NUMPHONENUMBERS=5
MAXNUMBERLEN=32


PACKET pbentry:
* CSVINT slot "Internal Slot"
* CSVINT uslot "User Slot, Speed dial"
# Phone does not support groups properly - default 0
* CSVINT {'default': 0} +group
# 0=default 1-5=Ring 1-5 6-10=Melody 1-5
* CSVINT {'default': 0} +ringtone "0: Default, 1: Ring 1, 2: Ring 2, 3: Ring 3, 4:
Ring 4, 5: Ring 5, 6: Melody 1, 7: Melody 2, 8: Melody 3, 9: Melody 4, 10: Melody 5"
* CSVSTRING name
* CSVINT speeddial "Which phone number assigned to speed dial uslot"
* CSVINT {'default': 0} +dunno1
* LIST {'length': NUMPHONENUMBERS, 'createdefault': True, 'elementclass':
phonenumber} +numbers
# email and url must have a space in the value when writing
* CSVSTRING {'default': ""} +email
* CSVSTRING {'default': ""} +email2(url)
* CSVSTRING {'default': ""} +OtherStringField(birthday)
# wallpaper values
# 8 = no image
# 3 = human
# 4 = animal
# 5 = others
# 2 = gallery - and wallpaper_file points to the file name
# 6 or 7 = image clips
# 1 = web downloads (maybe??) but have not downloaded an image to find out.
* CSVINT {'default': 8} +wallpaper "8: No Image, 3: Human, 4: Animal, 5: Other, 2:
Gallery, 6: Image, 7: Image"
# wallpaper_modifier
# selects specific image in human, animal, others
# selects an offset for image clips
# must be 0 if no image
# value ignored if gallery image
* CSVINT {'default': 0} +wallpaper_modifier
# full filespec to picture file for Gallery - otherwise empty quoted string
* CSVSTRING {'default': ""} wallpaper_file
* CSVTIME {'terminator': None, 'default': (1980,1,1,12,0,0)} +timestamp "Use
terminator None for last item"

Gotcha's... Keep in mind that all this is related to accessing the phone in phonebook
mode. I haven't yet tried to access the individual data on this phone through BREW mode. I
have taken a filesystem dump but not analyzed it yet.

- Phone does not return proper groups thru at#pbgrr. The first group is correct but the
remaining groups lose portions or all of the names assigned. This eventually leads to
assertion errors in the sqlite database unless you ignore what the phone returns for groups.

- at#pbgrw does not modify group names - seems to be ignored in phone even though it
returns OK.

- The above is no big deal, since setting a group for a pbentry doesn't change anything in
the returned values for a pbentry anyway.

- This phone doesn't use "groups" the same way previous phones I have used. You don't
place a "user name" (pbentry) into a group, you place a phone number into a group. Only
the mobile number and email addresses are allowed to be placed in a group, although you
can have the email addresses and the cell number for a specific location in different
groups. Groups seems to be oriented towards email and text messaging.. Apparently you can
send a single text message or email to a complete "group". You can also define additional
groups although you cannot access these group names through the at#pbgrr command.
- In fact, if you do try and save the phonebook where you have different "groups" assigned
to different locations (pbentry field 3), you can sometimes get the phone into a state
where the phonebook is screwed up and the only way to recover is to use the security
function on the phone to erase the whole phone book. In my code it always forces group 0
when writing.

- The phone will accept AT$QCDMG and enter brew mode, but if you try to return it to modem
mode it simply shuts off and you have to manually turn it on. Interestingly, a phone
reboot will bring it back without manual intervertion. You can use bitpim to browse the
file system (I have not tried to write yet).

- If either of the pbentry email fields are empty, they MUST be written back with a single
space in quotes or you will corrupt the entry on the phone. If they are not empty you must
not supply an extra space or corruption will occur. My code forces a single space to be
written if the email fields are empty.

- The above isn't really an issue, since email entries written back through phonebookmode
aren't saved on the phone anyway. It seems to accept them, but a subsequent read shows the
field blank and the field is blank on the phone. This probably relates to the code changes
they did for the new style groups (see above). Reading email addresses is fine, just
saving them doesn't work.

- The phone will not let you save the same phone number in multiple locations. Actually,
you can do this through the ATPBOKW command, and get away with it, but if you try to edit
an entry on the phone where one of it's phone numbers is "duplicated" in another entry it
won't let you save the entry on the phone - complains about "duplicate number in entry".

- uslot 1 should not be used. You can set it through bitpim (or terminal) but the phone
will not let you edit it unless you change and save it's "location" first. I don't do
anything in my code to protect this. It's livable just by changing the uslot (location) on
the phone while editing.

- there is no way to set (or unset) an entry as "secret" in the phone interface.

- The only way I could get a Calendar entry to write was to set start and end time to be
the same. Entries created on the phone have an invalid end time (always the same date in
the past).

- Occasionally reading the phone will have position 0 as the speeddial number, even when
there is no number in position 0. The phone display is correct but the pbentry data read
back is incorrect. This causes BitPim to "lose" the uslot data when reading and then
writing. Fix was to force the uslot to the first valid number entry and let the code "fix
it up later" if the phonebook had a valid speedial entry.


Resulting code so far:

- Get and Save of phone numbers works. Groups are not maintained. Email and "Other" field
are ignored by the phone.
- Builtin Ring tones are handled and can be managed through BitPim.
- Builtin Wallpaper (callerid pictures) are handled and can be managed by BitPim.
Non-builtin wallpaper (Images and Gallery) are maintained through a save if they exist on
the phone.
- The phone has 2 email addresses, but for expediency I treated one of them as a URL
(swiped code!). Since the phone ignores writes to these fields it doesn't matter..
- The "birthday" field in my code is actually a text string area ("OtherStringField"
above) that can even be used as an extra phone number position. I suspect this should be a
memo field in bitpim. But since the phone ignores anything written into this field it
doesn't matter..

Loading...