×
Namespaces

Variants
Actions

NFC Chat Application with Symbian LLCP API

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Created: mahbub_s60 (22 Jun 2011)
Last edited: hamishwillee (25 Jul 2012)

Introduction

Near field communication (NFC) is not new technology but has received momentum after introducing NFC forum. NFC forum generates specification in such a waythat compatible devices are interoperable. There are three major ways to communicate with NFC devices. These are:
Peer to peer mode
Two NFC enabled devices actively communicate with each other.
Card emulation mode
In this mode, phone behaves just like a tag.
Reader Writer mode
In this mode, phone can read and write data to passive tag.

In this code snippet we are going to use logical link control protocol (LLCP) and show how we can use native Symbian API to communicate between two devices.

Logical Link Control Protocol

The Logical Link Control Protocol (LLCP) specification provides the procedural means for the transfer of upper layer information units between two NFC Forum Devices.
It provides a reliable communication channel between the local and the remote Logical Link Control (LLC) that provides the transport for all data link connections and logical data links.


Starts listening for connection-less requests. Once remote peer has sent the first data packet to specified service access point MLlcpConnLessListener::FrameReceived method will be called. Only MLlcpConnectionListener object can be attached to given service at a time.

void CMyConnectionLessNFCHandler::Start()
{
if ( !iStarted )
{
// Adding LLCP link listener
iLlcp->AddLlcpLinkListenerL( *this );
 
// Adding listener to SSAP 35. If any Connection-less transport
// messages is sent to SSAP 35, this listener will handle them.
iLlcp->StartListeningConnLessRequestL( *this, KInterestingSsap );
 
iStarted = ETrue;
}
}


To get notification about remote device connection we need to implement MLlcpConnLessListener interface.

void CMyConnectionLessNFCHandler::FrameReceived( MLlcpConnLessTransporter* aConnection )
{
TInt error = KErrNone;
 
// Only accepting one incoming remote connection
if ( !iRemoteConnection )
{
// Creating wrapper for connection.
TRAP( error, iRemoteConnection = COwnLlcpConnection::NewL( aConnection ) );
if ( error == KErrNone )
{
// Start receiving data
iRemoteConnection->Receive( *this );
}
else
{
delete aConnection;
}
}
else
{
delete aConnection;
}
}


Download the example for C7: File:Symbianllcp.zip

This page was last modified on 25 July 2012, at 08:58.
63 page views in the last 30 days.