BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-19-2010, 11:44 AM   #1 (permalink)
New Member
 
Join Date: Feb 2010
Model: none
PIN: N/A
Carrier: verizon
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Major Problems sending/receiving SMS messages

Please Login to Remove!

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. **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

Last edited by psantimauro : 02-19-2010 at 11:46 AM. Reason: rename title
Offline  
Old 02-19-2010, 05:06 PM   #2 (permalink)
New Member
 
Join Date: Feb 2010
Model: none
PIN: N/A
Carrier: verizon
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Offline  
Closed Thread


Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright © 2004-2014 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.