×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    36

    Sending multiple SMS messages

    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?

  2. #2
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: Sending multiple SMS messages

    What phone and PyS60 version are you using?

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    36

    Re: Sending multiple SMS messages

    It's a Nokia 7610. From the App Manager, it's Python for Symbian OS v1.01.

  4. #4
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: Sending multiple SMS messages

    Could you post the complete code? Please use the CODE tag so that it remains readable.

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    36

    Re: Sending multiple SMS messages

    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

  6. #6
    Registered User
    Join Date
    Nov 2003
    Posts
    36

    Re: Sending multiple SMS messages

    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.

Similar Threads

  1. Sending Nokia Picture Messages with one SMS?
    By paulmckillop in forum Smart Messaging
    Replies: 8
    Last Post: 2006-11-10, 05:52
  2. Problems sending SMS messages on a Nokia 6310i
    By ajwiens in forum General Messaging
    Replies: 0
    Last Post: 2004-02-05, 20:15
  3. Error sending SMS
    By jorge_c in forum Multimodecards
    Replies: 0
    Last Post: 2003-10-07, 11:53
  4. Sending SMS Messages with multi-byte characters using Java
    By derek_ocallaghan in forum Mobile Java Tools & SDKs
    Replies: 5
    Last Post: 2003-06-05, 22:01
  5. Replies: 5
    Last Post: 2002-09-18, 08:10

Posting Permissions

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