You Are Here:

Community: Developer Discussion Boards

#1 Old Sending multiple SMS messages - 2005-09-27, 18:59

Join Date: Nov 2003
Posts: 4
hugovk
Offline
Registered User
I've modified the SMS_example.py to try and send more than one SMS at a time.

I added a real phone number to the self.dict list, and then added a new list of messages, and loop through it and try and send each one i.e.

messages = [u"Hello!",
u"Goodbye!"]
for message in messages:
# uncomment next line to add a dialogue
# if appuifw.query(u"Send message to " + nam + "?", 'query'):
t = u"Sent " + message + " to " + nbr + " (" + nam + ")\n"
self.log_contents += t
self.log_text.add(t)
messaging.sms_send(nbr, message)
e32.ao_sleep(30)

I commented out the query, and added a sleep of 30s to give it some time between messages. However, when I run it, the first SMS is usually sent, but then straight after I get a dialog:

"Python System Error (-50)"

then when I exit to the Python shell bit it says:

---
line 112, in activate messaging.sms_send(nbr, message)
SymbianError: KErrGeneral
---

I've also put the query back and commented out the sleep, so I can control the sending. But that gives the same results.

Any idea what's up?
Reply With Quote

#2 Old Re: Sending multiple SMS messages - 2005-09-28, 17:57

Join Date: Dec 2004
Posts: 646
jplauril's Avatar
jplauril
Offline
Forum Nokia Expert
What phone and PyS60 version are you using?
Reply With Quote

#3 Old Re: Sending multiple SMS messages - 2005-09-28, 23:46

Join Date: Nov 2003
Posts: 4
hugovk
Offline
Registered User
It's a Nokia 7610. From the App Manager, it's Python for Symbian OS v1.01.
Reply With Quote

#4 Old Re: Sending multiple SMS messages - 2005-09-29, 17:18

Join Date: Dec 2004
Posts: 646
jplauril's Avatar
jplauril
Offline
Forum Nokia Expert
Could you post the complete code? Please use the CODE tag so that it remains readable.
Reply With Quote

#5 Old Re: Sending multiple SMS messages - 2005-09-29, 17:54

Join Date: Nov 2003
Posts: 4
hugovk
Offline
Registered User
Here it is. I just noticed I call "logfile = f.write(t)" in the loop, when really it was "tempfile" I've opened.

I suppose that's not going to help, and I've not tested it with the bad line fixed yet, but it was complaining about "line 112, in activate messaging.sms_send(nbr, message)" which is before that line.

cheers,

Code:
# Copyright (c) 2004 Nokia
# Programming example -- see license agreement for additional rights
# SMS sending example application

import appuifw
import e32
import messaging

old_title = appuifw.app.title
appuifw.app.title = u"SMS sending"
tempfile = "c:\\log.txt"

class NumbersView:
    def __init__(self, SMS_multiviewApp):
        self.SMS_multiviewApp = SMS_multiviewApp
        self.dict = [(u"Jim", "55512345"), (u"Jane", "55567890")]
        self.names = [item[0] for item in self.dict]
        self.numbers = [item[1] for item in self.dict]

        self.numbers_list = appuifw.Listbox(self.names, self.handle_select)
        self.index = None
        appuifw.app.body = self.numbers_list

    def activate(self):
        appuifw.app.body = self.numbers_list
        appuifw.app.menu = [(u"Select", self.handle_select)]
        
    def handle_select(self):
        n = self.get_name()
        appuifw.note(u"Selected: "+ n, 'info')

    def get_current(self):
        return self.numbers_list.current()

    def get_name(self):
        i = self.get_current()
        return self.names[i]

    def get_number(self):
        i = self.get_current()
        return self.numbers[i]

class ChoiceView:
    def __init__(self, SMS_multiviewApp):
        self.SMS_multiviewApp = SMS_multiviewApp
        self.texts = [u"yo!",
                      u"wassup!"]
        self.listbox = appuifw.Listbox(self.texts, self.handle_select)

    def activate(self):
        appuifw.app.body = self.listbox
        appuifw.app.menu = [(u"Select", self.handle_select),
                            (u"Send", self.handle_send)]
        
    def handle_select(self):
        i = self.listbox.current()
        appuifw.note(u"Selected: " + self.get_text(),'info')

    def handle_send(self):
        appuifw.app.activate_tab(3)
        self.SMS_multiviewApp.handle_tab(3)

    def get_text(self):
        return self.texts[self.listbox.current()]


