// BeaconsDlg.h : header file
//

#pragma once
#include "afxcmn.h"
#include "afxwin.h"

#include "..\..\..\..\Source\Bluetooth\wclBluetooth.h"

using namespace wclCommon;
using namespace wclBluetooth;

typedef enum _AdvertisementFrame
{
	afAppearance,
	afExtInformation,
	afInformation,
	afRaw,
	afDetails,
	afService16Data,
	afService32Data,
	afService128Data,
	afSol16,
	afSol32,
	afSol128,
	afTxPower,
	afUuid,
	afAltBeacon,
	afEddystoneTlm,
	afEddystoneUid,
	afEddystoneUrl,
	afManufacturerRaw,
	afMicrosoftCdpBeacon,
	afAppleAirdrop,
	afAppleAirplaySource,
	afAppleAirplayTarget,
	afAppleAirprint,
	afAppleHomeKit,
	afAppleiBeacon,
	afAppleNearbyAction,
	afAppleNearbyInfo,
	afAppleProximityPairing,
	afAppleUnknown,
	afAppleFindMy,
    afAppleHandoff,
    afAppleHeySiri,
    afAppleMagicSwitch,
    afAppleTetheringSource,
    afAppleTetheringTarget,
	afDriAsd,
	afUnknown
} AdvertisementFrame;

class CFrameStorage
{
private:
	__int64 FAddress;
	AdvertisementFrame FFrame;
	__int64 FTimestamp;
	char FRssi;
	
public:
	CFrameStorage(const AdvertisementFrame Frame, const __int64 Address,
		const __int64 Timestamp, const char Rssi);
	virtual ~CFrameStorage();
	
	__int64 GetAddress() const;
	__declspec(property(get = GetAddress)) __int64 Address;
	
	AdvertisementFrame GetFrame() const;
	__declspec(property(get = GetFrame)) AdvertisementFrame Frame;
	
	__int64 GetTimestamp() const;
	__declspec(property(get = GetTimestamp)) __int64 Timestamp;
	
	char GetRssi() const;
	__declspec(property(get = GetRssi)) char Rssi;
};

class CGuidFrameStorage : public CFrameStorage
{
private:
	GUID FUuid;
	
public:
	CGuidFrameStorage(const AdvertisementFrame Frame, const __int64 Address,
		const __int64 Timestamp, const char Rssi, const GUID& Uuid);
	
	GUID GetUuid() const;
	__declspec(property(get = GetUuid)) GUID Uuid;
};

class CDataFrameStorage : public CFrameStorage
{
private:
	wclBluetoothLeAdvertisementFrameRawData FData;
	
public:
	CDataFrameStorage(const AdvertisementFrame Frame, const __int64 Address,
		const __int64 Timestamp, const char Rssi,
		const wclBluetoothLeAdvertisementFrameRawData& Data);
	
	wclBluetoothLeAdvertisementFrameRawData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAdvertisementFrameRawData Data;
};

class CGuidDataFrameStorage : public CDataFrameStorage
{
private:
	GUID FUuid;
	
public:
	CGuidDataFrameStorage(const AdvertisementFrame Frame, const __int64 Address,
		const __int64 Timestamp, const char Rssi, const GUID& Uuid,
		const wclBluetoothLeAdvertisementFrameRawData& Data);
	
	GUID GetUuid() const;
	__declspec(property(get = GetUuid)) GUID Uuid;
};

class CAppearanceFrame : public CFrameStorage
{
private:
	unsigned short FAppearance;
	
public:
	CAppearanceFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const unsigned short Appearance);
	
	unsigned short GetAppearance() const;
	__declspec(property(get = GetAppearance)) unsigned short Appearance;
};

class CExtInformationFrame : public CFrameStorage
{
private:
	wclBluetoothAddressType FAddressType;
	wclBluetoothLeExtendedFrameFlags FFlags;
	char FTxPower;
	
public:
	CExtInformationFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclBluetoothAddressType AddressType,
		const wclBluetoothLeExtendedFrameFlags& Flags, const char TxPower);
	
	wclBluetoothAddressType GetAddressType() const;
	__declspec(property(get = GetAddressType)) wclBluetoothAddressType AddressType;
	
	wclBluetoothLeExtendedFrameFlags GetFlags() const;
	__declspec(property(get = GetFlags)) wclBluetoothLeExtendedFrameFlags Flags;
	
	char GetTxPower() const;
	__declspec(property(get = GetTxPower)) char TxPower;
};

