微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > CC2541主从机配对问题

CC2541主从机配对问题

时间:10-02 整理:3721RD 点击:

环境:

固件: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 );   

结果:
无论那边发起配对请求,甚至是双方都发起,结果都是无视密码的存在,无论双方密码是否匹配,直接配对完成。手机就正常。
是否我哪里理解错了,还请大家帮帮忙。

GuangZhi,

请看另外一贴相同的问题,同样的问题希望不要问两次,在一个帖子讨论就行。

问题补充:

GAPCentralRole_EstablishLink(FALSE,FALSE,addrType, peerAddr );

我发现主机发出链接后,从机也是主动发出配对请求,但是我在跟踪调试的时候并没有发现主从机任何一方有发送密码的行为(GAPBondMgr_PasscodeRsp函数一直没有被调用)。

但是如果是手机发起的链接请求(GAPBondMgr_PasscodeRsp)会被立即调用。

这里很无解,为什么主机发出的请求从机会默认通过并且将其绑定,而却不向主机发出密码请求?

static void simpleBLECentralPasscodeCB( uint8 *deviceAddr, uint16 connectionHandle,
                                        uint8 uiInputs, uint8 uiOutputs )
{
  uint32  passcode=456789;
  uint8   str[7];

  // Create random passcode
  //LL_Rand( ((uint8 *) &passcode), sizeof( uint32 ));
  passcode %= 1000000;
  
  // Display passcode to user
  if ( uiOutputs != 0 )
  {
    LCD_WRITE_STRING( "Passcode:",  HAL_LCD_LINE_1 );
    LCD_WRITE_STRING( (char *) _ltoa(passcode, str, 10),  HAL_LCD_LINE_2 );
  }
  
  // Send passcode response
  GAPBondMgr_PasscodeRsp( connectionHandle, SUCCESS, passcode );
}

无奈得不到关注,唯一的回复竟然是管理层面,或许我发两次是过错,但这也是因为你们系统提示原帖也删,自己做了半个月还是一样结果。我只想问问ti员工,是我的问题弱智还是我的问题不详细?还是就因为你们系统过失导致我发两帖原因就无视了?

IO 能力配置有问题,没有一边有输入能力

看我个性签名档的博客地址,《CC2541之配对与绑定》。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top