Detailed Description
The Accessory Monitoring API interface offers accessory information about connected accessories. It also offers an easy-to-use implementation of a CActive-based wrapper for accessory connection status changed event notifications. The clients can get information about the connected accessories capabilities and, if the capabilities have values, get the values from these capabilites. This API consist of classes CAccMonitor, CAccMonitorInfo and MAccMonitorObserver. If the user wants to use the observer this API offers, the user has to implement callback function for receiving accessory connection and disconnection status notifications. The connected accessories are offered to the client in an array. This array presents the connected accessories as instances of CAccMonitorInfo class. The CAccMonitorInfo offers accessory information encapsulated to a class. It presents accessory device type, physical connection and device address information with basic getter functions. The rest of the accessories features are contained in an array. This array can be accessed with functions that are in CAccMonitorInfo. This class is not intended for user derivation.
Usage:
Example query for some accessory's information. All connected accessories are fetched and the instance of CAccessoryInfo is getted:
CAccMonitor* accMonitor = CAccMonitor::NewLC();
RConnectedAccessories connectedAccessories;
CleanupClosePushL( connectedAccessories );
accMonitor->GetConnectedAccessoriesL( connectedAccessories );
CAccMonitorInfo* accInfo = CAccMonitorInfo::NewLC();
TInt countOfArray = connectedAccessories.Count();
for( TInt i = 0; i != countOfArray; i++ )
{
TAccMonCapability deviceType = connectedAccessories[ i ]->AccDeviceType();
if( deviceType == KAccMonHeadset )
{
// Some Headset is connected, get the information to accInfo
accInfo->CopyL( connectedAccessories[ i ] );
}
}
// Destroy the pointers from the array, because those are owned by the client
CleanupStack::PopAndDestroy( accInfo );
CleanupStack::PopAndDestroy( &connectedAccessories );
CleanupStack::PopAndDestroy( accMonitor );
Example query for some accessorys capabilties. The user has fetched the
CAccMonitorInfo to accInfo instance from connected accessories:
TInt arrayCount = accInfo->Count();
for( TInt i = 0; i != arrayCount; i++ )
{
TAccMonCapability accCapa = accInfo->AccCapabilityAtIndex( i );
if( accCapa == KAccMonStereoAudio )
{
// Accessory has stereo capability, handle this situation.
}
}
Initialization example for the observer(from a class that implements
MAccMonitorObserver interface). Observer starts to listen for headset connects:
CAccMonitor* accMonitor = CAccMonitor::NewLC();
RAccMonCapabilityArray capabilityArray;
CleanupClosePushL( capabilityArray );
capabilityArray.Append( KAccMonHeadset );
accMonitor->StartObservingL( this, capabilityArray );
CleanupStack::PopAndDestroy( &capabilityArray );
CleanupStack::PopAndDestroy( accMonitor );
Uninitialization example:
accMonitor->StopObserving();
Connected method implementation example:
void CMyAccMonitorTest::Connected( CAccMonitorInfo* aAccessoryInfo )
{
// Notification about the connected accessory. aAccessoryInfo must
// be copied because the pointer is deleted after connected method
iAccessoryInfo->CopyL( aAccessoryInfo );
}