//---------------------------------------------------------------------------

#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "wclBluetooth.hpp"
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
class TfmMain : public TForm
{
__published:	// IDE-managed Components
        TLabel *laCharVal;
        TLabel *laOperationFlag;
        TButton *btDiscover;
        TListView *lvDevices;
        TListView *lvEvents;
        TButton *btClearEvents;
        TButton *btConnect;
        TButton *btDisconnect;
        TListView *lvServices;
        TButton *btGetServices;
        TButton *btGetIncludedServices;
        TButton *btGetCharacteristics;
        TListView *lvCharacteristics;
        TButton *btGetCharValue;
        TButton *btGetDescriptors;
        TListView *lvDescriptors;
        TButton *btGetDescValue;
        TListView *lvDescriptorValue;
        TButton *btSetValue;
        TEdit *edCharVal;
        TButton *btSubscribe;
        TButton *btUnsubscribe;
        TComboBox *cbOperationFlag;
        TButton *btCCCDSubscribe;
        TButton *btCCCDUnsubscribe;
        TwclBluetoothManager *wclBluetoothManager;
        TwclGattClient *wclGattClient;
        TButton *btTerminate;
        TLabel *laProtection;
        TComboBox *cbProtection;
        TCheckBox *cbConnectOnRead;
        TButton *btPair;
        TCheckBox *cbFastSubscribe;
        TCheckBox *cbForceIndications;
        TButton *btGetParams;
        TComboBox *cbParams;
        TButton *btSetParams;
        TButton *btGetMaxPduSize;
        TButton *btPhy;
        TLabel *laSubscribeKind;
        TComboBox *cbSubscribeKind;
        TLabel *laWriteKind;
        TComboBox *cbWriteKind;
        TLabel *laIoCap;
        TComboBox *cbIoCap;
        TComboBox *cbMitmProtection;
        TLabel *laMitmProtection;
        TButton *btEnumPaired;
        TButton *btUnpair;
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall FormDestroy(TObject *Sender);
        void __fastcall btDiscoverClick(TObject *Sender);
        void __fastcall btClearEventsClick(TObject *Sender);
        void __fastcall btConnectClick(TObject *Sender);
        void __fastcall btDisconnectClick(TObject *Sender);
        void __fastcall btGetServicesClick(TObject *Sender);
        void __fastcall btGetIncludedServicesClick(TObject *Sender);
        void __fastcall btGetCharacteristicsClick(TObject *Sender);
        void __fastcall btGetCharValueClick(TObject *Sender);
        void __fastcall btGetDescriptorsClick(TObject *Sender);
        void __fastcall btGetDescValueClick(TObject *Sender);
        void __fastcall btSetValueClick(TObject *Sender);
        void __fastcall btSubscribeClick(TObject *Sender);
        void __fastcall btUnsubscribeClick(TObject *Sender);
        void __fastcall btCCCDSubscribeClick(TObject *Sender);
        void __fastcall btCCCDUnsubscribeClick(TObject *Sender);
        void __fastcall wclBluetoothManagerNumericComparison(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const __int64 Address, const DWORD Number, bool& Confirm);
        void __fastcall wclBluetoothManagerPasskeyNotification(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const __int64 Address, const DWORD Passkey);
        void __fastcall wclBluetoothManagerPasskeyRequest(TObject *Sender,
          const TwclBluetoothRadio *Radio, const __int64 Address,
          DWORD& Passkey);
        void __fastcall wclBluetoothManagerPinRequest(TObject *Sender,
          const TwclBluetoothRadio *Radio, const __int64 Address,
          String& Pin);
        void __fastcall wclBluetoothManagerDeviceFound(TObject *Sender,
          const TwclBluetoothRadio *Radio, const __int64 Address);
        void __fastcall wclBluetoothManagerDiscoveringCompleted(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const int Error);
        void __fastcall wclBluetoothManagerDiscoveringStarted(
          TObject *Sender, const TwclBluetoothRadio *Radio);
        void __fastcall wclGattClientCharacteristicChanged(TObject *Sender,
          const WORD Handle, const TwclGattCharacteristicValue Value);
        void __fastcall wclGattClientConnect(TObject *Sender,
          const int Error);
        void __fastcall wclGattClientDisconnect(TObject *Sender,
          const int Reason);
        void __fastcall btTerminateClick(TObject *Sender);
        void __fastcall wclBluetoothManagerAuthenticationCompleted(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const __int64 Address, const int Error);
        void __fastcall btPairClick(TObject *Sender);
        void __fastcall wclBluetoothManagerConfirm(TObject *Sender,
          const TwclBluetoothRadio *Radio, const __int64 Address,
          bool& Confirm);
        void __fastcall cbFastSubscribeClick(TObject *Sender);
        void __fastcall btGetParamsClick(TObject *Sender);
        void __fastcall wclGattClientConnectionParamsChanged(
          TObject *Sender);
        void __fastcall btSetParamsClick(TObject *Sender);
        void __fastcall wclGattClientMaxPduSizeChanged(TObject *Sender);
        void __fastcall btGetMaxPduSizeClick(TObject *Sender);
        void __fastcall btPhyClick(TObject *Sender);
        void __fastcall wclGattClientConnectionPhyChanged(TObject *Sender);
        void __fastcall wclBluetoothManagerIoCapabilityRequest(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const __int64 Address, TwclBluetoothMitmProtection& Mitm,
          TwclBluetoothIoCapability& IoCapability, bool& OobPresent);
        void __fastcall btUnpairClick(TObject *Sender);
        void __fastcall btEnumPairedClick(TObject *Sender);
private:	// User declarations
        TwclGattCharacteristics FCharacteristics;
        TwclGattDescriptors FDescriptors;
        TwclGattServices FServices;

        TwclBluetoothRadio* __fastcall GetRadio();
        TwclGattOperationFlag __fastcall OpFlag();

        void __fastcall Cleanup();

        void __fastcall TraceEvent(__int64 Address, String Event, String Param,
          String Value);

        void __fastcall ListProp(String Name, String Value);

        TwclGattProtectionLevel Protection();

        void GetMaxPduSize();
        void GetConnectionParams();
        void GetConnectionPhy();

public:		// User declarations
        __fastcall TfmMain(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TfmMain *fmMain;
//---------------------------------------------------------------------------
#endif
