Hi,
i have developed a code for Nokia 6600 to talk to Computer. the only thing where it get's stuck is the UUID stuff. i am not sure what value to specify in for the UUID and the attribute set while opening the connection to the computer via the Nokia 6600 code.
Code:
public void connect(String s)throws IOException {
String UUID = new UUID("1101",false).toString();//1101 00112233445566778899AABBCCDDEEFF
System.out.println("UUID is....."+UUID);
int discoveryMode = DiscoveryAgent.GIAC;
LocalDevice device = null;
// no paring needed
try {
device = LocalDevice.getLocalDevice();
device.setDiscoverable(DiscoveryAgent.GIAC);
String url = "btspp://localhost:" + UUID + ";name=PCServerCOMM";
System.out.println("URL is....."+url);
synchronized (this)
{
notifier = (StreamConnectionNotifier) Connector.open(url);
servRecord = device.getRecord(notifier);
System.out.println("SERVRECORD is....."+servRecord);
StreamConnection conn= notifier.acceptAndOpen();
DataOutputStream out = conn.openDataOutputStream();
out.writeUTF(s);
/*LocalDevice local = LocalDevice.getLocalDevice();
DiscoveryAgent agent = local.getDiscoveryAgent();
String connString = agent.selectService(
new UUID("1101", false),
ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
*/
/*try {
// Connect to the server and send 'Hello, World'
/* StreamConnection conn = (StreamConnection)
Connector.open(connString);
OutputStream out = conn.openOutputStream();
out.write("Hello, World".getBytes());
out.close();
conn.close();
System.out.println("Message sent correctly");
} catch (IOException e) {
System.out.println("IOException: ");
System.out.println(e.getMessage());
}
*/
}
}
catch(IOException e) {
System.out.println("IOException");
}
catch(Exception e) {
System.out.println("exception of url");
e.printStackTrace();
}
}
}
this is the code on the computer so that the mobile can communicate.
in the constructor of my class.
Code:
System.out.println("Entering Client constructor");
localDevice = LocalDevice.getLocalDevice();
discoveryAgent = localDevice.getDiscoveryAgent();
//System.out.println(localDevice.getRecord().getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,true));
device = new RemoteDevice[10];
// Starts inquiry for devices in the proximity and waits till the
//inquiry is completed.
System.out.println("\nSearching for Devices...\n");
discoveryAgent.startInquiry(DiscoveryAgent.GIAC,this);
synchronized(this){
this.wait();
}
//Once the Device inquiry is completed it starts searching for the
//required service. service search is done with the given uuid.
//After starting each search it waits for the result. If the
//connectionURL is null, ie, if No service Records obtained, then
//it continues search in the next device detected.
// server 86b4d249fb8844d6a756ec265dd1f6a3
// client 86b4d249fb8844d6a756ec265dd1f6a3
String UUID = new UUID("0003",false).toString();//1101 00112233445566778899AABBCCDDEEFF
System.out.println("UUID is....."+UUID);
String url = "btspp://localhost:" + UUID + ";name=PCServerCOMM";
int[] attrSet = null;
UUID[] uuids = new UUID[1];
//uuids[0] = new UUID("0003",false); //Vid 1001 and Pid 1131.
//for(int i = 0; i< count;i++) {
System.out.println("Starting to search services...");
//int transactionid = discoveryAgent.searchServices(attrSet,uuids,device[i],this);
//System.out.println("Starting to search services transaction id..."+transactionid);
//if(transactionid != -1){
/*StreamConnection connection = getconnection();
op = connection.openOutputStream();
ip = connection.openInputStream();
readData();*/
notifier = (StreamConnectionNotifier) Connector.open(url);
//servRecord = localDevice.getRecord(notifier);
//System.out.println("SERVRECORD is....."+servRecord);
StreamConnection conn= notifier.acceptAndOpen();
DataInputStream in = conn.openDataInputStream();
in.readUTF();
synchronized(this){
System.out.println("Starting to wait after searching the service..");
this.wait();
}
u can clearly see that i've tried lot of stuff. pls help at the earliest. thanks a million.