| Reply | « Previous Thread | Next Thread » |
|
Hello!
I'm developing an application for the Nokia 6600. this application needs to connect to another 6600 via bluetooth. However, what i want is for my application to detect only devices which also has the application (this one i'm doing). Is it possible to do it using the Java Bluetooth? If also you have sample code on how to do it, it will be very much appreciated. And anyway, any help would really do! thanks a lot! ![]() |
|
Define a new service, and have your app advertise that service and search for it.
|
|
More specifically, you need to put a record to SDP database. How to do it is explained in BTAdvertiser example. Then look through BTDiscovery example to see how you can query remote device if it contains the specific service you put there...
|
|
Hi cyberabi and sopta007!
How can i store the service in my SDP database? where can i find the BTAdvertiser sample? I've read bout this but i really dont know how to do it. Also, i was doing a client-server app for bluetooth last night. The code is working perfectly in the emulator but when i tried it on the real device (2 Nokia 6600s), it fails to discover services. this is my code for the service discovery: public void discoverServices() { this.displayText("Discover services... please Wait"); try { int [] attr= new int[] { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x0100, 0x0101, 0x0102, 0x0200, 0x0201, 0x0301, 0x0302, 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308, 0x0309, 0x030A, 0x030B, 0x030C, 0x030D, 0x030E, 0x0310, 0x0311, 0x0312, 0x0313, }; services.removeAllElements(); //just get services of last discovered device agent.searchServices(attr, new UUID[]{new UUID(0x0100), uuid, new UUID(0x1101), new UUID(0x0001), new UUID(0x0003)}, (RemoteDevice) devices.lastElement(), new Listener()); } catch (Exception e) { e.printStackTrace(); } }// end of discoverServices for my listener, this is my serviceDiscovered code: public void servicesDiscovered(int transID, ServiceRecord[] records) { for ( int i=0; i< records.length; i ++ ) { ServiceRecord record = records[i]; // store the service records in list for later use services.addElement(record); g2.drawString("Adding service: ", 5, drawLine, 0); System.out.println("Adding service: " + record.toString()); drawLine +=13; g2.drawString(record.toString(), 5, drawLine, 0); drawLine +=13; flushGraphics(); } }// end of servicesDiscovered public void serviceSearchCompleted(int transID, int complete) { System.out.println("Service discovery complete!"); }// end of serviceSearchCompleted the search is completed but there were no services discovered. you guys find anything wrong with the code? any suggestions? thanks you very much! |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|