class TextView:
    def __init__(self, SMS_multiviewApp):
        self.SMS_multiviewApp = SMS_multiviewApp
        self.view_text = appuifw.Text()

    def activate(self):
        t = self.SMS_multiviewApp.get_text()
        self.view_text.set(t)
        appuifw.app.body = self.view_text
        appuifw.app.menu = [(u"Send", self.handle_send)]
        self.view_text.focus = True

    def handle_send(self):
        appuifw.app.activate_tab(3)
        self.SMS_multiviewApp.handle_tab(3)


class SendView:
    def __init__(self, SMS_multiviewApp):
        self.SMS_multiviewApp = SMS_multiviewApp
        self.log_text = appuifw.Text()
        self.log_contents = u""
        
    def activate(self):
        self.log_text.set(self.log_contents)
        appuifw.app.body = self.log_text
        appuifw.app.menu = []
        nbr = self.SMS_multiviewApp.get_number()
        txt = self.SMS_multiviewApp.get_text()
        nam = self.SMS_multiviewApp.get_name()

        f = open(tempfile, 'w')

#	insert messages here
        messages = [u"Hello!",
                   u"Goodbye!"]
        for message in messages:
#	uncomment next line to add a dialogue
#                if appuifw.query(u"Send message to " + nam + "?", 'query'):
#                    t = u"Sent " + txt + " to " + nbr + " (" + nam + ")\n"
                    t = u"Sent " + message + " to " + nbr + " (" + nam + ")\n"
                    self.log_contents += t
                    self.log_text.add(t)
                    #messaging.sms_send(nbr, txt)
                    messaging.sms_send(nbr, messages)
                    logfile = f.write(t)
#		    uncomment next line to sleep for 5 sec
                    e32.ao_sleep(3)  # sleep for 5 seconds
        f.close()


class SMS_multiviewApp:
    def __init__(self):
        self.lock = e32.Ao_lock()
        appuifw.app.exit_key_handler = self.exit_key_handler
        
        self.n_view = NumbersView(self)
        self.c_view = ChoiceView(self)
        self.t_view = TextView(self)
        self.s_view = SendView(self)
        self.views = [self.n_view, self.c_view, self.t_view, self.s_view]
        appuifw.app.set_tabs([u"Numbers", u"Choice", u"Text", u"Send"],
                             self.handle_tab)
        
    def run(self):
        self.handle_tab(0)
        self.lock.wait()
        self.close()

    def get_name(self):
        return self.n_view.get_name()

    def get_number(self):
        return self.n_view.get_number()

    def get_text(self):
        return self.c_view.get_text()

    def handle_tab(self, index):
        self.views[index].activate()

    def exit_key_handler(self):
        self.lock.signal()

    def close(self):
        appuifw.app.exit_key_handler = None
        appuifw.app.set_tabs([u"Back to normal"], lambda x: None)
        del self.t_view
        del self.s_view

myApp = SMS_multiviewApp()
myApp.run()

appuifw.app.title = old_title
appuifw.menu = None
Reply With Quote

#6 Old Re: Sending multiple SMS messages - 2005-09-29, 22:27

Join Date: Nov 2003
Posts: 4
hugovk
Offline
Registered User
I just took out all the log file stuff, and got the same "Python System Error (-50)" popup, at "activate messaging.sms_send(nbr, message)", then SymbianError: KerrGeneral.

This only happened on the second time in the loop; the first time it sent the message fine.

I increased the sleep to 60 seconds, but the error came very soon after sending the first message.

I also removed the sleep, and put the dialog back in, but the error came before the second dialog came up.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Nokia Picture Messages with one SMS? paulmckillop Smart Messaging 8 2006-11-10 06:52
Problems sending SMS messages on a Nokia 6310i ajwiens General Messaging 0 2004-02-05 21:15
Error sending SMS jorge_c Multimodecards 0 2003-10-07 12:53
Sending SMS Messages with multi-byte characters using Java derek_ocallaghan Mobile Java Tools & SDKs 5 2003-06-05 23:01
Help needed : sending long ringtones with multiple SMS messages jlmfr Smart Messaging 5 2002-09-18 09:10

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