Service creation

ulysse57
2005-04-13
2013-04-15
  • ulysse57

    ulysse57 - 2005-04-13

    Hello,

    I am writing an application to establsih a connection between a server with avetana under Linux and a mobile phone. I tried to create a service on the mobile phone and to scan this service with the server. This works fine.

    I want now to do this with a service on the server. So I tried to create a service on the server with avatana bluetooth but it seems that this function is not yet implemented. Are you planning to implement it soon or do you have an alpha version ?

    Many thanks.

     
    • Moritz Gmelin

      Moritz Gmelin - 2005-04-13

      Server functionality is fully implemented and working in avetanaBluetooth.
      What exactly is your problem ?

      M.

       
    • ulysse57

      ulysse57 - 2005-04-13

      When I try to set the device service class on the server with avetana with setDeviceServiceClasses method, avetana returns an exception :
      "...: Method setDeviceServiceClasses not yet implemented ..."
      I don't know if a bluetooth link can work well if I don't precise the service class.

       
    • n1ck

      n1ck - 2005-04-13

      I have a similar problem - I have an existing l2cap based bluetooth server application on linux. When running it with avetana I get an error message:
      " java.lang.RuntimeException : Not Implemented! Used to compile Code" at the point of opening an L2CAPConnectionNotifier.

      With thanks,

      N

       
      • Moritz Gmelin

        Moritz Gmelin - 2005-04-13

        Could you please post the piece of code where this happens ?

        Setting the DeviceClass or DeviceService class is not supported with avetanaBluetooth (because the underlying stack does not support this.)

         
    • n1ck

      n1ck - 2005-04-13

      String url = "btl2cap://localhost:58DDE9C900001000800000805F9B34FB;ReceiveMTU=512;TransmitMTU=512";
      L2CAPConnectionNotifier notifier = (L2CAPConnectionNotifier)Connector.open(url); -- Will error at this point.

      With thanks,

      N

       
      • Moritz Gmelin

        Moritz Gmelin - 2005-04-13

        Could it be that you have a VERY old version of avetanaBluetooth ? Try downloading a trial version from

        www.avetanabluetooth.com

        it will run on linux without any limitation.

        M.

         
    • n1ck

      n1ck - 2005-04-13

      I tried with this version (1st March 2005). I also checked out the latest code from cvs, and tried with this, with the same result (though initially I couldn't get the latest code to compile - it threw this compiliation error:

      BlueZ.cpp: In function `jint Java_de_avetana_bluetooth_stack_BlueZ_hciLinkQuality(JNIEnv*, _jclass*, _jstring*)':
      BlueZ.cpp:371: error: `read_link_quality_rp' undeclared (first use this function)
      BlueZ.cpp:371: error: (Each undeclared identifier is reported only once for each function it appears in.)
      BlueZ.cpp:371: error: expected `;' before "rp"
      BlueZ.cpp:400: error: `OCF_READ_LINK_QUALITY' undeclared (first use this function)
      BlueZ.cpp:403: error: `rp' undeclared (first use this function)
      BlueZ.cpp:404: error: `READ_LINK_QUALITY_RP_SIZE' undeclared (first use this function)

      So I commented out the body of this method (since I don't need this) and it compiled fine. But still produces the same error on trying to register an L2CAP service.

       
    • n1ck

      n1ck - 2005-04-13

      Stepping through the code the problem seems to be happening in the "L2CAPConnection acceptAndOpen()" method of de.avetana.bluetooth.l2cap.L2CAPConnectionNotifierImpl at these lines:      m_serviceHandle=BlueZ.createService((LocalServiceRecord)myRecord);
      if(m_serviceHandle < 0) throw new Exception();

      but m_serviceHandle is -122699768, so the exception is thrown.

      If I can figure out how to debug JNI I'll try dig further.

      With thanks,

      N

       
      • Moritz Gmelin

        Moritz Gmelin - 2005-04-13

        Seems to be a problem with your BlueZ library or installation.

         
    • n1ck

      n1ck - 2005-04-13

      Hitherto my BlueZ installation has seemed pretty solid - the same code works well with the Impronto JSR82 library (which also sits on top of BlueZ).

      Thanks,
      N

       
    • ulysse57

      ulysse57 - 2005-04-26

      hi,
      excuse me for the delay
      here is the code I use to create the server.

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

      public class BTServeur implements Runnable
      {
          LocalDevice device;
          DiscoveryAgent agent;
         
          public final static UUID uuid = new UUID("102435621AFF001", false);
         
          public StreamConnectionNotifier server;
         
          public BTServeur()
          {
              try
              {
                  device = LocalDevice.getLocalDevice();
                  device.setDiscoverable(DiscoveryAgent.GIAC);
                 
                  Thread t = new Thread( this );
                  t.start();
              }catch(Exception e){e.printStackTrace();}
          }
         
          public void run()
          {
              String nom = "BTServeur";
              StreamConnection c = null;
              String url = "btspp://localhost:" + uuid.toString() +";name="+ nom;
             
              System.out.println("url : "+url);
             
              try
              {
                  server =  (StreamConnectionNotifier)Connector.open(url);
                 
                  ServiceRecord rec = device.getRecord( server );
                 
                  rec.setAttributeValue( 0x0008, new DataElement( DataElement.U_INT_1, 0xFF ) );
                 
                 
                  rec.setDeviceServiceClasses( 0x400000  );
              } catch (Exception e) { e.printStackTrace(); }
             
              while(true)
              {
                  try
                  {
                      c = server.acceptAndOpen();
                  }catch(Exception e){ e.printStackTrace(); }
              }
          }
         
          public void main1(String[] args)
          {
              new BTServeur();
          }
      }

       
    • Jim Wyllie

      Jim Wyllie - 2005-10-23

      I have this error on a somewhat brain-damaged Fedora Core 3 server, though it works on a Gentoo Linux box (same code / library).  I'm looking into this and will post more information when I can get it. 

       
    • Jim Wyllie

      Jim Wyllie - 2005-10-23

      Alright everyone... for the first question posted, the error is that your Device Class doesn't support this.  This can be changed by modifying the class definition in your hcid.conf file (located, probably, in /etc/bluetooth) to 0x0x3e0100.  Not quite sure what all of the classes mean (I know they get various features by setting bits) but this fixed the problem for me.

      Hope this helps.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks