Skip to content

Commit

Permalink
[nrf noup] [nfconnet] Wi-FI directed scan implementation
Browse files Browse the repository at this point in the history
This patch implements directed scanning and
single ssid scanning during commissioning.

Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
  • Loading branch information
markaj-nordic committed Mar 21, 2024
1 parent 49b5f80 commit 7d49da8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/platform/nrfconnect/wifi/WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,22 @@ CHIP_ERROR WiFiManager::Scan(const ByteSpan & ssid, ScanResultCallback resultCal
mWiFiState = WIFI_STATE_SCANNING;
mSsidFound = false;

if (0 != net_mgmt(NET_REQUEST_WIFI_SCAN, mNetIf, NULL, 0))
wifi_scan_params * scanParamsFinal{ nullptr };
size_t scanParamsLen{ 0 };

if (!ssid.empty())
{
/* We must assume that the ssid is handled as a NULL-terminated string.
Note that the mScanSsidBuffer is initialized with zeros. */
VerifyOrReturnError(ssid.size() < sizeof(mScanParams), CHIP_ERROR_INVALID_ARGUMENT);
memcpy(mScanSsidBuffer, ssid.data(), ssid.size());
mScanSsidBuffer[ssid.size()] = 0; // indicate the end of ssid string
mScanParams.ssids[0] = mScanSsidBuffer;
mScanParams.ssids[1] = nullptr; // indicate the end of ssids list
scanParamsFinal = &mScanParams;
scanParamsLen = sizeof(*scanParamsFinal);
}
if (0 != net_mgmt(NET_REQUEST_WIFI_SCAN, mNetIf, scanParamsFinal, scanParamsLen))
{
ChipLogError(DeviceLayer, "Scan request failed");
return CHIP_ERROR_INTERNAL;
Expand Down
4 changes: 3 additions & 1 deletion src/platform/nrfconnect/wifi/WiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ class WiFiManager

net_if * mNetIf{ nullptr };
ConnectionParams mWiFiParams{};
ConnectionHandling mHandling;
ConnectionHandling mHandling{};
wifi_scan_params mScanParams{};
char mScanSsidBuffer[DeviceLayer::Internal::kMaxWiFiSSIDLength + 1] = { 0 };
wifi_iface_state mWiFiState;
wifi_iface_state mCachedWiFiState;
net_mgmt_event_callback mWiFiMgmtClbk{};
Expand Down

0 comments on commit 7d49da8

Please sign in to comment.