0
votes

Hi there I am trying to send a sms message using Java with a GSM Modem I am learning from this URL: http://www.codeproject.com/Tips/492716/How-to-send-SMS-using-Java-with-a-HSDPA-Dongle Here is my code:

import com.harshadura.gsm.smsdura.GsmModem;

public class TestSMS {
private static String port = "COM1"; //Modem Port.
private static int bitRate = 9600; //this is also optional. leave as it is.
private static String modemName = "ZTE"; //this is optional.
private static String modemPin = "0000"; //Pin code if any have assigned to the modem.
private static String SMSC = "+9477000003"; //Message Center Number ex. Mobitel

public static void main(String[] args) throws Exception {
    GsmModem gsmModem = new GsmModem();
    GsmModem.configModem(port, bitRate, modemName, modemPin, SMSC);
    gsmModem.Sender("+917350320106", "Test Message"); // (tp, msg)
}
}

I have added the various libraries to the built path of my project:

comm.jar
commons-net-3.0.1.jar
smsdura-1.0.jar
RXTXcomm.jar

However, I get this error when i run the project: Exception in thread main org.smslib.GatewayException: Comm library exception: java.lang.RuntimeException: javax.comm.NoSuchPortException

Please help

2
Can you access COM1 with hyperterminal and execute AT and see if you get an OK back?Matt Aldridge
support.microsoft.com/kb/124890/EN-US should help you out with hyperterminal. After you are connected just type AT and see if OK comes back.Matt Aldridge
Without knowing any details about this gsm modem library, the code you have presented looks ok. Your next step should be to turn on debugging in the library (which it absolutely should support, otherwise it is a extremely poor library) to debug why it does not work like expected.hlovdal
@user3631251 hey i have to do something like this only,but not getting how to do this,as what is using modem and all,i just have to do a task which send sms so what should i use can you please tell meuser11176692

2 Answers

1
votes

First fill arguments in this line "GsmModem.configModem(port, bitRate, modemName, modemPin, SMSC);"

1.port can simply right click the MyComputer Icon > go to Mange > then Search for Modems > then it will pop up a interface with several tabs. Okay then you can simply notice theirs a Name called port. In front of that there is the port number. Now you know the port number. Insert that into the code. 2.Modem name is a optional thing 3.Bit rate? Leave it as it is. Or change to a proper one. The number will change depending modem to modem. 4.Some modems are using PIN numbers for Security. Does your one also using such a pin? If so please insert it to the code. if you have code in your modem 5.fill your network service center no...check your message setting..

0
votes

This error can occur due to several reasons.

  1. Your dongle software might be opened. So close it, double check if its running as a background service by using Task Manager. Kill it if it still runs.
  2. Your SMSLib configurations to JVM is not affected properly. So check again the required files are there or not. You need to place them both JDK and JRE see 1
  3. This program does not work well with 64Bit JVM, but it does not say you cannot use it in a 64 bit machine. You have installed 32Bit JDK on the machine, remove the 64Bit JDK to prevent mix ups.
  4. The port you going to access might not really be available in the system. You can simple check the Dongle port if its there by: right clicking Computer icon then go manage > then select device manager > then expand Ports(COM LPT) column > You will see the Application interface port of your device. Thats the port you have to use thre.