Skip to content

Commit

Permalink
Use recently added methods to access system flags
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeuz committed Apr 17, 2016
1 parent 67a760f commit 033a524
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
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_ERRORS
API_COMPILE(System.enableResetNetworkOnCloudErrors());
API_COMPILE(System.disableResetNetworkOnCloudErrors());
API_COMPILE(System.resetNetworkOnCloudErrorsEnabled());
// Generic API
API_COMPILE(System.enable(SYSTEM_FLAG_MAX));
API_COMPILE(System.disable(SYSTEM_FLAG_MAX));
API_COMPILE(System.enabled(SYSTEM_FLAG_MAX));
}
20 changes: 4 additions & 16 deletions wiring/inc/spark_wiring_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,33 +261,21 @@ class SystemClass {
set_flag(flag, false);
}


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

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

inline uint8_t resetNetworkOnCloudErrorsEnabled()
{
return get_flag(SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS) != 0;
inline bool enabled(system_flag_t flag) const {
return get_flag(flag) != 0;
}


private:

inline uint8_t get_flag(system_flag_t flag)
static inline uint8_t get_flag(system_flag_t flag)
{
uint8_t value = 0;
system_get_flag(flag, &value, nullptr);
return value;
}

inline void set_flag(system_flag_t flag, uint8_t value)
static inline void set_flag(system_flag_t flag, uint8_t value)
{
system_set_flag(flag, value, nullptr);
}
Expand Down

0 comments on commit 033a524

Please sign in to comment.