# Receive wifi security reports

Steps to register listener and receive wifi connection security reports are:

> 
> 
> 1. Define listener that will receive report and receive invocation for consent to trusting an AP.
> 2. Get ConnectionSecurityFactory instance.
> 3. Get IWiFiSecurityManager instance from ConnectionSecurityFactory.
> 4. Wait for the security service to become available.
> 5. Register listener to receive security reports.
> 6. Receive reports in the registered listener.
> 7. When the use-case is complete, deregister the listener.

Copy to clipboard

#include &lt;iostream&gt;
#include &lt;chrono&gt;
#include &lt;thread&gt;
#include &lt;future&gt;

#include &lt;telux/sec/ConnectionSecurityFactory.hpp&gt;

- class WiFiSecurityReportListenerpublic telux::sec::IWiFiReportListener,
    - public std::enable\_shared\_from\_this&lt;WiFiSecurityReportListener&gt; {

public:

> 
> 
> /\* Step - 6 [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id1)/
> void onReportAvailable(telux::sec::WiFiSecurityReport report) {
> 
> 
> 
> > 
> > 
> > std::cout &lt;&lt; “ssid             : “ &lt;&lt; report.ssid &lt;&lt; std::endl;
> > std::cout &lt;&lt; “bssid            : “ &lt;&lt; report.bssid &lt;&lt; std::endl;
> > std::cout &lt;&lt; “is connected     : “ &lt;&lt; report.isConnectedToAP &lt;&lt; std::endl;
> > std::cout &lt;&lt; “is open          : “ &lt;&lt; report.isOpenAP &lt;&lt; std::endl;
> > std::cout &lt;&lt; “ml threat score  : “ &lt;&lt;
> > 
> > 
> > 
> > > 
> > > 
> > > report.mlAlgorithmAnalysis.threatScore &lt;&lt; std::endl;
> > 
> > 
> > 
> > 
> > - std::cout &lt;&lt; “ml result“ &lt;&lt;
> >     - static\_cast&lt;int&gt;(report.mlAlgorithmAnalysis.result) &lt;&lt; std::endl;
> > 
> > - std::cout &lt;&lt; “summoning result“ &lt;&lt;
> >     - static\_cast&lt;int&gt;(report.summoningAnalysis.result) &lt;&lt; std::endl;
> 
> 
> 
> }
> 
> 
> 
> - void onDeauthenticationAttack(telux::sec::DeauthenticationInfo deauthenticationInfo) {
>     - - std::cout &lt;&lt; “disconnect reason“ &lt;&lt;
>     - deauthenticationInfo.deauthenticationReason &lt;&lt; std::endl;
> 
> - std::cout &lt;&lt; “did AP initiated“ &lt;&lt;
>     - deauthenticationInfo.didAPInitiateDisconnect &lt;&lt; std::endl;
> 
> - std::cout &lt;&lt; “threat score“ &lt;&lt;
>     - deauthenticationInfo.threatScore &lt;&lt; std::endl;
> 
> 
> 
> 
> }
> 
> 
> 
> - void isTrustedAP(telux::sec::ApInfo apInfo, bool& isTrusted) {
>     - std::cout &lt;&lt; “ssid  : “ &lt;&lt; apInfo.ssid  &lt;&lt; std::endl;
> std::cout &lt;&lt; “bssid : “ &lt;&lt; apInfo.bssid &lt;&lt; std::endl;
> 
> 
> /\* In this example we always trust the AP [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id3)/
> isTrusted = true;
> 
> 
> 
> 
> }
> 
> 
> 
> - /\*
>     - - Initialize application and get a WiFiSecurityManager.
> 
> 
> 
> [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id5)/
> 
> 
> 
> 
> int init() {
> 
> 
> 
> > 
> > 
> > std::promise&lt;telux::common::ServiceStatus&gt; p{};
> > telux::common::ServiceStatus serviceStatus;
> > 
> > 
> > /\* Step - 2 [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id7)/
> > auto &wifiConSecFact = telux::sec::ConnectionSecurityFactory::getInstance();
> > 
> > 
> > /\* Step - 3 [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id9)/
> > [wifiConSecMgr\_](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id23) = wifiConSecFact.getWiFiSecurityManager([&](telux::common::ServiceStatus
> > srvStatus) {
> > 
> > 
> > 
> > > 
> > > 
> > > p.set\_value(srvStatus);
> > 
> > 
> > 
> > });
> > 
> > 
> > 
> > - if (!wifiConSecMgr\_) {
> >     - std::cout &lt;&lt; “failed to get IWiFiSecurityManager “ &lt;&lt; std::endl;
> > return -ENOMEM;
> > 
> > 
> > 
> > 
> > }
> > 
> > 
> > /\* Step - 4 [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id11)/
> > serviceStatus = p.get\_future().get();
> > if (serviceStatus != telux::common::ServiceStatus::SERVICE\_AVAILABLE) {
> > 
> > 
> > 
> > > 
> > > 
> > > std::cout &lt;&lt; “security service unavailable” &lt;&lt; std::endl;
> > > return -EIO;
> > 
> > 
> > 
> > }
> > 
> > 
> > std::cout &lt;&lt; “initialization finished” &lt;&lt; std::endl;
> > return 0;
> 
> 
> 
> }
> 
> 
> 
> - int registerSecurityReportListener() {
>     - telux::common::ErrorCode ec;
> /\* Step - 5 [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id13)/
> ec = [wifiConSecMgr\_](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id25)-&gt;registerListener(shared\_from\_this());
> if (ec != telux::common::ErrorCode::SUCCESS) {
> 
> 
> 
> > 
> > 
> > std::cout &lt;&lt; “can’t register listener, err “ &lt;&lt; static\_cast&lt;int&gt;(ec) &lt;&lt; std::endl;
> > return -EIO;
> 
> 
> 
> }
> 
> 
> return 0;
> 
> 
> 
> 
> }
> 
> 
> 
> - int deregisterSecurityReportListener() {
>     - /\* Step - 7 [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id15)/
> telux::common::ErrorCode ec;
> ec = [wifiConSecMgr\_](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id27)-&gt;deregisterListener(shared\_from\_this());
> if (ec != telux::common::ErrorCode::SUCCESS) {
> 
> 
> 
> > 
> > 
> > std::cout &lt;&lt; “can’t deregister listener, err “ &lt;&lt; static\_cast&lt;int&gt;(ec) &lt;&lt; std::endl;
> > return -EIO;
> 
> 
> 
> }
> 
> 
> return 0;
> 
> 
> 
> 
> }

- private:
    - std::shared\_ptr&lt;telux::sec::IWiFiSecurityManager&gt; [wifiConSecMgr\_](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id29);

};

