# Get/Set autoshutdown modes

This sample app demonstrates how to get/set thermal autoshutdown mode.

1. Get thermal factory instance

auto &thermalFactory = telux::therm::ThermalFactory::getInstance();
    Copy to clipboard

2. Prepare initialization callback

std::promise<telux::common::ServiceStatus> p;
    auto initCb = [&p](telux::common::ServiceStatus status) {
         std::cout << "Received service status: " << static_cast<int>(status) << std::endl;
         p.set_value(status);
    };
    Copy to clipboard

3. Get thermal shutdown manager instance

thermShutdownMgr_ = thermalFactory.getThermalShutdownManager(initCb);
    if(thermShutdownMgr_ == NULL)
    {
       std::cout << APP_NAME << " *** ERROR - Failed to get manager instance" << std::endl;
       return -1;
    }
    Copy to clipboard

4. Wait for the initialization callback and check the service status

telux::common::ServiceStatus serviceStatus = p.get_future().get();
    if(serviceStatus == telux::common::ServiceStatus::SERVICE_AVAILABLE) {
       std::cout << APP_NAME << " Thermal-Shutdown management services are ready !" << std::endl;
    } else {
       std::cout << APP_NAME << " *** ERROR - Unable to initialize Thermal-Shutdown management "
                                  "services" << std::endl;
       return -1;
    }
    Copy to clipboard

5. Query the current thermal auto shutdown mode

// Callback which provides response to query operation
    void getStatusCallback(AutoShutdownMode mode)
    {
        if(mode == AutoShutdownMode::ENABLE) {
           std::cout << " Current auto shutdown mode is: Enable" << std::endl;
        } else if(mode == AutoShutdownMode::DISABLE) {
           std::cout << " Current auto shutdown mode is: Disable" << std::endl;
        } else {
           std::cout << " *** ERROR - Failed to send get auto-shutdown mode " << std::endl;
        }
    }
    
    // Send get themal auto shutdown mode command
    auto status = thermShutdownMgr_->getAutoShutdownMode(getStatusCallback);
    if(status != telux::common::Status::SUCCESS) {
       std::cout << "getShutdownMode command failed with error" << static_cast<int>(status) << std::endl;
    } else {
       std::cout << "Request to query thermal shutdown status sent" << std::endl;
    }
    Copy to clipboard

6. Set thermal auto shutdown mode

// Callback which provides response to set thermal auto shutdown mode command
    void commandResponse(ErrorCode error)
    {
        if(error == ErrorCode::SUCCESS) {
        std::cout << " sent successfully" << std::endl;
        } else {
           std::cout << " failed\n errorCode: " << static_cast<int>(error) << std::endl;
        }
    }
    
    // Send set themal auto shutdown mode command
    auto status = thermShutdownMgr_->setAutoShutdownMode(state, commandResponse);
    if(status != telux::common::Status::SUCCESS) {
       std::cout << "setShutdownMode command failed with error" << static_cast<int>(status) << std::endl;
    } else {
       std::cout << "Request to set thermal shutdown status sent" << std::endl;
    }
    Copy to clipboard

Last Published: Mar 31, 2026

[Previous Topic
Get thermal autoshutdown mode updates](https://docs.qualcomm.com/bundle/publicresource/80-PF458-9/topics/get_thermal_autoshutdown_mode_updates.md) [Next Topic
Sensor](https://docs.qualcomm.com/bundle/publicresource/80-PF458-9/topics/sensor.md)