The controller is the device that sends commands to a target device.
Intended Audience:
This tutorial is designed for Symbian licensees and 3rd party application developers.
The following tasks will be covered in this tutorial:
Starting a Connectionless controller
Starting a Connection-Oriented controller
Stopping a controller
Basic procedure
The high level steps to start a controller are:
Create a controller interface by instantiating an interface selector using CRemConInterfaceSelector::NewL() , as shown here:
CRemConInterfaceSelector* iInterfaceSelector; iInterfaceSelector = CRemConInterfaceSelector::NewL();
Create a core remote control API controller and add the interface selector created above as shown here:
CRemConCoreApiController* iCoreController; iCoreController = CRemConCoreApiController::NewL(*iInterfaceSelector, *this);
Open the interface created above using CRemConInterfaceSelector::OpenControllerL() .
iInterfaceSelector->OpenControllerL();
The Target Selector Plugin (TSP) discovers the bearer and device address of target devices as required.
The first part of starting your Connection-Oriented controller is the same as that described above for starting a connectionless controller, but to go Connection-Oriented you will need to provide two additional pieces of information, the device address and the bearer.
The following code, which constructs a TUid , shows how to set information about the AVRCP bearer (it may be different for other bearers):
... TUid iBearerUid; RBuf8 iBearerData; iBearerUid = TUid::Uid(KAvrcpBearerUid);
To get the device address you can either use the SDP, a notifier, or the following:
GetDeviceAddressL() { // MTestManager iManager; iManager.MtmWrite( _L8( "Type device address and press enter\n0x" ) ); // Read address in unicode as human readable TBuf<12> buf; iManager.MtmRead( buf ); // Translate to machine readable TBTDevAddr btAddr; LEAVEIFERRORL( btAddr.SetReadable( buf ) ); // Store as 8 bit machine readable iBearerData.Close(); iBearerData.CreateL( btAddr.Des() ); }
Now that you have the device address and bearer information you can start the Connection-Oriented controller by adding the bearer and Bluetooth device address information to the addr using the TRemConAddress::BearerUid() and TRemConAddress::Addr() functions as follows:
TRemConAddress addr; addr.BearerUid() = iBearerUid; addr.Addr() = iBearerData; iInterfaceSelector->GoConnectionOrientedL( addr );
The CRemConInterfaceSelector::GoConnectionOrientedL() function makes the controller Connection-Oriented.
Switching to Connectionless
It is possible to switch a Connection-Oriented controller to connectionless if necessary. The CRemConInterfaceSelector::GoConnectionlessL() is used as shown here:
iInterfaceSelector->GoConnectionlessL();
Of course you can also switch back to a Connection-Oriented controller as needed.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.