Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

New Contributor
Posts: 5
Registered: ‎07-25-2011
My Device: 9300
My Carrier: Orange

Bluetooth setDeviceServiceClasses not working on Curve 9300??

Hi everybody,


I am desesperatly trying to turn my Curve 9300 (Orange carrier, OS5.0 JDE 5.0) into a GPS server (publishing JSR179 NMEA strings) in order to enable external devices to get accurate positioning.


To do so, I wrote a server application (see code below). The code looks to run fine and reaches AcceptandOpen.


The problem I have is that the service is not recognized from the outside as a positioning service (so no connection attempt at all) , and my assumption (but I am perhpas wrong) is that I have an issue with setting the positioning bit in the setDeviceServiceClasses (looks not to work).


I wrote as well a probe thread beside (see also code below)  that is always reporting  Device Service Classes to be decimal 52422880 that is x'500000'  which means bit set for telephony and object transfer. I should in my mind get back x'510000' back taking into account that the additionnal "positioning bit" has been set.(setDeviceServiceClasses(0x10000 )).


Could anyone help ??


Thank you !!



// start bluetooth NMEA server

new Thread(){

    public void run(){

try {

// init bluetooth

    localDevice = LocalDevice.getLocalDevice();

    StringBuffer url = new StringBuffer("btspp://localhost:"+MYSERVICEUUID_UUID.toString()+";name=NMEA-GPS;authorize=false;authenticate=false;encrypt=false");

    // Create notifier (and service record)
    StreamConnectionNotifier streamConnectionNotifier;
    streamConnectionNotifier =    (StreamConnectionNotifier) Connector.open(url.toString());

     sr = localDevice.getRecord(streamConnectionNotifier);

    /* Put it into public browse group */
    DataElement dBrowseGroupList = new DataElement(DataElement.DATSEQ);
    dBrowseGroupList.addElement(new DataElement(DataElement.UUID,new UUID(0x1002 ))); /* PublicBrowseGroup */
    sr.setAttributeValue(0x0005, dBrowseGroupList);/* BrowseGroupList */

// set ServiceAvailability (0x0008) attribute to indicate our service is  available, 0xFF indicate fully available status
      sr.setAttributeValue(0x0008, new DataElement( DataElement.U_INT_1, 0xFF));

    /* Set the Positioning service class bit  and update service record*/
    sr.setDeviceServiceClasses(0x10000 ); /*  Positioning */


// end init bluetooth

// endless loop

while (true) {

    // Wait for client connection
    StreamConnection conn = streamConnectionNotifier.acceptAndOpen();

    // New client connection accepted; get a handle on it
    RemoteDevice rd = RemoteDevice.getRemoteDevice(conn);

    // Read input message, in this example a String
    DataInputStream dataIn = conn.openDataInputStream();
    String s = dataIn.readUTF();

     friendlyname ="Connection: " + rd.getFriendlyName(false) + " Data: "+s;

    // Send NMEA strings back to client
        DataOutputStream dataout =  conn.openDataOutputStream();


} // end endless loop

} catch (Exception e) {trace = trace + " !! Exception !! "+e;}

} /* try */


// ///////////// PROBE CHECK THREAD ////////////////////////////////////:

new Thread(){

    public void run(){

try {

DeviceClass cod;

localDevice = LocalDevice.getLocalDevice();

// Endless loop

while (true) {


    cod = localDevice.getDeviceClass();
    int MajorDeviceClass = cod.getMajorDeviceClass();
    int MinorDeviceClass = cod.getMinorDeviceClass();
    int ServiceClasses = cod.getServiceClasses();

    trace2 = " ServiceClasses:" + ServiceClasses + " MajorDeviceClass:" +
        MajorDeviceClass + " MinorDeviceClass:" + MinorDeviceClass;

// end loop

} catch (Exception e) {trace2 = trace2 + " !! Exception !! "+e;}

} /* try */