aboutsummaryrefslogtreecommitdiff
path: root/libqcdm/src/log-items.c
diff options
context:
space:
mode:
Diffstat (limited to 'libqcdm/src/log-items.c')
-rw-r--r--libqcdm/src/log-items.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/libqcdm/src/log-items.c b/libqcdm/src/log-items.c
index de5302c7..4b75a9d2 100644
--- a/libqcdm/src/log-items.c
+++ b/libqcdm/src/log-items.c
@@ -18,6 +18,7 @@
#include <string.h>
#include <stdlib.h>
#include <endian.h>
+#include <sys/param.h>
#include "log-items.h"
#include "errors.h"
@@ -161,7 +162,7 @@ qcdm_log_item_evdo_pilot_sets_result_get_pilot (QcdmResult *result,
u_int32_t num,
u_int32_t *out_pilot_pn,
u_int32_t *out_energy,
- float *out_db,
+ float *out_ecio_db,
u_int32_t *out_band_class,
u_int32_t *out_channel,
u_int32_t *out_window_center)
@@ -213,21 +214,20 @@ qcdm_log_item_evdo_pilot_sets_result_get_pilot (QcdmResult *result,
if (out_window_center)
*out_window_center = window_center;
- /* Log item pilot energy is in units from 0 (bad signal) to about 400
- * (excellent signal), derived by walking around and correlating active
- * pilot energy from this log item to the RSSI from continuous Novatel
- * Snapshot requests.
+ /* Log item pilot energy is in units from 0 (bad signal) to 400+ (excellent
+ * signal), derived by walking around and correlating active pilot energy
+ * from this log item to the RSSI from continuous Novatel Snapshot requests.
*/
-#define MAX_ENERGY 400
-#define MAX_ECIO 32.0
-
- if (energy > MAX_ENERGY)
- energy = MAX_ENERGY;
if (out_energy)
*out_energy = energy;
- if (out_db)
- *out_db = (MAX_ECIO - (((float) energy * MAX_ECIO) / (float) MAX_ENERGY));
+ /* EC/IO (measured in dBm) is not received signal strength; it's an SnR
+ * measurement. Less (-32) = worse, high (0) = better.
+ */
+#define BEST_ENERGY 400
+#define WORST_ECIO 32.0
+ if (out_ecio_db)
+ *out_ecio_db = WORST_ECIO - (((float) MIN (energy, BEST_ENERGY) * WORST_ECIO) / (float) BEST_ENERGY);
return TRUE;
}