×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    48

    application freezes when pess any key (silentsms)

    Hi!
    I´m developing an application which listen to a defined port to catch incoming sms. I get the code from the silentSMS example provide in the wiki. It works fine, but when listening if i press a key the application freezes anf i can´t do nothing. Anyone has experimented the same problem?

    Thanks!

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: application freezes when pess any key (silentsms)

    "Freezing" often happens when one tries to use User::WaitForRequest instead of implementing active objects.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    48

    Re: application freezes when pess any key (silentsms)

    I´m using active objects, I have a view with a options menu. In one of this options i call SocketListen(), but i can receive only a message (class CSMSEngine : public CActive).

    Code:
    void CSMSEngine::SocketListen()
    	{
    	
    	 
    	_LIT(KTag, "##");
    	TBuf8<5> matchTag;
    	matchTag.Copy(KTag);
    
    	//Opens a socket by creating a new subsession to the socket server.
    	TInt err = iSocket.Open(iSocketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol);
    	if(err==KErrNone)
    		{ 
    		TRequestStatus iStatus;
    		TSmsAddr smsaddr; 
    		// App. listens for sms msgs with some special tag in it.
      		smsaddr.SetSmsAddrFamily(ESmsAddrMatchText); 
    		smsaddr.SetTextMatch(matchTag);
    		smsaddr.SetSmsAddrFamily(ESmsAddrApplication16BitPort); 
    		smsaddr.SetPort(5000);
    		TInt BindErr = iSocket.Bind(smsaddr);
    		if(BindErr == KErrNone)
    			{
    			iPckgBuf() = KSockSelectRead;
    			//Applies an asynchronous I/O control operation on a socket.
    			iSocket.Ioctl( KIOctlSelect,iStatus, &iPckgBuf, KSOLSocket);
    			iRead=ETrue;
    			SetActive();
    			}
    		}
    	}        
    
    // -----------------------------------------------------------------------------
    // CSMSEngine::RunL()
    // Gets hit everytime a message with the 'tag' arrives
    // -----------------------------------------------------------------------------
    //
    void CSMSEngine::RunL()
    	{
    	if(iRead)
    	    {
    	    
    			
    		CSmsBuffer *smsBuffer = CSmsBuffer::NewL();
    		CleanupStack::PushL(smsBuffer);
    		//Stream that reads a CSmsMessage object across a socket.
    		RSmsSocketReadStream readStream(iSocket);
    		//Allocates and creates a CSmsMessage
    		//ESmsDeliver-SMS-DELIVER, sent from service center to Mobile Station. 
    		iSmsMessage = CSmsMessage::NewL(iFs,CSmsPDU::ESmsDeliver,smsBuffer);
    		//Internalises data from stream to CSmsMessage
    		iSmsMessage->InternalizeL(readStream);
    		readStream.Close();	
    		//Extracting the received message to a buffer	
    		   iSmsMessage->Buffer().Extract(iBuf,0,iSmsMessage->Buffer().Length());
    	   	iSocket.Ioctl( KIoctlReadMessageSucceeded,iStatus, &iPckgBuf, KSolSmsProv);
    	   	//Printing the received Message.
    	   	
    	    CAknInformationNote* note122=new(ELeave) CAknInformationNote;
    	    note122->ExecuteLD(iBuf);
    	    
    	   	
    		iRead=EFalse;		
    		SetActive();
    		CleanupStack::PopAndDestroy(smsBuffer);
    	    }
    	}

  4. #4
    Regular Contributor
    Join Date
    May 2006
    Location
    Moscow, Russia
    Posts
    57

    Re: application freezes when pess any key (silentsms)

    I can say nothing about your problem, code looks good. Are you sure that SocketListen is called only once. But code in RunL is not correct. I think it must be like this, be attentive.
    Code:
    void CSMSEngine::RunL()
    	{
    		CSmsBuffer *smsBuffer = CSmsBuffer::NewL();
    		CleanupStack::PushL(smsBuffer);
    	
    		//Allocates and creates a CSmsMessage
    		CSmsMessage* smsMessage = CSmsMessage::NewL(iFs,CSmsPDU::ESmsDeliver,smsBuffer);
    
    		CleanupStack::Pop(1); //smsBuffer, CSmsMessage takes ownership of smsBuffer
    		CleanupStack::PushL( smsMessage ); 
    		
    		//Stream that reads a CSmsMessage object across a socket.
    		RSmsSocketReadStream readStream(iSocket);
    		CleanupClosePushL(readStream);
    
    		//Internalises data from stream to CSmsMessage
    		smsMessage->InternalizeL(readStream);
    
    		CleanupStack::PopAndDestroy(1); //readStream
    
    	
    		//Make dynamic buffer, use smsMessage->Buffer().Length() and smsMessage->Buffer().Extract
    		//...
    
    		CleanupStack::PopAndDestroy(1); //smsMessage
    
    	   	iSocket.Ioctl( KIoctlReadMessageSucceeded, iStatus, &iPckgBuf, KSolSmsProv);
    		SetActive();
    	    }

  5. #5
    Regular Contributor
    Join Date
    May 2009
    Posts
    51

    Re: application freezes when pess any key (silentsms)

    Quote Originally Posted by millansf View Post
    Hi!
    I´m developing an application which listen to a defined port to catch incoming sms. I get the code from the silentSMS example provide in the wiki. It works fine, but when listening if i press a key the application freezes anf i can´t do nothing. Anyone has experimented the same problem?
    Same problem here on SDK 3rd Ed FP1. Compiled the sample using gcce for an N95 and I get the freeze. The SMS I then send to the phone is never received. Well... it hasn't been yet!

    Will try the suggested change to RunL.

Similar Threads

  1. iPhone Blogger Blog Creation Application
    By semaphore10 in forum News and Announcements
    Replies: 4
    Last Post: 2009-10-06, 08:49
  2. Can a background application detect a key press when keypad is locked??
    By rohanwaugh in forum Symbian User Interface
    Replies: 17
    Last Post: 2009-08-14, 10:20
  3. Replies: 106
    Last Post: 2009-05-11, 05:53
  4. Replies: 5
    Last Post: 2006-12-22, 07:32
  5. application key manager error
    By ddamir95 in forum Symbian
    Replies: 0
    Last Post: 2004-04-02, 12:19

Posting Permissions

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