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

📄 btifclasses.h

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

    // 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.
    CSdpService(const CSdpService & x);
    CSdpService& operator= (const CSdpService & x); 
};


class WIDCOMMSDK CSdpDiscoveryRec
{
public:

    CSdpDiscoveryRec();
    ~CSdpDiscoveryRec();

    BT_CHAR m_service_name[BT_MAX_SERVICE_NAME_LEN + 1];

    GUID    m_service_guid;

    BOOL    FindRFCommScn (UINT8 *pScn);

    BOOL    FindL2CapPsm (UINT16 *pPsm);

    BOOL    FindProtocolListElem (UINT16 layer_uuid, tSDP_PROTOCOL_ELEM *p_elem);

    BOOL    FindAdditionalProtocolListElem (UINT16 layer_uuid, tSDP_PROTOCOL_ELEM *p_elem);

    BOOL    FindProfileVersion (GUID *p_profile_guid, UINT16 *p_version);

    BOOL    FindAttribute (UINT16 attr_id, SDP_DISC_ATTTR_VAL *p_val);

private:

    void    *m_p_rec;
    UINT8   *m_p_free_mem;
    UINT16  m_mem_free;

    void    Create(void *p);
    UINT8   *AddDiscoveryAttr (UINT8 *pp, int len, void *p_parent, int nest_level);

    friend class CBtIf;

    // 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.
    CSdpDiscoveryRec(const CSdpDiscoveryRec & x);
    CSdpDiscoveryRec& operator= (const CSdpDiscoveryRec & x); 
};


////////////////////////////////////////////////////////////////////////////
//
// Define a class to control the RfComm interface
//
class WIDCOMMSDK CRfCommIf  
{
public:
    CRfCommIf();
    ~CRfCommIf();

    // Server should call this method without any parameter
    // to assign a new SCN value, or with a SCN value if it
    // is using a fixed SCN. Client should call this method
    // with SCN found from service discovery
    //
    // UPDATED BTW 3.0.0.400, SDK 3.0.1.901:
    //  szServiceName parameter added to allow differentiation between 2 services using
    //  the same GUID
    //
    BOOL AssignScnValue (GUID *p_service_guid, UINT8 scn = 0, LPCSTR szServiceName = "");

    // Returns the SCN value currently in use.
    //
    inline UINT8 GetScn() { return m_scn; }

    // Both client and server MUST call this function to set
    // the security level for connections on the assigned SCN.
    //
    BOOL SetSecurityLevel (BT_CHAR *p_service_name, UINT8 security_level, BOOL is_server);

private:
    UINT8      m_scn;
    BOOL       m_scnWasAllocated;
    GUID       m_service_guid;
    UINT8      m_security_index;

    // 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.
    CRfCommIf(const CRfCommIf & x);
    CRfCommIf& operator= (const CRfCommIf & x); 
};



///////////////////////////////////////////////////////////////////////////////////////
// Define a class to control the RFCOMM connections (both client and server)
//
class WIDCOMMSDK  CRfCommPort
{
public:

    // Construction/destruction
    //
    CRfCommPort ();
    virtual ~CRfCommPort();
//
// Define return code for RFCOMM port functions
//
typedef enum
{
    SUCCESS,
    UNKNOWN_ERROR,
    ALREADY_OPENED,         // Client tried to open port to existing DLCI/BD_ADDR
    NOT_OPENED,             // Function called before conn opened, or after closed
    HANDLE_ERROR,           // Use of a bad connection handle within SDK
    LINE_ERR,               // Line error
    START_FAILED,           // Connection attempt failed
    PAR_NEG_FAILED,         // Parameter negotiation failed, currently only MTU
    PORT_NEG_FAILED,        // Port negotiation failed
    PEER_CONNECTION_FAILED, // Connection ended by remote side
    PEER_TIMEOUT,           
    INVALID_PARAMETER,
    NOT_SUPPORTED           // not supported on Profile Pack version - added SDK 6.1
} PORT_RETURN_CODE;


    // Open the RFComm serial port as a server (i.e. listen for
    // remote side to connect to us).
    //
   PORT_RETURN_CODE  OpenServer (UINT8 scn, UINT16 desired_mtu = RFCOMM_DEFAULT_MTU);

    // Open the RFComm serial port as a client (i.e. initiate
    // the connection).
    //
   PORT_RETURN_CODE  OpenClient (UINT8 scn, BD_ADDR RemoteBdAddr, UINT16 desired_mtu = RFCOMM_DEFAULT_MTU);

