bluetoothclient.h

来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C头文件 代码 · 共 79 行

H
79
字号
#ifndef __BLUETOOTHCLIENT_H__
#define __BLUETOOTHCLIENT_H__

// System Includes
#include <bt_sock.h>

// User defined includes
#include "BluetoothDefinitions.h" // KMaxMessageLength

// Forward Declaration
class MBluetoothObserver;

// CLASS DECLARATION

/**
*
* This is the Bluetooth Client and handles setting up sockets for Bluetooth communications
*
* It requires an observer to handle UI feedback on certain events
*
*/
/**
*
* @class    CBluetoothClient BluetoothClient.h 
* @brief    This is the Bluetooth Client and handles setting up sockets for Bluetooth communications
*
* It requires an observer to handle UI feedback on certain events
*
* Copyright (c) EMCC Software Ltd 2003
* @version    1.0
* 
*/
class CBluetoothClient : public CActive
{
    public: // Constructors
        static CBluetoothClient*     NewL(MBluetoothObserver& aObserver);
        ~CBluetoothClient();

    private: // Constructors - Symbian 2nd stage
        CBluetoothClient(MBluetoothObserver& aObserver);
        void                 ConstructL();

    public: // Member functions
        void                 ConnectToServerL(const TBTDevAddr& aBTDevAddr, const TInt aPort);
        void                 Send(const TDesC& aMessage);
        TBool                 IsConnected();
        TBool                 AvailableToSend();

    public:    // Member functions from CActive
        void                 RunL();
        void                 DoCancel();

    private: // member functions, utility functions
        void                 Disconnect();
        void                 RequestData();
        void                 SendL(const TDesC& aMessage);

    private: // Private member data
        RSocketServ                                        iSocketServer;
        RSocket                                            iSendingSocket;
        TBTSockAddr                                        iSocketAddress;
        TBuf8<KMaxMessageSizeDesc16 + sizeof (TInt)>    iMessage;
        TSockXfrLength                                     iLen;
        MBluetoothObserver&                                iObserver;

    private: // State machine definition
        enum TState 
        {
            EDisconnected,
            EConnecting,
            EConnected,
            EWaitingForMessage,
            ESendData
        };
    
        TState                iState;
};

#endif // __BLUETOOTHCLIENT_H__

⌨️ 快捷键说明

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