When an application is registered to listen to the LLCP-link status, CLlcpProvider
calls the MLlcpLinkListener::LlcpRemoteFound()
method when two NFC-enabled devices with LLCP support are placed
together and the MLlcpLinkListener::LlcpRemoteLost()
method when the devices are separated. When the MLlcpLinkListener::LlcpRemoteFound()
method is called, the data transfer is possible between the local
and the remote devices.
Create a connection-object between the local and remote devices to send the "Hello World!" ASCII text.
The following
code snippet illustrates how the CMyOwnLlcpApplication::LlcpRemoteFound
method is implemented:
// CMyOwnLlcpApplication::LlcpRemoteFound() // From MLlcpLinkListener // ----------------------------------------------------------------------------- // void CMyOwnLlcpApplication::LlcpRemoteFound() { TInt error = KErrNone; MLlcpConnLessTransporter* conn = NULL; // Notify the UI. iLLcpEventUpdater->DrawLlcpRemoteFound(); // Pointer of the MLlcpConnLessTransporter object is // stored to the iLocalConnection member variables. if ( !iLocalConnection ) { // Create the MLlcpConnLessTransporter object. TRAP( error, conn = iLlcp->CreateConnLessTransporterL( KInterestingSsap ) ); if ( error == KErrNone ) { // Create a connection wrapper to send data to the remote device. TRAP( error, iLocalConnection = COwnLlcpConnection::NewL( conn ) ); if ( error != KErrNone ) { delete conn; } } } } // ----------------------------------------------------------------------------- // End of CMyOwnLlcpApplication::LlcpRemoteFound()
Note: CLlcpProvider
does not deallocate
any memory block related to theMLlcpConnLessTransporter
object. Clients can remove the MLlcpConnLessTransporter
object at any time.
The following
code snippet illustrates how the CMyOwnLlcpApplication::LlcpRemoteLost
method is implemented. When this method is called, the data transfer
between the local and the remote devices stops, and all existing MLlcpConnLessTransporter
objects are removed.
// CMyOwnLlcpApplication::LlcpRemoteLost() // From MLlcpLinkListener // ----------------------------------------------------------------------------- // void CMyOwnLlcpApplication::LlcpRemoteLost() { Cleanup(); // Notify the UI. iLLcpEventUpdater->DrawLlcpRemoteLost(); } // ----------------------------------------------------------------------------- // End of CMyOwnLlcpApplication::LlcpRemoteLost()