Discussion:
[BitPim-devel] pm-8200 devel
j***@cinci.rr.com
2005-12-11 05:44:23 UTC
Permalink
I do not know how the code is setup in bitpim but i am working on
learning the in and outs of it. So I was hoping someone could help me
with implementing the sms code for this phone. If anyone can help me
with implenting this, memos, or todo in bitpim I would appreciate it.

So far I have only studied the files on the phone.

nvm_0021 SMS inbox
nvm_0026 SMS outbox
nvm_0027 SMS deleted
nvm_0028 SMS prewritten responses
nvm_0032 SMS drafts

I then studied nvm_0026 in a hexeditor
01
00 00 repeated
01 01 01(increases by 1 in hex for each msg) 00 00 00 00 00 00 00 02 01 00
6A(leads all msgs) followed by plaintext msg
00 00 repeat
05 08 1C 00 27 38 0A then the phone # of the sender
00 00 repeat
phone # of reciever
00 repeat
01 04 00 00 00 0C(increases by 1 for each msg in hex)

Thank you
Simon C
2005-12-11 15:32:57 UTC
Permalink
You have to create a PACKET definition for the files you are decoding.
This goes in the p_phone.p file.
The PACKET gets compiled by the protogen.py utility and it generates code
that makes breaking up the files into their individual fields much easier,
assuming that the data types in the file are supported (you can create your
own data types if they are not).

The next step is to add code to your phone class to allow bitpim to access
the SMS (or memo etc) message on your phone.
For each type of data bitpim retrieves there is a get and a save function
defined, so there is a getsms() and savesms(). You need to implement these
functions to read the SMS on your phone.
Your phone also has a Profile class (in the same file typically), in this
you define the features supported by the phone, look for _supportedsyncs,
you need to add SMS to this, note that SMS write only allows the user to
change the prewritten presponses at the moment. This is the _supportedsync ,
from the lgvx4400, it supports everything except todo. This list determines
what options are greyed out in the get/send data dialog boxes.
_supportedsyncs=(
('phonebook', 'read', None), # all phonebook reading
('calendar', 'read', None), # all calendar reading
('wallpaper', 'read', None), # all wallpaper reading
('ringtone', 'read', None), # all ringtone reading
('call_history', 'read', None),# all call history list reading
('sms', 'read', None), # all SMS list reading
('phonebook', 'write', 'OVERWRITE'), # only overwriting phonebook
('calendar', 'write', 'OVERWRITE'), # only overwriting calendar
('wallpaper', 'write', 'MERGE'), # merge and overwrite
wallpaper
('wallpaper', 'write', 'OVERWRITE'),
('ringtone', 'write', 'MERGE'), # merge and overwrite ringtone
('ringtone', 'write', 'OVERWRITE'),
('sms', 'write', 'OVERWRITE'), # all SMS list writing
)

The contents of the getsms() function in your phone will decode the
proprietary contents of files on your phone and convert them into a standard
format understood by bitpim. The data is stored in records in a python
dictionary data type. I don't know how familiar you are with python, but the
easiest way to do this is to copy code from another phone. I would recommend
the 4400 as it is file based like your phone and I wrote a lot of it so it
obviously rocks :), just ignore the stuff that unpacks the 7-bit ascii as it
sounds like your phone stores in plain text. Many other phones also
implement this, most of the LG family uses the code in the 4400, but the
other models contain other implmentations you can copy. Just search for
getsms to find them.

The same procedure applies to the memo and todo data. I would recommend
starting with the memo or the todo, it is probably simpler to implement than
SMS. The lg phones are a poor example for these two features as they barely
support memos and do not support todo, I think the Samsung phones are good
examples for these. Again the steps are
1) override the getmemo and savememo(if you want to support writing) in the
Phone class,
2) add the feature to the _supportedsyncs in the Profile class,
3) define the file format in the protocol file (p_phone.p).
4) write code to convert the phones file format into the bitpim record for
memos and add it to the getmemo function, do the reverse for savememo.

