Discussion:
[BitPim-devel] SMS pm-8200
Jordan Foley
2005-12-13 20:16:15 UTC
Permalink
I modified the code from samsung_prototype to what should be very simple
sms code where it just grabs the first message and puts their callback #
in the database but it will not work for some reason. I just wish I
could at least get something in the database then it would be a lot
easier from there.

def getsms(self, result):
sms = {}
self.log("Getting sms entries")
slot=1
req=self.protocolclass.messagerequest()
req.slot=slot
res=self.sendpbcommand(req, self.protocolclass.messageresponse)
entry=sms.SMSEntry()
entry.callback=callback
result['sms']=sms
return result

entry=sms.SMSEntry()
AttributeError: 'dict' object has no attribute 'SMSEntry, is the error
it throws.
Stephen Wood
2005-12-13 20:46:12 UTC
Permalink
Post by Jordan Foley
I modified the code from samsung_prototype to what should be very simple
sms code where it just grabs the first message and puts their callback #
in the database but it will not work for some reason. I just wish I
could at least get something in the database then it would be a lot
easier from there.
You have to put "import sms" some where at the top fo the file (like
com_samsung_packet has "import memo".)
Post by Jordan Foley
sms = {}
This is the array that the sms entries will go in. It can't be called sms
because that is the module you imported. For purposes of discussion, I
assum that you call this variable mysms.


self.log("Getting sms entries")
Post by Jordan Foley
slot=1
req=self.protocolclass.messagerequest()
req.slot=slot
res=self.sendpbcommand(req, self.protocolclass.messageresponse)
entry=sms.SMSEntry()
This will work if you do the "import sms" at the top.


entry.callback=callback


There is no variable callback. You probably mean something like "
res.entry.callback" which gets the callback field from the packet you read
in sendpbcommand. Actually, if you are using the packet definition you last
posted, you probably really want res.entry.phonenum, since you don't have a
callback field in your packet definition.

You need to put your entry into the mysms array. Add the following

mysms[entry.id]=entry

result['sms']=sms

Insted say result['sms']=mysms


Before trying to get the data pushed into BitPim, it might be good to put
some print statements after the sendpbcommand. Examples are
print res.entry.message
print res.entry.year, res.entry.month, res.entry.day

This will check that your packet definition really works and that you know
how to extract the fields of your result.


Stephen

Loading...