-
大小: 22KB文件类型: .7z金币: 1下载: 0 次发布日期: 2021-06-18
- 语言: 其他
- 标签: Bluetooth windows-API
资源简介
详细列出了windows蓝牙通信的所有功能,看此文档即可知道windows蓝牙通信API的开发流程
详细列出了windows蓝牙通信的所有功能,看此文档即可知道windows蓝牙通信API的开发流程
代码片段和文件信息
#include “StdAfx.h“
#include “BlueTooth.h“
CBlueTooth::CBlueTooth(void)
{
m_Ary_RemoteBthDevInfo.SetSize ( 0 10*sizeof(BLUETOOTH_DEVICE_INFO) );
m_Ary_LocalRadioInfo.SetSize ( 0 10*sizeof(t_LocalRadioInfo) );
}
CBlueTooth::~CBlueTooth(void)
{
RemoveAll_RemoteBthDevInfo ();
RemoveAllLocalRadio ();
}
//
// 用 Socket 函数搜索附近的蓝牙设备,成功时返回设备数,否则返回-1
//
int CBlueTooth::WSAScanNearbyBthDev ()
{
m_Ary_RemoteBthDevInfo.RemoveAll ();
WSAQUERYSET wsaq;
HANDLE hLookup;
union
{
CHAR buf[5000];
double __unused; // ensure proper alignment
};
LPWSAQUERYSET pwsaResults = (LPWSAQUERYSET) buf;
DWORD dwSize = sizeof(buf);
BOOL bHaveName;
ZeroMemory(&wsaq sizeof(wsaq));
wsaq.dwSize = sizeof(wsaq);
wsaq.dwNameSpace = NS_BTH;
wsaq.lpcsaBuffer = NULL;
if (ERROR_SUCCESS != WSALookupServiceBegin (&wsaq LUP_CONTAINERS &hLookup))
{
TRACE ( _T(“WSALookupServiceBegin failed\n“) );
return -1;
}
ZeroMemory(pwsaResults sizeof(WSAQUERYSET));
pwsaResults->dwSize = sizeof(WSAQUERYSET);
pwsaResults->dwNameSpace = NS_BTH;
pwsaResults->lpBlob = NULL;
while (ERROR_SUCCESS == WSALookupServiceNext (hLookup LUP_RETURN_NAME | LUP_RETURN_ADDR &dwSize pwsaResults))
{
ASSERT (pwsaResults->dwNumberOfCsAddrs == 1);
BTH_ADDR b = ((SOCKADDR_BTH *)pwsaResults->lpcsaBuffer->RemoteAddr.lpSockaddr)->btAddr;
bHaveName = pwsaResults->lpszServiceInstanceName && *(pwsaResults->lpszServiceInstanceName);
t_RemoteBthDevInfo RemoteBthDevInfo;
if ( bHaveName )
{
StringCchPrintf ( RemoteBthDevInfo.szName sizeof(RemoteBthDevInfo.szName) _T(“%s“)
pwsaResults->lpszServiceInstanceName );
}
RemoteBthDevInfo.Address.ullLong = b;
TRACE (L“%s ( %04x%08x )\n“ RemoteBthDevInfo.szName GET_NAP(b) GET_SAP(b) );
m_Ary_RemoteBthDevInfo.Add ( RemoteBthDevInfo );
}
WSALookupServiceEnd(hLookup);
return (int)m_Ary_RemoteBthDevInfo.GetSize();
}
BOOL AUTHENTICATION_CALLBACK (LPVOID pvParam PBLUETOOTH_DEVICE_INFO pDevice)
{
t_AUTHENTICATION_CALLBACK_Para *pAUTHENTICATION_CALLBACK_Para = (t_AUTHENTICATION_CALLBACK_Para*)pvParam;
if ( pAUTHENTICATION_CALLBACK_Para )
{
pDevice->fAuthenticated = TRUE;
DWORD result = BluetoothUpdateDeviceRecord ( pDevice );
ASSERT ( result == ERROR_SUCCESS );
result = BluetoothSendAuthenticationResponse ( pAUTHENTICATION_CALLBACK_Para->hRadio pDevice AUTHENTICATION_PASSKEY );
if ( result == ERROR_SUCCESS )
return TRUE;
}
return FALSE;
}
//
// 用蓝牙 APIs 搜索附近的蓝牙设备,成功时返回设备数,否则返回-1
//
int CBlueTooth::ScanNearbyBthDev (
HANDLE hRadio
BOOL fReturnAuthenticated/* = TRUE*/
BOOL fReturnRemembered/* = TRUE*/
BOOL fReturnUnknown/* = TRUE*/
BOOL fReturnConnected/* = TRUE*/
BOOL fIssueInquiry/* = FALSE*/
UCHAR cTimeoutMultiplier/* = 30*/
)
{
RemoveAll_RemoteBthDevInfo ();
CWaitCursor WaitCursor;
BLUETOOTH_DEVICE_INFO bdi = { sizeof(BLUETOOTH_DEVICE_INFO) };
BLUETOOTH_DEVICE_SEARCH_PARAMS
- 上一篇:engauge digitizer 4.1
- 下一篇:ls-dyna手册
相关资源
- windows蓝牙通信BluetoothApi接口功能说明
- 微软官方-使用Windows-API操作vhd
- 蓝牙(Bluetooth)设备查找、蓝牙服务
- 使用NFC实现蓝牙简易配对的规范
- bluetooth_rtl8821cs_BT_hciattach_imx6.rar
- 蓝牙Mesh基础开发-Nordic nRF5 SDK for Mes
- 支持多线程断点续传的文件传输(F
- InTheHand.Net.Personal+BlueTooth4,蓝牙开发
- bluez-demo
- sscom32.zip
- Bluetooth PBAP profile SPEC
- sdio 3.0 协议标准
- WINCE 蓝牙 NCF_BlueTooth
- CMW_Bluetooth_UserManual_V3-7-70_en_33.pdf
- Bluetooth SIG官方协议,Bluetooth Mesh 非扫
- nrf_sniffer_for_bluetooth_le_2.0.0_c87e17d.zip
- NativeBT 1.0.1_ree.rar
- Arduino Bluetooth Plugin.unitypackage
- BluetoothTools
- 手机蓝牙控制树莓派
评论
共有 条评论