/********************************************************************* * @fn Time_configGattMsg() * * @brief Handle GATT messages for characteristic configuration. * * @param state - Discovery state. * @param pMsg - GATT message. * * @return New configuration state. */ uint8_t Time_configGattMsg(uint8_t state, gattMsgEvent_t *pMsg) { if ((pMsg->method == ATT_READ_RSP || pMsg->method == ATT_WRITE_RSP) && (pMsg->hdr.status == SUCCESS)) { // Process response switch (Time_configList[state]) { case HDL_CURR_TIME_CT_TIME_START: // Set clock to time read from time server Time_clockSet(pMsg->msg.readRsp.pValue); break; default: break; } } return Time_configNext(state + 1); }
/********************************************************************* * @fn Thermometer_processGattMsg * * @brief Process GATT messages. * * @param pMsg - pointer the the GATT message. * * @return none */ static void Thermometer_processGattMsg(gattMsgEvent_t *pMsg) { // Measurement Indication Confirmation. if (pMsg->method == ATT_HANDLE_VALUE_CFM) { Thermometer_sendStoredMeas(); } if (pMsg->method == ATT_HANDLE_VALUE_NOTI || pMsg->method == ATT_HANDLE_VALUE_IND) { Time_indGattMsg(pMsg); } else if (pMsg->method == ATT_READ_RSP || pMsg->method == ATT_WRITE_RSP) { thermometer_timeCfgState = Time_configGattMsg(thermometer_timeCfgState, pMsg); if (thermometer_timeCfgState == TIME_CONFIG_CMPL) { servDiscComplete = TRUE; } } else { servDiscState = Time_discGattMsg(servDiscState, pMsg); if (servDiscState == DISC_IDLE) { // Start characteristic configuration. thermometer_timeCfgState = Time_configNext(TIME_CONFIG_START); } } GATT_bm_free(&pMsg->msg, pMsg->method); }