DG
unread,Aug 19, 2008, 4:05:40 AM8/19/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to bluecove-users
Hi,
I have a program, that when run to send AT Commands, e.g."AT\r" I get
a random number, either 75, 13 or 65. I can't figure out why its
doing it, its confusing and quite annoying!
I'm using BlueCove 2.0.3 and I'm testing against a Nokia 6310i with
firmware v5.51...
Please help!
CODE START
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.Vector;
import javax.bluetooth.ServiceRecord;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
public class AtSend {
public static void main(String[] args) throws IOException,
InterruptedException {
// String serverURL = "btspp://001783F4DFCF:
3;authenticate=false;encrypt=false;master=false";
String serverURL = "btspp://0060579E9ACC:
3;authenticate=false;encrypt=false;master=false";
if ((args != null) && (args.length > 0)) {
serverURL = args[0];
}
if (serverURL == null) {
String[] searchArgs = null;
// Connect to OBEXPutServer from examples
// searchArgs = new String[]
{ "11111111111111111111111111111123" };
ServicesSearch.main(searchArgs);
if (ServicesSearch.serviceFound.size() == 0) {
System.out.println("Service not found");
return;
}
// Select the first service found
serverURL =
(String)ServicesSearch.serviceFound.elementAt(0);
}
System.out.println("Connecting to " + serverURL);
// ClientSession clientSession = (ClientSession)
Connector.open(serverURL);
// HeaderSet hsConnectReply = clientSession.connect(null);
// if (hsConnectReply.getResponseCode() !=
ResponseCodes.OBEX_HTTP_OK) {
// System.out.println("Failed to connect");
// return;
// }
StreamConnection connection = (StreamConnection)
Connector.open(serverURL);
OutputStream out = connection.openOutputStream();
InputStream in = connection.openInputStream();
// BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
// String message = "ATEO\r";
// byte buffer[] = new byte[10000];
byte data[] = "AT\r".getBytes();
// String cr = "\r";
// String message =("AT\r");
// out.write(message.getBytes());
// System.out.println("AT Command Response : " + in.read());
out.write(data);
out.flush();
out.close();
byte buffer[] = new byte[10000];
in.read(buffer);
in.read(data);
System.out.println("Output Stream : " +out);
System.out.println("Input Stream : " +in);
// int bytes_read = in.read( buffer );
// String response = new String(buffer, 0, bytes_read);
// System.out.println("1st Response: " + response);
System.out.println("AT Command Response : " + in.read());
// connection.close();
// HeaderSet hsOperation = clientSession.createHeaderSet();
// hsOperation.setHeader(HeaderSet.NAME, "Hello.txt");
// hsOperation.setHeader(HeaderSet.TYPE, "text");
//Create PUT Operation
// Operation putOperation = clientSession.
// Send some text to server
//byte data[] = "Hello world!".getBytes("iso-8859-1");
// String lfcr = "\r\n";
// byte[] data =("ATEO" + lfcr).getBytes();
connection.close();
}
}
CODE END