⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btifclasses.h

📁 基于widcomm的蓝牙传输功能程序
💻 H
📖 第 1 页 / 共 5 页
字号:

///////////////////////////////////////////////////////////////////////////////////////
// Define a class to control the SPP server sessions
//
class WIDCOMMSDK  CSppServer
{
public:

//
// Define return code for SPP Server functions
//
typedef enum
{
    SUCCESS,             // Operation initiated without error
    NO_BT_SERVER,        // COM server could not be started
    ALREADY_CONNECTED,   // attempt to connect before previous connection closed
    NOT_CONNECTED,       // attempt to close unopened connection
    NOT_ENOUGH_MEMORY,   // local processor could not allocate memory for open
    NOT_SUPPORTED,       // requested service not available locally
    UNKNOWN_ERROR,       // Any condition other than the above
    NO_EMPTY_PORT,       // no empty port
    INVALID_PARAMETER,   // One or more of function parameters are not valid
    LICENSE_ERROR        // license error
} SPP_SERVER_RETURN_CODE;

private:

typedef struct {
    short   comPort;
    BOOL    authentication;
    BOOL    authorization;
    BOOL    encryption;
    BOOL    automatic;  // TRUE if this service is automatically started by stack server
    BT_CHAR serviceName[BT_MAX_SERVICE_NAME_LEN];
} SPP_LOCAL_SERVICE;

#define MAX_LOCAL_SERVICES  5

public:

    // Construction/destruction
    //
    CSppServer ();
    virtual ~CSppServer();

    SPP_SERVER_RETURN_CODE CreateConnection(BT_CHAR * szServiceName);
    SPP_SERVER_RETURN_CODE RemoveConnection();

    virtual void OnServerStateChange(BD_ADDR bda, DEV_CLASS dev_class, BD_NAME name, short com_port, SPP_STATE_CODE state) = 0;

    void  SetExtendedError(WBtRc code) { m_LastWBtRc = code; }
    WBtRc GetExtendedError() const { return m_LastWBtRc; }
    SPP_SERVER_RETURN_CODE GetConnectionStats (tBT_CONN_STATS *p_conn_stats);
    SPP_SERVER_RETURN_CODE CreateCOMPort(short *com_port);

private:
    short       m_comPort;
    CWBtAPI     *m_pBtApi;
    BOOL        m_authentication;           // future
    BOOL        m_authorization;            // future
    BOOL        m_encryption;               // future
    BOOL        m_startup;
    BT_CHAR     m_serviceName[BT_MAX_SERVICE_NAME_LEN];
    BOOL        serviceAvailable(LPCSTR szServiceName);
    BOOL        m_connected;
    BOOL        m_automatic;
    short       m_cntLocalServices;
    SPP_LOCAL_SERVICE m_localServiceList[MAX_LOCAL_SERVICES];
    
    void SppLocalServices(SPP_LOCAL_SERVICE *pLocalServiceList, short maxLocalServices, short *pCntLocalServices);
    WBtRc       m_LastWBtRc;    // Contains the last code returned by WBtApi 
    BD_ADDR     m_BdAddr;
    HANDLE      m_hMutex;

    friend class CSppServerFriend;

    // This class will not support the compiler-supplied copy constructor or assignment operator,
    // so these are declared private to prevent inadvertent use by the application.
    CSppServer(const CSppServer & x);
    CSppServer& operator= (const CSppServer & x); 
};



////////////////////////////////////////////////////////////////////////////
// The CPrintClient class
//
#define BPSF_TYPE    0x01   // Mask value

struct BTPRINTSTRUCT
{
    DWORD    dwSize;     // Must be sizeof(BTPRINTSTRUCT)
    UINT     mask;       // 0 or BPSF_TYPE
    LPCSTR   pszType;    // Data type
};


class CPrintInternal;
class WIDCOMMSDK CPrintClient
{
public:
 
    // Define the profiles supported by the Printing SDK
    //
    typedef enum
    {
        PRINT_PROFILE_BPP,
        PRINT_PROFILE_HCRP,
        PRINT_PROFILE_SPP

    } ePRINT_PROFILE;

    // Define the current state of the Printing SDK
    //
    typedef enum
    {
        PRINT_STATE_IDLE,
        PRINT_STATE_CONNECTING,     
        PRINT_STATE_PRINTING,
        PRINT_STATE_FLOW_CONTROLLED,
        PRINT_STATE_DISCONNECTING, 
        PRINT_STATE_DONE

    } ePRINT_STATE;