   // Close the RFComm serial port
   //
   PORT_RETURN_CODE  Close(void);

   // Check if connection is up, and if so to whom
   //
   BOOL IsConnected (BD_ADDR *p_remote_bdaddr);

   // Set port flow control - application level, not low level
   //
   PORT_RETURN_CODE SetFlowEnabled (BOOL enabled);

   // Set control leads see BtIfDefinitions.h
   //
   PORT_RETURN_CODE SetModemSignal (UINT8 signal);

   // Get control lead status
   //
   PORT_RETURN_CODE GetModemStatus (UINT8 *p_signal);

   // Send an error to the peer
   //
   PORT_RETURN_CODE SendError (UINT8 errors);

   // Purge transmit queue
   //
   PORT_RETURN_CODE Purge (UINT8 purge_flags);

   // Write data
   //
   PORT_RETURN_CODE Write (void *p_data, UINT16 len_to_write, UINT16 *p_len_written);

   // Get Current Connection Statistics
   //
   PORT_RETURN_CODE GetConnectionStats (tBT_CONN_STATS *p_conn_stats);

   // App may provide these functions
   //
   virtual void OnDataReceived (void *p_data, UINT16 len) {}
   virtual void OnEventReceived (UINT32 event_code) {}
   virtual void OnFlowEnabled (BOOL enabled) {}                 // never implemented, stub maintained for compatibility

   BOOL SwitchRole(MASTER_SLAVE_ROLE new_role);

   // Create AudioConnection
   AUDIO_RETURN_CODE CreateAudioConnection(BOOL bIsClient, UINT16 *audioHandle);
   AUDIO_RETURN_CODE CreateAudioConnection(BOOL bIsClient, UINT16 *audioHandle, BD_ADDR bda);   // added BTW 4.0.1.1400, SDK 4.0

   // Disconnect AudioConnection
   AUDIO_RETURN_CODE RemoveAudioConnection(UINT16 audioHandle);

   // audio callback functions
   virtual void OnAudioConnected(UINT16 audioHandle){};
   virtual void OnAudioDisconnect(UINT16 aidioHandle){};

   // eSCO functions
   AUDIO_RETURN_CODE RegForEScoEvts (UINT16 audioHandle, tBTM_ESCO_CBACK *p_esco_cback);        // added SDK 5.0, BTW 5.0.1.200
   AUDIO_RETURN_CODE SetEScoMode (tBTM_SCO_TYPE sco_mode, tBTM_ESCO_PARAMS *p_parms);           // added SDK 5.0, BTW 5.0.1.200
   AUDIO_RETURN_CODE ReadEScoLinkData (UINT16 audioHandle, tBTM_ESCO_DATA *p_Data);             // added SDK 5.0, BTW 5.0.1.200
   AUDIO_RETURN_CODE ChangeEScoLinkParms (UINT16 audioHandle, tBTM_CHG_ESCO_PARAMS *p_parms);   // added SDK 5.0, BTW 5.0.1.200
   void EScoConnRsp (UINT16 audioHandle, UINT8 hci_status, tBTM_ESCO_PARAMS *p_parms = NULL);   // added SDK 5.0, BTW 5.0.1.200

   PORT_RETURN_CODE SetLinkSupervisionTimeOut(UINT16 timeout);

private:

   UINT8               m_scn;
   BOOL                m_is_server;
   UINT16              m_RemoteMtu;

   UINT16              m_desired_mtu;

   static CRfCommPort  *m_p_first_port;
   CRfCommPort         *m_p_next_port;

   UINT16              m_handle;
   BOOL                m_is_connected;
   BD_ADDR             m_RemoteBdAddr;
   UINT16              m_audioHandle;
   UINT16              m_handle_saved;
   UINT16              *m_pPendingAudioHandle;
   friend class CRfCommFriend;

   // 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.
   CRfCommPort(const CRfCommPort & x);
   CRfCommPort& operator= (const CRfCommPort & x); 
};

