0 Replies Latest reply: Nov 27, 2012 3:26 AM by 976400 RSS

    Ubuntu and API bluecove : java and bluetooth

    976400
      Hi

      Here is my final project I want study worked with bluecove api (java bluetooth technology) and J2ME you guessed I am looking to make contacts and nokia laptop via bluetooth

      then voila I first exposed my equipment:

      hp laptop duel core processor, 200 gig hard drive, 2 GB rowing bone ubuntu 10.10 and set a date and I installed the bluetooth driver that ubuntu recommended me short I followed this short course:

      http://myexp101.wordpress.com/2011/11/11/develop-java-bluetooth-application-under-ubuntu-linux/

      for the library installed on ubuntu bluecove then I tested a small java program:

      http://www.miniware.net/mobile/programs/EchoServer.java

      to see that Bluetooth is enabled and can detect the presence of mobile phone nokia

      I created a test project in eclipse and I joined the library in my project brief bluecove here is the program:

      import java.io.*;
      import javax.bluetooth.*;
      import javax.microedition.io.*;

      public class EchoServer {
      public final UUID uuid = new UUID( //the uid of the service, it has to be unique,
                     "27012f0c68af4fbf8dbe6bbaf7aa432a", false); //it can be generated randomly
      public final String name = "Echo Server"; //the name of the service
      public final String url = "btspp://localhost:" + uuid //the service url
      + ";name=" + name
      + ";authenticate=false;encrypt=false;";
      LocalDevice local = null;
      StreamConnectionNotifier server = null;
      StreamConnection conn = null;

      public EchoServer() {
      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();
      System.out.println("Client Connected...");
      DataInputStream din = new DataInputStream(conn.openInputStream());
      while(true){
      String cmd = "";
      char c;
      while (((c = din.readChar()) > 0) && (c!='\n') ){
      cmd = cmd + c;
      }
      System.out.println("Received " + cmd);
      }

      } catch (Exception e) {System.out.println("Exception Occured: " + e.toString());}
      }

      public static void main (String args[]){
      EchoServer echoserver = new EchoServer();
      }

      }

      here is the result of the execution in eclipse:

      Setting device to be discoverable...
      BlueCove version 2.1.1-SNAPSHOT on bluez
      Exception Occured: javax.bluetooth.BluetoothStateException: Bluetooth Device is not ready. [1] Operation not permitted
      BlueCove stack shutdown completed

      Do you have an idea for solving the problem?

      cordially