/********************************************************************* * @fn Time_discGattMsg() * * @brief Handle GATT messages for characteristic discovery. * * @param state - Discovery state. * @param pMsg - GATT message. * * @return New discovery state. */ uint8_t Time_discGattMsg(uint8_t state, gattMsgEvent_t *pMsg) { // Execute discovery function for service do { switch (state & 0xF0) { // Current time service case DISC_CURR_TIME_START: state = Time_discCurrTime(state, pMsg); if (state == DISC_FAILED) { state = DISC_FAILED; } else if (state == DISC_IDLE) { state = DISC_IDLE; } break; default: break; } } while ((state != 0) && ((state & 0x0F) == 0)); return state; }
/********************************************************************* * @fn Time_discGattMsg() * * @brief Handle GATT messages for characteristic discovery. * * @param state - Discovery state. * @param pMsg - GATT message. * * @return New discovery state. */ uint8_t Time_discGattMsg(uint8_t state, gattMsgEvent_t *pMsg) { // Execute discovery function for service do { switch (state & 0xF0) { // Current time service case DISC_CURR_TIME_START: state = Time_discCurrTime(state, pMsg); if (state == DISC_FAILED) { state = DISC_NWA_START; } else if (state == DISC_IDLE) { state = DISC_DST_CHG_START; } break; // DST change service case DISC_DST_CHG_START: state = Time_discDstChg(state, pMsg); if (state == DISC_FAILED) { state = DISC_NWA_START; } else if (state == DISC_IDLE) { state = DISC_REF_TIME_START; } break; // Reference time service case DISC_REF_TIME_START: state = Time_discRefTime(state, pMsg); if (state == DISC_FAILED || state == DISC_IDLE) { state = DISC_NWA_START; } break; // NwA service case DISC_NWA_START: state = Time_discNwa(state, pMsg); if (state == DISC_FAILED || state == DISC_IDLE) { state = DISC_ALERT_NTF_START; } break; // Alert notification service case DISC_ALERT_NTF_START: state = Time_discAlertNtf(state, pMsg); if (state == DISC_FAILED || state == DISC_IDLE) { state = DISC_BATT_START; } break; // Battery service case DISC_BATT_START: state = Time_discBatt(state, pMsg); if (state == DISC_FAILED || state == DISC_IDLE) { state = DISC_PAS_START; } break; // Phone alert status service case DISC_PAS_START: state = Time_discPhoneAlert(state, pMsg); if (state == DISC_FAILED) { state = DISC_IDLE; } break; default: break; } } while ((state != 0) && ((state & 0x0F) == 0)); return state; }