
Originally Posted by
manoj_2580
hi friends . i am developing a project by which any student of my college can receive his result by sending sms to a mobile which is connected to computer.then computer will search his result and send his result in form of sms to mobile which is connected to computer.Then this mobile will send that sms to user. can u help me how to receive and send sms from mobile to pc in java code. can you help me by providing java code. i will be grateful to u if u help.
I didn't try this in Java , but I have an old sample to exaplin the concept:
This is written in Delphi:
Code:
procedure TForm1.SendSMS(tel,mesaj:string);
begin
ComPort1.Writestr('ATZ'+chr(13)); // reset device
delay(1000);
ComPort1.Writestr('AT+CMGF=1'+chr(13)); // operate in SMS text mode.
delay(1000);
ComPort1.Writestr('AT+CMGS="'+tel+'"'+chr(13));
delay(1000);
ComPort1.Writestr(mesaj + chr(26)); // character with ascii code 26
delay(3000);
end;
There must be a serial port component in Java and the code would look similar.
The reason why I put a delay there is because it takes a while to execute the command , normally this is not the correct way to do it but it works.
The best way to do it is to have a handler , that reads the data received from the mobile phone.
When you send ATZ you have to wait to receive an OK and only after that send the next instruction AT+CMGF=1 , and so on...
Try just to send an SMS for now, and then try to implement the receive SMS feature.
If you try to code it in C sharp I could help you faster with concrete sample code , I am currently working on something very similar in C sharp.
All the best,
Dobre