Skip to content

Commit e5e17f6

Browse files
[NXP] Fix TC-CNET-4.9 and add wifi reconnection in revert configuration (#41743)
* [NXP] Fix TC-CNET-4.9 and add wifi reconnection in revert configuration Signed-off-by: Martin Girardot <[email protected]> * Restyled by clang-format * [NXP] Fix PR comments Signed-off-by: Martin Girardot <[email protected]> * Restyled by clang-format * [NXP] Fix PR comments Signed-off-by: Martin Girardot <[email protected]> --------- Signed-off-by: Martin Girardot <[email protected]> Co-authored-by: Restyled.io <[email protected]>
1 parent 1223307 commit e5e17f6

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/platform/nxp/common/NetworkCommissioningWiFiDriver.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,27 @@ CHIP_ERROR NXPWiFiDriver::RevertConfiguration()
129129
{
130130
struct wlan_network searchedNetwork = { 0 };
131131

132-
/* If network was added we have to remove it (as the connection failed) from wifi driver to be able
133-
to connect to another network next commissioning */
134-
if (wlan_get_network_byname(mStagingNetwork.ssid, &searchedNetwork) == WM_SUCCESS)
132+
/* If network was added we have to remove it (only if device is not connected to a wifi network) from wifi driver to be able
133+
to connect to another network next commissioning.
134+
Do not remove the network if the device is already connected to a WiFi network,
135+
example scenario: TC-CNET-4.9
136+
*/
137+
if (!is_sta_connected() && wlan_get_network_byname(mStagingNetwork.ssid, &searchedNetwork) == WM_SUCCESS)
135138
{
136139
if (wlan_remove_network(mStagingNetwork.ssid) != WM_SUCCESS)
137140
{
138141
return CHIP_ERROR_INTERNAL;
139142
}
140143
}
144+
145+
/* Reset mStagingNetwork as it may have been updated during add/update network operation */
141146
mStagingNetwork = mSavedNetwork;
142147

143-
return CHIP_NO_ERROR;
148+
// succeed right away if no saved network
149+
VerifyOrReturnError(mStagingNetwork.ssidLen > 0, CHIP_NO_ERROR);
150+
// Connect to saved network
151+
return ConnectWiFiNetwork(mStagingNetwork.ssid, mStagingNetwork.ssidLen, mStagingNetwork.credentials,
152+
mStagingNetwork.credentialsLen);
144153
}
145154

146155
bool NXPWiFiDriver::NetworkMatch(const WiFiNetwork & network, ByteSpan networkId)

0 commit comments

Comments
 (0)