1 /******************************************************************************
2 *
3 * Copyright 2023 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 #pragma once
20
21 #include <bluetooth/log.h>
22
23 #include <cstdint>
24 #include <string>
25
26 #include "macros.h"
27 #include "types/ble_address_with_type.h"
28 #include "types/raw_address.h"
29
30 /*****************************************************************************
31 * Constants and data types
32 ****************************************************************************/
33
34 /* Status Return Value */
35 typedef enum : uint8_t {
36 BTA_SUCCESS = 0, /* Successful operation. */
37 BTA_FAILURE = 1, /* Generic failure. */
38 BTA_PENDING = 2, /* API cannot be completed right now */
39 BTA_BUSY = 3,
40 BTA_NO_RESOURCES = 4,
41 BTA_WRONG_MODE = 5,
42 } tBTA_STATUS;
43
bta_status_text(const tBTA_STATUS & status)44 inline std::string bta_status_text(const tBTA_STATUS& status) {
45 switch (status) {
46 CASE_RETURN_TEXT(BTA_SUCCESS);
47 CASE_RETURN_TEXT(BTA_FAILURE);
48 CASE_RETURN_TEXT(BTA_PENDING);
49 CASE_RETURN_TEXT(BTA_BUSY);
50 CASE_RETURN_TEXT(BTA_NO_RESOURCES);
51 CASE_RETURN_TEXT(BTA_WRONG_MODE);
52 default:
53 return std::format("UNKNOWN[{}]", static_cast<uint8_t>(status));
54 }
55 }
56
57 typedef struct {
58 RawAddress pairing_bda;
59 RawAddress id_addr;
60 tBLE_ADDR_TYPE id_addr_type;
61 } tBTA_DM_PROC_ID_ADDR;
62
63 typedef struct {
64 RawAddress bd_addr;
65 } tBTA_DM_KEY_MISSING;
66
67 namespace std {
68 template <>
69 struct formatter<tBTA_STATUS> : enum_formatter<tBTA_STATUS> {};
70 } // namespace std
71