This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unused variables in app_onoff example

The example app_onoff.c shipped with SDK For Mesh 4.2.0 (unchanged from 4.1.0) have two unused variables in its state struct.

diff --git a/examples/common/include/app_onoff.h b/examples/common/include/app_onoff.h
index e730675..8413c80 100644
--- a/examples/common/include/app_onoff.h
+++ b/examples/common/include/app_onoff.h
@@ -112,8 +112,6 @@ typedef struct
 {
     /** Present value of the OnOff state */
     bool present_onoff;
-    /** Initial value for transition */
-    bool initial_present_onoff;
     /** Target value of the OnOff state, as received from the model interface. */
     bool target_onoff;
     /** Structure for using transition module functionality */
@@ -200,9 +198,6 @@ struct __app_onoff_server_t
     app_onoff_state_t state;
     /** Internal variable. It is used for acquiring RTC counter value. */
     uint32_t last_rtc_counter;
-    /** Internal variable. To flag if the received message has been processed to update the present
-     * OnOff value */
-    bool value_updated;
 };
 
 /** Initiates value fetch from the user application by calling a get callback, updates internal
diff --git a/examples/common/src/app_onoff.c b/examples/common/src/app_onoff.c
index 0d2117d..a1bfcbf 100644
--- a/examples/common/src/app_onoff.c
+++ b/examples/common/src/app_onoff.c
@@ -130,8 +130,6 @@ static void generic_onoff_state_set_cb(const generic_onoff_server_t * p_self,
 
     bool present_on_off;
     p_app->onoff_get_cb(p_app, &present_on_off);
-    /* Update internal representation of OnOff value, process timing */
-    p_app->value_updated = false;
     p_app->state.target_onoff = p_in->on_off;
 
     uint32_t transition_time_ms = 0;
@@ -166,7 +164,7 @@ static void transition_start_cb(const app_transition_t * p_transition)
     app_onoff_server_t * p_app = transition_to_app(p_transition);
     app_transition_params_t * p_params = app_transition_ongoing_get(&p_app->state.transition);
 
-    if (p_app->state.initial_present_onoff == 0 && p_app->state.target_onoff == 1)
+    if (p_app->state.target_onoff == 1)
     {
         p_app->state.present_onoff = p_app->state.target_onoff;
         onoff_current_value_update(p_app);

The value_updated variable looks like a left over from the refactor as it was used in the pre-4.1.0 code but now is only set to false and never read anywhere.

The initial_present_onoff variable is never set and thus is always 0.

Thanks.

Parents Reply Children
No Data
Related