power_control: properly track the first initial state

Change-Id: I16e7474b5affbd90855a2e407b305e9dec581dfa
Related: SYS#4918, SYS#4917
This commit is contained in:
Vadim Yanitskiy 2021-01-08 02:30:43 +01:00
parent 834ba05cd2
commit e920902e25
2 changed files with 3 additions and 1 deletions

View File

@ -215,6 +215,8 @@ extern const struct gsm_power_ctrl_params power_ctrl_params_def;
/* Measurement pre-processing state */
struct gsm_power_ctrl_meas_proc_state {
/* Number of measurements processed */
unsigned int meas_num;
/* Algorithm specific data */
union {
struct {

View File

@ -78,7 +78,7 @@ static int do_pf_ewma(const struct gsm_power_ctrl_meas_params *mp,
int *Avg100 = &mps->ewma.Avg100;
/* We don't have 'Avg[n - 1]' if this is the first run */
if (*Avg100 == 0) {
if (mps->meas_num++ == 0) {
*Avg100 = Val * EWMA_SCALE_FACTOR;
return Val;
}