class CInformationFrame : public CFrameStorage
{
private:
	wclBluetoothLeAdvertisementFlags FFlags;
	tstring FName;
	wclBluetoothLeAdvertisementType FPacketType;
	
public:
	CInformationFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclBluetoothLeAdvertisementFlags& Flags,
		const tstring& Name, const wclBluetoothLeAdvertisementType PacketType);
	
	wclBluetoothLeAdvertisementFlags GetFlags() const;
	__declspec(property(get = GetFlags)) wclBluetoothLeAdvertisementFlags Flags;
	
	tstring GetName() const;
	__declspec(property(get = GetName)) tstring Name;
	
	wclBluetoothLeAdvertisementType GetPacketType() const;
	__declspec(property(get = GetPacketType)) wclBluetoothLeAdvertisementType PacketType;
};

class CRawFrame : public CDataFrameStorage
{
private:
	unsigned char FDataType;
	
public:
	CRawFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclBluetoothLeAdvertisementFrameRawData& Data,
		const unsigned char DataType);
	
	unsigned char GetDataType() const;
	__declspec(property(get = GetDataType)) unsigned char DataType;
};

class CDetailsFrame : public CDataFrameStorage
{
public:
	CDetailsFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclBluetoothLeAdvertisementFrameRawData& Data);
};

class CService16DataFrame : public CDataFrameStorage
{
private:
	unsigned short FUuid;
	
public:
	CService16DataFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclBluetoothLeAdvertisementFrameRawData& Data,
		const unsigned short Uuid);
	
	unsigned short GetUuid() const;
	__declspec(property(get = GetUuid)) unsigned short Uuid;
};

class CService32DataFrame : public CDataFrameStorage
{
private:
	unsigned long FUuid;
	
public:
	CService32DataFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclBluetoothLeAdvertisementFrameRawData& Data,
		const unsigned long Uuid);
	
	unsigned long GetUuid() const;
	__declspec(property(get = GetUuid)) unsigned long Uuid;
};

class CService128DataFrame : public CGuidDataFrameStorage
{
public:
	CService128DataFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const GUID& Uuid,
		const wclBluetoothLeAdvertisementFrameRawData& Data);
};

class CSol16Frame : public CFrameStorage
{
private:
	unsigned short FUuid;
	
public:
	CSol16Frame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const unsigned short Uuid);
	
	unsigned short GetUuid() const;
	__declspec(property(get = GetUuid)) unsigned short Uuid;
};

class CSol32Frame : public CFrameStorage
{
private:
	unsigned long FUuid;
	
public:
	CSol32Frame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const unsigned long Uuid);
	
	unsigned long GetUuid() const;
	__declspec(property(get = GetUuid)) unsigned long Uuid;
};

class CSol128Frame : public CGuidFrameStorage
{
public:
	CSol128Frame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const GUID& Uuid);
};

class CTxPowerFrame : public CFrameStorage
{
private:
	char FTxPower;
	
public:
	CTxPowerFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const char TxPower);
	
	char GetTxPower() const;
	__declspec(property(get = GetTxPower)) char TxPower;
};

class CUuidFrame : public CGuidFrameStorage
{
public:
	CUuidFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const GUID& Uuid);
};

class CBeaconFrame : public CGuidDataFrameStorage
{
private:
	unsigned short FCompanyId;
	unsigned short FMajor;
	unsigned short FMinor;
	char FTxRssi;
	
public:
	CBeaconFrame(const AdvertisementFrame Frame, const __int64 Address,
		const __int64 Timestamp, const char Rssi,
		const wclBluetoothLeAdvertisementFrameRawData& Data,
		const GUID& Uuid, const unsigned short CompanyId, const unsigned short Major,
		const unsigned short Minor, const char TxRssi);
	
	unsigned short GetCompanyId() const;
	__declspec(property(get = GetCompanyId)) unsigned short CompanyId;
	
	unsigned short GetMajor() const;
	__declspec(property(get = GetMajor)) unsigned short Major;
	
	unsigned short GetMinor() const;
	__declspec(property(get = GetMinor)) unsigned short Minor;
	
	char GetTxRssi() const;
	__declspec(property(get = GetTxRssi)) char TxRssi;
};

