net: lwm2m: temp_sensor: fix min/max measurement values
Initial values for the min/max measurements were 0 and this caused
issues with sensors maximums that weren't above 0 and minimums that
went below 0. Let's update those to MAX_INT so the first sensor
value update will set those to correct values.
When resetting the measured values, let's use the current sensor
value not 0.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
diff --git a/subsys/net/lib/lwm2m/ipso_temp_sensor.c b/subsys/net/lib/lwm2m/ipso_temp_sensor.c
index 5422a66..b38dbc9 100644
--- a/subsys/net/lib/lwm2m/ipso_temp_sensor.c
+++ b/subsys/net/lib/lwm2m/ipso_temp_sensor.c
@@ -80,10 +80,8 @@
SYS_LOG_DBG("RESET MIN/MAX %d", obj_inst_id);
for (i = 0; i < MAX_INSTANCE_COUNT; i++) {
if (inst[i].obj && inst[i].obj_inst_id == obj_inst_id) {
- min_measured_value[i].val1 = 0;
- min_measured_value[i].val2 = 0;
- max_measured_value[i].val1 = 0;
- max_measured_value[i].val2 = 0;
+ update_min_measured(obj_inst_id, i);
+ update_max_measured(obj_inst_id, i);
return 0;
}
}
@@ -162,9 +160,9 @@
sensor_value[index].val1 = 0;
sensor_value[index].val2 = 0;
units[index][0] = '\0';
- min_measured_value[index].val1 = 0;
+ min_measured_value[index].val1 = INT32_MAX;
min_measured_value[index].val2 = 0;
- max_measured_value[index].val1 = 0;
+ max_measured_value[index].val1 = -INT32_MAX;
max_measured_value[index].val2 = 0;
min_range_value[index].val1 = 0;
min_range_value[index].val2 = 0;