#pragma once

#include "data/config/LegacyConfig.h"

namespace inertia
{

#define RADIO_POWER_DEFAULT 0x0A		// default transmit power (certified -10dBm + PA = 10 dBm) (version 0)
#define RADIO_CHANNEL_DEFAULT 11		// default channel number
#define RADIO_SLOT_FREQ_DEFAULT 2000	// default slot frequency
#define RADIO_SLOTS_DEFAULT 40			// default number of slots
#define RADIO_VERSION_DEFAULT RADIO_V1	// default radio version
#define RADIO_CHIP_DEFAULT RADIO_A1		// default radio version
#define RADIO_RATE_DEFAULT 4000			// default transmission rate

/** RadioConfigVersion */
enum RadioConfigVersion : unsigned {
	RADIO_V0 = 0,
	RADIO_V1 = 1
};

/** RadioChip */
enum RadioChip : unsigned {
	RADIO_CC2430 = 0,
	RADIO_CC2530 = 1,
	RADIO_A0 = 2,
	RADIO_A1 = 3
};

struct INERTIA_API RadioConfig
	: LegacyConfig
{
	bool highGain; // true for enabling High Gain Mode (HGM) (only radio V0)
	bool listenAllSlots; // true for enabling listening in all slots
	bool radioEnabled; // true for enabling the radio (only radio V1)
	bool worEnabled;
	RadioConfigVersion radioConfigVersion; // radio config version
	RadioChip radioChip; // type of radio chip
	uint8_t transmitPower; // for config V0
	int8_t transmitdBm; // for config V1
	uint8_t channel;
	uint16_t slotFrequency; // in hertz
	uint8_t nSlots; // number of slots
	uint16_t transmissionRate; // in kbps
	uint8_t worEventChannel;

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

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

	static unsigned GetLength(uint8_t const* in);
	void GetBytes(std::vector<uint8_t>& out) const override;
	ConfigType GetConfigType() const override;
	const std::wstring ToString() const override;
	const std::wstring ToSimpleString() const;
};

}
