1/*
2 * Copyright 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <base/logging.h>
17
18#include "mcap_test_mdep.h"
19
20namespace SYSTEM_BT_TOOLS_MCAP_TOOL {
21
22McapMdep::McapMdep(btmcap_test_interface_t* mcap_test_interface,
23                   tMCA_HANDLE mcap_handle, uint8_t type, uint8_t max_mdl,
24                   tMCA_DATA_CBACK* data_callback) {
25  _mcap_test_interface = mcap_test_interface;
26  _mcap_handle = mcap_handle;
27  _mca_cs.type = (0 == type) ? MCA_TDEP_ECHO : MCA_TDEP_DATA;
28  _mca_cs.max_mdl = max_mdl;
29  _mca_cs.p_data_cback = data_callback;
30}
31
32bool McapMdep::Create() {
33  tMCA_RESULT ret =
34      _mcap_test_interface->create_mdep(_mcap_handle, &_mdep_handle, &_mca_cs);
35  LOG(INFO) << "mdep_handle=" << (int)_mdep_handle;
36  LOG_IF(INFO, ret != MCA_SUCCESS) << "ret=" << (int)ret;
37  return ret == MCA_SUCCESS;
38}
39
40bool McapMdep::Delete() {
41  tMCA_RESULT ret =
42      _mcap_test_interface->create_mdep(_mcap_handle, &_mdep_handle, &_mca_cs);
43  LOG_IF(INFO, ret != MCA_SUCCESS) << "ret=" << (int)ret;
44  return ret == MCA_SUCCESS;
45}
46
47tMCA_DEP McapMdep::GetHandle() const { return _mdep_handle; }
48
49bool McapMdep::IsRegistered() { return _mdep_handle > 0; }
50
51}  // namespace SYSTEM_BT_TOOLS_MCAP_TOOL
52