#pragma once

#include "data/config/LegacyConfig.h"

namespace inertia
{

#define SAMPLING_FREQ_DEFAULT 200
#define SAMPLING_FRAME_SIZE_DEFAULT 4

/** TransmitType */
enum TransmitType {
	TRANSMIT_NONE = 0,
	TRANSMIT_RADIO = 0x01,
	TRANSMIT_SERIAL = 0x02,
	TRANSMIT_BLUETOOTH = 0x04,
	TRANSMIT_RADIO_SERIAL = TRANSMIT_RADIO | TRANSMIT_SERIAL,
	TRANSMIT_RADIO_BLUETOOTH = TRANSMIT_RADIO | TRANSMIT_BLUETOOTH,
	TRANSMIT_SERIAL_BLUETOOTH = TRANSMIT_SERIAL | TRANSMIT_BLUETOOTH,
	TRANSMIT_RADIO_SERIAL_BLUETOOTH = TRANSMIT_RADIO | TRANSMIT_SERIAL | TRANSMIT_BLUETOOTH
};

/** SamplingTimerSource */
enum SamplingTimerSource {
	SAMPLING_TIMER_HIGH_FREQ = 0,
	SAMPLING_TIMER_LOW_FREQ = 1
};

/** SamplingTriggerSource */
enum SamplingTriggerSource {
	SAMPLING_TRIGGER_FASTMAC = 0,
	SAMPLING_TRIGGER_NONE = 1
};

struct INERTIA_API GlobalSamplingConfig
	: LegacyConfig
{
	bool globalEnable;
	bool transmitEnable;
	bool zeroPackets;
	bool disableAutoStart;
	bool bootEventChannelEnabled;

	uint16_t freq;
	SamplingTimerSource timerSource;
	SamplingTriggerSource triggerSource;
	uint8_t frameSize;
	uint8_t transmitTypes;
	uint8_t bootEventChannel;

	GlobalSamplingConfig();
	GlobalSamplingConfig(uint8_t const* in);
	GlobalSamplingConfig(std::wstring const& argString);

#ifdef WITH_BOOST_PROGRAM_OPTIONS
	static const po::options_description GetOptionDescription();
#endif

	static unsigned GetLength();
	void GetBytes(std::vector<uint8_t>& out) const override;
	ConfigType GetConfigType() const override;
	static bool CheckTransmitType(uint8_t input, TransmitType type);
	bool CheckTransmitType(TransmitType type) const;
	const std::wstring ToString() const override;
	const std::wstring ToSimpleString() const;
};

}
