Skip to content

Commit

Permalink
Adds API to set the wifi scan parameters. (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsracz authored Oct 30, 2021
1 parent 58d0221 commit 0f9a743
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/freertos_drivers/net_cc32xx/CC32xxWiFi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,38 @@ int CC32xxWiFi::wlan_country_code_set(CountryCode cc, bool restart)
return 0;
}

/*
* CC32xxWiFi::wlan_set_scan_params()
*/
void CC32xxWiFi::wlan_set_scan_params(int mask, int min_rssi)
{
SlWlanScanParamCommand_t param_config = {0};
uint16_t option = SL_WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS;
uint16_t param_len = sizeof(param_config);
int ret = sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID, &option, &param_len,
(_u8 *)&param_config);
SlCheckResult(ret);
bool apply = false;
if (mask >= 0 && param_config.ChannelsMask != (uint32_t)mask)
{
param_config.ChannelsMask = mask;
apply = true;
}
if (min_rssi < 0 && param_config.RssiThreshold != min_rssi)
{
param_config.RssiThreshold = min_rssi;
apply = true;
}
if (!apply)
{
return;
}
ret = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,
SL_WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS, sizeof(param_config),
(_u8 *)&param_config);
SlCheckResult(ret);
}

/*
* CC32xxWiFi::wlan_profile_add()
*/
Expand Down
7 changes: 7 additions & 0 deletions src/freertos_drivers/net_cc32xx/CC32xxWiFi.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ public:
*/
int wlan_country_code_set(CountryCode cc, bool restart = false);

/** Sets the scan parameters.
* @param mask the channel mask (bit 0 = channel1, bit1=channel2). If -1
* then the channel mask is not changed.
* @param min_rssi the minimal RSSI to return a wifi in the scan. If >= 0
* then the min_rssi is not changed. (Default min_rssi is -95.) */
void wlan_set_scan_params(int mask, int min_rssi);

/** Add a saved WLAN profile.
* @param ssid WLAN SSID of the profile to save
* @param sec_type @ref SecurityType of the profile to be saved
Expand Down

0 comments on commit 0f9a743

Please sign in to comment.