Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to get local Bluetooth Device Address

From Wiki
Jump to: navigation, search
Article Metadata
Platform Security
Capabilities: LocalServices
Created: patrickfrei (31 Jul 2007)
Last edited: hamishwillee (30 May 2013)

Usually, the local bluetooth address of a device can be retrieved by typing the following star-hash code: *#2820# (*#BTA0#) The following code retrieves your local bluetooth device address programatically (Symbian 3rd ed.).

Example code

Header files:

#include <bttypes.h>
#include <bt_subscribe.h>





The following Int, Uid & Uint values are provided in bt_subscribe.h:

const TInt KUidBluetoothPubSubKeyBase = 0x10203637;
const TUid KPropertyUidBluetoothCategory = {KUidSystemCategoryValue};
const TUint KPropertyKeyBluetoothGetLocalDeviceAddress =
(KUidBluetoothPubSubKeyBase + 0);

The following Int32 & Uid values are provided in e32_property.h (included in bt_subscribe.h):

static const TInt32 KUidSystemCategoryValue=0x101f75b6;
static const TUid KUidSystemCategory={KUidSystemCategoryValue};

The following code retrieves the unique Bluetooth HEX-address:

TBuf<20> aBTAddr;
TPckgBuf<TBTDevAddr> aDevAddrPckg;
KPropertyKeyBluetoothGetLocalDeviceAddress, aDevAddrPckg);
aDevAddrPckg().GetReadable(aBTAddr, KNullDesC, _L(":"), KNullDesC);

Note: The Bluetooth HEX-address will be stored in aBTAdd and contains exactly 17 characters in the format 00:00:00:00:00:00 (i.e. including 5 colons).

This page was last modified on 30 May 2013, at 23:27.
135 page views in the last 30 days.