class CAltBeaconFrame : public CBeaconFrame
{
private:
	unsigned char FReserved;
	
public:
	CAltBeaconFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclBluetoothLeAdvertisementFrameRawData& Data,
		const GUID& Uuid, const unsigned short CompanyId, const unsigned short Major,
		const unsigned short Minor, const char TxRssi, const unsigned char Reserved);
	
	unsigned char GetReserved() const;
	__declspec(property(get = GetReserved)) unsigned char Reserved;
};

class CMicrosoftCdpBeaconFrame : public CFrameStorage
{
private:
	bool FAddressAsDeviceId;
	wclBluetoothLeCdpBeaconDeviceType FDeviceType;
	wclBluetoothLeCdpBeaconExtendedDeviceStatuses FExtendedDeviceStatus;
	wclBluetoothLeCdpBeaconHash FHash;
	wclBluetoothLeCdpBeaconSalt FSalt;
	wclBluetoothLeCdpBeaconScenarioType FScenarioType;
	bool FShareNearBy;
	unsigned char FSubVersion;
	unsigned char FVersion;
	
public:
	CMicrosoftCdpBeaconFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const bool AddressAsDeviceId,
		const wclBluetoothLeCdpBeaconDeviceType DeviceType,
		const wclBluetoothLeCdpBeaconExtendedDeviceStatuses& ExtendedDeviceStatus,
		const wclBluetoothLeCdpBeaconHash& Hash, const wclBluetoothLeCdpBeaconSalt& Salt,
		const wclBluetoothLeCdpBeaconScenarioType ScenarioType,
		const bool ShareNearBy, const unsigned char SubVersion, const unsigned char Version);
	
	bool GetAddressAsDeviceId() const;
	__declspec(property(get = GetAddressAsDeviceId)) bool AddressAsDeviceId;
	
	wclBluetoothLeCdpBeaconDeviceType GetDeviceType() const;
	__declspec(property(get = GetDeviceType)) wclBluetoothLeCdpBeaconDeviceType DeviceType;
	
	wclBluetoothLeCdpBeaconExtendedDeviceStatuses GetExtendedDeviceStatus() const;
	__declspec(property(get = GetExtendedDeviceStatus)) wclBluetoothLeCdpBeaconExtendedDeviceStatuses ExtendedDeviceStatus;
	
	wclBluetoothLeCdpBeaconHash GetHash() const;
	__declspec(property(get = GetHash)) wclBluetoothLeCdpBeaconHash Hash;
	
	wclBluetoothLeCdpBeaconSalt GetSalt() const;
	__declspec(property(get = GetSalt)) wclBluetoothLeCdpBeaconSalt Salt;
	
	wclBluetoothLeCdpBeaconScenarioType GetScenarioType() const;
	__declspec(property(get = GetScenarioType)) wclBluetoothLeCdpBeaconScenarioType ScenarioType;
	
	bool GetShareNearBy() const;
	__declspec(property(get = GetShareNearBy)) bool ShareNearBy;
	
	unsigned char GetSubVersion() const;
	__declspec(property(get = GetSubVersion)) unsigned char SubVersion;
	
	unsigned char GetVersion() const;
	__declspec(property(get = GetVersion)) unsigned char Version;
};

class CAppleFrame : public CFrameStorage
{
public:
	CAppleFrame(const AdvertisementFrame Frame,
		const wclBluetoothLeAdvertisementInfo& Info);
};

class CAppleAirdropFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleAirdropFrameData FData;
	
public:
	CAppleAirdropFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleAirdropFrameData& Data);
	
	wclBluetoothLeAppleAirdropFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleAirdropFrameData Data;
};

class CAppleAirplaySourceFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleAirplaySourceFrameData FData;
	
public:
	CAppleAirplaySourceFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleAirplaySourceFrameData& Data);
	
	wclBluetoothLeAppleAirplaySourceFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleAirplaySourceFrameData Data;
};

class CAppleAirplayTargetFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleAirplayTargetFrameData FData;
	
public:
	CAppleAirplayTargetFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleAirplayTargetFrameData& Data);
	
	wclBluetoothLeAppleAirplayTargetFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleAirplayTargetFrameData Data;
};

class CAppleAirprintFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleAirprintFrameData FData;
	
public:
	CAppleAirprintFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleAirprintFrameData& Data);
	
	wclBluetoothLeAppleAirprintFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleAirprintFrameData Data;
};

class CAppleHomeKitFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleHomeKitFrameData FData;
	
