×
Namespaces

Variants
Actions
Revision as of 07:33, 30 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

File sharing over Bluetooth initiated by NFC

From Nokia Developer Wiki
Jump to: navigation, search

Contents

Introduction

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
Compatibility
Platform(s): Symbian^3
Symbian^3
Article
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.
inParamList->AppendL(obj);
 
// Send the file via NFC (asynchronous).
iAiwServiceHandler->ExecuteServiceCmdL( KAiwCmdNFCGiveUi, *inParamList,
iAiwServiceHandler->OutParamListL(), 0,
this);
CleanupStack::PopAndDestroy(); // inParamList.
iFile.Close();
iFs.Close();
//misleading return value should be fixed
return error;
}

Examples

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: File:Nfcsharewithbt.zip

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

References

This page was last modified on 30 May 2013, at 07:33.
102 page views in the last 30 days.
×