This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2640R2L:加密连接

Guru**** 1828310 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1190830/cc2640r2l-encrypted-connection

器件型号:CC2640R2L

大家好、

我对加密配对有两个问题。

1.在初始设置过程中,我已将配对后的选项设置为“假”,但在成功连接手机后,设备仍将自动绑定。  我设置的代码 如下。

    // Don't send a pairing request after connecting; the peer device must
    //uint32_t passkey = 0; // passkey "000000"
    // initiate pairing
    uint8_t pairMode = GAPBOND_PAIRING_MODE_INITIATE;
    // Use authenticated pairing: require passcode.
    uint8_t mitm = TRUE;
    // This device only has display capabilities. Therefore, it will display the
    // passcode during pairing. However, since the default passcode is being
    // used, there is no need to display anything.
    uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;    
    // Request bonding (storing long-term keys for re-encryption upon subsequent
    // connections without repairing)
    uint8_t bonding = FALSE;

    uint8_t gapbondSecure = GAPBOND_SECURE_CONNECTION_NONE;//GAPBOND_SECURE_CONNECTION_ONLY ;

    GAPBondMgr_SetParameter(GAPBOND_SECURE_CONNECTION, sizeof(uint8_t), &gapbondSecure);
    //GAPBondMgr_SetParameter(GAPBOND_DEFAULT_PASSCODE, sizeof(uint32_t), &passkey);
    GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode);
    GAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm);
    GAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap);
    GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding);

2.我在开始配置后输入了密钥连接事件。 根据我的需要、如果输入的连接密钥不正确、连接将断开。 但是 、当我输入错误的密钥后、器件会快速连接。 我在这里设置的代码是否有问题?

配对完成后、我在事件中添加了一个断开处理程序事件。

/*********************************************************************
 * @fn      SimplePeripheral_processPairState
 *
 * @brief   Process the new paring state.
 *
 * @return  none
 */
static void SimplePeripheral_processPairState(spPairStateData_t *pPairData)
{
  uint8_t state = pPairData->state;
  uint8_t status = pPairData->status;

  switch (state)
  {
    case GAPBOND_PAIRING_STATE_STARTED:
      Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Pairing started");
      break;

    case GAPBOND_PAIRING_STATE_COMPLETE:
      if (status == SUCCESS)
      {
        Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Pairing success");
      }
      else
      {
        //Disconnected 
        HCI_EXT_DisconnectImmedCmd();

        Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Pairing fail: %d", status);
      }
      break;

    case GAPBOND_PAIRING_STATE_ENCRYPTED:
      if (status == SUCCESS)
      {
        Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Encryption success");
      }
      else
      {
        Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Encryption failed: %d", status);
        //HCI_EXT_DisconnectImmedCmd();
      }
      break;

    case GAPBOND_PAIRING_STATE_BOND_SAVED:
      if (status == SUCCESS)
      {
        Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Bond save success");
      }
      else
      {
        //Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Bond save failed: %d", status);
          //HCI_EXT_DisconnectImmedCmd();
      }
      break;

    default:
      break;
  }
}

此致、

凯瑟琳

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Katherine、

    感谢您的参与。 我们正在调查您的问题、并将尽快回复您。 同时、您能否共享您正在使用的 SDK 版本?

    此致、

    1月

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Jan、

    客户使用的  

    此致、

    凯瑟琳

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Katherine、  

    我将深入了解这一点、并在明天回来、感谢 SDK 版本的更新。 我们建议您随时了解 SDK 的最新版本、该 SDK 现为5.30版

    此致、

    Rogelio

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Rogelio、

    我在5.30版上进行了测试,发现第二个问题是由 HCI_EXT_DisconnectImmedCmd()函数引起的。 在替换 GAPRole_TerminateConnection()函数之后,我发现连接可以顺利断开。

    此致、

    凯瑟琳

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你(们)好,Rogelio。

    客户表示 这两个问题都解决了。 之前4.3测试中使用的例程是 ble5stack、blestack 在5.3上使用。   他在4.3版的 blestack 中使用了该例程、可以实现 他想要的功能。 执行加密连接时、ble5stack 中的例程会处理与连接过程相关的某些事件、而不是 blestack 中的例程。 这可能会导致在加密过程中花费更多时间。 (当然,这是他的猜测。)

    此致、

    凯瑟琳