net: lwm2m: refactor min / max measurement update code

Split out update code to make it re-usable.

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 721dc05..5422a66 100644
--- a/subsys/net/lib/lwm2m/ipso_temp_sensor.c
+++ b/subsys/net/lib/lwm2m/ipso_temp_sensor.c
@@ -57,6 +57,22 @@
 static struct lwm2m_engine_obj_inst inst[MAX_INSTANCE_COUNT];
 static struct lwm2m_engine_res_inst res[MAX_INSTANCE_COUNT][TEMP_MAX_ID];
 
+static void update_min_measured(u16_t obj_inst_id, int index)
+{
+	min_measured_value[index].val1 = sensor_value[index].val1;
+	min_measured_value[index].val2 = sensor_value[index].val2;
+	NOTIFY_OBSERVER(IPSO_OBJECT_TEMP_SENSOR_ID, obj_inst_id,
+			TEMP_MIN_MEASURED_VALUE_ID);
+}
+
+static void update_max_measured(u16_t obj_inst_id, int index)
+{
+	max_measured_value[index].val1 = sensor_value[index].val1;
+	max_measured_value[index].val2 = sensor_value[index].val2;
+	NOTIFY_OBSERVER(IPSO_OBJECT_TEMP_SENSOR_ID, obj_inst_id,
+			TEMP_MAX_MEASURED_VALUE_ID);
+}
+
 static int reset_min_max_measured_values_cb(u16_t obj_inst_id)
 {
 	int i;
@@ -105,23 +121,11 @@
 			}
 
 			if (update_min) {
-				min_measured_value[i].val1 =
-						sensor_value[i].val1;
-				min_measured_value[i].val2 =
-						sensor_value[i].val2;
-				NOTIFY_OBSERVER(IPSO_OBJECT_TEMP_SENSOR_ID,
-						obj_inst_id,
-						TEMP_MIN_MEASURED_VALUE_ID);
+				update_min_measured(obj_inst_id, i);
 			}
 
 			if (update_max) {
-				max_measured_value[i].val1 =
-						sensor_value[i].val1;
-				max_measured_value[i].val2 =
-						sensor_value[i].val2;
-				NOTIFY_OBSERVER(IPSO_OBJECT_TEMP_SENSOR_ID,
-						obj_inst_id,
-						TEMP_MAX_MEASURED_VALUE_ID);
+				update_max_measured(obj_inst_id, i);
 			}
 		}
 	}