Skip to content

Commit

Permalink
Merge pull request #2669 from particle-iot/fix/test_sleep20
Browse files Browse the repository at this point in the history
[test] resolve sleep20 test failures.
  • Loading branch information
XuGuohui authored and technobly committed Sep 18, 2023
1 parent de8393b commit 1c3fa63
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
15 changes: 15 additions & 0 deletions hal/network/lwip/esp32/esp32ncpnetif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,21 @@ void Esp32NcpNetif::ncpEventHandlerCb(const NcpEvent& ev, void* ctx) {
} else {
LOG(ERROR, "NCP power state unknown");
}
} else if (ev.type == NcpEvent::NCP_STATE_CHANGED) {
const auto& cev = static_cast<const NcpStateChangedEvent&>(ev);
if_event evt = {};
struct if_event_phy_state ev_if_phy_state = {};
evt.ev_len = sizeof(if_event);
evt.ev_type = IF_EVENT_PHY_STATE;
evt.ev_phy_state = &ev_if_phy_state;
if (cev.state == NcpState::ON) {
evt.ev_phy_state->state = IF_PHY_STATE_ON;
} else if (cev.state == NcpState::OFF) {
evt.ev_phy_state->state = IF_PHY_STATE_OFF;
} else {
evt.ev_phy_state->state = IF_PHY_STATE_UNKNOWN;
}
if_notify_event(self->interface(), &evt, nullptr);
}
}

Expand Down
22 changes: 7 additions & 15 deletions user/tests/wiring/sleep20/sleep20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ test(07_System_Sleep_Mode_Deep_Wakeup_By_External_Rtc) {
}
}
#endif // HAL_PLATFORM_EXTERNAL_RTC

#endif // HAL_PLATFORM_GEN


test(08_System_Sleep_With_Configuration_Object_Stop_Mode_Without_Wakeup) {
SystemSleepConfiguration config;
config.mode(SystemSleepMode::STOP);
Expand Down Expand Up @@ -717,25 +717,21 @@ test(30_System_Sleep_With_Configuration_Object_Network_Power_State_Consistent_On
Particle.disconnect();
assertTrue(waitFor(Particle.disconnected, CLOUD_CONNECT_TIMEOUT));

for (uint8_t i = 0; i < 2; i++) {
{
// Make sure the modem is off first
Serial.println(" >> Powering off the modem...");
#if HAL_PLATFORM_CELLULAR
Cellular.off();
assertTrue(waitFor(Cellular.isOff, 60000));
Serial.println(" >> Powering on the modem...");
Cellular.on();
if (i == 1) {
assertTrue(waitFor(Cellular.isOn, 60000));
}
assertTrue(waitFor(Cellular.isOn, 60000));
#elif HAL_PLATFORM_WIFI
WiFi.off();
assertTrue(waitFor(WiFi.isOff, 60000));
Serial.println(" >> Powering on the modem...");
WiFi.on();
if (i == 1) {
assertTrue(waitFor(WiFi.isOn, 60000));
}
assertTrue(waitFor(WiFi.isOn, 60000));
#endif

Serial.println(" >> Entering sleep... Please reconnect serial after 3 seconds");
Expand Down Expand Up @@ -763,25 +759,21 @@ test(31_System_Sleep_With_Configuration_Object_Network_Power_State_Consistent_Of
(void)Serial.read();
}

for (uint8_t i = 0; i < 2; i++) {
{
// Make sure the modem is on first
Serial.println(" >> Powering on the modem...");
#if HAL_PLATFORM_CELLULAR
Cellular.on();
assertTrue(waitFor(Cellular.isOn, 60000));
Serial.println(" >> Powering off the modem...");
Cellular.off();
if (i == 1) {
assertTrue(waitFor(Cellular.isOff, 60000));
}
assertTrue(waitFor(Cellular.isOff, 60000));
#elif HAL_PLATFORM_WIFI
WiFi.on();
assertTrue(waitFor(WiFi.isOn, 60000));
Serial.println(" >> Powering off the modem...");
WiFi.off();
if (i == 1) {
assertTrue(waitFor(WiFi.isOff, 60000));
}
assertTrue(waitFor(WiFi.isOff, 60000));
#endif

Serial.println(" >> Entering sleep... Please reconnect serial after 3 seconds");
Expand Down

0 comments on commit 1c3fa63

Please sign in to comment.