rtl433  UNKNOWN
RTL-433 utility
pulse_detect.h File Reference

Pulse detection functions. More...

Go to the source code of this file.

Data Structures

struct  pulse_data
 Data for a compact representation of generic pulse train. More...
 

Typedefs

typedef struct pulse_data pulse_data_t
 Data for a compact representation of generic pulse train. More...
 
typedef struct pulse_detect pulse_detect_t
 

Enumerations

enum  package_types { PULSE_DATA_OOK = 1, PULSE_DATA_FSK = 2 }
 

Functions

void pulse_data_clear (pulse_data_t *data)
 Clear the content of a pulse_data_t structure. More...
 
void pulse_data_print (pulse_data_t const *data)
 Print the content of a pulse_data_t structure (for debug). More...
 
void pulse_data_dump_raw (uint8_t *buf, unsigned len, uint64_t buf_offset, pulse_data_t const *data, uint8_t bits)
 Dump the content of a pulse_data_t structure as raw binary. More...
 
void pulse_data_print_vcd_header (FILE *file, uint32_t sample_rate)
 Print a header for the VCD format. More...
 
void pulse_data_print_vcd (FILE *file, pulse_data_t const *data, int ch_id)
 Print the content of a pulse_data_t structure in VCD format. More...
 
void pulse_data_load (FILE *file, pulse_data_t *data)
 Read the next pulse_data_t structure from OOK text. More...
 
void pulse_data_print_pulse_header (FILE *file)
 Print a header for the OOK text format. More...
 
void pulse_data_dump (FILE *file, pulse_data_t *data)
 Print the content of a pulse_data_t structure as OOK text. More...
 
pulse_detect_tpulse_detect_create (void)
 
void pulse_detect_free (pulse_detect_t *pulse_detect)
 
int pulse_detect_package (pulse_detect_t *pulse_detect, int16_t const *envelope_data, int16_t const *fm_data, int len, int16_t level_limit, uint32_t samp_rate, uint64_t sample_offset, pulse_data_t *pulses, pulse_data_t *fsk_pulses)
 Demodulate On/Off Keying (OOK) and Frequency Shift Keying (FSK) from an envelope signal. More...
 
void pulse_analyzer (pulse_data_t *data, int package_type)
 Analyze and print result. More...
 

Detailed Description

Pulse detection functions.

Copyright (C) 2015 Tommy Vestermark

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Typedef Documentation

◆ pulse_data_t

typedef struct pulse_data pulse_data_t

Data for a compact representation of generic pulse train.

◆ pulse_detect_t

typedef struct pulse_detect pulse_detect_t

Enumeration Type Documentation

◆ package_types

Enumerator
PULSE_DATA_OOK 
PULSE_DATA_FSK 

Function Documentation

◆ pulse_analyzer()

◆ pulse_data_clear()

void pulse_data_clear ( pulse_data_t data)

Clear the content of a pulse_data_t structure.

Referenced by pulse_data_load(), and pulse_detect_package().

◆ pulse_data_dump()

void pulse_data_dump ( FILE *  file,
pulse_data_t data 
)

Print the content of a pulse_data_t structure as OOK text.

References pulse_data::freq1_hz, pulse_data::freq2_hz, pulse_data::fsk_f2_est, pulse_data::gap, pulse_data::num_pulses, pulse_data::pulse, and pulse_data::sample_rate.

Referenced by sdr_callback().

◆ pulse_data_dump_raw()

void pulse_data_dump_raw ( uint8_t buf,
unsigned  len,
uint64_t  buf_offset,
pulse_data_t const *  data,
uint8_t  bits 
)

Dump the content of a pulse_data_t structure as raw binary.

References bounded_memset(), pulse_data::gap, pulse_data::num_pulses, pulse_data::offset, and pulse_data::pulse.

Referenced by sdr_callback().

◆ pulse_data_load()

void pulse_data_load ( FILE *  file,
pulse_data_t data 
)

Read the next pulse_data_t structure from OOK text.

References pulse_data::freq1_hz, pulse_data::freq2_hz, pulse_data::gap, pulse_data::num_pulses, pulse_data::pulse, pulse_data_clear(), and pulse_data::sample_rate.

Referenced by main().

◆ pulse_data_print()

void pulse_data_print ( pulse_data_t const *  data)

Print the content of a pulse_data_t structure (for debug).

References pulse_data::gap, pulse_data::num_pulses, and pulse_data::pulse.

Referenced by sdr_callback().

◆ pulse_data_print_pulse_header()

void pulse_data_print_pulse_header ( FILE *  file)

Print a header for the OOK text format.

References format_time_str().

Referenced by add_dumper().

◆ pulse_data_print_vcd()

void pulse_data_print_vcd ( FILE *  file,
pulse_data_t const *  data,
int  ch_id 
)

Print the content of a pulse_data_t structure in VCD format.

References pulse_data::gap, pulse_data::num_pulses, pulse_data::offset, pulse_data::pulse, and pulse_data::sample_rate.

Referenced by sdr_callback().

◆ pulse_data_print_vcd_header()

void pulse_data_print_vcd_header ( FILE *  file,
uint32_t  sample_rate 
)

Print a header for the VCD format.

References format_time_str(), and nice_freq().

Referenced by add_dumper().

◆ pulse_detect_create()

pulse_detect_t* pulse_detect_create ( void  )

Referenced by main().

◆ pulse_detect_free()

void pulse_detect_free ( pulse_detect_t pulse_detect)

Referenced by r_free_cfg().

◆ pulse_detect_package()

int pulse_detect_package ( pulse_detect_t pulse_detect,
int16_t const *  envelope_data,
int16_t const *  fm_data,
int  len,
int16_t  level_limit,
uint32_t  samp_rate,
uint64_t  sample_offset,
pulse_data_t pulses,
pulse_data_t fsk_pulses 
)

Demodulate On/Off Keying (OOK) and Frequency Shift Keying (FSK) from an envelope signal.

Function is stateful and can be called with chunks of input data.

Parameters
envelope_dataSamples with amplitude envelope of carrier
fm_dataSamples with frequency offset from center frequency
lenNumber of samples in input buffers
samp_rateSample rate in samples per second
[in,out]pulsesWill return a pulse_data_t structure
[in,out]fsk_pulsesWill return a pulse_data_t structure for FSK demodulated data
Returns
0 if all input sample data is processed
1 if OOK package is detected (but all sample data is still not completely processed)
2 if FSK package is detected (but all sample data is still not completely processed)

References pulse_detect::data_counter, pulse_data::end_ago, pulse_FSK_state_t::fm_f1_est, pulse_FSK_state_t::fm_f2_est, pulse_data::fsk_f1_est, pulse_data::fsk_f2_est, pulse_detect::FSK_state, pulse_data::gap, pulse_detect::lead_in_counter, pulse_detect::max_pulse, pulse_data::num_pulses, pulse_data::offset, pulse_data::ook_high_estimate, pulse_detect::ook_high_estimate, pulse_data::ook_low_estimate, pulse_detect::ook_low_estimate, pulse_detect::ook_state, pulse_data::pulse, pulse_data_clear(), PULSE_DATA_FSK, PULSE_DATA_OOK, pulse_FSK_detect(), pulse_FSK_wrap_up(), pulse_detect::pulse_length, pulse_data::sample_rate, and pulse_data::start_ago.

Referenced by sdr_callback().