int main(int argc, char [\*\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id17)argv) {

> 
> 
> int ret;
> std::shared\_ptr&lt;WiFiSecurityReportListener&gt; app;
> 
> 
> /\* Step - 1 [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id19)/
> try {
> 
> 
> 
> > 
> > 
> > app = std::make\_shared&lt;WiFiSecurityReportListener&gt;();
> 
> 
> 
> 
> - } catch (const std::exception& e) {
>     - std::cout &lt;&lt; “can’t allocate WiFiSecurityReportListener” &lt;&lt; std::endl;
> return -ENOMEM;
> 
> 
> 
> 
> }
> 
> 
> ret = app-&gt;init();
> if (ret &lt; 0) {
> 
> 
> 
> > 
> > 
> > return ret;
> 
> 
> 
> }
> 
> 
> ret = app-&gt;registerSecurityReportListener();
> if (ret &lt; 0) {
> 
> 
> 
> > 
> > 
> > return ret;
> 
> 
> 
> }
> 
> 
> /\* Add application specific business logic here [\*](https://docs.qualcomm.com/doc/80-PF458-1/topic/WiFiConnectionReportListener.html#id21)/
> std::this\_thread::sleep\_for(std::chrono::milliseconds(10000));
> 
> 
> ret = app-&gt;deregisterSecurityReportListener();
> if (ret &lt; 0) {
> 
> 
> 
> > 
> > 
> > return ret;
> 
> 
> 
> }
> 
> 
> std::cout &lt;&lt; “application exiting” &lt;&lt; std::endl;
> return 0;

}

Last Published: Apr 14, 2026

[Previous Topic
WiFi connection security](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/wifi_connection_security.md) [Next Topic
WLAN](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/wlan.md)