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.

File sharing over Bluetooth initiated by NFC

From Wiki
Jump to: navigation, search



Nokia implementation enables a handover requester to negotiate an alternative communication carrier with a handover selector over the NFC link. Handover selector device might have multiple alternative carriers (Bluetooth, Wi-fi). Selecting alternative carrier is known as handover. In this code snippet NFC is the initiator carrier that handover connection to Bluetooth technology. The reason behind this is efficiency (for example data rate, distance covered are better in Bluetooth).

Article Metadata
Code ExampleTested with
Devices(s): Nokia C7-00
Platform(s): Symbian^3
Created: mahbub_s60 (27 Dec 2011)
Last edited: hamishwillee (30 May 2013)

Service Handler and NFC

We need to call service command for the NFC provider implementation. Once a service command has been executed, NFC implementation does all the details to find alternating carrier (Bluetooth) and setup connection. Once the connection has been set up data transfer occurs in usual way.

NFC implementation offers three different service handler related commands for these purpose defined in AiwCommon.hrh

Command ID Purposes
KAiwCmdNFCGive = 0x1028245F Give different objects to another device using Near Field Communications.
KAiwCmdNFCGiveUi = 0x10282461 The new command id will be used by clients who want to invoke a request for an NFC-initiated file transfer (an “NFC Give”), and want the AIW provider to show UI elements at various points during the command execution
KAiwCmdNFCEasySetup = 0x2001FE32 Start listening secondary bearer (e.g. Bluetooth) setup events via Near Field Communication.

Following code snippet shows how we call

TInt CNfcAiwEngine::DoFileSendCommandL( const TDesC& aFileName, TInt & error )
error = iFs.Connect();
if (error == KErrNone)
error = iFs.ShareProtected();
if (error == KErrNone)
{// Open file to be shared in read or sharereadonly mode.
error = iFile.Open(iFs, aFileName, EFileRead | EFileShareReadersOnly);
if (error != KErrNone)
return error;
CAiwGenericParamList* inParamList = CAiwGenericParamList::NewLC();
TAiwGenericParam obj(EGenericParamFile, TAiwVariant(iFile));
// Attach the file to inParamList.
// Send the file via NFC (asynchronous).
iAiwServiceHandler->ExecuteServiceCmdL( KAiwCmdNFCGiveUi, *inParamList,
iAiwServiceHandler->OutParamListL(), 0,
CleanupStack::PopAndDestroy(); // inParamList.
//misleading return value should be fixed
return error;


Sharing example can be found from the following link and this has been tested with C7 Belle software. The example can be compiled with Belle SDK. There is a unsigned sis file that can be signed with certificate and install it to devices for testing.

Download the example for C7:

How to use this example

Menu Command Explanation
Start Easy Setup Make paired with alternating carrier, for example Bluetooth
ShareVcard Send a Vcard that is hard coded with code and PKG file
ShareVcal Send Vcal that is hard coded with code and pkg file
SelectAny Select any file from the device and then touch other device to share it, basically same like previous two menu but it allow you to select and send it from device by browsing the folder.

Nfcsharereceve.jpg Nfcsharesending.jpg


This page was last modified on 30 May 2013, at 04:33.
68 page views in the last 30 days.