Refactor rtl_433_devices.h to r_device.h

This commit is contained in:
Christian W. Zuckschwerdt 2019-02-17 10:25:23 +00:00
parent 44a5c13c4b
commit 481394657c
9 changed files with 62 additions and 44 deletions

View file

@ -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"

View file

@ -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);

View file

@ -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.
///

48
include/r_device.h Normal file
View file

@ -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_ */

View file

@ -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

View file

@ -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);

View file

@ -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"

View file

@ -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" />

View file

@ -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>