Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to SMS send to CDMA modem using AT command in java?
    primarykey
    data
    text
    <p>I am trying to make a simple java application on windows-7 that can send SMS on my citycell Zoom USB Modem. I use AT Command(<a href="http://www.canarysystems.com/nsupport/CDMA_AT_Commands.pdf" rel="nofollow">http://www.canarysystems.com/nsupport/CDMA_AT_Commands.pdf</a>) . Flowing my Java Code:</p> <pre><code>import javax.comm.*; import java.io.*; import java.util.*; public class SimpleWrite implements Runnable, SerialPortEventListener { public void run() { } static Enumeration portList; static CommPortIdentifier portId; static String messageString = "AAA"; static char ch = '"'; static String dest = ch + "01739557775" + ch; // 11 Digit Mobile Number. static InputStream inputStream; static SerialPort serialPort; static OutputStream outputStream; public void serialEvent(SerialPortEvent event) { switch (event.getEventType()) { case SerialPortEvent.BI: case SerialPortEvent.OE: case SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD: case SerialPortEvent.CTS: case SerialPortEvent.DSR: case SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break; case SerialPortEvent.DATA_AVAILABLE: { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = ""; try { while ((line = reader.readLine()) != null) { System.out.println(line); } } catch (IOException e) { System.err.println("Error while reading Port " + e); } break; } } //switch } public SimpleWrite(SerialPort serial) { try { inputStream = serial.getInputStream(); try { serial.addEventListener(this); } catch (TooManyListenersException e) { System.out.println("Exception in Adding Listener" + e); } serial.notifyOnDataAvailable(true); } catch (Exception ex) { System.out.println("Exception in getting InputStream" + ex); } } public static void main(String[] args) { String line1 = "AT+CSMS=1\r\n"; String line2 = "AT+CMGS=" + dest + "\r\n"; String line3 = messageString + "\r\n"; portList = CommPortIdentifier.getPortIdentifiers(); while (portList.hasMoreElements()) { portId = (CommPortIdentifier) portList.nextElement(); if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { if (portId.getName().equals("COM13")) { System.out.println("SMS Sending....Port Found"); try { serialPort = (SerialPort) portId.open("SimpleWriteApp", 2000); SimpleWrite wr = new SimpleWrite(serialPort); } catch (PortInUseException e) { System.out.println("Port In Use " + e); } try { outputStream = serialPort.getOutputStream(); } catch (IOException e) { System.out.println("Error writing to output stream " + e); } try { serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { } try { outputStream.write(line1.getBytes()); outputStream.write(line1.getBytes()); outputStream.write(line2.getBytes()); outputStream.write(line3.getBytes()); outputStream.write(26); outputStream.flush(); } catch (Exception e) { System.out.println("Error writing message " + e); } } } } } /** * show text in the text window * * @param Text text string to show on the display */ public static void showText(String Text) { System.out.println(Text); } } </code></pre> <p>Output:</p> <pre><code>SMS Sending....Port Found AT+CSMS=1 ERROR AT+CSMS=1 ERROR AT+CMGS="01739557775" ERROR </code></pre> <p>Please help me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload