Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Bluetooth Problem

  • 12-01-2008 11:54AM
    #1
    Registered Users, Registered Users 2 Posts: 196 ✭✭


    I'm writing a bluetooth server to run on a dektop pc (dell; winxp sp2).
    But my server is throwing a BluetoohStateException

    Code:

    public MyServer() {
    try {
    System.out.println("Setting device to be discoverable...");
    local = LocalDevice.getLocalDevice();
    local.setDiscoverable(DiscoveryAgent.GIAC);
    System.out.println("Start advertising service...");
    server = (StreamConnectionNotifier)Connector.open(url);
    System.out.println("Waiting for incoming connection...");
    conn = server.acceptAndOpen();
    .....
    ...

    I debugged the code and the exception is being thrown on the line
    local = LocalDevice.getLocalDevice();

    Anybody have any idea why this exception is being thrown?


Comments

  • Moderators, Technology & Internet Moderators Posts: 1,337 Mod ✭✭✭✭croo


    have you defined what local is?
    maybe it should be
    LocalDevice local = ....


  • Registered Users, Registered Users 2 Posts: 196 ✭✭juror


    croo wrote: »
    have you defined what local is?
    maybe it should be
    LocalDevice local = ....


    Ya I have local defined as
    LocalDevice local = null;


  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    juror wrote: »
    I'm writing a bluetooth server to run on a dektop pc (dell; winxp sp2).
    But my server is throwing a BluetoohStateException

    Code:

    public MyServer() {
    try {
    System.out.println("Setting device to be discoverable...");
    local = LocalDevice.getLocalDevice();
    local.setDiscoverable(DiscoveryAgent.GIAC);
    System.out.println("Start advertising service...");
    server = (StreamConnectionNotifier)Connector.open(url);
    System.out.println("Waiting for incoming connection...");
    conn = server.acceptAndOpen();
    .....
    ...

    I debugged the code and the exception is being thrown on the line
    local = LocalDevice.getLocalDevice();

    Anybody have any idea why this exception is being thrown?

    What library are you using? What bluetoothstack are you using? What is the full stack trace of the BluetoothStateException?


  • Registered Users, Registered Users 2 Posts: 1,127 ✭✭✭smcelhinney


    Is it NullPointer maybe? Maybe LocalDevice needs to be instantiated ?


  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    Is it NullPointer maybe? Maybe LocalDevice needs to be instantiated ?

    His code is throwing a BluetoothStateException, not a NPE. That particular method is a static method defined in the jsr-82 for retrieving access to the Bluetooth Device. My guess is the bluetooth device is not correctly installed in windows or he is using a jsr-82 implementation that does not support the windows stack.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 196 ✭✭juror


    Well my bluetooth device is a Toshiba make (not at home right now so don't know exact details). The jsr-82 implementation i got with the wireless toolkit i downloaded from the java sun site


  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    juror wrote: »
    Well my bluetooth device is a Toshiba make (not at home right now so don't know exact details). The jsr-82 implementation i got with the wireless toolkit i downloaded from the java sun site

    So its probably using the toshiba stack and not the MS stack. I guess suns reference implementation doesnt work with the toshiba stack. Try download Bluecove or aventana and see if either of them work with toshiba's stack.


Advertisement