// BleSnifferDlg.h : header file
//

#pragma once
#include "afxwin.h"

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

using namespace wclCommon;
using namespace wclBluetooth;


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

// Dialog Data
	enum { IDD = IDD_BLESNIFFER_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()

private:
	CListBox lbPackets;
	CComboBox cbChannel;

	CwclBleSniffer FSniffer;

	void RawPacketReceived(void* Sender, const wclBluetoothLePacketHeader& Header,
		const unsigned char* const Payload, const unsigned short Size);
	void Started(void* Sender);
	void Stopped(void* Sender);
	void AdvIndReceived(void* Sender, const wclBluetoothLeAdvertisingPduHeader& PduHeader,
		const __int64 AdvA, const unsigned char* const AdvData,
		const unsigned char AdvDataLen);
	void AdvDirectIndReceived(void* Sender, const wclBluetoothLeAdvertisingPduHeader& PduHeader,
		const __int64 AdvA, const __int64 TargetA);
	void AdvNonConnIndReceived(void* Sender, const wclBluetoothLeAdvertisingPduHeader& PduHeader,
		const __int64 AdvA, const unsigned char* const AdvData, const unsigned char AdvDataLen);
	void AdvScanIndReceived(void* Sender, const wclBluetoothLeAdvertisingPduHeader& PduHeader,
		const __int64 AdvA, const unsigned char* const AdvData, const unsigned char AdvDataLen);
	void ScanReqReceived(void* Sender, const wclBluetoothLeAdvertisingPduHeader& PduHeader,
		const __int64 ScanA, const __int64 AdvA);
	void ScanRspReceived(void* Sender, const wclBluetoothLeAdvertisingPduHeader& PduHeader,
		const __int64 AdvA, const unsigned char* const ScanRspData,
		const unsigned char ScanRspDataLen);
	void ConnectIndReceived(void* Sender, const wclBluetoothLeAdvertisingPduHeader& PduHeader,
		const __int64 InitA, const __int64 AdvA, const wclBleSnifferLlData& LlData);

	void DumpHeader(const wclBluetoothLePacketHeader& Header);
	void DumpPduHeader(const wclBluetoothLeAdvertisingPduHeader& PduHeader);
	void DumpPayload(const unsigned char* const Payload, const unsigned short Size);

public:
	afx_msg void OnDestroy();
	afx_msg void OnBnClickedButtonStart();
	afx_msg void OnBnClickedButtonClear();
	afx_msg void OnBnClickedButtonStop();
};
