# How to configure and enable WLAN

The following steps illustrate how to configure WLAN.

1. Create the IWlanListener class.

class NotificationListener: public telux::wlan::IWlanListener {
    public:
    void onEnableChanged(bool enable) {
        promise_.set_value(enable);
    }
    
    bool getEnableStatus() {
        return promise_.get_future().get();
    }
    
    void resetPromise() {
        promise_ = std::promise<bool>();
    }
    private:
    std::promise<bool> promise_;
    };
    Copy to clipboard

2. Create the initialization callback object to be notified when initialization is complete and the object is ready to be used.

auto initCb = [&](telux::common::ServiceStatus status) {
        initPromise.set_value(status);
    };
    Copy to clipboard

3. Get the WlanFactory and WlanDeviceManager instances.

auto &wlanFactory = telux::wlan::WlanFactory::getInstance();
    wlanDevMgr  = wlanFactory.getWlanDeviceManager(initCb);
    Copy to clipboard

4. Wait for the object to complete initialization.

telux::common::ServiceStatus = subSystemStatus = initPromise.get_future().get();
    if (subSystemStatus == telux::common::ServiceStatus::SERVICE_AVAILABLE) {
        std::cout << " *** Wlan SubSystem is Ready *** " << std::endl;
    }
    else {
        std::cout << " *** Unable to initialize Wlan subsystem *** " << std::endl;
    }
    Copy to clipboard

5. If WLAN is enabled, disable it.

bool enableStat = false;
    std::vector<telux::wlan::InterfaceStatus> ifStatus;
    if(telux::common::ErrorCode::SUCCESS != wlanDevMgr->getStatus(enableStat, ifStatus)) {
        std::cout << "Failed to retrieve Wlan status" <<std::endl;
    }
    if(enableStat) {
        //Disable Wlan before changing configuration...
        wlanDevMgr->registerListener(listener);
        //Ensure callback returns SUCCESS and indication for Wlan disablement is received
        if((telux::common::ErrorCode::SUCCESS != wlanDevMgr->enable(false)) ||
            (true == listener->getEnableStatus())) {
            std::cout << "Failed to disable Wlan " <<std::endl;
            break;
        }
    }
    Copy to clipboard

6. Set the desired WLAN configurations.

if(telux::common::ErrorCode::SUCCESS != wlanDevMgr->setMode(numAp, numSta)) {
        std::cout << "Failed to set Wlan configuration" <<std::endl;
    }
    Copy to clipboard

7. Enable WLAN for new configurations to take effect

listener->resetPromise();
    //Ensure callback returns SUCCESS and indication for Wlan enablement is received
    if((telux::common::ErrorCode::SUCCESS != wlanDevMgr->enable(true)) ||
       (false == listener->getEnableStatus())) {
        std::cout << "Failed to enable Wlan " <<std::endl;
    }
    Copy to clipboard

Last Published: Apr 14, 2026

[Previous Topic
WLAN](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/wlan.md) [Next Topic
How to configure and use WLAN STA operations](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/wlan_sta_config.md)