rtl433
UNKNOWN
RTL-433 utility
|
A two-dimensional bit buffer consisting of bytes. More...
Go to the source code of this file.
Data Structures | |
struct | bitbuffer |
Bit buffer. More... | |
Typedefs | |
typedef uint8_t | bitrow_t[BITBUF_COLS] |
typedef bitrow_t | bitarray_t[BITBUF_ROWS] |
typedef struct bitbuffer | bitbuffer_t |
Bit buffer. More... | |
Functions | |
void | bitbuffer_clear (bitbuffer_t *bits) |
Clear the content of the bitbuffer. More... | |
void | bitbuffer_add_bit (bitbuffer_t *bits, int bit) |
Add a single bit at the end of the bitbuffer (MSB first). More... | |
void | bitbuffer_add_row (bitbuffer_t *bits) |
Add a new row to the bitbuffer. More... | |
void | bitbuffer_add_sync (bitbuffer_t *bits) |
Increment sync counter, add new row if not empty. More... | |
void | bitbuffer_extract_bytes (bitbuffer_t *bitbuffer, unsigned row, unsigned pos, uint8_t *out, unsigned len) |
Extract (potentially unaligned) bytes from the bit buffer. Len is bits. More... | |
void | bitbuffer_invert (bitbuffer_t *bits) |
Invert all bits in the bitbuffer (do not invert the empty bits). More... | |
void | bitbuffer_nrzs_decode (bitbuffer_t *bits) |
Non-Return-to-Zero Space (NRZI) decode the bitbuffer. More... | |
void | bitbuffer_nrzm_decode (bitbuffer_t *bits) |
Non-Return-to-Zero Mark (NRZI) decode the bitbuffer. More... | |
void | bitbuffer_print (const bitbuffer_t *bits) |
Print the content of the bitbuffer. More... | |
void | bitbuffer_debug (const bitbuffer_t *bits) |
Debug the content of the bitbuffer. More... | |
void | bitrow_print (bitrow_t const bitrow, unsigned bit_len) |
Print the content of a bit row (byte buffer). More... | |
void | bitrow_debug (bitrow_t const bitrow, unsigned bit_len) |
Debug the content of a bit row (byte buffer). More... | |
void | bitbuffer_parse (bitbuffer_t *bits, const char *code) |
Parse a string into a bitbuffer. More... | |
unsigned | bitbuffer_search (bitbuffer_t *bitbuffer, unsigned row, unsigned start, const uint8_t *pattern, unsigned pattern_bits_len) |
Search the specified row of the bitbuffer, starting from bit 'start', for the pattern provided. More... | |
unsigned | bitbuffer_manchester_decode (bitbuffer_t *inbuf, unsigned row, unsigned start, bitbuffer_t *outbuf, unsigned max) |
Manchester decoding from one bitbuffer into another, starting at the specified row and start bit. More... | |
unsigned | bitbuffer_differential_manchester_decode (bitbuffer_t *inbuf, unsigned row, unsigned start, bitbuffer_t *outbuf, unsigned max) |
Differential Manchester decoding from one bitbuffer into another, starting at the specified row and start bit. More... | |
int | compare_rows (bitbuffer_t *bits, unsigned row_a, unsigned row_b) |
Function to compare bitbuffer rows and count repetitions. More... | |
unsigned | count_repeats (bitbuffer_t *bits, unsigned row) |
int | bitbuffer_find_repeated_row (bitbuffer_t *bits, unsigned min_repeats, unsigned min_bits) |
Find a repeated row that has a minimum count of bits. More... | |
static uint8_t | bitrow_get_bit (const bitrow_t bitrow, unsigned bit_idx) |
Return a single bit from a bitrow at bit_idx position. More... | |
static uint8_t | bitrow_get_byte (const bitrow_t bitrow, unsigned bit_idx) |
Return a single byte from a bitrow at bit_idx position (which may be unaligned). More... | |
A two-dimensional bit buffer consisting of bytes.
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 bitrow_t bitarray_t[BITBUF_ROWS] |
typedef struct bitbuffer bitbuffer_t |
Bit buffer.
typedef uint8_t bitrow_t[BITBUF_COLS] |
void bitbuffer_add_bit | ( | bitbuffer_t * | bits, |
int | bit | ||
) |
Add a single bit at the end of the bitbuffer (MSB first).
References bitbuffer::bb, bitbuffer::bits_per_row, and bitbuffer::num_rows.
Referenced by am_analyze_classify(), bitbuffer_differential_manchester_decode(), bitbuffer_manchester_decode(), bitbuffer_parse(), ge_decode(), lightwave_rf_callback(), main(), pulse_demod_dmc(), pulse_demod_manchester_zerobit(), pulse_demod_osv1(), pulse_demod_pcm(), pulse_demod_piwm_dc(), pulse_demod_piwm_raw(), pulse_demod_ppm(), pulse_demod_pwm(), and vaillant_vrt340_callback().
void bitbuffer_add_row | ( | bitbuffer_t * | bits | ) |
Add a new row to the bitbuffer.
References bitbuffer::bits_per_row, and bitbuffer::num_rows.
Referenced by am_analyze_classify(), bitbuffer_add_sync(), bitbuffer_parse(), lightwave_rf_callback(), main(), pulse_demod_dmc(), pulse_demod_manchester_zerobit(), pulse_demod_piwm_dc(), pulse_demod_piwm_raw(), pulse_demod_ppm(), and pulse_demod_pwm().
void bitbuffer_add_sync | ( | bitbuffer_t * | bits | ) |
Increment sync counter, add new row if not empty.
References bitbuffer_add_row(), bitbuffer::bits_per_row, bitbuffer::num_rows, and bitbuffer::syncs_before_row.
Referenced by pulse_demod_ppm(), and pulse_demod_pwm().
void bitbuffer_clear | ( | bitbuffer_t * | bits | ) |
Clear the content of the bitbuffer.
References bitbuffer::bb, bitbuffer::bits_per_row, and bitbuffer::num_rows.
Referenced by am_analyze_classify(), bitbuffer_parse(), main(), pulse_demod_dmc(), pulse_demod_manchester_zerobit(), pulse_demod_pcm(), pulse_demod_piwm_dc(), pulse_demod_piwm_raw(), pulse_demod_ppm(), and pulse_demod_pwm().
void bitbuffer_debug | ( | const bitbuffer_t * | bits | ) |
unsigned bitbuffer_differential_manchester_decode | ( | bitbuffer_t * | inbuf, |
unsigned | row, | ||
unsigned | start, | ||
bitbuffer_t * | outbuf, | ||
unsigned | max | ||
) |
Differential Manchester decoding from one bitbuffer into another, starting at the specified row and start bit.
Decode at most 'max' data bits (i.e. 2*max) bits from the input buffer). Return the bit position in the input row (i.e. returns start + 2*outbuf->bits_per_row[0]).
References bitbuffer::bb, bit(), bitbuffer_add_bit(), and bitbuffer::bits_per_row.
Referenced by tpms_pmv107j_decode(), and tpms_toyota_decode().
void bitbuffer_extract_bytes | ( | bitbuffer_t * | bitbuffer, |
unsigned | row, | ||
unsigned | pos, | ||
uint8_t * | out, | ||
unsigned | len | ||
) |
Extract (potentially unaligned) bytes from the bit buffer. Len is bits.
References bitbuffer::bb.
Referenced by alecto_ws1200v1_callback(), alecto_ws1200v2_callback(), alecto_ws1200v2_dcf_callback(), ambient_weather_decode(), ambientweather_tx8300_callback(), ambientweather_wh31e_callback(), bresser_5in1_callback(), companion_wtr001_decode(), decode_xc0324_message(), directv_decode(), ecowitt_decode(), emontx_callback(), esa_cost_callback(), esic_emt7110_decode(), esperanza_ews_callback(), fineoffset_WH0290_callback(), fineoffset_WH0530_callback(), fineoffset_wh1050_callback(), fineoffset_wh1080_callback(), fineoffset_WH24_callback(), fineoffset_WH25_callback(), fineoffset_WH2_callback(), flex_callback(), ge_coloreffects_decode(), gt_wt_02_process_row(), holman_ws5029_decode(), ht680_callback(), ibis_beacon_callback(), ikea_sparsnas_callback(), interlogix_callback(), kedsum_callback(), lacrosse_it(), m_bus_mode_c_t_callback(), m_bus_mode_r_callback(), oregon_scientific_sl109h_callback(), oregon_scientific_v3_decode(), radiohead_ask_extract(), s3318p_callback(), schrader_EG53MA4_callback(), schraeder_callback(), tpms_pmv107j_decode(), ts_ft002_decoder(), and ttx201_decode().
int bitbuffer_find_repeated_row | ( | bitbuffer_t * | bits, |
unsigned | min_repeats, | ||
unsigned | min_bits | ||
) |
Find a repeated row that has a minimum count of bits.
Return the row index or -1.
References bitbuffer::bits_per_row, count_repeats(), and bitbuffer::num_rows.
Referenced by acurite_606_decode(), bresser_3ch_callback(), bt_rain_callback(), companion_wtr001_decode(), dish_remote_6_3_callback(), elro_db286a_callback(), eurochron_callback(), flex_callback(), honeywell_wdb_callback(), kedsum_callback(), kw9015b_callback(), lacrosse_tx141x_decode(), maverick_et73_sensor_callback(), new_template_decode(), nexus_callback(), prologue_callback(), quhwa_callback(), rftech_callback(), rubicson_48659_decode(), s3318p_callback(), smoke_gs558_callback(), ss_sensor_callback(), tfa_303196_callback(), tfa_twin_plus_303049_callback(), thermopro_tp11_sensor_callback(), thermopro_tp12_sensor_callback(), and wssensor_callback().
void bitbuffer_invert | ( | bitbuffer_t * | bits | ) |
Invert all bits in the bitbuffer (do not invert the empty bits).
References bitbuffer::bb, bitbuffer::bits_per_row, and bitbuffer::num_rows.
Referenced by acurite_00275rm_decode(), acurite_txr_decode(), calibeur_rf104_callback(), current_cost_decode(), flex_callback(), hideki_ts04_callback(), honeywell_wdb_callback(), lacrosse_tx141x_decode(), lightwave_rf_callback(), main(), new_template_decode(), newkaku_callback(), nexa_callback(), philips_aj3650_decode(), philips_aj7010_decode(), proove_callback(), smoke_gs558_callback(), ss_sensor_callback(), tpms_citroen_decode(), tpms_ford_callback(), tpms_jansite_callback(), and tpms_renault_callback().
unsigned bitbuffer_manchester_decode | ( | bitbuffer_t * | inbuf, |
unsigned | row, | ||
unsigned | start, | ||
bitbuffer_t * | outbuf, | ||
unsigned | max | ||
) |
Manchester decoding from one bitbuffer into another, starting at the specified row and start bit.
Decode at most 'max' data bits (i.e. 2*max) bits from the input buffer). Return the bit position in the input row (i.e. returns start + 2*outbuf->bits_per_row[0]). per IEEE 802.3 conventions, i.e. high-low is a 0 bit, low-high is a 1 bit.
References bitbuffer::bb, bit(), bitbuffer_add_bit(), and bitbuffer::bits_per_row.
Referenced by current_cost_decode(), maverick_et73x_callback(), newkaku_callback(), nexa_callback(), oil_standard_decode(), oil_watchman_callback(), oregon_scientific_v2_1_decode(), proove_callback(), tfa_303196_callback(), tpms_citroen_decode(), tpms_ford_decode(), tpms_jansite_decode(), and tpms_renault_decode().
void bitbuffer_nrzm_decode | ( | bitbuffer_t * | bits | ) |
Non-Return-to-Zero Mark (NRZI) decode the bitbuffer.
"One" is represented by change in level, "Zero" is represented by no change in level.
References bitbuffer::bb, bitbuffer::bits_per_row, and bitbuffer::num_rows.
void bitbuffer_nrzs_decode | ( | bitbuffer_t * | bits | ) |
Non-Return-to-Zero Space (NRZI) decode the bitbuffer.
"One" is represented by no change in level, "Zero" is represented by change in level.
References bitbuffer::bb, bitbuffer::bits_per_row, and bitbuffer::num_rows.
Referenced by main().
void bitbuffer_parse | ( | bitbuffer_t * | bits, |
const char * | code | ||
) |
Parse a string into a bitbuffer.
References bitbuffer_add_bit(), bitbuffer_add_row(), bitbuffer_clear(), bitbuffer::bits_per_row, and bitbuffer::num_rows.
Referenced by parse_bits(), and pulse_demod_string().
void bitbuffer_print | ( | const bitbuffer_t * | bits | ) |
Print the content of the bitbuffer.
References print_bitbuffer().
Referenced by am_analyze_classify(), bitbuffer_printf(), danfoss_cfr_callback(), dish_remote_6_3_callback(), dsc_callback(), fineoffset_WH24_callback(), flex_callback(), fordremote_callback(), honeywell_wdb_callback(), lightwave_rf_callback(), m_bus_mode_c_t_callback(), m_bus_mode_f_callback(), main(), nexus_callback(), pulse_demod_dmc(), pulse_demod_manchester_zerobit(), pulse_demod_pcm(), pulse_demod_piwm_dc(), pulse_demod_piwm_raw(), pulse_demod_ppm(), pulse_demod_pwm(), pulse_demod_string(), tpms_pmv107j_decode(), ttx201_decode(), wssensor_callback(), wt1024_callback(), and x10_sec_callback().
unsigned bitbuffer_search | ( | bitbuffer_t * | bitbuffer, |
unsigned | row, | ||
unsigned | start, | ||
const uint8_t * | pattern, | ||
unsigned | pattern_bits_len | ||
) |
Search the specified row of the bitbuffer, starting from bit 'start', for the pattern provided.
Return the location of the first match, or the end of the row if no match is found. The pattern starts in the high bit. For example if searching for 011011 the byte pointed to by 'pattern' would be 0xAC. (011011xx).
References bitbuffer::bb, bit(), and bitbuffer::bits_per_row.
Referenced by ambient_weather_callback(), ambientweather_wh31e_callback(), bresser_5in1_callback(), current_cost_decode(), danfoss_cfr_callback(), emontx_callback(), esic_emt7110_decode(), fineoffset_WH0290_callback(), fineoffset_WH24_callback(), fineoffset_WH25_callback(), flex_callback(), ge_coloreffects_callback(), holman_ws5029_decode(), ibis_beacon_callback(), ikea_sparsnas_callback(), interlogix_callback(), lacrosse_it(), lacrosse_ws7000_decode(), m_bus_mode_c_t_callback(), m_bus_mode_f_callback(), m_bus_mode_r_callback(), oil_standard_callback(), oil_watchman_callback(), radiohead_ask_extract(), tfa_303196_callback(), tpms_citroen_callback(), tpms_ford_callback(), tpms_jansite_callback(), tpms_pmv107j_callback(), tpms_renault_callback(), tpms_toyota_callback(), and xc0324_callback().
void bitrow_debug | ( | bitrow_t const | bitrow, |
unsigned | bit_len | ||
) |
Debug the content of a bit row (byte buffer).
References print_bitrow().
Referenced by bitrow_debugf().
Return a single bit from a bitrow at bit_idx position.
Referenced by bitrow_dpwm_decode(), lightwave_rf_callback(), and vaillant_vrt340_callback().
Return a single byte from a bitrow at bit_idx position (which may be unaligned).
Referenced by danfoss_cfr_callback(), ft004b_callback(), m_bus_decode_3of6_buffer(), m_bus_mode_c_t_callback(), and m_bus_mode_f_callback().
void bitrow_print | ( | bitrow_t const | bitrow, |
unsigned | bit_len | ||
) |
Print the content of a bit row (byte buffer).
References print_bitrow().
Referenced by ambient_weather_decode(), bitrow_printf(), lacrossews_detect(), maverick_et73_sensor_callback(), philips_aj3650_decode(), thermopro_tp12_sensor_callback(), tpms_pmv107j_decode(), validate_checksum(), ws2000_callback(), and wssensor_callback().
int compare_rows | ( | bitbuffer_t * | bits, |
unsigned | row_a, | ||
unsigned | row_b | ||
) |
Function to compare bitbuffer rows and count repetitions.
References bitbuffer::bb, and bitbuffer::bits_per_row.
Referenced by count_repeats().
unsigned count_repeats | ( | bitbuffer_t * | bits, |
unsigned | row | ||
) |
References compare_rows(), and bitbuffer::num_rows.
Referenced by bitbuffer_find_repeated_row(), and generic_motion_callback().