Skip to content

Commit

Permalink
Create a define for timeout in hal platform
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Nov 1, 2021
1 parent b0dd125 commit eedcc56
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 34 deletions.
4 changes: 4 additions & 0 deletions hal/inc/hal_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,8 @@
#define HAL_PLATFORM_INTERNAL_LOW_SPEED_CLOCK (0)
#endif // HAL_PLATFORM_INTERNAL_LOW_SPEED_CLOCK

#ifndef HAL_PLATFORM_CELLULAR_CONN_TIMEOUT
#define HAL_PLATFORM_CELLULAR_CONN_TIMEOUT (9*60*1000)
#endif

#endif /* HAL_PLATFORM_H */
2 changes: 1 addition & 1 deletion user/tests/app/band_select/band_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ bool BAND_SELECT_09_restore_connection() {
Log.trace("%s", __func__);
// Allow network registration
cellular_command(NULL, NULL, 30000, "AT+COPS=0,2\r\n"); // blocking call to avoid adding delays
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
if (Particle.disconnected()) {
Log.error("Connection was not restored and timed out!");
return false;
Expand Down
2 changes: 1 addition & 1 deletion user/tests/app/testmodepin/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool wifiPowersaveClockRunning(int mirror) {

bool connectToCloud(void) {
Particle.connect();
if (!waitFor(Particle.connected, 9*60*1000)) {
if (!waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT)) {
Serial1.println("Cloud did not connect within 30s!");
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test(01_connect_set_feature_reset) {
}

Particle.connect();
assertTrue(waitFor(Particle.connected, 9 * 60 * 1000));
assertTrue(waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT));

if (!Particle.syncTimeDone()) {
Particle.syncTime();
Expand Down
4 changes: 2 additions & 2 deletions user/tests/wiring/no_fixture/cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test(CLOUD_04_socket_errors_do_not_cause_a_full_handshake) {
const int GET_CLOUD_SOCKET_HANDLE_INTERNAL_ID = 3;

Particle.connect();
assertTrue(waitFor(Particle.connected, 9*60*1000));
assertTrue(waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT));

sock_handle_t cloudSock = (sock_handle_t)system_internal(GET_CLOUD_SOCKET_HANDLE_INTERNAL_ID, nullptr);
assertTrue(socket_handle_valid(cloudSock));
Expand Down Expand Up @@ -70,7 +70,7 @@ test(CLOUD_04_socket_errors_do_not_cause_a_full_handshake) {
(void)Particle.publish("test", "test");
assertTrue(waitFor(handshakeState, 120000));
assertEqual((int)handshakeState.handshakeType, (int)cloud_status_session_resume);
assertTrue(waitFor(Particle.connected, 9*60*1000));
assertTrue(waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT));
}

#endif // HAL_PLATFORM_CLOUD_UDP
4 changes: 2 additions & 2 deletions user/tests/wiring/no_fixture/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ test(SYSTEM_06_system_describe_is_not_overflowed_when_factory_module_present)
// Connect to the cloud, if there is a system describe overflow, we'll trigger assertion failure here
assertTrue(Particle.disconnected);
Particle.connect();
assertTrue(waitFor(Particle.connected, 9*60*1000));
assertTrue(waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT));
}

test(SYSTEM_07_system_describe_is_not_overflowed_when_factory_module_present_but_invalid)
Expand Down Expand Up @@ -297,5 +297,5 @@ test(SYSTEM_07_system_describe_is_not_overflowed_when_factory_module_present_but
// Connect to the cloud, if there is a system describe overflow, we'll trigger assertion failure here
assertTrue(Particle.disconnected);
Particle.connect();
assertTrue(waitFor(Particle.connected, 9*60*1000));
assertTrue(waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT));
}
6 changes: 3 additions & 3 deletions user/tests/wiring/no_fixture/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test(THREAD_06_particle_process_behavior_when_threading_disabled)

// Make sure Particle is connected
Particle.connect();
waitFor(Particle.connected,9*60*1000);
waitFor(Particle.connected,HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());

// Call disconnect from main thread
Expand Down Expand Up @@ -151,7 +151,7 @@ test(THREAD_07_particle_process_behavior_when_threading_enabled)

// Make sure Particle is connected
Particle.connect();
waitFor(Particle.connected,9*60*1000);
waitFor(Particle.connected,HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());

// Schedule function on application thread that does not run for sometime because of hard delays
Expand Down Expand Up @@ -181,7 +181,7 @@ test(THREAD_07_particle_process_behavior_when_threading_enabled)
test_val = 0;
Particle.connect();
// Address this comment before merging! Replace 20s with 9m?
waitFor(Particle.connected,9*60*1000);
waitFor(Particle.connected,HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());
});

Expand Down
6 changes: 3 additions & 3 deletions user/tests/wiring/no_fixture/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ test(TIME_13_syncTimePending_syncTimeDone_when_disconnected)
if (!Particle.connected())
{
Particle.connect();
waitFor(Particle.connected, 9 * 60 * 1000);
waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
}
assertTrue(Particle.connected());
Particle.syncTime();
Expand All @@ -228,7 +228,7 @@ test(TIME_14_timeSyncedLast_works_correctly)
if (!Particle.connected())
{
Particle.connect();
waitFor(Particle.connected, 9*60*1000);
waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
}
uint32_t mil = millis();
Particle.syncTime();
Expand All @@ -240,7 +240,7 @@ test(TIME_15_RestoreSystemMode) {
set_system_mode(AUTOMATIC);
if (!Particle.connected()) {
Particle.connect();
waitFor(Particle.connected, 9*60*1000);
waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
}
}

Expand Down
14 changes: 7 additions & 7 deletions user/tests/wiring/no_fixture_cellular/cellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,24 @@ void checkIPAddress(const char* name, const IPAddress& address)

test(CELLULAR_01_local_ip_cellular_config)
{
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
checkIPAddress("local", Cellular.localIP());
}

test(CELLULAR_02_resolve) {
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
checkIPAddress("www.particle.io", Cellular.resolve("www.particle.io"));
}

test(CELLULAR_03_resolve) {
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
IPAddress addr = Cellular.resolve("this.is.not.a.real.host");
assertEqual(addr, 0);
}

// Collects cellular signal strength and quality and validates Accesstechnology (RAT)
test(CELLULAR_05_sigstr_is_valid) {
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());
CellularSignal s;
bool values_in_range = false;
Expand Down Expand Up @@ -159,7 +159,7 @@ test(CELLULAR_05_sigstr_is_valid) {
}

test(CELLULAR_06_on_off_validity_check) {
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Cellular.isOn());
assertFalse(Cellular.isOff());

Expand Down Expand Up @@ -192,7 +192,7 @@ test(CELLULAR_06_on_off_validity_check) {
ret = Cellular.command("AT\r\n");
assertEqual(ret, (int)RESP_OK);

connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
}

#if HAL_PLATFORM_GEN == 2
Expand Down Expand Up @@ -395,7 +395,7 @@ test(MDM_02_at_commands_with_long_response_are_correctly_parsed_and_flow_control
}

test(MDM_03_restore_cloud_connection) {
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
}

#endif // Wiring_Cellular == 1
4 changes: 2 additions & 2 deletions user/tests/wiring/no_fixture_cellular/cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ HandshakeState handshakeState;

test(CLOUD_05_loss_of_cellular_network_connectivity_does_not_cause_full_handshake) {
Particle.connect();
assertTrue(waitFor(Particle.connected, 9*60*1000));
assertTrue(waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT));

