Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Bluetooth Problem

  • 12-01-2008 10: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,336 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 Posts: 2,013 ✭✭✭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 Posts: 2,013 ✭✭✭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 Posts: 2,013 ✭✭✭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