@@ -832,7 +832,8 @@ static void command_execute(uint32_t command_type)
832832}
833833
834834static void handle_cloud_shadow_response (struct main_state * state_object ,
835- const struct cloud_msg * msg )
835+ const struct cloud_msg * msg ,
836+ bool in_buffer_mode )
836837{
837838 int err ;
838839 struct config_params config = { 0 };
@@ -861,6 +862,15 @@ static void handle_cloud_shadow_response(struct main_state *state_object,
861862 config .sample_interval = state_object -> sample_interval_sec ;
862863 config .update_interval = state_object -> update_interval_sec ;
863864
865+ /* Set buffer_mode based on what was applied or current state.
866+ * If the cloud sent a mode change request (buffer_mode_valid is true), report that.
867+ * Otherwise, report the current operating mode passed in by the caller.
868+ */
869+ if (!config .buffer_mode_valid ) {
870+ config .buffer_mode = in_buffer_mode ;
871+ config .buffer_mode_valid = true;
872+ }
873+
864874 /* Only process commands from delta responses, not from desired responses.
865875 * Delta responses contain only new commands that haven't been executed yet.
866876 * While desired responses may contain old commands that have already been executed.
@@ -1044,7 +1054,7 @@ static enum smf_state_result buffer_connected_run(void *o)
10441054 case CLOUD_SHADOW_RESPONSE_DESIRED :
10451055 __fallthrough ;
10461056 case CLOUD_SHADOW_RESPONSE_DELTA :
1047- handle_cloud_shadow_response (state_object , msg );
1057+ handle_cloud_shadow_response (state_object , msg , true );
10481058
10491059 break ;
10501060 case CLOUD_SHADOW_RESPONSE_EMPTY_DESIRED :
@@ -1451,7 +1461,7 @@ static enum smf_state_result passthrough_connected_run(void *o)
14511461 case CLOUD_SHADOW_RESPONSE_DESIRED :
14521462 __fallthrough ;
14531463 case CLOUD_SHADOW_RESPONSE_DELTA :
1454- handle_cloud_shadow_response (state_object , msg );
1464+ handle_cloud_shadow_response (state_object , msg , false );
14551465
14561466 return SMF_EVENT_HANDLED ;
14571467 case CLOUD_SHADOW_RESPONSE_EMPTY_DESIRED :
0 commit comments