BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Major Problems sending/receiving SMS messages (http://www.blackberryforums.com/developer-forum/220057-major-problems-sending-receiving-sms-messages.html)

psantimauro 02-19-2010 10:44 AM

Major Problems sending/receiving SMS messages
 
Hello,

I am trying to send and receive SMS messages using Java ME. I was following a tutorial from howto.org (forum wont le me post link). I have written two applications so far.

The first is running on a blackberry simulator. Once a button is pressed, a thread is started and it sends the message out. I dont know if its working because I cannot get the server application to run.

The server application is a java application that runs a thread. In the constructor I try to open the DatagramConnection. :x**This is where the problem starts**. The debugger is telling me that there is an UnsatisfiedLinkError. The the Connector.open(Sting) line: not avaible [native method]. A page also opens saying:
The JAR file C:\Devel\eclipse\plugins\net.rim.eide.componentpac k4.5.0_4.5.0.16\components\lib\net_rim_api.jar has no source attachment.
I have been trying to get this stuff working for over a week. Its for my senior capstone course, and I am getting pretty far behind with out it.

ANY HELP IS MUCH APPRECIATED!!!!

thanx
pete

psantimauro 02-19-2010 04:06 PM

I dont know if this will help, but here are the source files...


Server Thread
PHP Code:



import java
.io.IOException;

import javax.microedition.io.*;
import javax.wireless.messaging.*;


public class 
RunnerThread implements Runnable
{
    
MessageConnection in;
    
TextMessage msg;
    
bytexxx91;xxx93; payload;
    
//HttpConnection c;
    
DatagramConnection incomingConnection;
    
    
//DatagramConnection incomingconnection = (DatagramConnection)Connector.open("sms://:1234");
    
    
    
public RunnerThread() 
    {
        
System.out.println("Runner Constructing...");
        
System.out.print("Opening conection.");
        
        try{
            
incomingConnection = (DatagramConnection)Connector.open("sms://:1234");        
        }
        catch(
IOException e)
        {
            
System.out.println("\tfailed");
            
System.out.println(e.toString());
        }
        
System.out.println("\tdone");
    }
    public 
RunnerThread(MessageConnection dc)
    {

        
in=dc;
    }

    public 
void run()
    {
        while(
true)
        {
            try
            {

                
System.out.println("top  ==================");
            
                
Datagram sms incomingConnection.newDatagram(incomingConnection.getMaximumLength());
                
incomingConnection.receive(sms);
                
                
bytexxx91;xxx93; payload sms.getData();
                
                
System.out.println(payload);
                
                
//msg = (TextMessage)in.receive();
                //System.out.println(msg.getPayloadText());
                
System.out.println("bottom==================");
                
                
//wait(100);
            
} catch (Exception e)
            {
                
// TODO Auto-generated catch block
                
e.printStackTrace();
                
                
System.out.println(e.toString());
            }
        }
        
        
    }




and the sender thread
PHP Code:

import java.io.IOException;

import javax.microedition.io.Connector;
import javax.microedition.io.Datagram;
import javax.microedition.io.DatagramConnection;
import javax.wireless.messaging.BinaryMessage;
import javax.wireless.messaging.MessageConnection;

import net.rim.device.api.io.DatagramBase;
import net.rim.device.api.io.SmsAddress;
import net.rim.device.api.system.SMSPacketHeader;
import net.rim.device.api.system.SMSParameters;


public class 
MyThread implements Runnable {
    
    
    
DatagramConnection connection null;
    
String sendPrefix "sms://1234567890:1234";
    
Datagram d;
    
    public 
void run() {
        
        
        

        
System.out.print("ADFASFDASFDASFDASFDASDSFASDAFASFDASFDASFD");
        
SmsAddress destinationAddr = new SmsAddress("//1234567890:1234");
        
SMSPacketHeader h destinationAddr.getHeader();
        
h.setStatusReportRequest(false);
        
h.setUserDataHeaderPresent(true);
        
h.setValidityPeriod(SMSParameters.PERIOD_INDEFINITE);
        
h.setDeliveryPeriod(SMSParameters.PERIOD_INDEFINITE);
        
h.setMessageClass(SMSParameters.MESSAGE_CLASS_1);
        
h.setMessageCoding(SMSParameters.MESSAGE_CODING_8_BIT);
        
        
        
        


        
        try 
        {
            
            
int maxDatagramLength connection.getMaximumLength();
            
// note - I have seen this method returning some strange
            // values. If it returns anything bigger than 140 you have
            // to limit your message size to 140 bytes
            
final bytexxx91;xxx93; myUDH = new bytexxx91;xxx93; {
                    
0x06,
                    
0x05,   // application addressing scheme
                    
0x04,   // address size in bytes: 2 x 2 bytes
                    
0x04,   // destination port=1234, little-endian
                    
0x04,   // source port=1234, little-endian
            
};
            
// calculating the remaining space for the data
            
maxDatagramLength -= myUDH.length;
            
bytexxx91;xxx93; message "Bonjour de Montréal".getBytes("UTF-8");
            
// building the actual SMS payload
            
bytexxx91;xxx93; completePayload = new bytexxx91;myUDH.length message.lengthxxx93;;
            
System.arraycopy(myUDH0completePayload0myUDH.length);
            
System.arraycopy(message0completePayloadmyUDH.lengthmessage.length);
            
            
connection = (DatagramConnection)Connector.open("sms://1234567890:1234");
            
connection.newDatagram(message.length);
            ((
DatagramBase)d).setAddressBase(destinationAddr);
            
d.setData(completePayload0completePayload.length);
            
connection.send(d);
            
        
        } catch (
Exception e) {
            
// TODO Auto-generated catch block
            
e.printStackTrace();
        }
        

        
        
        
    }




thanks again
pete


All times are GMT -5. The time now is 07:29 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.