How to get local Bluetooth Device Address
Article Metadata
Platform Security
Capabilities: LocalServices
Article
Created: patrickfrei
(31 Jul 2007)
Last edited: hamishwillee
(31 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>
Library:
bluetooth.lib
Capabilities:
LocalServices
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;
RProperty::Get(KUidSystemCategory,
KPropertyKeyBluetoothGetLocalDeviceAddress, aDevAddrPckg);
aDevAddrPckg().GetReadable(aBTAddr, KNullDesC, _L(":"), KNullDesC);
aBTAddr.UpperCase();
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).


10 Sep
2009
This example demonstrates how to obtain bluetooth address of the current device. You could obtain this information if you type special number *#2820# with the help of keyboard on device. Or you could obtain this address with the help of the code snippet from this article. Bluetooth address of a device could help you in case of identification.
This code works fine on my Nokia 5800.