/* -*- c++ -*- */
/*
 * Copyright 2014 Free Software Foundation, Inc.
 *
 * This file is part of GNU Radio
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#ifndef INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_FIXED_IMPL_H
#define INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_FIXED_IMPL_H

#include <gnuradio/satlab/correlate_access_code_tag_fixed.h>

namespace gr {
    namespace satlab {

        class correlate_access_code_tag_fixed_impl :
            public correlate_access_code_tag_fixed
        {
            private:
                enum state_t {STATE_SYNC_SEARCH, STATE_SYNC_FOUND};

                state_t d_state;

                unsigned long long d_access_code;
                unsigned long long d_data_reg;
                unsigned long long d_mask;
                unsigned int d_threshold;
                unsigned int d_len;

                pmt::pmt_t d_key, d_me;
                int d_pkt_len, d_pkt_count, d_pkt_len_current;

            public:
                correlate_access_code_tag_fixed_impl(const std::string &access_code,
                                                     int threshold,
                                                     const std::string &tag_name,
                                                     unsigned int pkt_len);
                ~correlate_access_code_tag_fixed_impl();

                int general_work(int noutput_items,
                                 gr_vector_int &ninput_items,
                                 gr_vector_const_void_star &input_items,
                                 gr_vector_void_star &output_items);

                bool set_access_code(const std::string &access_code);
                void set_packet_len(unsigned int pkt_len);
                void set_threshold(unsigned int threshold);
        };

    } /* namespace satlab */
} /* namespace gr */

#endif /* INCLUDED_DIGITAL_CORRELATE_ACCESS_CODE_FIXED_IMPL_H */