    // Define error codes returned by the Printing SDK
    //
    typedef enum
    {
        // Generic to all profiles
        //
        PRINT_RC_OK,
        PRINT_RC_FILE_PRINTED_OK,
        PRINT_RC_FILE_NOT_FOUND,
        PRINT_RC_FILE_READ_ERROR,
        PRINT_RC_ALREADY_PRINTING,
        PRINT_RC_UNKNOWN_PROFILE,
        PRINT_RC_SERVICE_NOT_FOUND,
        PRINT_RC_SECURITY_ERROR,
        PRINT_RC_CONNECT_ERROR,
        PRINT_RC_WRITE_ERROR,
        PRINT_RC_REMOTE_DISCONNECTED,
        PRINT_RC_INVALID_PARAM,


        // BPP Specific errors
        //
        PRINT_RC_BPP_SCN_NOT_FOUND,
        PRINT_RC_BPP_SCN_NOT_ASSIGNED,
        PRINT_RC_BPP_OBEX_ABORTED,
        PRINT_RC_BPP_OBEX_MISMATCH,

        // HCRP Specific errors
        //
        PRINT_RC_HCRP_CTL_PSM_NOT_FOUND,
        PRINT_RC_HCRP_DATA_PSM_NOT_FOUND,

        // SPP Specific errors
        //
        PRINT_RC_SPP_SCN_NOT_FOUND,

    } ePRINT_ERROR;

public:
    CPrintClient();
    ~CPrintClient();

    ePRINT_ERROR        Start (BD_ADDR pBDA, ePRINT_PROFILE eProfile, LPCSTR pszFile, 
                               BTPRINTSTRUCT * pBtPrintStruct = NULL);

    void                Cancel();
    ePRINT_STATE        GetState();
    UINT                GetBytesSent();
    UINT                GetBytesTotal();
    ePRINT_ERROR        GetLastError(BT_CHAR **pDescr);

    virtual void OnStateChange (ePRINT_STATE NewState) { };
    static CPrintInternal *pIp;
};

///////////////////////////////////////////////////////////////////////////////////////
// Define a class to control the headphone client sessions
//
// New Class added in SDK 5.0.  
// Supported in BTW stacks version 4.0 and greater
class WIDCOMMSDK  CHeadphoneClient
{
public:

    //
    // Define return code for Headphone Client functions
    //
    typedef enum
    {
        SUCCESS,             // Operation initiated without error
        NO_BT_SERVER,        // COM server could not be started
        ALREADY_CONNECTED,   // attempt to connect before previous connection closed
        NOT_CONNECTED,       // attempt to close unopened connection
        NOT_ENOUGH_MEMORY,   // local processor could not allocate memory for open
        INVALID_PARAMETER,   // One or more of function parameters are not valid
        UNKNOWN_ERROR,       // Any condition other than those here
        LICENSE_ERROR,       // invalid license
        DEVICE_BUSY,         // Device busy                             - added SDK 5.0.1.902
        SERVICE_NOT_FOUND,   // no SDP record found                     - added SDK 5.0.1.902
        BTM_WRONG_MODE       // local device is disabled or not up      - added SDK 5.0.1.902

    } HEADPHONE_RETURN_CODE;

    //
    // Define connection states for AV. Ref. from a2d_api.h
    //
    typedef enum
    {
        HEADPHONE_CONNECTED = 0,                // device is connected
        HEADPHONE_LOCAL_DISCONNECT = 10,        // connection closed by local device
        HEADPHONE_REMOTE_DISCONNECT = 11,       // connection closed by remote device
        HEADPHONE_DEVICE_NOT_AUTHORIZED = 15,   // device not authorized
        HEADPHONE_NO_STREAM_FOUND =  13,        // no audio stream found                 - added SDK 5.0.1.902
        HEADPHONE_REMOTE_SUSPENDED = 16,        // remote device suspended the stream    - added SDK 5.0.1.902
        HEADPHONE_INCOMING_STREAM  = 17,        // incoming stream                       - added SDK 5.0.1.902
        HEADPHONE_STREAMING      =   18,        // streaming data                        - added SDK 5.0.1.902
        HEADPHONE_STOPPED        =   19         // streaming stopped                     - added SDK 5.0.1.902
    } HEADPHONE_STATUS;


    typedef void (*tOnHAGConnectionStatusChangedCallback)
        (void *userData, BD_ADDR bda, DEV_CLASS dev_class, BD_NAME bd_name, long lHandle, long lStatus);

public:

