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

📄 bluetooth_wm.h

📁 在mobile 6.0上实现蓝牙通讯
💻 H
字号:
#pragma once

#include <initguid.h>
#include <ws2bth.h>
#include <bthapi.h>
#include <bthutil.h>
#include <winsock2.h>

/****************************************************************************************************************
		投稿说明:
****************************************************************************************************************/
#define NOTE_BlueTooth_WM \
L"	◆◆◆ 《pda动态侦测轨道》◆◆◆\r\n\
	北京三岭公司科技开发有限公司\r\n\
	开发专用于火车震动检测\r\n\
\r\n\
	◆◆◆ 作者 ◆◆◆\r\n\
    高廉墀 · gaolch · \r\n\
\r\n\
	◆◆◆ 日期 ◆◆◆\r\n\
    2008-03-01 23:31:18"

// 配对时用得PIN码
#define AUTHENTICATION_PASSKEY		_T("0000")

// 心电仪蓝牙名称
#define RDS_BLUETOOTH_DEVICE_NAME	_T("CONTRON")

// 远程蓝牙设备详细信息
typedef struct _RemoteBthDevInfo
{
	_RemoteBthDevInfo ()
	{
		memset ( szName, 0, sizeof(szName) );
		memset ( &RemoteAddr, 0, sizeof(BT_ADDR) );
		memset ( &LocalAddr, 0, sizeof(BT_ADDR) );
	}
	TCHAR szName[64];
	BT_ADDR RemoteAddr;
	BT_ADDR LocalAddr;
} t_RemoteBthDevInfo;
typedef CArray<t_RemoteBthDevInfo,t_RemoteBthDevInfo&> t_Ary_RemoteBthDevInfo;

//----------------------------------------------------------------------------------------------------
// 一些在 bluetoothapis.h 或 bthsdpdef.h 中定义这里重新定义,因为不能包含这些 Windows 头文件
//----------------------------------------------------------------------------------------------------

typedef struct _BLUETOOTH_ADDRESS {
    union {
        BT_ADDR ullLong;       //  easier to compare again BLUETOOTH_NULL_ADDRESS
        BYTE    rgBytes[ 6 ];   //  easier to format when broken out
    };

} BLUETOOTH_ADDRESS_STRUCT;
#define BLUETOOTH_ADDRESS BLUETOOTH_ADDRESS_STRUCT

class CBlueTooth_WM
{
public:
	CBlueTooth_WM(void);
	~CBlueTooth_WM(void);
	BOOL Init ( LPCTSTR lpszCurDir );
	int ScanNearbyBthDev_Direct ();
	CString FormatBthAddress(BT_ADDR BthAddress);
	void ThreadProc_ScanNearbyBthDev ();
	BOOL ScanNearbyBthDev ( HANDLE hEvt_Notify=NULL, HWND hWnd_Noify=NULL);
	BOOL Save_RemoteBthDevInfo_ToFile(LPCTSTR lpszPath);
	BOOL Read_RemoteBthDevInfo_FromFile(LPCTSTR lpszPath);
	int ConnectToBlueToothServer ( BT_ADDR ServerAddress, LPCTSTR lpszServiceGUID );
	BOOL IsConnect () { return ( m_socketClient!=INVALID_SOCKET ); }
	void Disconnect ();
	int Transmite ( LPVOID lpData, int nSize, BOOL bSend );
	int Send ( LPVOID lpData, int nSize );
	int Recv ( LPVOID lpData, int nSize );
	int Find_RemoteBthDevInfo ( LPCTSTR lpszName_Found, t_RemoteBthDevInfo *pRemoteBthDevInfo=NULL );
	int Find_RemoteBthDevInfo ( BT_ADDR Addr_Found, t_RemoteBthDevInfo *pRemoteBthDevInfo=NULL );

private:
	void RemoveAll_RemoteBthDevInfo(void);
	int ScanNearbyBthDevFinished ( int nRetValue );
	BOOL StringToGUID ( LPCTSTR lpszGUID, GUID *pGUID);
	BOOL Add_RemoteBthDevInfo ( t_RemoteBthDevInfo &RemoteBthDevInfo );

public:
	t_Ary_RemoteBthDevInfo m_Ary_RemoteBthDevInfo;
private:
	HANDLE m_hEvtEndModule;
	CString m_csCurDir;
	SOCKET m_socketClient;

	HANDLE m_hEvt_Notify_ScanNearbyBthDev;
	HWND m_hWnd_Noify_ScanNearbyBthDev;
	DWORD m_dwThreadID_ScanNearbyBthDev;
	HANDLE m_hThread_ScanNearbyBthDev;
};

⌨️ 快捷键说明

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