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.

[参考译文] CC1350:当客户端设置“通知”时,特性停止发送数据

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

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1086434/cc1350-characteristic-stops-sending-data-when-client-sets-notify

部件号:CC1350

我正在使用 CC1350处理 BLE 应用程序,当我从传感器读取数据时工作正常,但当我设置为通知它时,不再更新该值

bStatus_t ADXL_setParameter(uint8_t param, uint8_t len, void *value)
{
  bStatus_t ret = SUCCESS;

  switch (param)
  {
    case SENSOR_DATA:
    if (len == SENSOR_DATA_LEN)
    {
      memcpy(sensorData, value, SENSOR_DATA_LEN);
      // See if Notification has been enabled
      ret = GATTServApp_ProcessCharCfg(sensorDataConfig, sensorData, FALSE,
                                 sensorAttrTable,
                                 GATT_NUM_ATTRS(sensorAttrTable),
                                 INVALID_TASK_ID, sensor_ReadAttrCB);
    }
    else
    {
      ret = bleInvalidRange;
    }
    break;

    case SENSOR_CONF:
      if (len == sizeof(uint8_t))
      {
        sensorCfg = *((uint8_t*)value);
      }
      else
      {
        ret = bleInvalidRange;
      }
      break;

    case SENSOR_PERI:
      if (len == sizeof(uint8_t))
      {
        sensorPeriod = *((uint8_t*)value);
      }
      else
      {
        ret = bleInvalidRange;
      }
      break;

    default:
      ret = INVALIDPARAMETER;
      break;
  }

  return (ret);
}

这是设置参数的代码,这里是我读取传感器的任务循环

static void sensorTaskFxn(UArg a0, UArg a1)
{
  uint8_t data[SENSOR_DATA_LEN];

  if(!adxlRegistered){
     DELAY_MS(100);
  }
  // Register task with BLE stack
  ICall_registerApp(&sensorSelfEntity, &sensorSem);

  // Deactivate task (active only when measurement is enabled)
  Task_setPri(Task_handle(&sensorTask), -1);

  // Task loop
  while (true)
  {
     data[0] = 0;
    if (sensorConfig == ST_CFG_SENSOR_ENABLE)
    {

      // Read data
      ADXL_read(data);

      // Update GATT
      ADXL_setParameter(SENSOR_DATA, SENSOR_DATA_LEN, data);

      // Next cycle
      DELAY_MS(100000);
    }
    else
    {
      DELAY_MS(SENSOR_DEFAULT_PERIOD);
    }
  }
}

