/* * FindSensorL is used to find if a specific sensor is available on the * device, if FindSensorL leaves then the sensor is not supported */ void CSensorBackendSym::FindSensorL() { // This method scans the device for the availability // of specified sensor using Sensor APIs CSensrvChannelFinder* finder = CSensrvChannelFinder::NewLC(); RSensrvChannelInfoList channelList; TSensrvChannelInfo channelInfo; channelInfo.iChannelType = iBackendData.iSensorType; // Retrieve the list of channels available finder->FindChannelsL( channelList, channelInfo ); CleanupStack::PopAndDestroy(finder); // Iterate the channel list and look for required sensor for (TInt i = 0; i<channelList.Count(); i++) { // Iterate the available channels if (channelList[i].iChannelType == iBackendData.iSensorType) { // Required sensor found iBackendData.iChannelInfo = channelList[i]; channelList.Close(); return; } } // Required sensor not found, leave with error channelList.Close(); iBackendData.iSensorAvailable = EFalse; User::Leave(KErrNotFound); }
void HbSensorListener::startSensorChannel() { #ifdef Q_OS_SYMBIAN CSensrvChannelFinder *sensrvChannelFinder = CSensrvChannelFinder::NewLC(); RSensrvChannelInfoList channelInfoList; CleanupClosePushL(channelInfoList); TSensrvChannelInfo mySearchConditions; //Search only Orientation events. mySearchConditions.iChannelType = KSensrvChannelTypeIdOrientationData; TRAPD(err, sensrvChannelFinder->FindChannelsL(channelInfoList, mySearchConditions)); if (!err) { if (channelInfoList.Count()) { TRAP(err, mSensrvChannel = CSensrvChannel::NewL(channelInfoList[0])); if (!err) { TRAP(err, mSensrvChannel->OpenChannelL()); if (!err) { TRAP_IGNORE(mSensrvChannel->StartDataListeningL(this, 1, 1, 0)); } else { qWarning("HbSensorListener::startSensorChannel fails, error code = %d", err); } } } channelInfoList.Close(); CleanupStack::Pop(&channelInfoList); CleanupStack::PopAndDestroy(sensrvChannelFinder); } else { qWarning("HbSensorListener::startSensorChannel fails, error code = %d", err); } #endif }
// ---------------------------------------------------------------------------------- // CSSYControlOrientation::CreateAndRegisterChannelsL() // ---------------------------------------------------------------------------------- // void CSSYControlOrientation::CreateAndRegisterChannelsL( const TSSsyChannelInfo* aChannelConfigurations, const TUint aNumberofConfigurations ) { SSY_TRACE_IN(); ASSERT_ALWAYS_SSY( aChannelConfigurations ); ASSERT_ALWAYS_SSY( aNumberofConfigurations ); RSensrvChannelInfoList channelInfoList; for ( TInt index = 0; index < aNumberofConfigurations; index++ ) { CSSYChannel* channel( NULL ); TSensrvChannelInfo channelInfo ( aChannelConfigurations[index].iChannelId, aChannelConfigurations[index].iContextType, aChannelConfigurations[index].iQuantity, aChannelConfigurations[index].iChannelType, aChannelConfigurations[index].iLocation, aChannelConfigurations[index].iVendorId, aChannelConfigurations[index].iDataItemSize, aChannelConfigurations[index].iDataTypeId ); switch ( channelInfo.iChannelType ) { case KSensrvChannelTypeIdOrientationData: // Intentional flowthrough case KSensrvChannelTypeIdRotationData: channel = CSSYChannel::NewL( iSensorProperties, iCallback, channelInfo ); break; default: ASSERT_ALWAYS_SSY( 0 ); break; } if ( channel ) { User::LeaveIfError(iChannelArray.Append( channel )); User::LeaveIfError(channelInfoList.Append( channelInfo)); } } // Register channels to the client SSY_TRACE_TRAP( err, iCallback->RegisterChannelsL( channelInfoList ) ); // Update ChannelId for ( TInt i = 0; i < iChannelArray.Count(); i++ ) { (*iChannelArray[i]).SetChannelId( channelInfoList[i].iChannelId ); } channelInfoList.Reset(); channelInfoList.Close(); SSY_TRACE_OUT(); }
void CSensorListener::ConstructL(TUint32 aSensorType) { CSensrvChannelFinder* sensrvChannelFinder = CSensrvChannelFinder::NewLC(); RSensrvChannelInfoList channelInfoList; CleanupClosePushL(channelInfoList); TSensrvChannelInfo mySearchConditions; mySearchConditions.iChannelType = aSensorType; sensrvChannelFinder->FindChannelsL(channelInfoList,mySearchConditions); if (channelInfoList.Count()) { iSensrvChannel = CSensrvChannel::NewL(channelInfoList[0]); } channelInfoList.Close(); CleanupStack::Pop( &channelInfoList ); CleanupStack::PopAndDestroy( sensrvChannelFinder ); }