Sensor operation parameter update support

This CL passes the update of location geomagnetic field information on
to the mag cal algorithm via the local field updated function. Added
MAX and MIN field test for local file update in diversity checker.
This is a follow up CL from CL 1998219.

Bug: 30958130

Test: Tested on sailfish and marlin, functionality confirmed

Change-Id: I8b717fd8e805d2ac84dd640a670be98116c9418c
diff --git a/firmware/os/algos/calibration/common/diversity_checker.c b/firmware/os/algos/calibration/common/diversity_checker.c
index 312be69..198a08d 100644
--- a/firmware/os/algos/calibration/common/diversity_checker.c
+++ b/firmware/os/algos/calibration/common/diversity_checker.c
@@ -22,6 +22,9 @@
 #include <string.h>
 #include "common/math/vec.h"
 
+#define MAX_FIT_MAG 70.0f
+#define MIN_FIT_MAG 20.0f
+
 // Struct initialization.
 void diversityCheckerInit(
     struct DiversityChecker* diverse_data,
@@ -188,7 +191,7 @@
 
 void diversityCheckerLocalFieldUpdate(struct DiversityChecker* diverse_data,
                                       float local_field) {
-  if ( local_field > 0 ) {
+  if ((local_field < MAX_FIT_MAG) && (local_field > MIN_FIT_MAG)) {
     // Updating threshold based on the local field information.
     diverse_data->threshold = diverse_data->threshold_tuning_param_sq *
         (local_field * local_field);
diff --git a/firmware/os/drivers/bosch_bmi160/bosch_bmi160.c b/firmware/os/drivers/bosch_bmi160/bosch_bmi160.c
index 026be73..407bd80 100644
--- a/firmware/os/drivers/bosch_bmi160/bosch_bmi160.c
+++ b/firmware/os/drivers/bosch_bmi160/bosch_bmi160.c
@@ -3087,8 +3087,11 @@
                 (int)(d->strength * 1000),
                 (int)(d->declination * 180 / M_PI + 0.5f),
                 (int)(d->inclination * 180 / M_PI + 0.5f));
-        //TODO: pass local field information to mag calibration routine
-        //      and rotation vector sensor.
+
+        // Passing local field information to mag calibration routine
+        diversityCheckerLocalFieldUpdate(&mTask.moc.diversity_checker, d->strength);
+
+        // TODO: pass local field information to rotation vector sensor.
     } else {
         ERROR_PRINT("magCfgData: unknown type 0x%04x, size %d", p->type, p->size);
     }