Please does anyone know how I can gain access to my USB bluetooth device using JSR-82 API. With my bluetooth device turned on, when i run my code belox: I get a BluetoothStateException
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.UUID;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.StreamConnectionNotifier;
public class PcServer {
/**
* @declarations
*/
protected LocalDevice lDevice;
public PcServer()throws BluetoothStateException {
try{
// retrieve the local Bluetooth device object
lDevice = LocalDevice.getLocalDevice();
}catch(Exception e){
e.printStackTrace();
}
// retrieve the Bluetooth address of the local device
String address = lDevice.getBluetoothAddress();
log(“My Bluetooth address is ” + address);
// retrieve the name of the local Bluetooth device
String name = lDevice.getFriendlyName();
log(“My friendly name is ” + name);
}
/**
* @param args
*/
public static void main(String[] args) throws BluetoothStateException {
// TODO Auto-generated method stub
PcServer pcSvr = new PcServer();
log(“Server String…”);log(” “);
log(pcSvr);
}
}