Simon
-----Original Message-----
Sent: Saturday, December 10, 2005 9:44 PM
Subject: [BitPim-devel] pm-8200 devel
I do not know how the code is setup in bitpim but i am working on
learning the in and outs of it. So I was hoping someone could help me
with implementing the sms code for this phone. If anyone can help me
with implenting this, memos, or todo in bitpim I would appreciate it.
So far I have only studied the files on the phone.
nvm_0021 SMS inbox
nvm_0026 SMS outbox
nvm_0027 SMS deleted
nvm_0028 SMS prewritten responses
nvm_0032 SMS drafts
I then studied nvm_0026 in a hexeditor
01
00 00 repeated
01 01 01(increases by 1 in hex for each msg) 00 00 00 00 00 00 00 02 01 00
6A(leads all msgs) followed by plaintext msg
00 00 repeat
05 08 1C 00 27 38 0A then the phone # of the sender
00 00 repeat
phone # of reciever
00 repeat
01 04 00 00 00 0C(increases by 1 for each msg in hex)
Thank you
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
BitPim-devel mailing list
https://lists.sourceforge.net/lists/listinfo/bitpim-devel
Stephen Wood
2005-12-11 17:09:20 UTC
Permalink
It is a good idea to use sync protocols for reading the sms, memo and todos,
like is done for the phonebook and calendar. These protocols don't change
much between each Sanyo phone, while the nvm files with the SMS, etc
information likely will vary more between models. We should only resort to
reading the NVM files if they contain information that can not be read using
the sync protocol.

I partially worked out the protocol for reading message a long time ago,
using the SCP-4900. The packet definitions (with a lot of fields I didn't
decode), are in p_sanyo.p. Look for PACKET definition names that start with
folder or message.

The SMS packet definitions for the 8200 won't be exactly the same as what is
in p_sanyo.p as the overall format for packets changed for models newer than
the 4900. So at a minimum, the packet definitions for messages will need to
be copied into p_sanyonewer.p.

If you change packet definitions, make sure you "compile" the packet
defintions. This is done by doing

python protogen.py

A good way to start understanding the format of the phones sms packets is to
add sms to the supportsyncs like Simon described and write a dummy getsms
routine and put in in the Phone class for the 8200.

def getsms(self, result):
req=self.protocolclass.messagerequest()
for slot in range(200):
req.slot=slot
res=self.sendpbcommand(req, self.protocolclass.messageresponse)

return result
Assuming you have the messagerequest packet defined correctly, this should
read the messages from the phone (I am just guessing that there are up to
200.) but not do anything with the results. However, if you turn on
protocol logging, you highlight a response and hit ctrl-alt-p to bring up
the protocol analyzer. Then you can see how good the messageresponse packet
definition picks apart the response.

Before I heard about BitPim, I wrote a perl script to explore the SCP-4900.
That script in experiments/sanyo.pl might have some marginal value in
understanding the protocol for Sanyo phones.

I am sure that this is a lot to digest, and not explained too well, so keep
asking questions.

Stephen
Roger Binns
2005-12-12 04:10:37 UTC
Permalink
[A whole bunch of useful stuff]
Please update dev-doc/phonespec.html with the additional information.

Roger
Simon C
2005-12-12 07:53:34 UTC
Permalink
Post by Roger Binns
Please update dev-doc/phonespec.html with the additional information.
Is there a preferred html editor, or is it done by hand?

Simon
Roger Binns
2005-12-12 16:31:19 UTC
Permalink
Post by Simon C
Is there a preferred html editor, or is it done by hand?
I always edit html by hand. That way you don't get lots of
junk put in the file.

Roger
Jordan Foley
2005-12-12 15:49:20 UTC
Permalink
Thank you Simon and Stephen for the info. I have the definitions created
for the different routines I wish to implement. With a little bit of
tweaking I was able to make your code work and dump the sms's from my
phone and it works like a charm. This is the edited messageentry that I
created. I am pretty sure all of the variables are correct (all of them
but slot,messagetype, and folder are verified but they look correct).

PACKET messageentry:
1 UINT slot
1 UINT messagetype
1 UINT dunno1
1 UINT dunno2
1 UINT dunno3
1 UINT dunno4
1 UINT dunno5
1 UINT dunno6
1 UINT dunno7
1 UINT dunno8
1 UINT dunno9
1 UINT dunno10
1 UINT dunno11
1 UINT message_len
255 STRING message "Text of the notification"
1 UINT dunno12
1 UINT year
1 UINT month
1 UINT day
1 UINT hour
1 UINT minute
1 UINT second
35 UNKNOWN pad1
1 UINT phonenum_len
33 STRING phonenum
5 UNKNOWN pad2
1 UINT folder

