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 find Bluetooth device name by touching two NFC devices
Near field communication (NFC) is not new technology but has received momentum after introducing NFC forum. NFC forum generates specification in such a way compatible devices are interoperable. NFC devices are integrated circuit (IC) that can generate magnetic field (Active) or can be induced by magnetic field (Passive). The magnetic field frequency is 13.56 Mz. The passive tag relies on the RF energy it receives to power the tag from active device. Any way we discuss more details about NFC/RF in separate article. In this article we are going to show and explain how we can use Symbian API to know the Bluetooth device name of another device.
Why we need to know Bluetooth address
Typically how we use Bluetooth devices? We start searching the devices with our Nokia devices and we wait a bit and get a list of devices and from there we select the device and get the address and then we can pair with other device by exchanging passkey and connect. This is a bit lengthy process. This time can be reduced dramatically by using NFC. Another most useful case, pairing with headset. We just touch headset with NFC phone and it is connected automatically.
Using Symbian API
To identify Bluetooth device, Symbian platform use AIW service API (AIW Criteria API). A resource is created based on the service command id (KAiwCmdNFCEasySetup) with other necessary parameters. The parameters can be generated also by code. In this example we are using resource to generate it.
RESOURCE AIW_INTEREST r_example_app_aiw_nfc_bt_interest
id = 20001;
serviceCmd = KAiwCmdNFCEasySetup;
contentType = "*";
serviceClass = KAiwClassBase;
maxProviders = 1;
Now we can create AIW command with the following code.
iMyNfcBtHandler = CAiwServiceHandler::NewL();
iMyNfcBtHandler->AttachL( R_EXAMPLE_APP_AIW_NFC_BT_INTEREST );
iMyNfcBtHandler->ExecuteServiceCmdL( KAiwCmdNFCEasySetup, iMyNfcBtHandler->InParamListL(), iMyNfcBtHandler->OutParamListL(), KAiwOptASyncronous, this );
Now we get call back in our code where we can extract the Bluetooth device name.
const CAiwGenericParamList& aInParamList)
if( aCmdId == KAiwCmdNFCEasySetup )
for (int i = 0; (i < aEventParamList.Count()); i++)
TAiwVariant parameterValue = aEventParamList[i].Value();
TPtrC8 data = parameterValue.AsData(); // data contains Device name, Address and CoD
TPtrC8 name = data.Mid(data.Length()-data, data); // BT Device name
TPtrC8 data = parameterValue.AsData();
TPtrC8 name = data.Mid(data+3, 6); // BTAddress
Also note there is a bug in platform API, BT device name come 2 times
The following code was used to test the API with two C7 devices. If we touch the devices each other it prints the Bluetooth device name of other device in UI. If we want to get notification every time, we have to generate AIW command each time.
- Download the example for C7: File:NFCBtDeviceName.zip