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 17, 2016
1 parent 180a9b7 commit 67a760f
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
Expand Up @@ -119,7 +119,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,

SYSTEM_FLAG_MAX

Expand Down
2 changes: 1 addition & 1 deletion system/src/system_task.cpp
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
Expand Up @@ -61,15 +61,19 @@ 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_WIFITESTER_OVER_SERIAL1 == 5, "system flag value");
static_assert(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERROR == 6, "system flag value");
static_assert(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS == 6, "system flag value");
static_assert(SYSTEM_FLAG_MAX == 7, "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,
0, // SYSTEM_FLAG_SETUP_OVER_SERIAL1
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
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
Expand Up @@ -262,19 +262,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 67a760f

Please sign in to comment.