调用回调函数出现has triggered a breakpoint, 求教如何解决?

LEI_GQ 2015-12-22 11:18:25


如上图,代码如下,请教高手指点问题解决.
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;
}
...全文
605 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
LEI_GQ 2015-12-22
  • 打赏
  • 举报
回复
找到原因了,回调函数的调用种类需要设为_stdcall 感谢关注.
paschen 版主 2015-12-22
  • 打赏
  • 举报
回复
点break,然后通过观察分析原因
内容概要:本文围绕“新型电力系统下多分布式电源接入配电网承载力评估方法”的研究,系统性地介绍了基于Matlab的仿真建模与代码实现方案,旨在评估高比例分布式电源(如光伏、风电等)接入背景下配电网的接纳能力。研究融合了智能优化算法(如蜣螂优化、灰狼优化、遗传算法)、多目标优化、鲁棒优化及双层优化模型,结合潮流计算、稳定性分析与故障仿真,构建了完整的承载力评估体系。文档不仅提供核心算法实现,还拓展至微电网调度、储能配置、电氢耦合系统、电动汽车协同等前沿方向,强调“复现+创新”相结合的科研路径,助力研究者快速掌握高水平论文复现技巧并激发原创思路。; 适合人群:具备电力系统、自动化或相关专业背景,熟悉Matlab/Simulink仿真环境,正在从事科研或工程应用的研究生及初级科研人员(工作1-3年);; 使用场景及目标:①复现高水平期刊中关于配电网承载力的优化模型;②开展高比例可再生能源接入下的配电网规划与运行研究;③学习并应用智能优化算法解决复杂电力系统问题;④获取完整科研资源包以加速课题进展与论文撰写; 阅读建议:建议读者关注公众号“荔枝科研社”获取网盘资源,下载全套代码与模型文件,按照文档结构循序渐进学习,重点理解算法设计逻辑与仿真建模细节,结合所提供的复现案例深化对优化模型与工程应用场景的理解,提升科研效率与创新能力。

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