环境:
固件:SDK—1.41
IDE:IAR-9.2
芯片:CC2541
手机配对从机,如果密码错误则提示错误,正确则配对通过(正常)
主机配对从机,无论密码是否匹配都会配对成功,简直就是无视了密码的存在,有配对过程。(错误)
在配对过程中的每个步骤我都会用串口打印出来,虽然密码错误了,但是还是现实验证通过了。
尝试修改模式:
从:
uint8 pairMode = GAPBOND_PAIRING_MODE_INITIATE;uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;uint8 bonding = TURE;uint8 mitm = TRUE;GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
主:
uint8 pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY; uint8 bonding = TURE;uint8 mitm = TRUE; GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );
GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );
GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
尝试修改模式二:
从:
uint8 pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;uint8 bonding = TURE; uint8 mitm = TRUE;GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
主:
uint8 pairMode = GAPBOND_PAIRING_MODE_INITIATE;uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;uint8 bonding = TURE;uint8 mitm = TRUE;GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
尝试修改模式三:
从:
uint8 pairMode = GAPBOND_PAIRING_MODE_INITIATE;uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;uint8 bonding = TURE;uint8 mitm = TRUE;GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
主:
uint8 pairMode = GAPBOND_PAIRING_MODE_INITIATE;uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;uint8 bonding = TURE;uint8 mitm = TRUE;GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
结果:
无论那边发起配对请求,甚至是双方都发起,结果都是无视密码的存在,无论双方密码是否匹配,直接配对完成。手机就正常。
是否我哪里理解错了,还请大家帮帮忙。
Yan:
GuangZhi,
请看另外一贴相同的问题,同样的问题希望不要问两次,在一个帖子讨论就行。
GuangZhi Liu:
回复 Yan:
问题补充:
GAPCentralRole_EstablishLink(FALSE,FALSE,addrType, peerAddr );
我发现主机发出链接后,从机也是主动发出配对请求,但是我在跟踪调试的时候并没有发现主从机任何一方有发送密码的行为(GAPBondMgr_PasscodeRsp函数一直没有被调用)。
但是如果是手机发起的链接请求(GAPBondMgr_PasscodeRsp)会被立即调用。
这里很无解,为什么主机发出的请求从机会默认通过并且将其绑定,而却不向主机发出密码请求?
static void simpleBLECentralPasscodeCB( uint8 *deviceAddr, uint16 connectionHandle,uint8 uiInputs, uint8 uiOutputs ) {uint32passcode=456789;uint8str[7];// Create random passcode//LL_Rand( ((uint8 *) &passcode), sizeof( uint32 ));passcode %= 1000000;// Display passcode to userif ( uiOutputs != 0 ){LCD_WRITE_STRING( "Passcode:",HAL_LCD_LINE_1 );LCD_WRITE_STRING( (char *) _ltoa(passcode, str, 10),HAL_LCD_LINE_2 );}// Send passcode responseGAPBondMgr_PasscodeRsp( connectionHandle, SUCCESS, passcode ); }
GuangZhi Liu:
无奈得不到关注,唯一的回复竟然是管理层面,或许我发两次是过错,但这也是因为你们系统提示原帖也删,自己做了半个月还是一样结果。我只想问问ti员工,是我的问题弱智还是我的问题不详细?还是就因为你们系统过失导致我发两帖原因就无视了?
Derrick Cheng:
回复 GuangZhi Liu:
IO 能力配置有问题,没有一边有输入能力
甜甜的大香瓜:
看我个性签名档的博客地址,《CC2541之配对与绑定》。