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.

CC2650 手机连上走远导致蓝牙断线后,蓝牙程序死机,原因不明

Other Parts Discussed in Thread: CC2650

这个是周期性发送程序,50ms执行一次:

static void HeartRate_measNotify(void)
{
  attHandleValueNoti_t heartRateMeas;

  heartRateMeas.pValue = GATT_bm_alloc(gapConnHandle, ATT_HANDLE_VALUE_NOTI,
                                       HEARTRATE_MEAS_LEN, NULL);
  if (heartRateMeas.pValue != NULL)
  {
    
    uint8_t *p = heartRateMeas.pValue;
   
    //返回值大于0,说明组帧完成
    unsigned char ret = construct_LongBleFrame(p);
    
    heartRateMeas.len = (uint8)(p - heartRateMeas.pValue);

    
    heartRateMeas.len = ret;
    
    if(ret==0)    GATT_bm_free((gattMsg_t *)&heartRateMeas, ATT_HANDLE_VALUE_NOTI);
    // Send notification.
    if (HeartRate_MeasNotify(gapConnHandle, &heartRateMeas) != SUCCESS)
    {
      GATT_bm_free((gattMsg_t *)&heartRateMeas, ATT_HANDLE_VALUE_NOTI);
      //PPG_LED_OFF;
    }
    else
    {
      //PPG_LED_ON;
    }
  }//end if pvalue != NULL
}

组帧失败,就释放内存。
发送失败,就释放内存。
发送成功,为啥不主动释放内存?

这样写有问题么,经常遇到这种死机情况。