    // Construction/destruction
    //
    CHeadphoneClient ();
    virtual ~CHeadphoneClient();

    void SetSecurity(BOOL authentication, BOOL encryption);
    void SetExtendedError(WBtRc code) { m_LastWBtRc = code; }
    WBtRc GetExtendedError() const { return m_LastWBtRc; }

    HEADPHONE_RETURN_CODE ConnectHeadphone(BD_ADDR bda, LPCSTR szServiceName = "");
    HEADPHONE_RETURN_CODE DisconnectHeadphone(long hHandle);
    HEADPHONE_RETURN_CODE GetConnectionStats (tBT_CONN_STATS *p_conn_stats);
    HEADPHONE_RETURN_CODE RegStatusChangeCB (tOnHAGConnectionStatusChangedCallback pOnHAGStatus,
                                             void *userData);
    
private:
    CWBtAPI     *m_pBtApi;
    BOOL        m_authentication_requested_by_app;
    BOOL        m_encryption_requested_by_app;
    BOOL        m_authentication_saved;
    BOOL        m_encryption_saved;
    void        SaveSecurity();
    void        RestoreSecurity();
    WBtRc       m_LastWBtRc;    // Contains the last code returned by WBtApi
    BD_ADDR     m_BdAddr;
    HANDLE      m_hMutex;


    friend class CHeadphoneClientFriend;

    // This class will not support the compiler-supplied copy constructor or assignment operator,
    // so these are declared private to prevent inadvertent use by the application.
    CHeadphoneClient(const CHeadphoneClient & x);
    CHeadphoneClient& operator= (const CHeadphoneClient & x); 
};

///////////////////////////////////////////////////////////////////////////////////////
// Define a class to control the OPPMultiPush sessions
//

// BEGIN - added SDK 6.1, BTW 6.1.0.1300
typedef void (*tOnOppMultiPushCB)(long lOPPHandle,BD_ADDR bda,LPCWSTR pszName,long lError);
typedef void (*tOnOppMultiOpenCB)(long lError);
typedef void (*tOnOppMultiCloseCB)(long lError);
class COppClient_Impl;

class WIDCOMMSDK COppMultiPush
{
public:

//
// Define return code for OPPMultiPush functions
//
//
// Define return code for OPP Client functions
//
//#define OPP_MPUSH_RETURN_CODE COppClient::OPP_RETURN_CODE

public:

    // Construction/destruction
    //
    COppMultiPush ();
    virtual ~COppMultiPush();
    
    void  SetExtendedError(WBtRc code) { m_LastWBtRc = code; }
    WBtRc GetExtendedError() const { return m_LastWBtRc; }
  
    COppClient::OPP_RETURN_CODE MultiPush(WCHAR * pszPathName);
    COppClient::OPP_RETURN_CODE OpenOppConnection (BD_ADDR bdAddr, CSdpDiscoveryRec & sdp_rec);
    COppClient::OPP_RETURN_CODE CloseOppConnection();
    COppClient::OPP_RETURN_CODE RegOppMultiPushCB(tOnOppMultiPushCB  pOnOppMultiPushCB);
    COppClient::OPP_RETURN_CODE RegOppMultiOpenCB(tOnOppMultiOpenCB  pOnOppMultiOpenCB);
    COppClient::OPP_RETURN_CODE RegOppMultiCloseCB(tOnOppMultiCloseCB  pOnOMultippCloseCB);
  
private:
    BOOL        m_authentication_requested_by_app;
    BOOL        m_encryption_requested_by_app;
    BOOL        m_authentication_saved;
    BOOL        m_encryption_saved;
    void        SaveSecurity();
    void        RestoreSecurity();
    long        m_OppHandle;
    CWBtAPI     *m_pBtApi;
    WBtRc       m_LastWBtRc;    // Contains the last code returned by WBtApi
    GUID        m_guid;
    BD_ADDR     m_addr;
    HANDLE      m_hMutex;

    // This class will not support the compiler-supplied copy constructor or assignment operator,
    // so these are declared private to prevent inadvertent use by the application.
    COppMultiPush(const COppMultiPush & x);
    COppMultiPush& operator= (const COppMultiPush & x); 
    friend class COppMultiPushFriend;
};
// END   - added SDK 6.1, BTW 6.1.0.1300


#pragma pack ()


#endif // !defined(AFX_WIDCOMMSDK_H__1F5ED990_6FC6_4B0D_882C_8D7C98C16A06__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -