From 481394657c3adb15c0fe7257c0a6c035ef031151 Mon Sep 17 00:00:00 2001 From: "Christian W. Zuckschwerdt" <christian@zuckschwerdt.org> Date: Sun, 17 Feb 2019 10:25:23 +0000 Subject: [PATCH] Refactor rtl_433_devices.h to r_device.h --- include/decoder.h | 2 +- include/decoder_util.h | 2 +- include/pulse_demod.h | 2 +- include/r_device.h | 48 ++++++++++++++++++++++++++++++++++++ include/rtl_433_devices.h | 44 +++------------------------------ src/devices/fineoffset.c | 3 +++ src/rtl_433.c | 1 + vs15/rtl_433.vcxproj | 1 + vs15/rtl_433.vcxproj.filters | 3 +++ 9 files changed, 62 insertions(+), 44 deletions(-) create mode 100644 include/r_device.h diff --git a/include/decoder.h b/include/decoder.h index 66c215c6..d7457fe9 100644 --- a/include/decoder.h +++ b/include/decoder.h @@ -6,7 +6,7 @@ #define INCLUDE_DECODER_H_ #include <string.h> -#include "rtl_433_devices.h" +#include "r_device.h" #include "bitbuffer.h" #include "data.h" #include "util.h" diff --git a/include/decoder_util.h b/include/decoder_util.h index 4185b996..34d2ab4d 100644 --- a/include/decoder_util.h +++ b/include/decoder_util.h @@ -14,7 +14,7 @@ #include <stdarg.h> #include "bitbuffer.h" -#include "rtl_433_devices.h" +#include "r_device.h" /// Create a new r_device, copy from template if not NULL. r_device *create_device(r_device *template); diff --git a/include/pulse_demod.h b/include/pulse_demod.h index ec67d38f..d6199d02 100644 --- a/include/pulse_demod.h +++ b/include/pulse_demod.h @@ -15,7 +15,7 @@ #define INCLUDE_PULSE_DEMOD_H_ #include "pulse_detect.h" -#include "rtl_433_devices.h" +#include "r_device.h" /// Demodulate a Pulse Code Modulation signal. /// diff --git a/include/r_device.h b/include/r_device.h new file mode 100644 index 00000000..c4f00b72 --- /dev/null +++ b/include/r_device.h @@ -0,0 +1,48 @@ +/** @file + Definition of r_device struct. +*/ + +#ifndef INCLUDE_R_DEVICE_H_ +#define INCLUDE_R_DEVICE_H_ + +struct bitbuffer; +struct data; + +typedef struct r_device { + unsigned protocol_num; ///< fixed sequence number, assigned in main(). + + /* information provided by each decoder */ + char *name; + unsigned modulation; + float short_width; + float long_width; + float reset_limit; + float gap_limit; + float sync_width; + float tolerance; + int (*decode_fn)(struct r_device *decoder, struct bitbuffer *bitbuffer); + struct r_device *(*create_fn)(char *args); + unsigned disabled; + char **fields; ///< List of fields this decoder produces; required for CSV output. NULL-terminated. + + /* public for each decoder */ + int verbose; + int verbose_bits; + void (*output_fn)(struct r_device *decoder, struct data *data); + + /* private for flex decoder and output callback */ + void *decode_ctx; + void *output_ctx; + + /* private pulse limits (converted to count of samples) */ + float f_short_width; ///< precision reciprocal for PCM. + float f_long_width; ///< precision reciprocal for PCM. + int s_short_width; + int s_long_width; + int s_reset_limit; + int s_gap_limit; + int s_sync_width; + int s_tolerance; +} r_device; + +#endif /* INCLUDE_R_DEVICE_H_ */ diff --git a/include/rtl_433_devices.h b/include/rtl_433_devices.h index 15e173d4..0bfbdfdc 100644 --- a/include/rtl_433_devices.h +++ b/include/rtl_433_devices.h @@ -1,10 +1,12 @@ /** @file - Definition of r_device and all available decoders. + Definition all available decoders. */ #ifndef INCLUDE_RTL_433_DEVICES_H_ #define INCLUDE_RTL_433_DEVICES_H_ +#include "r_device.h" + #define DEVICES \ DECL(silvercrest) \ DECL(rubicson) \ @@ -127,46 +129,6 @@ DECL(bresser_5in1) \ DECL(digitech_xc0324) -struct bitbuffer; -struct data; - -typedef struct r_device { - unsigned protocol_num; ///< fixed sequence number, assigned in main(). - - /* information provided by each decoder */ - char *name; - unsigned modulation; - float short_width; - float long_width; - float reset_limit; - float gap_limit; - float sync_width; - float tolerance; - int (*decode_fn)(struct r_device *decoder, struct bitbuffer *bitbuffer); - struct r_device *(*create_fn)(char *args); - unsigned disabled; - char **fields; ///< List of fields this decoder produces; required for CSV output. NULL-terminated. - - /* public for each decoder */ - int verbose; - int verbose_bits; - void (*output_fn)(struct r_device *decoder, struct data *data); - - /* private for flex decoder and output callback */ - void *decode_ctx; - void *output_ctx; - - /* private pulse limits (converted to count of samples) */ - float f_short_width; ///< precision reciprocal for PCM. - float f_long_width; ///< precision reciprocal for PCM. - int s_short_width; - int s_long_width; - int s_reset_limit; - int s_gap_limit; - int s_sync_width; - int s_tolerance; -} r_device; - #define DECL(name) extern r_device name; DEVICES #undef DECL diff --git a/src/devices/fineoffset.c b/src/devices/fineoffset.c index 38e6bed4..26ddd0a7 100644 --- a/src/devices/fineoffset.c +++ b/src/devices/fineoffset.c @@ -7,9 +7,12 @@ * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ + #include "decoder.h" #include <stdlib.h> +r_device fineoffset_WH2; + static r_device *fineoffset_WH2_create(char *arg) { r_device *r_dev = create_device(&fineoffset_WH2); diff --git a/src/rtl_433.c b/src/rtl_433.c index c4f6e891..b7d0405c 100644 --- a/src/rtl_433.c +++ b/src/rtl_433.c @@ -30,6 +30,7 @@ #include <signal.h> #include "rtl_433.h" +#include "r_device.h" #include "rtl_433_devices.h" #include "sdr.h" #include "baseband.h" diff --git a/vs15/rtl_433.vcxproj b/vs15/rtl_433.vcxproj index df1c9eec..66e5f2e0 100644 --- a/vs15/rtl_433.vcxproj +++ b/vs15/rtl_433.vcxproj @@ -101,6 +101,7 @@ <ClInclude Include="..\include\optparse.h" /> <ClInclude Include="..\include\pulse_demod.h" /> <ClInclude Include="..\include\pulse_detect.h" /> + <ClInclude Include="..\include\r_device.h" /> <ClInclude Include="..\include\r_util.h" /> <ClInclude Include="..\include\rtl_433.h" /> <ClInclude Include="..\include\rtl_433_devices.h" /> diff --git a/vs15/rtl_433.vcxproj.filters b/vs15/rtl_433.vcxproj.filters index 72b6241d..a10ce1fe 100644 --- a/vs15/rtl_433.vcxproj.filters +++ b/vs15/rtl_433.vcxproj.filters @@ -65,6 +65,9 @@ <ClInclude Include="..\include\pulse_detect.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\include\r_device.h"> + <Filter>Header Files</Filter> + </ClInclude> <ClInclude Include="..\include\r_util.h"> <Filter>Header Files</Filter> </ClInclude>