public:
	CAppleHomeKitFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleHomeKitFrameData& Data);
	
	wclBluetoothLeAppleHomeKitFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleHomeKitFrameData Data;
};

class CAppleiBeaconFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleiBeaconFrameData	FData;
	
public:
	CAppleiBeaconFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleiBeaconFrameData& Data);

	wclBluetoothLeAppleiBeaconFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleiBeaconFrameData Data;
};

class CAppleNearbyActionFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleNearbyActionFrameData FData;
	
public:
	CAppleNearbyActionFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleNearbyActionFrameData& Data);
	
	wclBluetoothLeAppleNearbyActionFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleNearbyActionFrameData Data;
};

class CAppleNearbyInfoFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleNearbyInfoFrameData FData;
	
public:
	CAppleNearbyInfoFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleNearbyInfoFrameData& Data);
	
	wclBluetoothLeAppleNearbyInfoFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleNearbyInfoFrameData Data;
};

class CAppleProximityPairingFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleProximityPairingFrameData FData;
	
public:
	CAppleProximityPairingFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleProximityPairingFrameData& Data);

	wclBluetoothLeAppleProximityPairingFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleProximityPairingFrameData Data;
};

class CAppleUnknownFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleUnknownFrameData FData;
	
public:
	CAppleUnknownFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleUnknownFrameData& Data);
	
	wclBluetoothLeAppleUnknownFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleUnknownFrameData Data;
};

class CAppleFindMyFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleFindMyFrameData FData;
	
public:
	CAppleFindMyFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleFindMyFrameData& Data);
	
	wclBluetoothLeAppleFindMyFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleFindMyFrameData  Data;
};

class CAppleHandoffFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleHandoffFrameData FData;
	
public:
	CAppleHandoffFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleHandoffFrameData& Data);
	
	wclBluetoothLeAppleHandoffFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleHandoffFrameData Data;
};

class CAppleHeySiriFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleHeySiriFrameData FData;
	
public:
	CAppleHeySiriFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleHeySiriFrameData& Data);
	
	wclBluetoothLeAppleHeySiriFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleHeySiriFrameData Data;
};

class CAppleMagicSwitchFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleMagicSwitchFrameData FData;
	
public:
	CAppleMagicSwitchFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleMagicSwitchFrameData& Data);
	
	wclBluetoothLeAppleMagicSwitchFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleMagicSwitchFrameData  Data;
};

class CAppleTetheringSourceFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleTetheringSourceFrameData FData;
	
public:
	CAppleTetheringSourceFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleTetheringSourceFrameData& Data);
	
	wclBluetoothLeAppleTetheringSourceFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleTetheringSourceFrameData Data;
};

class CAppleTetheringTargetFrame : public CAppleFrame
{
private:
	wclBluetoothLeAppleTetheringTargetFrameData FData;
	
public:
	CAppleTetheringTargetFrame(const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleTetheringTargetFrameData& Data);
	
	wclBluetoothLeAppleTetheringTargetFrameData GetData() const;
	__declspec(property(get = GetData)) wclBluetoothLeAppleTetheringTargetFrameData Data;
};

class CEddystoneTlmFrame : public CDataFrameStorage
{
private:
	unsigned long FAdvCnt;
	unsigned short FBatt;
	unsigned long FSecCnt;
	double FTemp;
	
public:
	CEddystoneTlmFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclBluetoothLeAdvertisementFrameRawData& Data,
		const unsigned long AdvCnt, const unsigned short Batt, const unsigned long SecCnt,
		const double Temp);
	
	unsigned long GetAdvCnt() const;
	__declspec(property(get = GetAdvCnt)) unsigned long AdvCnt;
	
	unsigned short GetBatt() const;
	__declspec(property(get = GetBatt)) unsigned short Batt;
	
	unsigned long GetSecCnt() const;
	__declspec(property(get = GetSecCnt)) unsigned long SecCnt;
	
	double GetTemp() const;
	__declspec(property(get = GetTemp)) double Temp;
};

class CEddystoneUidFrame : public CGuidDataFrameStorage
{
private:
	char FTxRssi;
	
public:
	CEddystoneUidFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclBluetoothLeAdvertisementFrameRawData& Data,
		const GUID& Uuid, const char TxRssi);
	
	char GetTxRssi() const;
	__declspec(property(get = GetTxRssi)) char TxRssi;
};

