From b77d52bd1f193847e3fbd5bebefc788fd43b833f Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 22 Jan 2015 15:30:34 +0000 Subject: [PATCH] Include recent RSSI in aircraft output. --- net_io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net_io.c b/net_io.c index c4265d5..a1ed88a 100644 --- a/net_io.c +++ b/net_io.c @@ -772,8 +772,10 @@ char *generateAircraftJson(const char *url_path, int *len) { if (a->bFlags & MODES_ACFLAGS_SPEED_VALID) p += snprintf(p, end-p, ",\"speed\":%d", a->speed); - p += snprintf(p, end-p, ",\"messages\":%ld, \"seen\":%d}", - a->messages, (int)(now - a->seen)); + p += snprintf(p, end-p, ",\"messages\":%ld,\"seen\":%d,\"rssi\":%.1f}", + a->messages, (int)(now - a->seen), + 10 * log10((a->signalLevel[0] + a->signalLevel[1] + a->signalLevel[2] + a->signalLevel[3] + + a->signalLevel[4] + a->signalLevel[5] + a->signalLevel[6] + a->signalLevel[7] + 1e-5) / 8)); // If we're getting near the end of the buffer, expand it. if ((end - p) < 256) {