📄 usbcomm.h
字号:
//===========================================================================
// USB Communications
//
// A class wrapper around the USB functions in WinRT for USB to support
// the Zeevo Bluetooth device.
//
//---------------------------------------------------------------------------
#ifndef USBCommH
#define USBCommH
#include "WinRTUsbCtl.h"
//---------------------------------------------------------------------------
// DATA
const int MAX_USB_DEVICES = 4;
const int MAX_USB_EVENT_SIZE = 256;
const int MAX_USB_ACL_SIZE = 1360;
// Parameters to select SCO channel configuration
enum tScoCapacity {
ONEVOICE8,
TWOVOICE8_ONEVOICE16,
THREEVOICE8,
TWOVOICE16,
THREEVOICE16
};
//---------------------------------------------------------------------------
//Added By Melvin
typedef void(*ZV_USB_CLOSE)(void);
// USB Device Class
class TUsbDevice
{
private: // User declarations
static bool deviceTracker[MAX_USB_DEVICES]; // Tracks device numbers used
ULONG deviceNum; // Unique for each object
HANDLE deviceHandle; // WinRT device handle
LONG savedError;
USHORT langID[4];
OVERLAPPED intEpOverlapStruct; // Interrupt endpoint overlapped struct
OVERLAPPED bulkEpOverlapStruct; // Bulk endpoint overlapped struct
// Suppress the Copy CONSTRUCTOR
TUsbDevice(const TUsbDevice&);
// Suppress the Assignment CONSTRUCTOR
TUsbDevice& operator=(const TUsbDevice&);
// Destructor helper function from More Effective C++ Item 10.
void cleanup(void);
// Used to clear and restart an endpoint
LONG clearStall(UCHAR endpoint);
public: // User declarations
// CONSTRUCTOR default
TUsbDevice();
// DESTRUCTOR default
~TUsbDevice();
// Used to check the result of an operation, zero = success
// Call this after instantiation or a command to get the return error code.
LONG getDeviceStatus(void);
// USB Specific Functions
bool setFeature(int feature);
bool clearFeature(int feature);
bool enableRemoteWakeup(void);
bool disableRemoteWakeup(void);
bool getLanguangeInfo(void);
bool readStrings(void);
// Bluetooth HCI Functions
// The following calls are all synchronous, they will not return until
// completed.
// Sends an HCI command to the device, returns true if successful
bool sendHCICommand(LPVOID buffer, DWORD buffSize);
// Polls device for an event. Buffer should be at least 256 bytes long.
// Returns true if an event was retrieved.
bool getHCIEvent(LPVOID buffer, DWORD& eventSize);
// Sends an ACL packet to the device. Returns true if successful.
// buffer can be up to 32K bytes in length.
bool sendACLpacket(LPVOID buffer, DWORD buffSize);
// Gets an ACL packet from the device. bufferLen is the size of
// of the supplied buffer. packetSize is filled with the total packet
// size retrieved. true is returned if there was data to get.
bool getACLpacket(LPVOID buffer, DWORD bufferLen, DWORD& packetSize);
// SCO Channel support
bool enableScoChannel(tScoCapacity scoCapacity);
bool disableScoChannel(void);
// The following are Async versions of the get functions. They will
// always return immediately. If the return value is true, data is
// available immediately. Otherwise, the matching poll function must
// be called to check for I/O completion. Data is available when the
// poll function returns true.
// Asynchronous HCI events functions
bool getAsyncHCIEvent(LPVOID buffer, DWORD& eventSize);
bool pollAsyncHCIEvent(DWORD& eventSize);
// Asynchronous ACL packet functions
bool getAsyncACLpacket(LPVOID buffer, DWORD bufferLen, DWORD& packetSize);
bool pollAsyncACLpacket(DWORD& packetSize);
ZV_USB_CLOSE OnClose;
};
//---------------------------------------------------------------------------
// This functions registers the handle passed to receive device change
// messages from Windows
extern BOOL isWin98; // Windows version flag
HDEVNOTIFY registerForDevNotify(HWND m_hWnd);
void unregisterForDevNotify(HDEVNOTIFY notifyHandle);
void getGUID(LPGUID pGUID);
void detectWinVer(void);
bool validateZeevoIDs(char* vendorPidString);
#endif // USBCommH
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -