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.

CC2642R: CC2642R作为central打开peripheral的Notify失败

Part Number: CC2642R
Other Parts Discussed in Thread: CC2640R2F

我现在正将之前CC2640R2F的一个central项目的功能移植到CC2642R,该项目连接一个perpheral,接收peripheral通过自定义特征值notify的数据。现在遇到的问题是,CC2642R在连接上peripheral后,发现服务和特征值都完成了,打开服务通知时失败。打开服务代码如下:

static void Notify_Enable(void)
{
  attWriteReq_t AttReq;
  uint8 ValueBuf[2];

  AttReq.pValue = GATT_bm_alloc(simpleBLEConnHandle, ATT_WRITE_REQ, 1, NULL);
  if ( AttReq.pValue != NULL )
  {
    AttReq.handle = charHd7+2;
    AttReq.len = 2;
    AttReq.sig = 0;
    AttReq.cmd = 0;
    ValueBuf[0] = 0x01;
    ValueBuf[1] = 0x00;
    memcpy(AttReq.pValue,ValueBuf,2);

    status = GATT_WriteCharValue(simpleBLEConnHandle, &AttReq, selfEntity);
    if ( status != SUCCESS )
    {
        DBG_Print("Enable service notify fail\r\n",28);
        GATT_bm_free((gattMsg_t *)&AttReq, ATT_WRITE_REQ);
    }
    else
    {
        DBG_Print("Enable service notify ok\r\n",26);
    }
  }
}

charHd7是特征值的句柄。

CC2640R2F是可以成功打开通知,并收到peripheral通知过来的数据的。

CC2642R却始终是打开通知失败,GATT_WriteCharValue返回0x16.

两个项目都是基于simple_central修改。CC2642R所用SDK版本是5.40.00.40

还有一个现象是,CC2640R2F程序发现服务和特征值的速度非常快(1s内完成),CC2642R程序则需要8s,不知为何。