From 6443809ff9dc7eb29db70d32be3097d3daa17fd3 Mon Sep 17 00:00:00 2001 From: Gennaro Tortone Date: Mon, 22 May 2017 20:32:40 +0200 Subject: [PATCH] hop interval param added (multiple frequencies) --- src/rtl_433.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/rtl_433.c b/src/rtl_433.c index fb72d80b..9c787184 100755 --- a/src/rtl_433.c +++ b/src/rtl_433.c @@ -74,6 +74,7 @@ struct dm_state { int analyze; int analyze_pulses; int debug_mode; + int hop_time; /* Signal grabber variables */ int signal_grabber; @@ -100,6 +101,7 @@ void usage(r_device *devices) { "\t[-d ] (default: 0)\n" "\t[-g ] (default: 0 for auto)\n" "\t[-f ] [-f...] Receive frequency(s) (default: %i Hz)\n" + "\t[-H ] Hop interval for polling of multiple frequencies (default: %i seconds)\n" "\t[-p ] Set sample rate (default: %i Hz)\n" "\t[-S] Force sync output (default: async)\n" @@ -133,7 +135,7 @@ void usage(r_device *devices) { "\t[-T] specify number of seconds to run\n" "\t[-U] Print timestamps in UTC (this may also be accomplished by invocation with TZ environment variable set).\n" "\t[] Save data stream to output file (a '-' dumps samples to stdout)\n\n", - DEFAULT_FREQUENCY, DEFAULT_SAMPLE_RATE, DEFAULT_LEVEL_LIMIT); + DEFAULT_FREQUENCY, DEFAULT_HOP_TIME, DEFAULT_SAMPLE_RATE, DEFAULT_LEVEL_LIMIT); fprintf(stderr, "Supported device protocols:\n"); for (i = 0; i < num_r_devices; i++) { @@ -744,7 +746,7 @@ static void rtlsdr_callback(unsigned char *iq_buf, uint32_t len, void *ctx) { time_t rawtime; time(&rawtime); if (frequencies > 1) { - if (difftime(rawtime, rawtime_old) > DEFAULT_HOP_TIME || events >= DEFAULT_HOP_EVENTS) { + if (difftime(rawtime, rawtime_old) > demod->hop_time || events >= DEFAULT_HOP_EVENTS) { rawtime_old = rawtime; events = 0; do_exit_async = 1; @@ -898,8 +900,9 @@ int main(int argc, char **argv) { num_r_devices = sizeof(devices)/sizeof(*devices); demod->level_limit = DEFAULT_LEVEL_LIMIT; + demod->hop_time = DEFAULT_HOP_TIME; - while ((opt = getopt(argc, argv, "x:z:p:DtaAI:qm:r:l:d:f:g:s:b:n:SR:F:C:T:UWG")) != -1) { + while ((opt = getopt(argc, argv, "x:z:p:DtaAI:qm:r:l:d:f:H:g:s:b:n:SR:F:C:T:UWG")) != -1) { switch (opt) { case 'd': dev_index = atoi(optarg); @@ -908,6 +911,9 @@ int main(int argc, char **argv) { if (frequencies < MAX_PROTOCOLS) frequency[frequencies++] = (uint32_t) atof(optarg); else fprintf(stderr, "Max number of frequencies reached %d\n", MAX_PROTOCOLS); break; + case 'H': + demod->hop_time = atoi(optarg); + break; case 'g': gain = (int) (atof(optarg) * 10); /* tenths of a dB */ break;