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

📄 bluegpsengine.h

📁 S60系统下的蓝牙GPS连接程序 包括client和server端的连接方式
💻 H
字号:
/*****************************************************************************
 COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2003.

 The software is the copyrighted work of Sony Ericsson Mobile Communications AB.
 The use of the software is subject to the terms of the end-user license
 agreement which accompanies or is included with the software. The software is
 provided "as is" and Sony Ericsson specifically disclaim any warranty or
 condition whatsoever regarding merchantability or fitness for a specific
 purpose, title or non-infringement. No warranty of any kind is made in
 relation to the condition, suitability, availability, accuracy, reliability,
 merchantability and/or non-infringement of the software provided herein.

 *****************************************************************************/

#if !defined(__BlueGPSEngine_H__)
#define __BlueGPSEngine_H__

#include <bt_sock.h>
#include <btdevice.h> 
#include <btsdp.h>
#include <bttypes.h>
#include <es_sock.h>
#include <e32base.h>
#include <e32std.h>	
#include <f32file.h>
#include <qbtselectdlg.h>

#include "trfcommserviceseeker.h" 
#include "BlueGPSParser.h"
#include "BlueGPSServer.h"


class CServiceFinder;
class CServiceSeeker;
class CBlueGPSServer;
class CBlueGPSParser;
class CBTReader;

const TUint KReadBufferSize = 100;
const TUint KReconnectTimeout = 5000000;

/*
 *********************************************************************
 * Class CBlueGPSEngine
 *
 *********************************************************************
 */
class CBlueGPSEngine : public CActive
{
public:
	~CBlueGPSEngine();

	static CBlueGPSEngine* NewL( CBlueGPSServer* aServer, CBlueGPSParser* aParser );
	
	void Connect();
	void CloseConnection();

	void Start();
	void Stop();
	void SetStatus( TInt aStatus ) { iStatus = aStatus; }
	void ReadDeviceAddressFile();

private: 
	enum TEngineState 
	{	
		EDisconnected, 
		EConnecting,
		EConnected,
		EReconnecting,
		EClosingReader,
		ENewDevice,
		EFindingPort,
		ENoValidAddress
	};


	CBlueGPSEngine( const CBlueGPSEngine &aEngine );
	CBlueGPSEngine();
	
	void ConstructL( CBlueGPSServer* aServer, CBlueGPSParser* aParser );
	void RunL();
	void DoCancel();
	TInt ReadAddress();

	TBuf8<128> iTempBuf;
	TDes8 *iReadBuffer;

	TBTSockAddr		iRemoteSockAddr;
	TBTDevAddr*		iRemoteDevAddr;
	TBTDeviceName	iRemoteDevName;
	TBTDeviceClass	iRemoteDevClass;

	TEngineState iEngineState;
	RTimer iTimer;
	TBool iConnected;
	//TInt iPort;
    
	RSocket* iSocket;
	CRFCOMMServiceFinder* iServiceFinder;
	CServiceSeeker* iPortSeeker;

	CBlueGPSServer* iServer;    
	CBTReader* iReader;
	TDesC8* iDevAddr;
	TBuf8<32> iBuf;

	RSemaphore iRunning;
};


/*
 *********************************************************************
 * Class CServiceSeeker
 * 
 *********************************************************************
 */
class CServiceSeeker : public CBase, public MRFCOMMServiceSeeker
{
public:
	CServiceSeeker( CBlueGPSEngine* aEngine ) : iEngine(aEngine), iPort(0xFF) {}
	~CServiceSeeker() {}

	void SearchResult(TInt aError, TUint8 aPort);
	TUint8 iPort;
	CBlueGPSEngine* iEngine;
};





/*
 *********************************************************************
 * Class CBTReader
 *
 *********************************************************************
 */
class CBTReader : public CActive
	{
public:
	static CBTReader* NewL(RSocket* aSocket, CBlueGPSParser* aParser, CBlueGPSEngine* iEngine, TInt aBufSize);
	void IssueRead();
	~CBTReader();
	void Disable();
	void Enable();

private:
	void ConstructL(RSocket* aSocket, TInt aBufSize);
	CBTReader(CBlueGPSParser* aParser, CBlueGPSEngine* iEngine);

	void DoCancel();
	void RunL();

private:
	RSocket*			iBTSocket;	// owned by CBTEngine
	
	TBool				iClosed;
	HBufC8*				iReadBuffer;
	TPtr8				iBuffPtr;	
	CBlueGPSParser*		iParser;
	CBlueGPSEngine*     iEngine;
	RSemaphore			iRunning;
};


#endif

⌨️ 快捷键说明

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