From 451381ddef42d826a4fc6c4111ee8098b289071e Mon Sep 17 00:00:00 2001 From: c vw Date: Mon, 4 Nov 2019 16:53:20 +0100 Subject: [PATCH] a) save/restore DIVERSITY settings b) upon startup, do not activate DIVERSITY unless there are two ADCs. --- radio.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/radio.c b/radio.c index d7a2e10..f3457ec 100644 --- a/radio.c +++ b/radio.c @@ -725,7 +725,9 @@ void start_radio() { // It is possible that an option has been read in // which is not compatible with the hardware. // Change setting to reasonable value then. +// This could possibly be moved to radioRestoreState(). // +// Sanity Check #1: restrict buffer size in new protocol // switch (protocol) { case ORIGINAL_PROTOCOL: @@ -740,6 +742,12 @@ void start_radio() { break; #endif } +// +// Sanity Check #2: enable diversity only if there are two RX and two ADCs +// + if (RECEIVERS < 2 || n_adc < 2) { + diversity_enabled=0; + } radio_change_region(region); @@ -1459,6 +1467,16 @@ fprintf(stderr,"sem_wait\n"); fprintf(stderr,"sem_wait: returner\n"); loadProperties(property_path); + value=getProperty("diversity_enabled"); + if (value) diversity_enabled=atoi(value); + value=getProperty("diversity_gain"); + if (value) div_gain=atof(value); + value=getProperty("diversity_phase"); + if (value) div_phase=atof(value); + value=getProperty("diversity_cos"); + if (value) div_cos=atof(value); + value=getProperty("diversity_sin"); + if (value) div_sin=atof(value); value=getProperty("new_pa_board"); if (value) new_pa_board=atoi(value); value=getProperty("region"); @@ -1698,6 +1716,16 @@ fprintf(stderr,"sem_wait\n"); sem_wait(&property_sem); #endif fprintf(stderr,"sem_wait: returned\n"); + sprintf(value,"%d",diversity_enabled); + setProperty("diversity_enabled",value); + sprintf(value,"%f",div_gain); + setProperty("diversity_gain",value); + sprintf(value,"%f",div_phase); + setProperty("diversity_phase",value); + sprintf(value,"%f",div_cos); + setProperty("diversity_cos",value); + sprintf(value,"%f",div_sin); + setProperty("diversity_sin",value); sprintf(value,"%d",new_pa_board); setProperty("new_pa_board",value); sprintf(value,"%d",region); -- 2.45.2