1 /** @file 2 Definition of r_device struct. 3 */ 4 5 #ifndef INCLUDE_R_DEVICE_H_ 6 #define INCLUDE_R_DEVICE_H_ 7 8 /** Supported modulation types. */ 9 enum modulation_types { 10 OOK_PULSE_MANCHESTER_ZEROBIT = 3, ///< Manchester encoding. Hardcoded zerobit. Rising Edge = 0, Falling edge = 1. 11 OOK_PULSE_PCM_RZ = 4, ///< Pulse Code Modulation with Return-to-Zero encoding, Pulse = 0, No pulse = 1. 12 OOK_PULSE_PPM = 5, ///< Pulse Position Modulation. Short gap = 0, Long = 1. 13 OOK_PULSE_PWM = 6, ///< Pulse Width Modulation with precise timing parameters. 14 OOK_PULSE_PIWM_RAW = 8, ///< Level shift for each bit. Short interval = 1, Long = 0. 15 OOK_PULSE_PIWM_DC = 11, ///< Level shift for each bit. Short interval = 1, Long = 0. 16 OOK_PULSE_DMC = 9, ///< Level shift within the clock cycle. 17 OOK_PULSE_PWM_OSV1 = 10, ///< Pulse Width Modulation. Oregon Scientific v1. 18 OOK_PULSE_NRZS = 12, ///< NRZS modulation 19 FSK_DEMOD_MIN_VAL = 16, ///< Dummy. FSK demodulation must start at this value. 20 FSK_PULSE_PCM = 16, ///< FSK, Pulse Code Modulation. 21 FSK_PULSE_PWM = 17, ///< FSK, Pulse Width Modulation. Short pulses = 1, Long = 0. 22 FSK_PULSE_MANCHESTER_ZEROBIT = 18, ///< FSK, Manchester encoding. 23 }; 24 25 /** Decoders should return n>0 for n packets successfully decoded, 26 an ABORT code if the bitbuffer is no applicable, 27 or a FAIL code if the message is malformed. */ 28 enum decode_return_codes { 29 DECODE_FAIL_OTHER = 0, ///< legacy, do not use 30 /** Bitbuffer row count or row length is wrong for this sensor. */ 31 DECODE_ABORT_LENGTH = -1, 32 DECODE_ABORT_EARLY = -2, 33 /** Message Integrity Check failed: e.g. checksum/CRC doesn't validate. */ 34 DECODE_FAIL_MIC = -3, 35 DECODE_FAIL_SANITY = -4, 36 }; 37 38 struct bitbuffer; 39 struct data; 40 41 /** Device protocol decoder struct. */ 42 typedef struct r_device { 43 unsigned protocol_num; ///< fixed sequence number, assigned in main(). 44 45 /* information provided by each decoder */ 46 char *name; 47 unsigned modulation; 48 float short_width; 49 float long_width; 50 float reset_limit; 51 float gap_limit; 52 float sync_width; 53 float tolerance; 54 int (*decode_fn)(struct r_device *decoder, struct bitbuffer *bitbuffer); 55 struct r_device *(*create_fn)(char *args); 56 unsigned priority; ///< Run later and only if no previous events were produced 57 unsigned disabled; ///< 0: default enabled, 1: default disabled, 2: disabled, 3: disabled and hidden 58 char **fields; ///< List of fields this decoder produces; required for CSV output. NULL-terminated. 59 60 /* public for each decoder */ 61 int verbose; 62 int verbose_bits; 63 void (*output_fn)(struct r_device *decoder, struct data *data); 64 65 /* Decoder results / statistics */ 66 unsigned decode_events; 67 unsigned decode_ok; 68 unsigned decode_messages; 69 unsigned decode_fails[5]; 70 71 /* private for flex decoder and output callback */ 72 void *decode_ctx; 73 void *output_ctx; 74 } r_device; 75 76 #endif /* INCLUDE_R_DEVICE_H_ */ 77