Fork me on GitHub

一 前记
梳理该可穿戴产品的手环,产品,是一种成长。也是一个总结。
二 源码解析
1 初始化:这里主要初始化心率的检测间隔时间和心率值的位数。
  /* initialize heart rate profile sensor */
  HrpsInit(handlerId, (hrpsCfg_t *) &fitHrpsCfg);
  HrpsSetFlags(fitHrmFlags);
2 心率写状态的回调函数,这个地方有问题,是手机写吗?
SvcHrsCbackRegister(NULL, HrpsWriteCback); SvcHrsAddGroup();
3 接收到的attr的返回值确认。
static void hrpsHandleValueCnf(attEvt_t *pMsg)
4 启动心率测量的定时器,
void HrpsMeasStart(dmConnId_t connId, uint8_t timerEvt, uint8_t hrmCccIdx)
5 发送心率测量的值的notify函数:
static void hrpsSendHrmNtf(dmConnId_t connId)
6 读取心率值并发送给你手机
void AppHwHrmRead(appHrm_t *pHrm)
{
  pHrm->heartRate = appHwHeartRate;

  /* calculate simulated RR intervals from heart rate */
  appHwRrInterval[0] = APP_HR_MEAS_SIM_RR(appHwHeartRate);
  appHwRrInterval[1] = APP_HR_MEAS_SIM_RR(appHwHeartRate);

  pHrm->pRrInterval = appHwRrInterval;
  pHrm->numIntervals = 2;
}

 

三 问题点梳理
1 cc是什么时候调用呢?
static void fitProcCccState(fitMsg_t *pMsg)
这个什么时候被调用呢?且看下面的说明
Initialize the client characteristic configuration descriptor value table for avconnection.
This function is typically called when a connection is established or when a device is bonded.

 

 
posted on 2022-04-14 14:18  虚生  阅读(210)  评论(0编辑  收藏  举报