DG
unread,Aug 15, 2008, 2:11:51 PM8/15/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'm having some trouble with connection and sending AT Commands to my
Nokia 6310i. Its part of a college project and I'm at the final
hurdle (I think) of getting it to accept the commands...
I've tried looking at some other code (like sms.java) for some
pointers, but that seems to be doing an awful lot!
I'm a little lost. Any help would be much appreciated!
//CODE START
import javax.microedition.io.Connector;
import javax.obex.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.bluetooth.UUID;
iimport javax.microedition.io.StreamConnection;
import javax.microedition.io.StreamConnectionNotifier;
import java.io.IOException;
import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.ServiceRecord;
public class AtSend {
public static void main(String[] args) throws IOException,
InterruptedException {
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 os = connection.openOutputStream();
InputStream is = connection.openInputStream();
byte data[] = "AT+CMGD=1,0,1000".getBytes();
// byte data =("AT E1" + lfcr).getBytes();
os.write(data);
// 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
There is some reference to some old OBEX stuff in there which I tried
first.... with no joy! Then I moved on to RFCOMM.
Thanks,
DG.