class CEddystoneUrlFrame : public CFrameStorage
{
private:
	char FTxRssi;
	tstring FUrl;
	
public:
	CEddystoneUrlFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const char TxRssi, const tstring& Url);
	
	char GetTxRssi() const;
	__declspec(property(get = GetTxRssi)) char TxRssi;
	
	tstring GetUrl() const;
	__declspec(property(get = GetUrl)) tstring Url;
};

class CManufacturerFrame : public CDataFrameStorage
{
private:
	unsigned short FCompanyId;
	
public:
	CManufacturerFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const unsigned short CompanyId,
		const wclBluetoothLeAdvertisementFrameRawData& Data);
	
	unsigned short GetCompanyId() const;
	__declspec(property(get = GetCompanyId)) unsigned short CompanyId;
};

class CDriAsdFrame : public CFrameStorage
{
private:
	wclDriRawData FRaw;
	
public:
	CDriAsdFrame(const __int64 Address, const __int64 Timestamp,
		const char Rssi, const wclDriRawData& Raw);
	
	wclDriRawData GetRaw() const;
	__declspec(property(get = GetRaw)) wclDriRawData Raw;
};



// CBeaconsDlg dialog
class CBeaconsDlg : public CDialog
{
// Construction
public:
	CBeaconsDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_BEACONS_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

	virtual BOOL PreTranslateMessage(MSG* pMsg) override;

private:
	CComboBox cbWatcherScanMode;
	CEdit edWatcherScanInterval;
	CEdit edWatcherScanWindow;
	CButton cbWatcherEnableExtended;
	CButton btWatcherDefault;
	CButton btWatcherStart;
	CButton btWatcherStop;
	CListCtrl lvDevices;
	CListCtrl lvFrameDetails;
	CEdit edAdvertiserInterval;
	CButton btAdvertiserDefault;
	CButton btAdvertiserStart;
	CButton btAdvertiserStop;
	CButton cbAdvertiserBeacon;
	CButton cbAdvertiserProximityBeacon;
	CButton cbAdvertiserAltBeacon;
	CButton cbAdvertiserEddystoneUid;
	CButton cbAdvertiserEddystoneUrl;
	CButton cbAdvertiserManufacturer;
	CButton cbAdvertiser16Uuid;
	CButton cbAdvertiser32Uuid;
	CButton cbAdvertiser128Uuid;
	CButton cbAdvertiser16UuidData;
	CButton cbAdvertiser32UuidData;
	CButton cbAdvertiser128UuidData;
	CButton cbAdvertiser128SolUuid;
	CButton cbAdvertiserCustom;
	CButton cbAdvertiserExtended;
	CButton cbAdvertiserAnonymous;
	CButton cbAdvertiserTxRssi;
	CButton cbAutoScroll;
	CListBox lbLog;

private:
	CwclBluetoothManager BluetoothManager;
	CwclBluetoothLeBeaconWatcher BeaconWatcher;
	CwclBluetoothLeAdvertiser LeAdvertiser;

	void MakeBold(int Id);

	void AdvertiserDefaults();
	void WatcherDefaults();

	void AdvertiserEnableControls(const BOOL Stopped);
	void WatcherEnableControls(const BOOL Stopped);

	void Trace(const CString& Msg);
	void Trace(const CString& Msg, const int Res);

	CwclBluetoothRadio* GetRadio();

	int AddDevice(const __int64 Address);
	void AddFrame(CFrameStorage* const Frame);

	CString ConvertTime(const __int64 Timestamp);

	void ShowData(const CString& Name, const CString& Value);
	void ShowFrameBaseData(CFrameStorage* const Frame);
	void ShowFrameRawData(const wclBluetoothLeAdvertisementFrameRawData& Data);
	void ShowDriFrameRawData(const wclDriRawData& Raw);

