基于环形缓冲区的生产者消费者模式
758 2023-04-03 04:01:19
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的各种状态信息值得深入分析