// --------------------------------------------------------------
#ifndef _RADIO_FORMATTER_HPP_
#define	_RADIO_FORMATTER_HPP_

#include <radio/radio_types.h>
#include <radio/cpx.h>
#include <cpp/radio/processor/src/Block.hpp>
#include "FrameDefs.hpp"
#include "Scrambler.hpp"


class Formatter : public Processor::Block
{
public:
	Formatter();
	virtual ~Formatter() = default;
	frame_statistics_t getStats();
	void resetStats();

	// Processor::Block
	void prepare() override;
	void process() override;

private:
	Scrambler m_scrambler;
	frame_t m_frame;
	size_t m_dataCount;
	size_t m_idleCount;
	frame_statistics_t m_frameStats;
	Processor::Buffer<uint8_t> *m_buf_in;
	Processor::Buffer<uint8_t> *m_buf_out;

	void process_idle(size_t len);
	void process_data();

	void commit(frame_type frameType, size_t m_dataCount);
};

// --------------------------------------------------------------
#endif // _RADIO_FORMATTER_HPP_