	void ShowAppearanceFrame(CAppearanceFrame* const Frame);
	void ShowExtInformationFrame(CExtInformationFrame* const Frame);
	void ShowInformationFrame(CInformationFrame* const Frame);
	void ShowRawFrame(CRawFrame* const Frame);
	void ShowDetailsFrame(CDetailsFrame* const Frame);
	void ShowService16DataFrame(CService16DataFrame* const Frame);
	void ShowService32DataFrame(CService32DataFrame* const Frame);
	void ShowService128DataFrame(CService128DataFrame* const Frame);
	void ShowSol16Frame(CSol16Frame* const Frame);
	void ShowSol32Frame(CSol32Frame* const Frame);
	void ShowSol128Frame(CSol128Frame* const Frame);
	void ShowTxPowerFrame(CTxPowerFrame* const Frame);
	void ShowUuidFrame(CUuidFrame* const Frame);
	void ShowAltBeaconFrame(CAltBeaconFrame* const Frame);
	void ShowEddystoneTlmFrame(CEddystoneTlmFrame* const Frame);
	void ShowEddystoneUidFrame(CEddystoneUidFrame* const Frame);
	void ShowEddystoneUrlFrame(CEddystoneUrlFrame* const Frame);
	void ShowManufacturerFrame(CManufacturerFrame* const Frame);
	void ShowMicrosoftCdpBeaconFrame(CMicrosoftCdpBeaconFrame* const Frame);
	void ShowAppleAirdropFrame(CAppleAirdropFrame* const Frame);
	void ShowAppleAirplaySourceFrame(CAppleAirplaySourceFrame* const Frame);
	void ShowAppleAirplayTargetFrame(CAppleAirplayTargetFrame* const Frame);
	void ShowAppleAirprintFrame(CAppleAirprintFrame* const Frame);
	void ShowAppleHomeKitFrame(CAppleHomeKitFrame* const Frame);
	void ShowAppleiBeaconFrame(CAppleiBeaconFrame* const Frame);
	void ShowAppleNearbyActionFrame(CAppleNearbyActionFrame* const Frame);
	void ShowAppleNearbyInfoFrame(CAppleNearbyInfoFrame* const Frame);
	void ShowAppleProximityPairingFrame(CAppleProximityPairingFrame* const Frame);
	void ShowAppleUnknownFrame(CAppleUnknownFrame* const Frame);
	void ShowAppleFindMyFrame(CAppleFindMyFrame* const Frame);
	void ShowAppleHandoffFrame(CAppleHandoffFrame* const Frame);
	void ShowAppleHeySiriFrame(CAppleHeySiriFrame* const Frame);
	void ShowAppleMagicSwitchFrame(CAppleMagicSwitchFrame* const Frame);
	void ShowAppleTetheringSourceFrame(CAppleTetheringSourceFrame* const Frame);
	void ShowAppleTetheringTargetFrame(CAppleTetheringTargetFrame* const Frame);
	void ShowDriAsdFrame(CDriAsdFrame* const Frame);
	void ShowFrameData(CFrameStorage* const Frame);

	void AddAdvertisement(CwclBluetoothLeAdvertisement* const Adv);

	void BluetoothManagerAfterOpen(void* Sender);
	void BluetoothManagerBeforeClose(void* Sender);
	void BluetoothManagerClosed(void* Sender);

