×

Discussion Board

Results 1 to 14 of 14

Thread: SMS Problem

  1. #1
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    87

    SMS Problem

    I'm just trying to get a notification of incoming and outgoing SMS messages, but I'm having some problems. Here's a minimal test program to demonstrate:

    import e32
    import inbox
    import logs
    import sys

    def handle_incoming_sms(message_id):
    - print(u"Incoming SMS: id=" + str(message_id))
    - sms_log = logs.sms(mode='in')[0]
    - body = sms_log['subject']
    - print(u"body= " + body)
    - sys.stdout.flush()

    def handle_outgoing_sms(message_id):
    - print(u"Outgoing SMS: id=" + str(message_id))
    - sms_log = logs.sms(mode='out')[0]
    - body = sms_log['subject']
    - print(u"body= " + body)
    - sys.stdout.flush()

    the_inbox = inbox.Inbox()
    the_inbox.bind(handle_incoming_sms)

    the_outbox = inbox.Inbox(inbox.EOutbox)
    the_outbox.bind(handle_outgoing_sms)

    app_lock = e32.Ao_lock()
    app_lock.wait()
    And here's the problem. Everything in brackets is what I do, and the rest is the output that appears in the python output window.

    [ Send outgoing SMS. Nothing happens. ]
    [ Receive incoming SMS. Outputs: ]
    Incoming SMS: id=1048669
    Outgoing SMS: id=1048669
    body=Test out
    body=Test in
    [ Receive incoming SMS #2. Outputs: ]
    Incoming SMS: id=1048670
    Outgoing SMS: id=1048670
    body=Test out
    body=Test in 2

    So, sending doesn't really call a handler. But receiving seems to cause both handlers to get called at the same time, so their output is interleaved this way. The outgoing message that appears has the same ID as the incoming, but the body is that of the previously-received message.


  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: SMS Problem

    Hi i think this is due the coding you have done, i might be wrong because i haven't tested your code but it seems that your handle_incoming_sms and handle_outgoing_sms both will be called even when only incoming message or outgoing message takes place. So when you want to see outbox your program will be still stuck for handle_incoming_sms.
    IDEAS is all they need but still they think only Genius can give them that.

  3. #3
    Wiki Moderators
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,779

    Re: SMS Problem

    Hello GonzalezM,

    Do you have Delivery Reports enabled or disabled ?

    Best regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    87

    Re: SMS Problem

    Quote Originally Posted by shubhendra View Post
    Hi i think this is due the coding you have done, i might be wrong because i haven't tested your code but it seems that your handle_incoming_sms and handle_outgoing_sms both will be called even when only incoming message or outgoing message takes place. So when you want to see outbox your program will be still stuck for handle_incoming_sms.
    Hmm, you're right that both are being called when an incoming SMS occurs. I still don't understand why though? Neither occurs during an outgoing SMS.

  5. #5
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    87

    Re: SMS Problem

    Quote Originally Posted by croozeus View Post
    Hello GonzalezM,

    Do you have Delivery Reports enabled or disabled ?

    Best regards,
    Croozeus
    I don't know. I've never even heard of that!

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: SMS Problem

    Quote Originally Posted by GonzalezM View Post
    I don't know. I've never even heard of that!
    Hi GonzalezM
    delivery reports are in the message option of your phone its really strange that you havent heard of delivery reports.
    its makes you know that your msg is delivered to the sender.
    Go to message>settings>text message>delivery reports.

    hope you got it now
    Gaba88

  7. #7
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    87

    Re: SMS Problem

    Quote Originally Posted by gaba88 View Post
    Hi GonzalezM
    delivery reports are in the message option of your phone its really strange that you havent heard of delivery reports.
    It's not in the PyS60 reference manual or the book Mobile Python. When I type this into google:

    "delivery reports" pys60

    The only thing that appears is THIS THREAD!

  8. #8
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: SMS Problem

    Quote Originally Posted by GonzalezM View Post
    It's not in the PyS60 reference manual or the book Mobile Python. When I type this into google:

    "delivery reports" pys60

    The only thing that appears is THIS THREAD!
    That's because they have nothing to do with Python . They are a setting in the phone's messaging application, and can cause some strange behaviour with your code (you get the output twice, almost identically), but that's not the cause of your problem.

  9. #9
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    87

    Re: SMS Problem

    Quote Originally Posted by bogdan.galiceanu View Post
    That's because they have nothing to do with Python . They are a setting in the phone's messaging application, and can cause some strange behaviour with your code (you get the output twice, almost identically), but that's not the cause of your problem.
    Ah, that makes sense.

    If there's a phone setting that affects the behavior of python code it should still be noted in the manual.

  10. #10
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: SMS Problem

    hi GonzalezM
    i hope you got it now why you get only this thread when you search in google.

    Enjoy Pythoning
    Gaba88

  11. #11
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    87

    Re: SMS Problem

    Quote Originally Posted by gaba88 View Post
    hi GonzalezM
    i hope you got it now why you get only this thread when you search in google.

    Enjoy Pythoning
    Gaba88
    Yes, but it's still surprising whenever google returns ONE hit, especially when it's a thread I made. I'm still sort of in shock I think.

  12. #12
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    87

    Re: SMS Problem

    To simplify, if I only listen for outgoing messages, this behavior occurs:

    - Outgoing messages are not detected

    - Incoming messages are detected as outgoing messages

    It only works halfway. Incoming messages are detected properly as incoming messages. I guess this is a bug in Python because this part of my program was working fine in Symbian C++.

    But aren't other people using this without problems? So for that reason it seems like I must be doing something wrong.

  13. #13
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    87

    Re: SMS Problem

    I think I see what's going on now, over in src/ext/inbox/indboxadapter.cpp. Here's the code, in bizarre Symbian C++ indentation:

    Code:
    void CInboxAdapter::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
      {
          TInt i; 
          switch(aEvent) {
    	      // New entries only
            case EMsvEntriesCreated:
              {
              if (iCallBackSet) {
                // Messages that are created in Inbox
                TMsvId* parent;
    	          parent = static_cast<TMsvId*>(aArg2);
    
                // XXX is this needed for Outbox etc.?
                // Check the parent folder to be global inbox
    	          if(*parent != KMsvGlobalInBoxIndexEntryId) 
    	            return;
    
    	          CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
    	          for(i = 0; i < entries->Count(); i++) {
    	            iErrorState = iCallMe.NewInboxEntryCreated(static_cast<TInt>(entries->At(i)));
    	          }
              }
    	        break;
              }
            default:
    	        break;
         }
      }
    It's only checking for new KMsvGlobalInBoxIndexEntryId's, but once it finds one, it loops through all the new MSV entries which might be in any box.

    From my (very tiny) Symbian C++ experience, EMsvEntriesCreated didn't signify that the newly-created incoming message had even been populated with data yet. It was just blank. You have to remember the new incoming message's ID, and match it to the next instance of a EMsvEntriesChanged event to be sure it's the fully-populated new message.

    Meanwhile, EMsvEntriesMoved with an Arg2 of KMsvSentEntryId signified an outgoing message. It's very strange and roundabout, but that's the way they do it.

    So it seems that this first example is just nonsense because you *can't* detect an outgoing message with the inbox.Inbox class (at least not when it actually occurs):

    http://wiki.forum.nokia.com/index.ph..._SMS_in_Outbox

  14. #14
    Regular Contributor
    Join Date
    Jun 2008
    Posts
    87

    Re: SMS Problem

    I just did this for now:

    Code:
    SMS_POLL_TIME = 10 # seconds
    last_outgoing_sms = None
    
    def check_outgoing_sms():
    
    	global last_outgoing_sms
    	
    	sms_log = logs.sms(0, 1, mode='out')[0]	
    	message_id = sms_log['id']
    	if last_outgoing_sms != message_id:
    		if not last_outgoing_sms is None:
    			handle_outgoing_sms(message_id)
    		last_outgoing_sms = message_id		
    		
    while app.is_running:	
    	check_outgoing_sms()
    	app.wait_seconds(SMS_POLL_TIME)
    It's probably not too great but it works.

Similar Threads

  1. SMS sending and receiving problem
    By soujirou in forum Symbian Networking & Messaging (Closed)
    Replies: 12
    Last Post: 2008-08-18, 13:34
  2. Getting Problem sending SMS second time.
    By sagar.pune in forum Symbian
    Replies: 4
    Last Post: 2008-05-29, 14:10
  3. Sms Receving problem
    By cdoewarrior in forum General Messaging
    Replies: 5
    Last Post: 2007-03-03, 15:47
  4. SMS Problem with 3650&6600
    By CemKarahan in forum General Messaging
    Replies: 2
    Last Post: 2004-03-10, 21:04
  5. recieve SMS problem
    By ahsamah in forum General Messaging
    Replies: 5
    Last Post: 2004-03-09, 14:12

Posting Permissions

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