Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


8 posts

Wannabe Geek


Topic # 9561 27-Sep-2006 10:19
Send private message

Hi,

Im running a java bluetooth server on my laptop using avetana bluetooth api and have a client that i have installed on
a Motorola Razor V3i. My client is not able to discover the services. It returns the message Unable to find service!

Can someone please help me with this problem?

regards
Saguna.

The server code looks like:


import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
//import java.lang.*;
import java.io.IOException;
import javax.bluetooth.*;
//import javax.bluetooth.UUID;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.StreamConnectionNotifier;

public class blueconn {
public static final UUID uuid = new UUID(
"27012f0c68af4fbf8dbe6bbaf7ab651b", false);

public blueconn() {
try {

LocalDevice local = LocalDevice.getLocalDevice();
if(!local.setDiscoverable(DiscoveryAgent.GIAC)) {
System.out.println("failed to Set Discoverable");
// f.append("Failed to change to the dicoverable mode");
return;

}
System.out.println("Set Discoverable");
StreamConnectionNotifier server = (StreamConnectionNotifier) Connector
.open("btspp://localhost:"
+ uuid
//+ ";name="
//+ name
//+ ";authorize=false;authenticate=false;encrypt=false"
);
System.out.println("connecting...");
StreamConnection conn = server.acceptAndOpen();

// Open the input to read data from
InputStream in = conn.openInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();

// Read the data sent from the client until the end of stream
int data;
while((data = in.read()) != -1){
out.write(data);
}
System.out.println("Data Read");

System.out.println(out.toString());

// Close all open resources
in.close();
conn.close();
server.close();

} catch (IOException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
new blueconn();

}
}


and the Client code looks like:

/*
* HelloClient.java
*
* Created on 20 September 2006, 01:48
*/

package messagepassing;

import java.lang.*;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.bluetooth.*;

/**
*
* @author Saguna
* @version
*/
public class HelloClient extends BluetoothMIDlet {

/**
* Connects to the server and sends 'Hello, World'
* to the server.
*/

public void run() {

// Creates the Form and adds the Exit Command to it
Form f = new Form("Client");
f.addCommand(new Command("Exit", Command.EXIT, 1));
f.setCommandListener(this);
Display.getDisplay(this).setCurrent(f);
try {

// Retrieve the connection string to connect to the server
LocalDevice local = LocalDevice.getLocalDevice();
DiscoveryAgent agent = local.getDiscoveryAgent();

String connString = agent.selectService (
new UUID("27012f0c68af4fbf8dbe6bbaf7ab651b", false),
ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
if (connString != null){

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();

f.append("Message sent correctly");

} catch (IOException e) {
f.append("IOException: ");
f.append(e.getMessage());
}
} else {
// Unable to locate a service so just print an error message
// on the screen
f.append("Unable to locate service");
}

} catch (BluetoothStateException e){
f.append("BluetoothStateException: ");
f.append(e.getMessage());

}
}
}



Create new topic
871 posts

Ultimate Geek

Trusted

  Reply # 47013 28-Sep-2006 09:11
Send private message

Is bluetooth set to discoverable?

BDFL - Memuneh
60807 posts

Uber Geek
+1 received by user: 11689

Administrator
Trusted
Geekzone
Lifetime subscriber



8 posts

Wannabe Geek


Reply # 47183 30-Sep-2006 02:42
Send private message

ya bluetooth is set to discoverable and services are enabled! Infact there is just one service that is represented by the UUID!
Can someone plz plz help me out! Its drivin me a little crazy now!

All ur help is really appreciated!




8 posts

Wannabe Geek


Reply # 47360 3-Oct-2006 03:48
Send private message

hey guys,



im still looking for help on this! I tried communicatin between two laptops using two BT dongles,

i am able to discover the service but it seems my client is not able to make a connection to my server.



Can someone please help!!



thanks!

Create new topic

Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

Hawaiki Transpacific cable ready-for-service
Posted 20-Jul-2018 11:29


Microsoft Dynamics 365 Business Central launches
Posted 10-Jul-2018 10:40


Spark completes first milestone in voice platform upgrade
Posted 10-Jul-2018 09:36


Microsoft ices heated developers
Posted 6-Jul-2018 20:16


PB Technologies charged for its extended warranties and warned for bait advertising
Posted 3-Jul-2018 15:45


Almost 20,000 people claim credits from Spark
Posted 29-Jun-2018 10:40


Cove sells NZ's first insurance policy via chatbot
Posted 25-Jun-2018 10:04


N4L helping TAKA Trust bridge the digital divide for Lower Hutt students
Posted 18-Jun-2018 13:08


Winners Announced for 2018 CIO Awards
Posted 18-Jun-2018 13:03


Logitech Rally sets new standard for USB-connected video conference cameras
Posted 18-Jun-2018 09:27


Russell Stanners steps down as Vodafone NZ CEO
Posted 12-Jun-2018 09:13


Intergen recognised as 2018 Microsoft Country Partner of the Year for New Zealand
Posted 12-Jun-2018 08:00


Finalists Announced For Microsoft NZ Partner Awards
Posted 6-Jun-2018 15:12


Vocus Group and Vodafone announce joint venture to accelerate fibre innovation
Posted 5-Jun-2018 10:52


Kogan.com to launch Kogan Mobile in New Zealand
Posted 4-Jun-2018 14:34



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.