5

I am new to java programming. I have used smsj api to send messages from pc to mobile through a gsm modem. I have succesfully been able to send plain text messages using SmsSender.sendTextSms(msg, reciever, sender) as well as unicode messages using SmsSender.sendUnicodeTextSms("smsj हिन्दी मेसेज", reciever);.

They say it supports EMS messages too. I am trying to send picture messages (black and white), and audio clips through this. But i cannot figure out how to do this.

The documentation shows that there is a class EmsMessage that implements SmsMessage But i couldn't find any details on how to use it. I have also gone through its forum but again cant find any solution.

Hoping someone could guide me on this.

this is my code for sending text messages..

public class SendMessage  {

    public void send() {
    try{
        SmsSender smsSender = SmsSender.getGsmSender("COM14");
            String msg ="smsj test message";        
            String reciever = "919790968633"; 
            String sender ="919176968289";      
            smsSender.connect();

            smsSender.sendTextSms(msg, reciever, sender);  //simple text message

                   smsSender.sendUnicodeTextSms("smsj हिन्दी मेसेज", reciever); //unicode message

            smsSender.disconnect();

    } catch(IOException i){
        i.printStackTrace();
        System.out.println("i");
    } catch(SmsException s){
        s.printStackTrace();
        System.out.println("s");
    }
    }

    public static void main(String args[]){
        SendMessage app = new SendMessage();
        app.send();
    }


}

i tried this code for sending ems message.. but it seems to be wrong.

     EmsMessage ems = new EmsMessage();
     ems.addText(msg);
     SmsMessage sms ;
     sms=ems;
     smsSender.sendSms(sms, reciever, sender);

i get this error message:

60 [main] INFO org.marre.sms.transport.gsm.SerialComm - >> AT+CMGF=0    
261 [main] INFO org.marre.sms.transport.gsm.SerialComm - << 
261 [main] INFO org.marre.sms.transport.gsm.SerialComm - << OK
Exception in thread "main" java.lang.NullPointerException
    at org.marre.sms.transport.gsm.GsmTransport.send(GsmTransport.java:175)
    at org.marre.SmsSender.sendSms(SmsSender.java:551)
    at org.marre.SendMessage.send(SendMessage.java:44)
    at org.marre.SendMessage.main(SendMessage.java:58)

Can anyone help me what is the correct syntax of using this EmsMessage and SmsMessage class?

newbee
  • 409
  • 2
  • 12
  • 34

1 Answers1

1

http://smsj.sourceforge.net/apidocs/org/marre/sms/ems/EmsMessage.html here you have needed documentation

addElement should add graphics, movies etc..

addText this should add text

dantuch
  • 9,123
  • 6
  • 45
  • 68
  • i have gone through these documents... [http://smsj.sourceforge.net/apidocs/org/marre/sms/ems/EmsElement.html](http://smsj.sourceforge.net/apidocs/org/marre/sms/ems/EmsElement.html) and [http://smsj.sourceforge.net/apidocs/org/marre/sms/ems/EmsPictureElement.html](http://smsj.sourceforge.net/apidocs/org/marre/sms/ems/EmsPictureElement.html) but could not understand how to implement these in the code. – newbee Mar 20 '13 at 08:21
  • @newtoandroid yes, your right. Are there any methods in this class that are present in source code, and are not present in the docs? Maybe it's just javadoc that is broken.... Or this project has 0 capabilieties to handle EMS – dantuch Mar 20 '13 at 11:29
  • According to me, i think its just that there are no examples given at all. Hence it is getting difficult to code. the javadoc seems to be fine. – newbee Mar 20 '13 at 11:40