///////////////////////////////////////////////////////////////////////////////////////
// Define a class to control the FTP client sessions
//
class WIDCOMMSDK  CFtpClient
{

public:

//
// Define return code for FTP Client functions
//
typedef enum
{
    SUCCESS,                // Operation initiated without error
    OUT_OF_MEMORY,          // Not enough memory to initiate operation
    SECURITY_ERROR,         // Error implementing requested security level
    FTP_RETURN_ERROR,       // FTP-specific error
    NO_BT_SERVER,           // cannot access the local Bluetooth COM server
    FILE_NOT_FOUND,         // file/dirctory does not found
    FILE_SHARING,           // file sharing violation
    ALREADY_CONNECTED,      // Only one connection at a time supported for each instantiated CFtpClient object
    NOT_OPENED,             // Connection must be opened before requesting this operation
    INVALID_PARAMETER,      // One or more of function parameters are not valid
    UNKNOWN_RETURN_ERROR,   // Any condition other than the above
    LICENSE_ERROR           // license error
} FTP_RETURN_CODE;



//
// Define return code for FTP response functions
//
typedef enum
{
    COMPLETED,              // operation completed without error
    BAD_ADDR,               // bad BD_ADDR
    FILE_EXISTS,            // file already exists
    BAD_STATE,              // could not handle request in present state
    BAD_REQUEST,            // invalid request
    NOT_FOUND,              // no such file
    NO_SERVICE,             // could not find the specified FTP server
    DISCONNECT,             // connection lost
    READ,                   // read error
    WRITE,                  // write error
    OBEX_AUTHEN,            // OBEX Authentication required
    DENIED,                 // request could not be honored
    DATA_NOT_SUPPORTED,     // server does not support the requested data
    CONNECT,                // error establishing connection
    PERMISSIONS,            // incorrect file or service permissions
    NOT_INITIALIZED,        // not initialized
    PARAM,                  // invalid parameter
    RESOURCES,              // out of file system resources (handles, disk space, etc)
    SHARING,                // sharing violation
    UNKNOWN_RESULT_ERROR    // Any condition other than the above
} FTP_RESULT_CODE;

// FTP
enum FtpFolder
{
    FTP_ROOT_FOLDER = 1,
    FTP_PARENT_FOLDER,
    FTP_SUBFOLDER
};
typedef enum FtpFolder tFtpFolder;


public:

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

    FTP_RETURN_CODE OpenConnection (BD_ADDR bdAddr, CSdpDiscoveryRec & sdp_rec);
    FTP_RETURN_CODE CloseConnection();
    FTP_RETURN_CODE PutFile(WCHAR * localFileName);
    FTP_RETURN_CODE GetFile(WCHAR * remoteFileName,  WCHAR * localFolder);
    FTP_RETURN_CODE FolderListing();
    FTP_RETURN_CODE ChangeFolder(WCHAR * szFolder);
    FTP_RETURN_CODE DeleteFile(WCHAR * szFile) { return _DeleteFile(szFile); }      // BtwDeleteFile == DeleteFile, added Btw version to 
    FTP_RETURN_CODE BtwDeleteFile(WCHAR * szFile) { return _DeleteFile(szFile); }   // avoid issue with UNICODE and standard lib DeleteFileA/W
    FTP_RETURN_CODE Abort();
    FTP_RETURN_CODE Parent();
    FTP_RETURN_CODE Root();
    FTP_RETURN_CODE CreateEmpty(WCHAR * szFile);
    FTP_RETURN_CODE CreateFolder(WCHAR * szFolder);
    void SetSecurity(BOOL authentication, BOOL encryption);

   // Application may provide these functions to facilitate managing the connection
    virtual void OnOpenResponse(FTP_RESULT_CODE result_code) {}
    virtual void OnCloseResponse(FTP_RESULT_CODE result_code){}
    

// windows
    virtual void OnProgress(FTP_RESULT_CODE result_code, WCHAR * name, long current, long total) {}
    virtual void OnPutResponse(FTP_RESULT_CODE result_code, WCHAR * name) {}
    virtual void OnGetResponse(FTP_RESULT_CODE result_code, WCHAR * name) {}
    virtual void OnCreateResponse(FTP_RESULT_CODE result_code, WCHAR * name) {}
    virtual void OnDeleteResponse(FTP_RESULT_CODE result_code, WCHAR * name){}
    
    virtual void OnChangeFolderResponse(FTP_RESULT_CODE result_code, tFtpFolder folder_type, WCHAR * szFolder) {}
    virtual void OnFolderListingResponse(FTP_RESULT_CODE result_code, tFTP_FILE_ENTRY * listing, long entries) {}
    virtual void OnXmlFolderListingResponse(FTP_RESULT_CODE rc, WCHAR * pfolder_listing, long folder_length ){}
    virtual void OnAbortResponse(FTP_RESULT_CODE result_code) {}

    void  SetExtendedError(WBtRc code) { m_LastWBtRc = code; }
    WBtRc GetExtendedError() const { return m_LastWBtRc; }


private:

⌨️ 快捷键说明

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