Skip to content

Commit

Permalink
Conditional default value for the flag; minor renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeuz committed Apr 7, 2016
1 parent 75a34c0 commit ba9f8a2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion system/inc/system_update.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ typedef enum
* When 1 (default), the system resets network connection after a number of failed attempts to
* connect to the cloud.
*/
SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERROR,
SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS,

/**
* When 0, the application code is not paused.
Expand Down
2 changes: 1 addition & 1 deletion system/src/system_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void handle_cfod()
++cfod_count;

uint8_t reset = 0;
system_get_flag(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERROR, &reset, nullptr);
system_get_flag(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS, &reset, nullptr);
if (reset && cfod_count >= MAX_FAILED_CONNECTS)
{
SPARK_WLAN_RESET = RESET_ON_CFOD;
Expand Down
8 changes: 6 additions & 2 deletions system/src/system_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ static_assert(SYSTEM_FLAG_OTA_UPDATE_ENABLED==1, "system flag value");
static_assert(SYSTEM_FLAG_RESET_PENDING==2, "system flag value");
static_assert(SYSTEM_FLAG_RESET_ENABLED==3, "system flag value");
static_assert(SYSTEM_FLAG_STARTUP_SAFE_LISTEN_MODE == 4, "system flag value");
static_assert(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERROR == 5, "system flag value");
static_assert(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS == 5, "system flag value");
static_assert(SYSTEM_FLAG_MAX == 6, "system flag max value");

volatile uint8_t systemFlags[SYSTEM_FLAG_MAX] = {
0, 1, // OTA updates pending/enabled
0, 1, // Reset pending/enabled
0, // SYSTEM_FLAG_STARTUP_SAFE_LISTEN_MODE
1, // SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERROR
#if PLATFORM_ID < 3
1 // SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS
#else
0 // SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS
#endif
};

const uint16_t SAFE_MODE_LISTEN = 0x5A1B;
Expand Down
8 changes: 4 additions & 4 deletions user/tests/wiring/api/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ test(system_flags)
API_COMPILE(System.resetEnabled());
// SYSTEM_FLAG_RESET_PENDING
API_COMPILE(System.resetPending());
// SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERROR
API_COMPILE(System.enableResetNetworkOnCloudError());
API_COMPILE(System.disableResetNetworkOnCloudError());
API_COMPILE(System.resetNetworkOnCloudErrorEnabled());
// SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS
API_COMPILE(System.enableResetNetworkOnCloudErrors());
API_COMPILE(System.disableResetNetworkOnCloudErrors());
API_COMPILE(System.resetNetworkOnCloudErrorsEnabled());
}
12 changes: 6 additions & 6 deletions wiring/inc/spark_wiring_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,19 @@ class SystemClass {
}


inline void enableResetNetworkOnCloudError()
inline void enableResetNetworkOnCloudErrors()
{
set_flag(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERROR, true);
set_flag(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS, true);
}

inline void disableResetNetworkOnCloudError()
inline void disableResetNetworkOnCloudErrors()
{
set_flag(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERROR, false);
set_flag(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS, false);
}

inline uint8_t resetNetworkOnCloudErrorEnabled()
inline uint8_t resetNetworkOnCloudErrorsEnabled()
{
return get_flag(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERROR) != 0;
return get_flag(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS) != 0;
}


Expand Down

0 comments on commit ba9f8a2

Please sign in to comment.