Hi guys,
Am sending SMS messages from a java application.
The problem is, the messages that are sent and received contain AT commands like AT+CMGS in the message.
Is there a way I can surpress the AT commands from being sent. Below is my code segment for sending the messages.
The send() method is shown belowCode:gsm.connect(); //gsm.enableExtendedCommands(); gsm.checkStatus(); //Thread.sleep(5000); Thread.sleep(5000); //gsm.flush(); //Put the GSM modem/phone in text mode gsm.send("AT+CMGF=1\r\n"); //out.flush(); //Enable extended error codes gsm.send("AT+CMEE=1\r\n"); //out.flush(); //Clear the outputstream of any characters unwanted in SMS to be sent //gsm.flush(); //Send SMS gsm.send("AT+CMGS=\"" + phoneNumber + "\"\r\n"); //gsm.flush(); //Add a whitespace character gsm.send(message + '\032'); //gsm.sendSmsMessage(message, phoneNumber); //Thread.sleep(200); Thread.sleep(2000); gsm.hangup(); gsm.serialPort.close();
Code:public void send(String cmd) { try { outputStream.write(cmd.getBytes()); } catch (IOException ioException) { ioException.printStackTrace(); } }

Reply With Quote


