From b517d7db4d001f66f4f7f38cd2177219a1cdfb4d Mon Sep 17 00:00:00 2001 From: Balazs Racz Date: Sat, 17 Oct 2020 13:54:18 +0200 Subject: [PATCH] Adds an accessor to fetch the number of connected stations. --- src/freertos_drivers/net_cc32xx/CC32xxWiFi.cxx | 16 ++++++++++++++++ src/freertos_drivers/net_cc32xx/CC32xxWiFi.hxx | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/src/freertos_drivers/net_cc32xx/CC32xxWiFi.cxx b/src/freertos_drivers/net_cc32xx/CC32xxWiFi.cxx index 7076754c3..2abd43825 100644 --- a/src/freertos_drivers/net_cc32xx/CC32xxWiFi.cxx +++ b/src/freertos_drivers/net_cc32xx/CC32xxWiFi.cxx @@ -804,6 +804,22 @@ void CC32xxWiFi::wlan_get_ap_config(string *ssid, SecurityType *security_type) } } +int CC32xxWiFi::wlan_get_ap_station_count() +{ + if (wlanRole != WlanRole::AP) + { + return 0; + } + uint8_t num_connected = 0; + uint16_t len = sizeof(num_connected); + auto status = sl_NetCfgGet( + SL_NETCFG_AP_STATIONS_NUM_CONNECTED, NULL, &len, &num_connected); + if (status) + { + return -1; + } + return num_connected; +} void CC32xxWiFi::connecting_update_blinker() { diff --git a/src/freertos_drivers/net_cc32xx/CC32xxWiFi.hxx b/src/freertos_drivers/net_cc32xx/CC32xxWiFi.hxx index ae52944dd..b45df6ea9 100644 --- a/src/freertos_drivers/net_cc32xx/CC32xxWiFi.hxx +++ b/src/freertos_drivers/net_cc32xx/CC32xxWiFi.hxx @@ -218,6 +218,12 @@ public: */ void wlan_get_ap_config(string *ssid, SecurityType *security_type); + /** Retrieves how many stations are connected to the wifi in AP mode. + * @return number of connected stations (0 to 4). If not in AP mode, + * returns 0. + */ + int wlan_get_ap_station_count(); + /** @return true if the wlan interface is ready to establish outgoing * connections. */ bool wlan_ready()