基于Apollo3-Blue-MCU的智能手表方案源码解析

基于Apollo3-Blue-MCU的智能手表方案源码解析
一 方案简介1.简介Apollo3 Blue Wireless SoC是一款超低功耗无线mcu芯片,它的运行功耗降至6μA/ MHz以下。该器件采用ARM Cortex M4F内核,运行频率高达96 MHz,集成了蓝牙低功耗(BLE5),并提供一些更新的外设,附加内存和高级DMA引擎。凭借着出色的超低功耗性能,该芯片在智能手表上应用十分广泛。2.特性二 源码解析1.启动并初始化手表相关的协议内容
void WatchStart(void){  /* Register for stack callbacks */  DmRegister(watchDmCback);  DmConnRegister(DM_CLIENT_ID_APP, watchDmCback);  AttRegister(watchAttCback);  AttConnRegister(AppServerConnCback);  AttsCccRegister(WATCH_NUM_CCC_IDX, (attsCccSet_t *) watchCccSet, watchCccCback);  /* Register for app framework button callbacks */  AppUiBtnRegister(watchBtnCback);  /* Register for app framework discovery callbacks */  AppDiscRegister(watchDiscCback);  /* Initialize attribute server database */  SvcCoreAddGroup();  /* Reset the device */  DmDevReset();}

2. 处理手表的无线业务信息

void WatchHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg){  if (pMsg != NULL)  {    APP_TRACE_INFO1("Watch got evt %d", pMsg->event);    /* process ATT messages */    if (pMsg->event <= ATT_CBACK_END)    {      /* process discovery-related ATT messages */      AppDiscProcAttMsg((attEvt_t *) pMsg);      /* process server-related ATT messages */      AppServerProcAttMsg(pMsg);    }    /* process DM messages */    else if (pMsg->event <= DM_CBACK_END)    {      if (pMsg->param == DM_CONN_ID_NONE || DmConnRole((dmConnId_t) pMsg->param) == DM_ROLE_MASTER)      {        /* process advertising and connection-related messages */        AppMasterProcDmMsg((dmEvt_t *) pMsg);        /* process security-related messages */        AppMasterSecProcDmMsg((dmEvt_t *) pMsg);      }      if (pMsg->param == DM_CONN_ID_NONE || DmConnRole((dmConnId_t) pMsg->param) == DM_ROLE_SLAVE)      {        /* process advertising and connection-related messages */        AppSlaveProcDmMsg((dmEvt_t *) pMsg);        /* process security-related messages */        AppSlaveSecProcDmMsg((dmEvt_t *) pMsg);      }      /* process discovery-related messages */      AppDiscProcDmMsg((dmEvt_t *) pMsg);    }    /* perform profile and user interface-related operations */    watchProcMsg((dmEvt_t *) pMsg);  }}

3.更新手表的业务信息

static void watchMasterValueUpdate(attEvt_t *pMsg){  if (pMsg->hdr.status == ATT_SUCCESS)  {    /* determine which profile the handle belongs to; start with most likely */    /* heart rate */    if (HrpcHrsValueUpdate(pWatchHrsHdlList, pMsg) == ATT_SUCCESS)    {      return;    }    /* device information */    if (DisValueUpdate(pWatchDisHdlList, pMsg) == ATT_SUCCESS)    {      return;    }    /* GATT */    if (GattValueUpdate(pWatchMstGattHdlList, pMsg) == ATT_SUCCESS)    {      return;    }  }}
三 总结备忘1.还需要进一步的分析显示屏和协议部分。2.ble的各种状态信息值得深入分析
免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部