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.

cc2540

Other Parts Discussed in Thread: CC2540

用CC2540接收标准heart rate profile  的数据时,当我读到使能 notification 时,为什么Handle 值 要在我读到Handle的基础上 加2  这是什么原因???

  • +1吧? 因为clientCharCfgUUID,所有notification的UUID都是一样的,你可能包含多个profile,而有多个notification,你无法通过这个UUID来唯一确定究竟使能哪个notification.而Characteristic Value的UUID是唯一的,而notification就是Characteristic Value的handle+1,因此用这种方式来使能确定使能指定的notificaiton.

    如下例子,绿色的UUID在所有profile结构里都是一样的,只有红色的UUID是不和其他应用共用的。而notification就是它的handle+1.以此来定位notification的handle

    static gattAttribute_t heartRateAttrTbl[] =
    {
      // Heart Rate Service
      {
        { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
        GATT_PERMIT_READ,                         /* permissions */
        0,                                        /* handle */
        (uint8 *)&heartRateService                /* pValue */
      },

        // Heart Rate Measurement Declaration
        {
          { ATT_BT_UUID_SIZE, characterUUID },
          GATT_PERMIT_READ,
          0,
          &heartRateMeasProps
        },

          // Heart Rate Measurement Value
          {
            { ATT_BT_UUID_SIZE, heartRateMeasUUID },
            0,
            0,
            &heartRateMeas
          },

          // Heart Rate Measurement Client Characteristic Configuration
          {
            { ATT_BT_UUID_SIZE, clientCharCfgUUID },
            GATT_PERMIT_READ | GATT_PERMIT_WRITE,
            0,
            (uint8 *) &heartRateMeasClientCharCfg
          },      

        // Sensor Location Declaration
        {
          { ATT_BT_UUID_SIZE, characterUUID },
          GATT_PERMIT_READ,
          0,
          &heartRateSensLocProps
        },

          // Sensor Location Value
          {
            { ATT_BT_UUID_SIZE, heartRateSensLocUUID },
            GATT_PERMIT_READ,
            0,
            &heartRateSensLoc
          },

        // Command Declaration
        {
          { ATT_BT_UUID_SIZE, characterUUID },
          GATT_PERMIT_READ,
          0,
          &heartRateCommandProps
        },

          // Command Value
          {
            { ATT_BT_UUID_SIZE, heartRateCommandUUID },
            GATT_PERMIT_WRITE,
            0,
            &heartRateCommand
          }
    };

  • 用monitor把service结构抓下来看看,就清楚了

  • 你要用btool1.2.1,而不是新版本。新版本读回来的值跟显示在handle中的值有时候会有差异的(差1)。