我使用了 SensorTag 示例代码作为参考,但我看不到我做了什么错。

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

    您好,  

    已经指派了一个人员来研究这一问题。 同时,请您提及您使用的 SDK 版本?

    此致,
    SID

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

    您好,

    1.正如 Siddanth 所说,您使用的是 SimpleLink CC13x0 SDK 的哪个版本?

    2.您是否看到了简单的外设示例,简单的 GATT 配置文件? 特性4具有通知属性。 您可以将此作为实施示例。

    3.如果您需要更多的帮助,请捕获整个过程的嗅探器日志。

    谢谢,

    玛丽·H

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

    我使用的是13x0 2.20.1.8和 BLE 2.01.18

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

    我看过这个例子,但它不符合我的需要。 我 正在尝试制作2650stk 这样的应用程序,这样我就可以同时使用我开发的应用程序

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

    nRF Connect, 2022-03-21
    YSU SensorTag (C4:64:E3:B4:DE:F4)
    V 16:27:25.415 Connecting to C4:64:E3:B4:DE:F4...
    D 16:27:25.415 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D 16:27:25.854 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 16:27:25.854 Connected to C4:64:E3:B4:DE:F4
    D 16:27:25.870 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    I 16:27:26.298 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    V 16:27:26.823 Discovering services...
    D 16:27:26.823 gatt.discoverServices()
    D 16:27:26.850 [Callback] Services discovered with status: 0
    I 16:27:26.850 Services discovered
    V 16:27:26.860 Generic Access (0x1800)
    - Device Name [R] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    Generic Attribute (0x1801)
    Device Information (0x180A)
    - System ID [R] (0x2A23)
    - Model Number String [R] (0x2A24)
    - Serial Number String [R] (0x2A25)
    - Firmware Revision String [R] (0x2A26)
    - Hardware Revision String [R] (0x2A27)
    - Software Revision String [R] (0x2A28)
    - Manufacturer Name String [R] (0x2A29)
    - IEEE 11073-20601 Regulatory Certification Data List [R] (0x2A2A)
    - PnP ID [R] (0x2A50)
    Unknown Service (0000ad00-0000-1000-8000-00805f9b34fb)
    - Unknown Characteristic [N R] (0000ad01-0000-1000-8000-00805f9b34fb)
       Client Characteristic Configuration (0x2902)
       Characteristic User Description (0x2901)
    - Unknown Characteristic [R W] (0000ad02-0000-1000-8000-00805f9b34fb)
       Characteristic User Description (0x2901)
    - Unknown Characteristic [R W] (0000ad03-0000-1000-8000-00805f9b34fb)
       Characteristic User Description (0x2901)
    Unknown Service (0000bf00-0000-1000-8000-00805f9b34fb)
    - Unknown Characteristic [N R] (0000bf01-0000-1000-8000-00805f9b34fb)
       Client Characteristic Configuration (0x2902)
       Characteristic User Description (0x2901)
    - Unknown Characteristic [R W] (0000bf02-0000-1000-8000-00805f9b34fb)
       Characteristic User Description (0x2901)
    - Unknown Characteristic [R W] (0000bf03-0000-1000-8000-00805f9b34fb)
       Characteristic User Description (0x2901)
    D 16:27:26.860 gatt.setCharacteristicNotification(0000ad01-0000-1000-8000-00805f9b34fb, true)
    D 16:27:26.863 gatt.setCharacteristicNotification(0000bf01-0000-1000-8000-00805f9b34fb, true)
    I 16:27:26.881 Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms)
    V 16:27:34.898 Writing request to characteristic 0000ad02-0000-1000-8000-00805f9b34fb
    D 16:27:34.898 gatt.writeCharacteristic(0000ad02-0000-1000-8000-00805f9b34fb, value=0x01)
    I 16:27:35.163 Data written to 0000ad02-0000-1000-8000-00805f9b34fb, value: (0x) 01
    A 16:27:35.163 "(0x) 01" sent
    V 16:27:35.888 Reading characteristic 0000ad01-0000-1000-8000-00805f9b34fb
    D 16:27:35.888 gatt.readCharacteristic(0000ad01-0000-1000-8000-00805f9b34fb)
    I 16:27:36.107 Read Response received from 0000ad01-0000-1000-8000-00805f9b34fb, value: (0x) 42-01-E3-FE-75-01
    A 16:27:36.107 "(0x) 42-01-E3-FE-75-01" received
    V 16:27:38.748 Enabling notifications for 0000ad01-0000-1000-8000-00805f9b34fb
    D 16:27:38.748 gatt.setCharacteristicNotification(0000ad01-0000-1000-8000-00805f9b34fb, true)
    D 16:27:38.749 gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x0100)
    I 16:27:38.896 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 01-00
    A 16:27:38.896 "Notifications enabled" sent
    V 16:27:38.910 Notifications enabled for 0000ad01-0000-1000-8000-00805f9b34fb
    V 16:27:44.364 Reading characteristic 0000ad01-0000-1000-8000-00805f9b34fb
    D 16:27:44.364 gatt.readCharacteristic(0000ad01-0000-1000-8000-00805f9b34fb)
    I 16:27:44.521 Read Response received from 0000ad01-0000-1000-8000-00805f9b34fb, value: (0x) 41-01-E4-FE-74-01
    A 16:27:44.521 "(0x) 41-01-E4-FE-74-01" received
    V 16:27:47.849 Reading characteristic 0000ad01-0000-1000-8000-00805f9b34fb
    D 16:27:47.849 gatt.readCharacteristic(0000ad01-0000-1000-8000-00805f9b34fb)
    I 16:27:47.988 Read Response received from 0000ad01-0000-1000-8000-00805f9b34fb, value: (0x) 41-01-E4-FE-74-01
    A 16:27:47.988 "(0x) 41-01-E4-FE-74-01" received
    V 16:28:07.849 Disconnecting...
    D 16:28:07.849 gatt.disconnect()
    D 16:28:07.854 [Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
    I 16:28:07.854 Disconnected
    D 16:28:07.855 gatt.close()
    D 16:28:07.858 wait(200)

    这是我刚刚进行的测试结果。 最后两次读数是手动的,显示它不再更新该值

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

    您好,RJ,

    您需要在服务中实施回写回调,并检查是否已将 CCC 属性写入。 您可以在 SimpleLink Academy 实验室自定义配置文件中看到如何实施服务的完整演练:  

    https://dev.ti.com/tirex/explore/node?node=ACAn8XZNDy1n1bEFwSDnJQ__BSEc4rl__LATEST

    谢谢,

    玛丽·H

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

    我想我已经有了这个。  

    static bStatus_t adxl_WriteAttrCB(uint16_t connHandle, gattAttribute_t *pAttr,
                                        uint8_t *pValue, uint16_t len,
                                        uint16_t offset, uint8_t method)
    {
      bStatus_t status = SUCCESS;
      uint8_t notifyApp = 0xFF;
      uint16_t uuid;
    
    
      if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
        // Invalid handle
        return ATT_ERR_INVALID_HANDLE;
      }
    
      switch (uuid)
      {
        case ADXL_DATA_UUID:
          // Should not get here
          break;
    
        case ADXL_CONF_UUID:
          // Validate the value
          // Make sure it's not a blob oper
          if (offset == 0)
          {
            if (len != 1)
            {
              status = ATT_ERR_INVALID_VALUE_SIZE;
            }
          }
          else
          {
            status = ATT_ERR_ATTR_NOT_LONG;
          }
    
          // Write the value
          if (status == SUCCESS)
          {
            uint8_t *pCurValue = (uint8_t *)pAttr->pValue;
    
            *pCurValue = pValue[0];
    
            if (pAttr->pValue == &adxlCfg)
            {
              notifyApp = SENSOR_CONF;
            }
          }
          break;
    
        case ADXL_PERI_UUID:
          // Validate the value
          // Make sure it's not a blob oper
          if (offset == 0)
          {
            if (len != 1)
            {
              status = ATT_ERR_INVALID_VALUE_SIZE;
            }
          }
          else
          {
            status = ATT_ERR_ATTR_NOT_LONG;
          }
          // Write the value
          if (status == SUCCESS)
          {
            if (pValue[0]>=(ADXL_MIN_UPDATE_PERIOD/SENSOR_PERIOD_RESOLUTION))
            {
    
              uint8_t *pCurValue = (uint8_t *)pAttr->pValue;
              *pCurValue = pValue[0];
    
              if (pAttr->pValue == &adxlPeriod)
              {
                notifyApp = SENSOR_PERI;
              }
            }
            else
            {
               status = ATT_ERR_INVALID_VALUE;
            }
          }
          break;
    
        case GATT_CLIENT_CHAR_CFG_UUID:
          status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
                                                  offset, GATT_CLIENT_CFG_NOTIFY);
          break;
    
        default:
          // Should never get here!
          status = ATT_ERR_ATTR_NOT_FOUND;
          break;
      }
    
      // If a characteristic value changed then callback function
      // to notify application of change
      if ((notifyApp != 0xFF) && adxl_AppCBs && adxl_AppCBs->pfnSensorChange)
      {
        adxl_AppCBs->pfnSensorChange(notifyApp);
      }
    
      return (status);
    }

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

    它似乎在这里停止了:

    case HAL_ASSERT_CAUSE_ICALL_ABORT:
    Display_print0(dispHandle, 0, 0, "***ERROR***");
    Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!");
    HAL_ASSERT_SPINLOCK;
    break;
    

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

    您好,

    您是否在 _AddService API 中分配了 CCCD?

    参考 我发布的 SimpleLink Academy 代码片段:

    /*********************************************************************
     * @fn      SimpleProfile_AddService
     *
     * @brief   Initializes the Simple Profile service by registering
     *          GATT attributes with the GATT server.
     *
     * @param   services - services to add. This is a bit map and can
     *                     contain more than one service.
     *
     * @return  Success or Failure
     */
    bStatus_t SimpleProfile_AddService( uint32 services )
    {
      uint8 status;
    
      // Allocate Client Characteristic Configuration table
      simpleProfileChar4Config = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) *
                                                                MAX_NUM_BLE_CONNS );
      if ( simpleProfileChar4Config == NULL )
      {
        return ( bleMemAllocError );
      }
    
      // Initialize Client Characteristic Configuration attributes
      GATTServApp_InitCharCfg( LINKDB_CONNHANDLE_INVALID, simpleProfileChar4Config );
    
      if ( services & SIMPLEPROFILE_SERVICE )
      {
        // Register GATT attribute list and CBs with GATT Server App
        status = GATTServApp_RegisterService( simpleProfileAttrTbl,
                                              GATT_NUM_ATTRS( simpleProfileAttrTbl ),
                                              GATT_MAX_ENCRYPT_KEY_SIZE,
                                              &simpleProfileCBs );
      }
      else
      {
        status = SUCCESS;
      }
    
      return ( status );
    }

    谢谢,

    玛丽·H

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

    发生 ICall_abort() 以下情况之一时,BLE 堆栈将调用:

    • 通过堆栈回调中的 iCall 或 TI-RTOS SWI 或 HWI 调用堆栈功能
    • 错误配置其他 iCall 任务或实体(通常在 OSAL_MAX_NUM_PROXY_TASKS + 1  iCall 任务数小于时)
    • iCall 任务注册不正确
    • iCall 等待响应时,堆栈 API 调用超时
    • iCall 在执行堆栈 API 时遇到错误
    • ICall_primSetTimer()  ICall_setTimer() 无法创建时钟对象

    https://dev.ti.com/tirex/explore/content/simplelink_cc13xx_cc26xx_sdk_5_40_00_40/docs/ble5stack/ble_user_guide/html/ble-stack-5.x-guide/debugging-index.html?highlight=icall_abort#icall-abort 

    谢谢,

    玛丽·H

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

    我有这个

    bStatus_t ADXL_addService(void)
    {
      // Allocate Client Characteristic Configuration table
      adxlDataConfig = (gattCharCfg_t *)ICall_malloc(sizeof(gattCharCfg_t) *
                                                        linkDBNumConns);
      if (adxlDataConfig == NULL)
      {
        return (bleMemAllocError);
      }
    
      // Register with Link DB to receive link status change callback
      GATTServApp_InitCharCfg(INVALID_CONNHANDLE, adxlDataConfig);
    
      // Register GATT attribute list and CBs with GATT Server App
      return GATTServApp_RegisterService(adxlAttrTable,
                                          GATT_NUM_ATTRS (adxlAttrTable),
                                          GATT_MAX_ENCRYPT_KEY_SIZE,
                                          &adxlCBs);
    }