Code Bye

调用回调函数出现has triggered a breakpoint, 请教怎么样解决?


如上图,代码如下,讨教高手指点问题解决.
BOOL BluetoothAuthCallback(LPVOID pvParam, PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS pAuthCallbackParams)
{
DWORD dwRet;
BLUETOOTH_AUTHENTICATE_RESPONSE AuthRes;
AuthRes.authMethod = pAuthCallbackParams->authenticationMethod;
// GUID AudioService=AudioVideoServiceClass_UUID;
// GUID headsetService=HeadsetServiceClass_UUID;
GUID handfreeService=HandsfreeServiceClass_UUID;
// Check to make sure we are using numeric comparison (Just Works)
HANDLE btHandle=(HANDLE)pvParam;
AuthRes.bthAddressRemote = pAuthCallbackParams->deviceInfo.Address;
AuthRes.negativeResponse = FALSE;
// Commented out code is used for pairing using the BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY method
//    memcpy_s(AuthRes.pinInfo.pin, sizeof(AuthRes.pinInfo.pin), L”1234″, 0)
memcpy(AuthRes.pinInfo.pin,”1234″,sizeof(AuthRes.pinInfo.pin));
AuthRes.pinInfo.pinLength = 0;
// Respond with numerical value for Just Works pairing
AuthRes.numericCompInfo.NumericValue = 1;
// Send authentication response to authenticate device
BluetoothSetServiceState(btHandle,&pAuthCallbackParams->deviceInfo,&handfreeService,BLUETOOTH_SERVICE_ENABLE);
dwRet=BluetoothUpdateDeviceRecord(&pAuthCallbackParams->deviceInfo);
dwRet=BluetoothSendAuthenticationResponseEx(btHandle,&AuthRes);
return FALSE; // This value is ignored
}
int main(void)
{
wcout.imbue(locale(“”));
HBLUETOOTH_RADIO_FIND hbf = NULL;
HANDLE hbr = NULL;
HBLUETOOTH_DEVICE_FIND hbdf = NULL;
BLUETOOTH_FIND_RADIO_PARAMS btfrp = { sizeof(BLUETOOTH_FIND_RADIO_PARAMS) };
BLUETOOTH_RADIO_INFO bri = { sizeof(BLUETOOTH_RADIO_INFO)};
BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = { sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS) };
BLUETOOTH_DEVICE_INFO btdi = { sizeof(BLUETOOTH_DEVICE_INFO) };
hbf=BluetoothFindFirstRadio(&btfrp, &hbr);
BOOL status;
UINT sizeb=sizeof(BLUETOOTH_ADDRESS);
bool brfind = hbf != NULL;
while (brfind)
{
if (BluetoothGetRadioInfo(hbr, &bri) == ERROR_SUCCESS)
{
cout << “Class of device: 0x” << uppercase << hex << bri.ulClassofDevice << endl;
wcout <<“Name:”<< bri.szName << endl;
cout <<“Manufacture:0x”<< uppercase << hex << bri.manufacturer << endl;
cout << “Subversion:0x” << uppercase << hex << bri.lmpSubversion << endl;
//
btsp.hRadio = hbr;
btsp.fReturnAuthenticated = FALSE;
btsp.fReturnConnected = FALSE;
btsp.fReturnRemembered = FALSE;
btsp.fReturnUnknown = TRUE;
btsp.fIssueInquiry=TRUE;
btsp.cTimeoutMultiplier = 3;
WCHAR tempkey[7] = { “”7″”, “”3″”, “”8″”, “”2″”, “”5″”, “”1″”, “”\0″” };
PWCHAR pszPasskey = tempkey;
ULONG ulPasskeyLength = (ULONG)wcslen(tempkey);
HBLUETOOTH_AUTHENTICATION_REGISTRATION hRegHandle=NULL;
unsigned int success=0;
hbdf=BluetoothFindFirstDevice(&btsp, &btdi);
bool bfind = hbdf != NULL;
DWORD Service=0;
GUID AudioService=AudioVideoServiceClass_UUID;
GUID headsetService=HeadsetServiceClass_UUID;
GUID handfreeService=HandsfreeServiceClass_UUID;
while (bfind)
{
wcout << “[Name]:” << btdi.szName;
cout << “,[Address]:0x” << uppercase << hex << btdi.Address.ullLong << endl;
//register callabck function
success=BluetoothRegisterForAuthenticationEx(&btdi,&hRegHandle,(PFN_AUTHENTICATION_CALLBACK_EX)&BluetoothAuthCallback,NULL);
success=BluetoothAuthenticateDeviceEx(NULL,NULL,&btdi,NULL,MITMProtectionRequired);
status=BluetoothUnregisterAuthentication(hRegHandle);
bfind=BluetoothFindNextDevice(hbdf, &btdi);
}
BluetoothFindDeviceClose(hbdf);
}
CloseHandle(hbr);
brfind=BluetoothFindNextRadio(hbf, &hbr);
}
_getch();
return 0;
}
解决方案:40分
点break,然后通过观察分析原因

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明调用回调函数出现has triggered a breakpoint, 请教怎么样解决?