Merge pull request #3584 from nieldk/BWM-work
Enhance bwm_wifi_forward_down for better disable confirmation
This commit is contained in:
1 file changed
+17
-3
+17
-3
@@ -256,7 +256,21 @@ int bwm_wifi_forward_status(uint8_t *state, uint32_t *ip_out) {
|
||||
}
|
||||
|
||||
int bwm_wifi_forward_down(void) {
|
||||
// Single command: the BWM deinits the TCP server + disconnects the STA and
|
||||
// returns to BLE-only. It persists the disable mode to NVS.
|
||||
return step(BWM_CMD_SET_TO_WIFI_DISABLE_MODE, NULL, 0, NULL, NULL, 2000, "wifi disable");
|
||||
// Once WiFi is gone the status query returns a non-timeout error.
|
||||
(void)bwm_cmd(BWM_CMD_SET_TO_WIFI_DISABLE_MODE, NULL, 0, NULL, NULL, 3000);
|
||||
|
||||
uint32_t t0 = GetTickCount();
|
||||
while (GetTickCountDelta(t0) < 12000) { // overall cap
|
||||
uint8_t st = 0;
|
||||
uint16_t sl = sizeof(st);
|
||||
int q = bwm_cmd(BWM_CMD_GET_WIFI_CONNECT_STATUS, NULL, 0, &st, &sl, 500);
|
||||
// ETIMEOUT while the ESP is busy tearing down -> keep waiting.
|
||||
// SUCCESS with a state -> still up mid-teardown -> keep waiting.
|
||||
// any other (EFAILED etc.) -> BWM answered but WiFi is gone -> disabled.
|
||||
if (q != PM3_SUCCESS && q != PM3_ETIMEOUT) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
SpinDelay(300);
|
||||
}
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
Reference in new issue
Block a user