auto evHandler = [](system_event_t event, int param, void* ctx) {
if (event == cloud_status) {
Expand Down Expand Up @@ -68,7 +68,7 @@ test(CLOUD_05_loss_of_cellular_network_connectivity_does_not_cause_full_handshak
#endif // HAL_PLATFORM_NCP_AT
assertTrue(waitFor(handshakeState, 120000));
assertEqual((int)handshakeState.handshakeType, (int)cloud_status_session_resume);
assertTrue(waitFor(Particle.connected, 9*60*1000));
assertTrue(waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT));
}

#endif // HAL_PLATFORM_CELLULAR
Expand Down
12 changes: 6 additions & 6 deletions user/tests/wiring/no_fixture_long_running/cellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test(CELLULAR_01_device_will_connect_to_the_cloud_when_all_tcp_sockets_consumed)
close_consumed_sockets(socks);
});
// And the device attempts to connect to the Cloud
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
// Then the device overcomes this socket obstacle and connects to the Cloud
assertEqual(Particle.connected(), true);
}
Expand All @@ -110,7 +110,7 @@ test(CELLULAR_02_device_will_connect_to_the_cloud_when_all_udp_sockets_consumed)
});
// And the device attempts to connect to the Cloud
// Account for exponential backoff and potentially long registration
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
// Then the device overcomes this socket obstacle and connects to the Cloud
assertEqual(Particle.connected(), true);
}
Expand Down Expand Up @@ -142,7 +142,7 @@ void busyDelay(system_tick_t m) {
test(CELLULAR_03_device_will_reconnect_to_the_cloud_within_2mins_when_unexpected_modem_brown_out_occurs) {
// Serial.println("the device will reconnect to the cloud within 2 min when unexpected modem brown out occurs");
// Given the device is currently connected to the Cloud
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
// Using single threaded section to prevent the system from executing any modem operations
SINGLE_THREADED_BLOCK() {
// Disable UART interrupts so that we are not receiving any new data from the modem
Expand Down Expand Up @@ -184,7 +184,7 @@ test(CELLULAR_03_device_will_reconnect_to_the_cloud_within_2mins_when_unexpected
test(CELLULAR_04_device_will_reconnect_to_the_cloud_within_2mins_when_unexpected_modem_power_off_occurs) {
// Serial.println("the device will reconnect to the cloud when unexpected modem power off occurs, within 2min");
// Given the device is currently connected to the Cloud
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());

CellularDevice dev;
Expand Down Expand Up @@ -226,7 +226,7 @@ test(CELLULAR_04_device_will_reconnect_to_the_cloud_within_2mins_when_unexpected
}

test(CELLULAR_05_device_will_poweroff_when_modem_is_not_responsive) {
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());

// Using single threaded section to prevent the system from executing any modem operations
Expand All @@ -245,7 +245,7 @@ test(CELLULAR_05_device_will_poweroff_when_modem_is_not_responsive) {
assertFalse(modemPowerState());

// Make sure the device can reconnect
connect_to_cloud(9*60*1000);
connect_to_cloud(HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());
}

Expand Down
2 changes: 1 addition & 1 deletion user/tests/wiring/no_fixture_stress/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,5 @@ test(SYSTEM_09_out_of_memory_restore_state)
// Restore connection to the cloud and network
Network.connect();
Particle.connect();
waitFor(Particle.connected, 9*60*1000);
waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
}
4 changes: 2 additions & 2 deletions user/tests/wiring/sleep/sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SYSTEM_THREAD(ENABLED);
*/
test(sleep_0_device_wakes_from_deep_sleep_with_short_sleep_time)
{
waitFor(Particle.connected, 9 * 60 * 1000);
waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
if (magick == 0xdeadbeef) {
magick = 0;
// We should have woken up from deep sleep
Expand Down Expand Up @@ -182,7 +182,7 @@ test(sleep_2_udp_all_confirmable_messages_are_sent_before_sleep_step_1)
// Connect
//Serial.println("Connecting...");
Particle.connect();
waitFor(Particle.connected, 9 * 60 * 1000);
waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());
//Serial.println("Connected");

Expand Down
2 changes: 1 addition & 1 deletion user/tests/wiring/threading/listening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void listening_start_with_delay() {
Particle.disconnect();
network_power_cycle();
Particle.connect();
waitFor(Particle.connected, 9*60*1000);
waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
}
assertTrue(Particle.connected()); // make sure we are not stuck trying to handshake before trying to enter listening mode
listening_test_flag = false;
Expand Down
4 changes: 2 additions & 2 deletions user/tests/wiring/time_compat/time_compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ STARTUP({

test(TIME_COMPAT_00_TimeIsValid) {
Particle.connect();
waitFor(Particle.connected, 9 * 60 * 1000);
waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());
if (Particle.syncTimePending()) {
waitFor(Particle.syncTimeDone, 120000);
Expand Down Expand Up @@ -265,7 +265,7 @@ test(TIME_COMPAT_04_RtcHal) {

test(TIME_COMPAT_05_SyncTime) {
Particle.connect();
waitFor(Particle.connected, 9 * 60 * 1000);
waitFor(Particle.connected, HAL_PLATFORM_CELLULAR_CONN_TIMEOUT);
assertTrue(Particle.connected());

time_t refTime = 1546300800; // 2019-01-01 00:00:00
Expand Down

0 comments on commit eedcc56

Please sign in to comment.