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

📄 bluetoothapi.h.svn-base

📁 qaSDQDaca<FCSASDAVCASC SDVFDSVDF
💻 SVN-BASE
字号:
 /*
============================================================================================
 Name		: BluetoothAPI.h
 Author	    : BluetoothAPI is a initiative of Embedded LAB - http://www.embedded.ufcg.edu.br/
 			  OpenC/SymbianC++ - http://efforts.embedded.ufcg.edu.br/symbiancpp	
 Version	 :
 Copyright   : This file is part of BluetoothAPI.
               Bluetooth is free software: you can redistribute it and/or modify
               it under the terms of the GNU Lesser General Public License as published by
               the Free Software Foundation, either version 3 of the License, or
               (at your option) any later version.

               BluetoothAPI is distributed in the hope that it will be useful,
               but WITHOUT ANY WARRANTY; without even the implied warranty of
               MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
               GNU Lesser General Public License for more details.

               You should have received a copy of the GNU Lesser General Public License
               along with BluetoothAPI. If not, see <http://www.gnu.org/licenses/>.
 
 Description : BluetoothAPI.h implementation
===========================================================================================
*/

// This file defines the API for BluetoothAPI.dll

#ifndef __BLUETOOTHAPI_H__
#define __BLUETOOTHAPI_H__

//  Include Files

#include "BluetoothDeviceSearcher.h"
#include "BluetoothServiceSearcher.h"
#include "BluetoothServiceAdvertiser.h"
#include "BluetoothServer.h"
#include "BluetoothClient.h"
#include <vector>

// Other definitions
using namespace std;

struct BTDeviceData
{
	char devName[256];
	char devAdr[32];
	unsigned int RfCommServicePort;
};

//  Listener Class Definitions

class BluetoothAPIListener
{
	public:
		virtual void devicesDiscoverFinished( vector<BTDeviceData>& aDiscoveredDeviceList )=0;
		virtual void servicesDiscoverFinished( vector<BTDeviceData>& aDiscoveredServiceList )=0;

		virtual void serverConnected()=0;
		virtual void serverDisconnected()=0;
		virtual void clientConnected()=0;
		virtual void clientDisconnected()=0;
		virtual void messageReceived( char * aMessage)=0;
		virtual void messageSent()=0;
		virtual void errorOcurred(int aError)=0;
};

//  Class Definitions

class BluetoothAPI : private MBTDeviceSearcherObserver, MBluetoothServiceSearcherObserver,
	MBTClientObserver, MBTServerObserver
{
	public:
		IMPORT_C static BluetoothAPI* create(  BluetoothAPIListener *aListener );
		IMPORT_C void searchDevices();
		IMPORT_C void searchServices(unsigned long int BTServiceUUID);
		IMPORT_C void searchServices(unsigned long int BTServiceUUID1,
				unsigned long int BTServiceUUID2, unsigned long int BTServiceUUID3,
				unsigned long int BTServiceUUID4);
		IMPORT_C void connectToServer(BTDeviceData DeviceData);
		IMPORT_C void startAdvertising(unsigned long int BTServiceUUID1,
				unsigned long int BTServiceUUID2, unsigned long int BTServiceUUID3,
				unsigned long int BTServiceUUID4, char* BTServiceName );
		IMPORT_C void startAdvertising(unsigned long int BTServiceUUID,
				char* BTServiceName );
		IMPORT_C void stopServerAndAdvertising();
		IMPORT_C void disconnectAsClient();
		IMPORT_C vector<BTDeviceData>& foundDevicesList();
		IMPORT_C vector<BTDeviceData>& foundServicesList();
		IMPORT_C virtual ~BluetoothAPI();
		IMPORT_C void sendMessage(char* message);
		
	private:
		RSocketServ iSocketServ;
		BluetoothAPIListener *APIListener;
		vector<BTDeviceData> DeviceList;
		vector<BTDeviceData> ServiceList;
		CBluetoothDeviceSearcher* iBTDeviceDiscovery;
		CBluetoothServiceSearcher* iBTServiceDiscovery;
		CBluetoothServiceAdvertiser* iBTServiceAdvertiser;
		CBluetoothServer* iBTServer;
		CBluetoothClient* iBTClient;
		int iIndex;
		int iIndice;
		TUUID iServiceSearch;
		TBool iSearch;
		TBool isAdvertising;
		TBool iIsServer;
		TBool iConnected;
		BluetoothAPI(BluetoothAPIListener *Listener);
		BluetoothAPI(const BluetoothAPI&){};
		void SearchServices();
		void HandleBTDeviceSearchCompleteL( RBTDeviceDataArray );
		void OnServiceSearchComplete(TInt aPort, TInt aError);
		
		void HandleBTServerConnected();
		void HandleBTServerDisconnected();
		void HandleBTServerMessageRecvd();
		
		void HandleBTClientConnected();
		void HandleBTClientDisconnected();
		void HandleBTClientMessageRcvd();
		
		void HandleBTMessageSent();
		void HandleBTError(TInt aError);
};

#endif  // __BLUETOOTHAPI_H__

⌨️ 快捷键说明

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