diff --git a/README.md b/README.md index f91cff1..2e25b89 100644 --- a/README.md +++ b/README.md @@ -169,8 +169,8 @@ If you have set `READSB_GAIN=autogain`, then the system will take signal strengt There are 2 distinct periods in which the container will attempt to figure out the gain: -* The initial period of 90 minutes, in which a measurement is taken every 5 minutes -* The subsequent period, in which a measurement is taken once every day +* The initial period of 2 hours, in which an adjustment is done every 5 minutes +* The subsequent period, in which an adjustment is done once every day Please note that in order for the initial period to complete, the container must run for 90 minutes without restarting. @@ -182,10 +182,11 @@ Although not recommended, you can change the measurement intervals and low/high | Environment Variable | Purpose | Default | |----------------------|---------|---------| +| `READSB_AUTOGAIN_INITIAL_TIMEPERIOD` | How long the Initial Time Period should last (in seconds) | `7200` | | `READSB_AUTOGAIN_INITIAL_INTERVAL` | The measurement interval to optimize gain during the initial period of 90 minutes (in seconds) | `300` | | `READSB_AUTOGAIN_SUBSEQUENT_INTERVAL` | The measurement interval to optimize gain during the subsequent period (in seconds) | `86400` | -| `READSB_AUTOGAIN_LOW_PCT` | If the percentage of "strong signals" (stronger than 3dBFS RSSI) is below this number, gain will be increased | `0.5` | -| `READSB_AUTOGAIN_HIGH_PCT` | If the percentage of "strong signals" (stronger than 3dBFS RSSI) is above this number, gain will be decreased | `7.0` | +| `READSB_AUTOGAIN_LOW_PCT` | If the percentage of "strong signals" (stronger than 3dBFS RSSI) is below this number, gain will be increased | `2.5` | +| `READSB_AUTOGAIN_HIGH_PCT` | If the percentage of "strong signals" (stronger than 3dBFS RSSI) is above this number, gain will be decreased | `6.0` | If you need to reset AutoGain and start over determining the gain, you can do so with this command: diff --git a/rootfs/etc/services.d/autogain/run b/rootfs/etc/services.d/autogain/run index a2083f5..d0ef46a 100644 --- a/rootfs/etc/services.d/autogain/run +++ b/rootfs/etc/services.d/autogain/run @@ -11,6 +11,7 @@ READSB_AUTOGAIN_INITIAL_INTERVAL="${READSB_AUTOGAIN_INITIAL_INTERVAL:-300}" READSB_AUTOGAIN_SUBSEQUENT_INTERVAL="${READSB_AUTOGAIN_SUBSEQUENT_INTERVAL:-86400}" +READSB_AUTOGAIN_INITIAL_TIMEPERIOD="${READSB_AUTOGAIN_INITIAL_TIMEPERIOD:-7200}" if [[ "${READSB_GAIN,,}" != "autogain" ]]; then # Autogain is not enabled, so let's do nothing forever @@ -26,8 +27,8 @@ mkdir -p /var/globe_history/autogain # Do special things if it's the first time AUTOGAIN is running if [[ ! -f /var/globe_history/autogain/autogain_initialized ]]; then - # run autogain every $READSB_AUTOGAIN_INITIAL_INTERVAL minutes for 90 minutes - for (( i=0; i<$((5400/READSB_AUTOGAIN_INITIAL_INTERVAL)); i++ )) + # run autogain every $READSB_AUTOGAIN_INITIAL_INTERVAL secs (default 5 mins) for $READSB_AUTOGAIN_INITIAL_TIMEPERIOD secs (default 2 hours) + for (( i=0; i<$(( READSB_AUTOGAIN_INITIAL_TIMEPERIOD / READSB_AUTOGAIN_INITIAL_INTERVAL )); i++ )) do sleep "$READSB_AUTOGAIN_INITIAL_INTERVAL" # sleep first to give readsb the opportunity to collect some initial data /usr/local/bin/autogain1090 2>&1 | mawk -W Interactive '{print "[autogain] " $0}' diff --git a/rootfs/usr/local/bin/autogain1090 b/rootfs/usr/local/bin/autogain1090 index 8fbacfa..1eee71e 100755 --- a/rootfs/usr/local/bin/autogain1090 +++ b/rootfs/usr/local/bin/autogain1090 @@ -1,8 +1,8 @@ #!/usr/bin/with-contenv bash # shellcheck shell=bash -low="${READSB_AUTOGAIN_LOW_PCT:-0.5}" -high="${READSB_AUTOGAIN_HIGH_PCT:-7.0}" +low="${READSB_AUTOGAIN_LOW_PCT:-2.5}" +high="${READSB_AUTOGAIN_HIGH_PCT:-6.0}" ga=(0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 -10) tmp=/var/globe_history/autogain mkdir -p $tmp