I have been looking at example code for implementing this into the sms
tab and it looks like the sanyo deals with this in a different way then
the other phones. Do I just write code to convert these variables to the
Bitpim variables and send them to ['sms']? Also are there any good
examples for this process?
The next problem is the todo list. I have created a test todo in my
phone and have found the nvm file for it but I do not know how to start
loading it in the debugger. I figure you load it the same way as an sms
but with a different header. Thank you for all of the help and so far
this is easier then it looks even with my limited python knowledge.
Stephen Wood
2005-12-12 17:20:42 UTC
Permalink
Post by Jordan Foley
...
This is the edited messageentry that I
Post by Jordan Foley
created. I am pretty sure all of the variables are correct (all of them
but slot,messagetype, and folder are verified but they look correct).
If you can figure out any of the dunno fields that would be great.

...
Post by Jordan Foley
1 UINT folder
The folder is a index to the list of folder names that you should be able to
read with the folderrequest packet. When I looked at this for the 4900, I
think I found that there were up to 100 folders.
Post by Jordan Foley
I have been looking at example code for implementing this into the sms
tab and it looks like the sanyo deals with this in a different way then
the other phones.
The coding style of different developers may differ, but we all have to end
up with the result dictionary populated with the same information.

Feel free to change field names in messageentry etc if it makes sense to do
so. The SMS related packet definitions in p_sanyo.p were done before BitPim
had SMS capability and were just put there to sort of document the little
bit that I had learned.

Stephen
Simon C
2005-12-12 16:31:12 UTC
Permalink
Post by Jordan Foley
I have been looking at example code for implementing this into the sms
tab and it looks like the sanyo deals with this in a different way then
the other phones. Do I just write code to convert these variables to the
Bitpim variables and send them to ['sms']?
In short yes.

Also are there any good
Post by Jordan Foley
examples for this process?
Look at the getsms() code in com_lgvx4400.py. Cut and paste is your friend.
You basically need to replace the vx4400 PACKET definitions with the ones
for the 8200. If there are fields that are not supported by the phone either
ignore them or hard code them to sensible values, the defaults are usually
OK.

Simon
Jordan Foley
2005-12-12 19:00:27 UTC
Permalink
I have updated my packet for the messageentry, i forgot to add the callback # to it.

PACKET messageentry:
1 UINT slot
1 UINT read
1 UINT counter
1 UINT dunno1
1 UINT dunno2
1 UINT dunno3
1 UINT cons1
1 UINT cons2
1 UINT cons3
1 UINT dunno4
1 UINT cons4
1 UINT cons5
1 UINT dunno5
1 UINT message_len
255 STRING message "Text of the notification"
1 UINT dunno11
1 UINT year
1 UINT month
1 UINT day
1 UINT hour
1 UINT minute
1 UINT second
1 UINT callback_len
33 STRING callback
1 UINT dunno12
1 UINT phonenum_len
33 STRING phonenum
5 UNKNOWN pad2
1 UINT folder
1 UINT dunno13
1 UINT dunno14
1 UINT dunno15
1 UINT dunno16
1 UINT dunno17

I have been trying to implement passing these variables to the sms tab but this is not working, it keeps throwing errors, complaing about how sf.callback is not defined. Does anyone have any example code that passes a variable straight through to the sms tab so that i can see something simple in action?

def getsms(self, result):
result['sms']=self._readsms()
return result

def _readsms(self):
self.log("Getting sms entries")
req=self.protocolclass.messagerequest()
for slot in range(200):
req.slot=slot
res=self.sendpbcommand(req, self.protocolclass.messageresponse)
entry.callback=sf.callback
return res
Stephen Wood
2005-12-12 19:49:13 UTC
Permalink
Look at getmemo in com_samsung_packet.py for a simple example of how memo
information gets passed back. For SMS you'll create a sms entry object
instead of a memo object with entry=sms.SMSEntry(). You then set the fields
of entry with the information you get from the packet decoding. Then each
entry is added to the result dictionary.

Don't be confused by the different usages of the local variable "res" in
different developers code. I tend tend to use "res" for the result of a
sendpbcommand, others use it to hold a dictionary that will be result of a
getsomething call.

Stephen
Post by Jordan Foley
...
result['sms']=self._readsms()
return result
self.log("Getting sms entries")
req=self.protocolclass.messagerequest()
req.slot=slot
res=self.sendpbcommand(req, self.protocolclass.messageresponse
)
entry.callback=sf.callback
return res
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
BitPim-devel mailing list
https://lists.sourceforge.net/lists/listinfo/bitpim-devel
Loading...