C
chao
Gast
Hello all,
I'm trying to write a program which should send AT-commands to a mobile phone via bluetooth. I use JSR-82 as API. The program establishes a SPP connection to the mobile phone and sends the AT-commands as a string. But the mobile phone does'nt response to the AT-commands. Is it possible to send AT-commands through a SPP connection? How can I receive a response from the mobile phone, if it gives me one?
here is the sending code:
try{
// connectionURL is got from service discovery, //servRecord.getConnectionURL(1,false)
connection = (StreamConnection) Connector.open(connectionURL);
OutputStream out = connection.openOutputStream();
InputStream in = connection.openInputStream();
String message = "ATD123445678";// AT-command to dial 12345678
// send AT-command
out.write(message.getBytes());
out.flush();
out.close();
byte buffer[] = new byte[10000];
// read the response from mobile phone
in.read(buffer);
System.out.println(buffer.toString());
connection.close();
} catch (Exception e){
e.printStackTrace();
}
Is there some thing wrong in the code? Why did the mobile phone not response to the AT-command?
thanks for any tips!
I'm trying to write a program which should send AT-commands to a mobile phone via bluetooth. I use JSR-82 as API. The program establishes a SPP connection to the mobile phone and sends the AT-commands as a string. But the mobile phone does'nt response to the AT-commands. Is it possible to send AT-commands through a SPP connection? How can I receive a response from the mobile phone, if it gives me one?
here is the sending code:
try{
// connectionURL is got from service discovery, //servRecord.getConnectionURL(1,false)
connection = (StreamConnection) Connector.open(connectionURL);
OutputStream out = connection.openOutputStream();
InputStream in = connection.openInputStream();
String message = "ATD123445678";// AT-command to dial 12345678
// send AT-command
out.write(message.getBytes());
out.flush();
out.close();
byte buffer[] = new byte[10000];
// read the response from mobile phone
in.read(buffer);
System.out.println(buffer.toString());
connection.close();
} catch (Exception e){
e.printStackTrace();
}
Is there some thing wrong in the code? Why did the mobile phone not response to the AT-command?
thanks for any tips!