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.

[参考译文] CC2340R5:cc2340r5

Guru**** 2551640 points


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

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1355462/cc2340r5-cc2340r5

器件型号:CC2340R5

您好!

我在 basic_ble_profiles 示例中存在问题。 我已激活葡萄糖配置文件并修改了示例、每1分钟发送一次葡萄糖测量通知。 我已经运行示例并与移动应用建立了连接、并通过移动应用激活了葡萄糖测量特性的通知。 当应用程序 到达 GATT_Notification 函数时、它没有向中央发送任何通知并返回状态代码(5)、尽管该函数的 API 文档中未提及该代码。 我搜索了那个错误代码、发现它意味着 INVALID_MSG_POINTER、但我调试了代码、发现发送到函数 的指针是有效的。 问题可能是什么?

static bStatus_t GLS_sendNotiInd(uint8 *pValue, uint16 len, gattCharCfg_t *charCfgTbl, uint8 *pAttValue)
{
  bStatus_t status = SUCCESS;
  gattAttribute_t *pAttr = NULL;
  attHandleValueNoti_t noti = {0};
  linkDBInfo_t connInfo = {0};
  uint16 offset = 0;
  uint8 i = 0;

  // Verify input parameters
  if (( charCfgTbl == NULL ) || ( pValue == NULL ) || ( pAttValue == NULL ))
  {
    return ( INVALIDPARAMETER );
  }

  // Find the characteristic value attribute
  pAttr = GATTServApp_FindAttr(gls_attrTbl, GATT_NUM_ATTRS(gls_attrTbl), pAttValue);
  if ( pAttr != NULL )
  {
    for ( i = 0; i < MAX_NUM_BLE_CONNS; i++ )
    {
      gattCharCfg_t *pItem = &( charCfgTbl[i] );
      if ( ( pItem->connHandle != LINKDB_CONNHANDLE_INVALID ) &&
           ( pItem->value != GATT_CFG_NO_OPERATION) )
      {
        // Find out what the maximum MTU size is for each connection
        status = linkDB_GetInfo(pItem->connHandle, &connInfo);
        offset = 0;

        while ( status != bleTimeout && status != bleNotConnected &&  len > offset )
          // Determine allocation size
        {
          uint16_t allocLen = (len - offset);
          if ( allocLen > ( connInfo.MTU - GLS_NOTI_HDR_SIZE ) )
          {
            // If len > MTU split data to chunks of MTU size
            allocLen = connInfo.MTU - GLS_NOTI_HDR_SIZE;
          }

          noti.len = allocLen;
          noti.pValue = (uint8 *)GATT_bm_alloc( pItem->connHandle, ATT_HANDLE_VALUE_NOTI, allocLen, 0 );
          if ( noti.pValue != NULL )
          {
            // If allocation was successful, copy out data and send it
            VOID memcpy(noti.pValue, pValue + offset, noti.len);
            noti.handle = pAttr->handle;
            if( pItem->value == GATT_CLIENT_CFG_NOTIFY )
            {
              // Send the data over BLE notifications
              status = GATT_Notification( pItem->connHandle, &noti, TRUE );
            }
            else if ( pItem->value == GATT_CLIENT_CFG_INDICATE )
            {
              // Send the data over BLE indication
              status = GATT_Indication( pItem->connHandle, (attHandleValueInd_t *)&noti, TRUE, INVALID_TASK_ID);
            }
            else
            {
              // If Client Characteristic Configuration is not notifications/indication
              status = INVALIDPARAMETER;
            }

            // If unable to send the data, free allocated buffers and return
            if ( status != SUCCESS )
            {
              GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );

              // Failed to send notification/indication, print error message
              MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE4, 0,
                                "Failed to send notification/indication - Error: " MENU_MODULE_COLOR_RED "%d " MENU_MODULE_COLOR_RESET,
                                 status);
            }
            else
            {
              // Increment data offset
              offset += allocLen;

              // Notification/indication sent
              MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE4, 0,
                                "Notification/indication sent");
            }
          }
          else
          {
            status = bleNoResources;
          }
        } // End of while
      }
    } // End of for
  } // End of if

  // Return status value
  return ( status );
}

提前感谢您!

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

    尊敬的 Abdelrahman:

    感谢您的联系。

    请通过以下内容帮助我进一步了解此处的问题:

    1. 您正在使用哪个 SDK 版本?
    2. 您能分享您的 charCfgTbl (attribute 表)吗? 是否已为此特性启用通知?
    3. status = linkDB_getinfo (pItem->connHandle、&connInfo)的值是多少?

    Br、

    大卫。