From a68174bafc239aaecc9c71af390bff8faa6fd5d9 Mon Sep 17 00:00:00 2001 From: Alan Mitchell Date: Tue, 16 Jul 2019 19:58:59 -0800 Subject: [PATCH] Added signal RSSI to collected data. --- bmsapp/views.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bmsapp/views.py b/bmsapp/views.py index 50d221d..ff6b1cc 100644 --- a/bmsapp/views.py +++ b/bmsapp/views.py @@ -273,10 +273,12 @@ def store_readings_things(request): if fld not in EXCLUDE_THINGS_FIELDS: readings.append( [ts, f'{hdw_serial}_{fld}', val] ) - # Also extract the max SNR received by gateways that received this - # message - snrs = [gtw['snr'] for gtw in req_data['metadata']['gateways']] - readings.append([ts, f'{hdw_serial}_snr', max(snrs)]) + # Also extract the SNR and RSSI received by gateway that received this + # message and had the best SNR. + sigs = [(gtw['snr'], gtw['rssi']) for gtw in req_data['metadata']['gateways']] + snr, rssi = max(sigs) + readings.append([ts, f'{hdw_serial}_snr', snr]) + readings.append([ts, f'{hdw_serial}_rssi', rssi]) msg = storereads.store_many({'readings': readings}) -- 2.26.2