Saturday, May 10, 2014

Why i m not receiving correctly the SMS over length of more the a page Using AT Cmand




i m working on the SMS receiving using AT Commands using JAVA. i m getting the message of one page correctly using AT commands, but as i increase the size of SMS as 2, 3 or bigger pages the alphabets are converted to some thing like this




+CMGL: 0,"REC UNREAD","+923028910082",,"14/05/10,19:32:40+20"



4469616C202A3334352A393333232061757220536972662052 732E3230206D65696E20332064696E206B6120696E7465726E 65742028333030204D422920686173696C206B6172656E2120 7777772E776170747269636B2E636F6D2070657220736F6E67 73206175722067616D657320656E6A6F79206B6172656E2120 42616C616E636520636865636B206B206C7965202A39393923 206D69




whats the problem i m not getting the right text which i have sent through my mobile phone.



please help me out it very urgent




my function of receiving SMS is as follows




public void send(String cmd) {



try {



outputStream.write(cmd.getBytes());



} catch (IOException e) {



e.printStackTrace();



}



}



public void recieveMessage() throws InterruptedException, IOException{




send("AT+CMGF=1\r"); //send ok if suport txt msg



Thread.sleep(100);




send("AT+CMGL=\"REC UNREAD\"\r"); //return list mesgs received on gsm modem




byte[] readBuffer = new byte[2048];



try {




InputStream inputStrea = null;



inputStrea=serialPort.getInputStream();



int numBytes = inputStrea.read(readBuffer);




//print response message



String st=new String(readBuffer);



st=st.trim();




System.out.println(st);




setRecieveMsg(st);



} catch (IOException e) {



}



send("AT+CMGD=1,4\r");



}







No comments:

Post a Comment