// RfCommClientDlg.h : header file
//

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

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

using namespace wclCommon;
using namespace wclBluetooth;


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

// Dialog Data
	enum { IDD = IDD_RFCOMMCLIENT_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:
	CListCtrl lvDevices;
	CEdit edTimeout;
	CButton cbAuthentication;
	CButton cbEncryption;
	CEdit edText;
	CEdit edReadBuffer;
	CEdit edWriteBuffer;
	CListBox lbEvents;

	CwclBluetoothManager wclBluetoothManager;
	CwclRfCommClient wclRfCommClient;

	CString IntToHex(const int i) const;
	CString IntToHex(const __int64 i) const;
	__int64 StrToInt64(const CString& s) const;
	int StrToInt(const CString& s) const;
	CString IntToStr(const int i) const;

	CwclBluetoothRadio* GetRadio() const;
	void GetBuffers();

	void wclBluetoothManagerNumericComparison(void* Sender, CwclBluetoothRadio* const Radio,
		const __int64 Address, const unsigned long Number, bool& Confirm);
	void wclBluetoothManagerPasskeyNotification(void* Sender, CwclBluetoothRadio* const Radio,
		const __int64 Address, const unsigned long Passkey);
	void wclBluetoothManagerPasskeyRequest(void* Sender, CwclBluetoothRadio* const Radio,
		const __int64 Address, unsigned long& Passkey);
	void wclBluetoothManagerPinRequest(void* Sender, CwclBluetoothRadio* const Radio,
		const __int64 Address, tstring& Pin);
	void wclBluetoothManagerConfirm(void* Sender, CwclBluetoothRadio* const Radio,
		const __int64 Address, bool& Confirm);
	void wclBluetoothManagerAuthenticationCompleted(void* Sender, CwclBluetoothRadio* const Radio,
		const __int64 Address, const int Error);
	void wclBluetoothManagerDeviceFound(void* Sender, CwclBluetoothRadio* const Radio,
		const __int64 Address);
	void wclBluetoothManagerDiscoveringCompleted(void* Sender, CwclBluetoothRadio* const Radio, 
		const int Error);
	void wclBluetoothManagerDiscoveringStarted(void* Sender, CwclBluetoothRadio* const Radio);

	void wclRfCommClientConnect(void* Sender, const int Error);
	void wclRfCommClientData(void* Sender, const void* const Data, const unsigned long Size);
	void wclRfCommClientDisconnect(void* Sender, const int Reason);

public:
	afx_msg void OnDestroy();
	afx_msg void OnBnClickedButtonDiscover();
	afx_msg void OnBnClickedButtonClear();
	afx_msg void OnBnClickedButtonConnect();
	afx_msg void OnBnClickedButtonDisconnect();
	afx_msg void OnBnClickedButtonSend();
	afx_msg void OnBnClickedButtonSetBuffers();
	afx_msg void OnBnClickedButtonGetBuffers();
private:
	CButton cbServiceName;
	CEdit edServiceName;
public:
	afx_msg void OnBnClickedButtonPair();
private:
	CButton cbEnumPaired;
public:
	afx_msg void OnBnClickedButtonUnpair();
};
