/* Function checking if length of event is correct, given the frame data.  */
static bool length_is_valid(uint8_t *p_data, uint8_t length)
/* Function checking if length of event is correct, given the frame data.  */
static bool length_is_valid(uint8_t *p_data, uint8_t length)
{
    if (length == 0 || (length == 1 && p_data[0] == 0))
    {
        return true;
    }
    else
    {
        switch ((es_frame_type_t)p_data[0])
        {
            case ES_FRAME_TYPE_UID:
                return length == ESCS_UID_WRITE_LENGTH;
            case ES_FRAME_TYPE_URL:
                return ((length >= ESCS_URL_MIN_WRITE_LENGTH) && (length <= ESCS_URL_WRITE_LENGTH));
            case ES_FRAME_TYPE_TLM:
                return (length == ESCS_TLM_WRITE_LENGTH);
            case ES_FRAME_TYPE_EID:
                return ((length == ESCS_EID_WRITE_ECDH_LENGTH) ||
                        (length == ESCS_EID_WRITE_IDK_LENGTH));
            default:
                return false;
        }
    }
}