# Control sensor features This sample application demonstrates how to control sensor features. 1. Get sensor factory instance auto &sensorFactory = telux::sensor::SensorFactory::getInstance(); Copy to clipboard 2. Prepare a callback that is invoked when the sensor sub-system initialization is complete std::promise p; auto initCb = [&p](telux::common::ServiceStatus status) { std::cout << "Received service status: " << static_cast(status) << std::endl; p.set_value(status); }; Copy to clipboard 3. Get the sensor feature manager. If initialization fails, perform necessary error handling std::shared_ptr sensorFeatureManager = sensorFactory.getSensorFeatureManager(initCb); if (sensorFeatureManager == nullptr) { std::cout << "sensor feature manager is nullptr" << std::endl; exit(1); } std::cout << "obtained sensor feature manager" << std::endl; Copy to clipboard 4. Wait until initialization is complete p.get_future().get(); if (sensorManager->getServiceStatus() != telux::common::ServiceStatus::SERVICE_AVAILABLE) { std::cout << "Sensor service not available" << std::endl; exit(1); } Copy to clipboard 5. Get information regarding available sensor features std::cout << "Sensor feature service is now available" << std::endl; std::vector sensorFeatures; telux::common::Status status = sensorFeatureManager->getAvailableFeatures(sensorFeatures); if (status != telux::common::Status::SUCCESS) { std::cout << "Failed to get information on available features" << static_cast(status) << std::endl; exit(1); } std::cout << "Received sensor features" << std::endl; for (auto feature : sensorFeatures) { printSensorFeatureInfo(feature); } Copy to clipboard 6. Create and register a sensor feature event listener std::shared_ptr sensorFeatureEventListener = std::make_shared(); sensorFeatureManager->registerListener(sensorFeatureEventListener); Copy to clipboard 7. Enable the required features status = sensorFeatureManager->enableFeature(name); if (status != telux::common::Status::SUCCESS) { std::cout << "Failed to enable feature: " << name << std::endl; exit(1); } Copy to clipboard Note: Enabling a sensor feature when the system is active would additionally require enabling the corresponding sensor which is used by the sensor feature. If the sensor feature only needs to be enabled during suspend mode, just enabling the sensor feature using this method would be sufficient. The underlying framework would take care to enable the required sensor when the system is about to enter suspend state. 8. Receive sensor feature events with the registered listener when device is not suspended virtual void onEvent(telux::sensor::SensorFeatureEvent event) override { printSensorFeatureEvent(event); } Copy to clipboard 9. Receive sensor feature events with the registered listener when device in suspended state virtual void onBufferedEvent(std::string sensorName, std::shared_ptr> events, bool isLast) override { printSensorFeatureEvent(event); } Copy to clipboard 10. When the sensor feature(s) are no longer necessary, disable them status = sensorFeatureManager->disableFeature(name); if (status != telux::common::Status::SUCCESS) { std::cout << "Failed to disable feature: " << name << std::endl; exit(1); } Copy to clipboard 11. Release the instance of ISensorFeatureManager to cleanup resources sensorFeatureManager = nullptr; Copy to clipboard Last Published: Jun 24, 2026 [Previous Topic Configure and acquire sensor data](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/sensor_data_acquisition.md) [Next Topic Platform](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/platform.md)