diff --git a/include/am_analyze.h b/include/am_analyze.h index c2611382..4c0e52db 100644 --- a/include/am_analyze.h +++ b/include/am_analyze.h @@ -16,7 +16,7 @@ #define PULSE_DATA_SIZE 4000 /* maximum number of pulses */ -typedef struct { +typedef struct am_analyze { int32_t *level_limit; int override_short; int override_long; diff --git a/include/baseband.h b/include/baseband.h index cb754e6a..9dc431e1 100644 --- a/include/baseband.h +++ b/include/baseband.h @@ -34,39 +34,39 @@ void magnitude_true_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len); #define FILTER_ORDER 1 /// Filter state buffer. -typedef struct { +typedef struct filter_state { int16_t y[FILTER_ORDER]; int16_t x[FILTER_ORDER]; -} FilterState; +} filter_state_t; /// FM_Demod state buffer. -typedef struct { +typedef struct demodfm_state { int32_t br, bi; // Last I/Q sample int32_t xlp, ylp; // Low-pass filter state -} DemodFM_State; +} demodfm_state_t; /** Lowpass filter. Function is stateful - @param *x_buf: input samples to be filtered - @param *y_buf: output from filter + @param x_buf: input samples to be filtered + @param[out] y_buf: output from filter @param len: number of samples to process - @param FilterState: State to store between chunk processing + @param[in,out] state: State to store between chunk processing */ -void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, FilterState *state); +void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, filter_state_t *state); /** FM demodulator. Function is stateful - @param *x_buf: input samples (I/Q samples in interleaved uint8) - @param *y_buf: output from FM demodulator + @param x_buf: input samples (I/Q samples in interleaved uint8) + @param[out] y_buf: output from FM demodulator @param len: number of samples to process - @param DemodFM_State: State to store between chunk processing + @param[in,out] state: State to store between chunk processing */ -void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state); +void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state); /// For evaluation. -void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state); +void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state); /** Initialize tables and constants. Should be called once at startup. diff --git a/include/pulse_detect.h b/include/pulse_detect.h index ae1f2148..87dbb33c 100644 --- a/include/pulse_detect.h +++ b/include/pulse_detect.h @@ -25,7 +25,7 @@ #define PD_MAX_PULSE_MS 100 // Pulse width in ms to exceed to declare End Of Package (e.g. for non OOK packages) /// Data for a compact representation of generic pulse train. -typedef struct { +typedef struct pulse_data { uint64_t offset; ///< Offset to first pulse in number of samples from start of stream. uint32_t sample_rate; ///< Sample rate the pulses are recorded with. unsigned start_ago; ///< Start of first pulse in number of samples ago. diff --git a/include/samp_grab.h b/include/samp_grab.h index 62755d94..4e0d2152 100644 --- a/include/samp_grab.h +++ b/include/samp_grab.h @@ -14,7 +14,7 @@ #include <stdint.h> -typedef struct { +typedef struct samp_grab { uint32_t *frequency; uint32_t *samp_rate; int *sample_size; diff --git a/src/baseband.c b/src/baseband.c index d1c14b03..ac1734c5 100644 --- a/src/baseband.c +++ b/src/baseband.c @@ -120,7 +120,7 @@ void magnitude_true_cs16(int16_t const *iq_buf, uint16_t *y_buf, uint32_t len) but the b coeffs are small so it wont happen Q15.14>>14 = Q15.0 \o/ */ -void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, FilterState *state) +void baseband_low_pass_filter(uint16_t const *x_buf, int16_t *y_buf, uint32_t len, filter_state_t *state) { /// [b,a] = butter(1, 0.01) -> 3x tau (95%) ~100 samples //static int const a[FILTER_ORDER + 1] = {FIX(1.00000), FIX(0.96907)}; @@ -175,7 +175,7 @@ int16_t atan2_int16(int16_t y, int16_t x) return angle; } -void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state) +void baseband_demod_FM(uint8_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state) { /// [b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples //static int const alp[2] = {FIX(1.00000), FIX(0.72654)}; @@ -246,7 +246,7 @@ int32_t atan2_int32(int32_t y, int32_t x) } /// for evaluation. -void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, DemodFM_State *state) +void baseband_demod_FM_cs16(int16_t const *x_buf, int16_t *y_buf, unsigned long num_samples, demodfm_state_t *state) { /// [b,a] = butter(1, 0.1) -> 3x tau (95%) ~10 samples //static int const alp[2] = {FIX32(1.00000), FIX32(0.72654)}; diff --git a/src/rtl_433.c b/src/rtl_433.c index e1753955..0f3344b8 100644 --- a/src/rtl_433.c +++ b/src/rtl_433.c @@ -71,6 +71,18 @@ #define VERSION "version unknown" #endif +char const *version_string(void) +{ + return "rtl_433 " VERSION " inputs file rtl_tcp" +#ifdef RTLSDR + " RTL-SDR" +#endif +#ifdef SOAPYSDR + " SoapySDR" +#endif + ; +} + r_device *flex_create_device(char *spec); // maybe put this in some header file? void data_acquired_handler(r_device *r_dev, data_t *data); @@ -87,8 +99,8 @@ struct dm_state { float f32_buf[MAXIMAL_BUF_LENGTH]; // format conversion buffer int sample_size; // CU8: 1, CS16: 2 pulse_detect_t *pulse_detect; - FilterState lowpass_filter_state; - DemodFM_State demod_FM_state; + filter_state_t lowpass_filter_state; + demodfm_state_t demod_FM_state; int enable_FM_demod; samp_grab_t *samp_grab; am_analyze_t *am_analyze; @@ -111,14 +123,7 @@ struct dm_state { static void print_version(void) { - fprintf(stderr, "rtl_433 " VERSION " inputs file rtl_tcp" -#ifdef RTLSDR - " RTL-SDR" -#endif -#ifdef SOAPYSDR - " SoapySDR" -#endif - "\n"); + fprintf(stderr, "%s\n", version_string()); } static void usage(r_device *devices, unsigned num_devices, int exit_code) diff --git a/tests/baseband-test.c b/tests/baseband-test.c index 11834ed7..a206648b 100644 --- a/tests/baseband-test.c +++ b/tests/baseband-test.c @@ -85,8 +85,8 @@ int main(int argc, char *argv[]) long n_read; unsigned long n_samples; int max_block_size = 4096000; - FilterState state; - DemodFM_State fm_state; + filter_state_t state; + demodfm_state_t fm_state; if (argc <= 1) { return 1;