	void BeaconWatcherStarted(void* Sender);
	void BeaconWatcherStopped(void* Sender);
	void BeaconWatcherAdvertisementAppearanceFrame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const unsigned short Appearance);
	void BeaconWatcherAdvertisementExtFrameInformation(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const wclBluetoothAddressType AddressType, const char TxPower,
		const wclBluetoothLeExtendedFrameFlags& Flags);
	void BeaconWatcherAdvertisementFrameInformation(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const tstring& Name, const wclBluetoothLeAdvertisementType PacketType,
		const wclBluetoothLeAdvertisementFlags& Flags);
	void BeaconWatcherAdvertisementRawFrame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const unsigned char DataType, const wclBluetoothLeAdvertisementFrameRawData& Data);
	void BeaconWatcherAdvertisementReceived(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const wclBluetoothLeAdvertisementFrameRawData& Data);
	void BeaconWatcherAdvertisementService128DataFrame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const GUID& Uuid, const wclBluetoothLeAdvertisementFrameRawData& Data);
	void BeaconWatcherAdvertisementService16DataFrame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const unsigned short Uuid, const wclBluetoothLeAdvertisementFrameRawData& Data);
	void BeaconWatcherAdvertisementService32DataFrame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const unsigned long Uuid, const wclBluetoothLeAdvertisementFrameRawData& Data);
	void BeaconWatcherAdvertisementServiceSol128Frame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const GUID& Uuid);
	void BeaconWatcherAdvertisementServiceSol16Frame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const unsigned short Uuid);
	void BeaconWatcherAdvertisementServiceSol32Frame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const unsigned long Uuid);
	void BeaconWatcherAdvertisementTxPowerLevelFrame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const char TxPower);
	void BeaconWatcherAdvertisementUuidFrame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const GUID& Uuid);
	void BeaconWatcherAltBeaconFrame(void* Sender, const __int64 Address,
		const __int64 Timestamp, const char Rssi, const unsigned short CompanyId,
		const unsigned short Major, const unsigned short Minor, const GUID& Uuid,
		const char TxRssi, const unsigned char Reserved,
		const wclBluetoothLeAdvertisementFrameRawData& Data);
	void BeaconWatcherEddystoneTlmFrame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const unsigned long AdvCnt, const unsigned short Batt, const unsigned long SecCnt,
		const double Temp, const wclBluetoothLeAdvertisementFrameRawData& Data);
	void BeaconWatcherEddystoneUidFrame(void* Sender, const __int64 Address,
		const __int64 Timestamp, const char Rssi, const char TxRssi, const GUID& Uuid,
		const wclBluetoothLeAdvertisementFrameRawData& Data);
	void BeaconWatcherEddystoneUrlFrame(void* Sender, const __int64 Address,
		const __int64 Timestamp, const char Rssi, const char TxRssi, const tstring& Url);
	void BeaconWatcherManufacturerRawFrame(void* Sender, const __int64 Address,
		const __int64 Timestamp, const char Rssi, const unsigned short CompanyId,
		const wclBluetoothLeAdvertisementFrameRawData& Data);
	void BeaconWatcherMicrosoftCdpBeaconFrame(void* Sender,
		const __int64 Address, const __int64 Timestamp, const char Rssi,
		const wclBluetoothLeCdpBeaconScenarioType ScenarioType,
		const unsigned char Version, const wclBluetoothLeCdpBeaconDeviceType DeviceType,
		const unsigned char SubVersion, const bool ShareNearBy, const bool AddressAsDeviceId,
		const wclBluetoothLeCdpBeaconExtendedDeviceStatuses& ExtendedDeviceStatus,
		const wclBluetoothLeCdpBeaconSalt& Salt, const wclBluetoothLeCdpBeaconHash& Hash);
	void BeaconWatcherAppleiBeaconFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleiBeaconFrameData& Data);
	void BeaconWatcherAppleNearbyActionFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleNearbyActionFrameData& Data);
	void BeaconWatcherAppleNearbyInfoFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleNearbyInfoFrameData& Data);
	void BeaconWatcherAppleHomeKitFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleHomeKitFrameData& Data);
	void BeaconWatcherAppleUnknownFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleUnknownFrameData& Data);
	void BeaconWatcherDriAsdMessage(void* Sender, const __int64 Address,
		const __int64 Timestamp, const char Rssi, const wclDriRawData& Raw);
	void BeaconWatcherAppleAirplaySourceFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleAirplaySourceFrameData& Data);
	void BeaconWatcherAppleAirplayTargetFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleAirplayTargetFrameData& Data);
	void BeaconWatcherAppleAirdropFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleAirdropFrameData& Data);
	void BeaconWatcherAppleAirprintFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleAirprintFrameData& Data);
	void BeaconWatcherAppleProximityPairingFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleProximityPairingFrameData& Data);
	void BeaconWatcherAppleFindMyFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleFindMyFrameData& Data);
	void BeaconWatcherAppleHandoffFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleHandoffFrameData& Data);
	void BeaconWatcherAppleHeySiriFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleHeySiriFrameData& Data);
	void BeaconWatcherAppleMagicSwitchFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleMagicSwitchFrameData& Data);
	void BeaconWatcherAppleTetheringSourceFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleTetheringSourceFrameData& Data);
	void BeaconWatcherAppleTetheringTargetFrame(void* Sender, const wclBluetoothLeAdvertisementInfo& Info,
		const wclBluetoothLeAppleTetheringTargetFrameData& Data);
	
	void LeAdvertiserStarted(void* Sender);
	void LeAdvertiserStopped(void* Sender);

public:
	afx_msg void OnLvnItemchangedListDevices(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnDestroy();
	afx_msg void OnBnClickedButtonClearLog();
	afx_msg void OnBnClickedButtonWatcherDefault();
	afx_msg void OnBnClickedButtonAdvertiserDefault();
	afx_msg void OnBnClickedCheckAdvertiserExtended();
	afx_msg void OnBnClickedButtonWatcherStart();
	afx_msg void OnBnClickedButtonWatcherStop();
	afx_msg void OnBnClickedButtonAdvertiserStart();
	afx_msg void OnBnClickedButtonAdvertiserStop();
};
