Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2004

    Get local Bluetooth Address with v8.0a

    I need to access the local Bluetooth address in an application I'm developing. The phone is an N70, so I'm using Series 60 SDK 2.6.

    There is a previous thread on this, with respect to Symbian v7.0s:

    In fact, that code does work on a v7.0s phone that I have. However, with version 8.0a, I'm receiving all zeros as the Bluetooth address. Here are two code snippets I have tried:

    The first, based on that previous post:

    TPckgBuf<TBTDevAddr> iDevAddr;
    RSocket iSocket;
    RSocketServ iSocketServer;
    TProtocolDesc protocolInfo;
    User::LeaveIfError(iSocketServer.FindProtocol(_L("BTLinkManager"), protocolInfo));
    TRequestStatus aStatus;
    TBuf<128> aAddr;

    iSocket.Ioctl(KHCILocalAddressIoctl, aStatus, &iDevAddr, KSolBtHCI);
    iDevAddr().GetReadable(aAddr, _L("btaddr: "), _L(":"), _L("Q"));

    THCILocalVersionBuf lvb;
    lvb().iLMPSubversion=0; // just for testing if nothing happens
    iSocket.Ioctl(KHCILocalVersionIoctl, aStatus, &lvb, KSolBtHCI);
    iLog->WriteFormat(_L("%d %d %d %d %d\n"),

    Much to my surprise, this code successfully reads the local version information, but not the bluetooth address.

    Here is another snippet I've tried, which also returns all zeros for the Bluetooth address:

    TInt result = iListeningSocket.Open(iSocketServer, KServerTransportName /*RFCOMM*/);
    if (result != KErrNone)

    // Get a channel to listen on - same as the socket's port number
    TInt channel;
    KSolBtRFCOMM, channel));
    iFileLog->WriteFormat(_L("Channel %d"),channel);
    TBTSockAddr listeningAddress;

    TBuf<128> aAddr;
    TBTDevAddr iDevAddr;
    iDevAddr = listeningAddress.BTAddr();
    iDevAddr.GetReadable(aAddr, _L("BTADDR: "), _L(":"), _L("R"));

    I often get channel 4 out of this snippet, but no bluetooth address.

    I'm guessing there is some kind of API change between v7.0s and v8.0a/v8.1a that affects this behavior, since there were similar changes wrt the Bluetooth security settings.

    I'm building this stuff in Carbide C++ Express v1.1 with the ARMI target for S60 2.6.

    Can anybody help me out?


  2. #2
    Registered User
    Join Date
    Feb 2004

    Re: Get local Bluetooth Address with v8.0a

    So I figured this out. In v8.0a one should use the "Publish-Subscribe API". It actually says this in the README_BLUETOOTH.txt file which comes with the 2.6 API:

    Bluetooth Changes
    Due to introduction of new architecture there are changes in bluetooth
    api which will impact new application development.The major changes
    that are required from developer perspective are listed below.

    Stack/Hardware Settings
    Publish and subscribe method is provided for setting the stack
    settings.The bluetooth stack publishes the values of its various
    settings in the category KPropertyUidBluetoothCategory and applications
    can request that settings be changed by setting the value of
    the equivalent property in the KPropertyUidBluetoothControlCategory.

    Therefore a typical pattern for an application wishing to set the
    device discoverable would be:
    1. Subscribe to the key of interest in the Bluetooth category.
    2. Call the RProperty::Set(...) method on the matching key in the
    Bluetooth Control category.
    3. When the stack has serviced the request, it will re-publish
    the new value of the key (whether changed or unchanged)
    on the Bluetooth category, calling the RunL of any subscribers

    The Available property keys are
    Key: KpropertyKeyBluetoothLocalDeviceAddress
    Type: ByteArray
    Description: The Local Device Address as a
    descriptor (BluetoothCategory only)

    A quick Google search on KpropertyKeyBluetoothLocalDeviceAddress lead me to this page at NewLC:

    TPckgBuf<TBTDevAddr> aDevAddrPckg;
    TInt error = RProperty::Get(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothLocalDeviceAddress, aDevAddrPckg);

    Two lines. That's much better! If only it wasn't so f***ing impossible to find this information in a reasonable period of time.

Similar Threads

  1. Replies: 0
    Last Post: 2006-02-05, 14:25
  2. Help to get local bluetooth address on Symbian OS 8
    By kkboy1 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-09-13, 18:09
  3. Local Bluetooth device address??
    By timbe78 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2005-06-05, 04:01
  4. local bluetooth address
    By sopta007 in forum Symbian
    Replies: 1
    Last Post: 2004-01-14, 10:39
  5. Local Bluetooth address?
    By liloulouli in forum Bluetooth Technology
    Replies: 2
    Last Post: 2003-12-17, 10:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts