You Are Here:

Community: Developer Discussion Boards

#1 Old searching for bluetooth devices which has a specified application - 2004-02-02, 06:42

Join Date: Nov 2003
Posts: 16
tserivdd
Offline
Registered User
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!
Reply With Quote

#2 Old 2004-02-04, 23:21

Join Date: Mar 2003
Posts: 53
Location: Seattle, WA USA
Send a message via ICQ to cyberabi Send a message via AIM to cyberabi Send a message via Yahoo to cyberabi
cyberabi
Offline
Regular Contributor
Define a new service, and have your app advertise that service and search for it.
Reply With Quote

#3 Old 2004-02-05, 08:30

Join Date: Apr 2003
Posts: 915
Location: Czech Republic
sopta007
Offline
Super Contributor
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...
Reply With Quote

#4 Old on service discovery too... - 2004-02-05, 10:15

Join Date: Nov 2003
Posts: 16
tserivdd
Offline
Registered User
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia