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.

[参考译文] CC2652R:什么是"写入错误160"?

Guru**** 2392285 points


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

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1115114/cc2652r-what-is-write-error-160

器件型号:CC2652R

您好!

我使用 multi_role (simplelink_cc13xx_cc26xx_sdk_5_30_01_01)、并且遇到问题。

我使用 multi_role_getBondInfo 函数来查找 irk 值。

bool multi_role_getBondInfo(uint8_t index)
{
  (void) index;

  Display_printf(dispHandle, DisplayUart_SCROLLING, 0, "");
  Display_printf(dispHandle, DisplayUart_SCROLLING, 0, "===================================================================");
  Display_printf(dispHandle, DisplayUart_SCROLLING, 0, "Get Bonding Information");
  // Parameters needed for storing bonding information.
  static gapBondRec_t pSavedBondRec;
  static gapBondLTK_t pLocalLtk;
  static gapBondLTK_t pPeerLtk;
  static uint8_t pPeerIRK[KEYLEN];
  static uint8_t pPeerSRK[KEYLEN];
  static uint32_t pPeerSignCount;
  static gapBondCharCfg_t charCfg;
  uint8_t i;

  uint8_t readStatus = FAILURE;
  readStatus = gapBondMgrReadBondRec(pPeerAddrType,
                                     peerDeviceAddr,
                                     &pSavedBondRec,
                                     &pLocalLtk,
                                     &pPeerLtk,
                                     pPeerIRK,
                                     pPeerSRK,
                                     pPeerSignCount,
                                     &charCfg);
  if (readStatus == SUCCESS)
  {
    Display_printf(dispHandle, DisplayUart_SCROLLING, 0,
                   "  Peer Device Addr = [0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x];",
                   pSavedBondRec.addr[0],
                   pSavedBondRec.addr[1],
                   pSavedBondRec.addr[2],
                   pSavedBondRec.addr[3],
                   pSavedBondRec.addr[4],
                   pSavedBondRec.addr[5]);

    Display_printf(dispHandle, DisplayUart_SCROLLING, 0, "  Peer Device AddrType = 0x%02x; stateFlag = 0x%02x;", pSavedBondRec.addrType, pSavedBondRec.stateFlags);
    Display_printf(dispHandle, DisplayUart_SCROLLING, 0, "  Local Device eDiv = 0x%02x; keySize = 0x%02x", pLocalLtk.div, pLocalLtk.keySize);
    Display_printf(dispHandle, DisplayUart_SCROLLING, 0, "  peer Device SignCount = 0x%08x;", pPeerSignCount);

    for (i = 0; i < KEYLEN; i++)
    {
        Display_printf(dispHandle, DisplayUart_SCROLLING, 0, "  Peer Device IRK[%d]= 0x%02x;", i, pPeerIRK[i]);
    }
  }
  Display_printf(dispHandle, DisplayUart_SCROLLING, 0, "===================================================================");
  Display_printf(dispHandle, DisplayUart_SCROLLING, 0, "");

  return (true);
}

之后、如果我使用 GATT_WriteCharValue() API、则响应 将为 "ATT_ERROR_RSP"。

attWriteReq_t conPoWriteValueReq;
uint8_t conPoWriteValueConnIndex;

bool multi_role_doGattConPoWriteValue(uint8 NotiUid1, uint8 NotiUid2, uint8 NotiUid3, uint8 NotiUid4)
{
  conPoWriteValueReq.pValue = GATT_bm_alloc(g_connHandle, ATT_WRITE_REQ, 10, NULL);

  if (conPoWriteValueReq.pValue != NULL)
  {
      conPoWriteValueConnIndex = multi_role_getConnIndex(g_connHandle);

    // connIndex cannot be equal to or greater than MAX_NUM_BLE_CONNS
    MULTIROLE_ASSERT(conPoWriteValueConnIndex < MAX_NUM_BLE_CONNS);

    conPoWriteValueReq.handle = ancsConPoHdl;
    conPoWriteValueReq.len = 10;

    conPoWriteValueReq.pValue[0] = 0;
    conPoWriteValueReq.pValue[1] = NotiUid1;
    conPoWriteValueReq.pValue[2] = NotiUid2;
    conPoWriteValueReq.pValue[3] = NotiUid3;
    conPoWriteValueReq.pValue[4] = NotiUid4;
    conPoWriteValueReq.pValue[5] = 0;
    conPoWriteValueReq.pValue[6] = 1; 
    conPoWriteValueReq.pValue[7] = 0xFF; 
    conPoWriteValueReq.pValue[8] = 0xFF;  
    conPoWriteValueReq.pValue[9] = 4; 

    conPoWriteValueReq.sig = 0;
    conPoWriteValueReq.cmd = 0;

    response = GATT_WriteCharValue(g_connHandle, &conPoWriteValueReq, selfEntity);

    if ( response != SUCCESS )
    {
      GATT_bm_free((gattMsg_t *)&conPoWriteValueReq, ATT_WRITE_REQ);
    }
  }

  return (true);
}

Display_printf (dispHandle、DisplayUart_scrolling、0、"写入错误%d"、pMsg->msg.errorRsp.errCode);

=>写入错误160

(如果我没有使用 multi_role_getBondInfo 函数、则没有任何问题)

可以提供一些建议吗?

是否存在超时问题?

此致、

Kim。

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

    尊敬的 Kim:

    感谢您提供有关问题的信息。 我正在研究它、并将向您更新我的调查结果。  

    最棒的
    NIMA Behmanesh

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

    尊敬的 Kim:

    在研究这个问题后、我有几个问题。

    1.您在代码中打印出错误代码的时间是什么时候?

    2.释放 conPoWriteValueReq 之前"Response"变量的值是什么?

    最棒的
    NIMA Behmanesh

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

    尊敬的 Kim:

    想知道是否有任何更新?

    最棒的

    NIMA

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

    你(们)好、Nima。

    我很抱歉迟到了。

    1.您在代码中打印出错误代码的时间是什么时候?

    >>>1. BLE 连接已完成、绑定-> 2.搜索服务-> 3.搜索特征-> 4. CCCD 的"写入描述符请求"->   5."写入值请求"-> 6.调用 multi_role_getBondInfo 函数-> 7. "写入值请求" 并返回  "ATT_ERROR_RSP"。

    2.释放 conPoWriteValueReq 之前"Response"变量的值是什么?

    >>"RESPONSE" 在空闲 conPoWriteValueReq 之前为0x00。

    我只是在 multi_role_getBondInfo 函数之后将其延迟一段时间。  "写入值请求"响应我需要的内容。

    我认为这可能是个待解决的问题。

    此致、

    Kim。

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

    尊敬的 Kim:

    为了澄清这一点,在 multi_role_getBondInfo()之后加上一个延迟,您遇到的问题是否得到了解决?

    最棒的

    NIMA

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

    你(们)好、Nima。

    是的、它是固定的。  

    我在   multi_role_getBondInfo()函数之后使用了 Util_constructClock() API 作为延迟。

    它工作得非常完美。

    此致、

    Kim