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 <base/strings/stringprintf.h>
22 #include <bluetooth/log.h>
23
24 #include <cstdint>
25 #include <string>
26
27 #include "macros.h"
28 #include "types/ble_address_with_type.h"
29 #include "types/raw_address.h"
30
31 /*****************************************************************************
32 * Constants and data types
33 ****************************************************************************/
34
35 /* Status Return Value */
36 typedef enum : uint8_t {
37 BTA_SUCCESS = 0, /* Successful operation. */
38 BTA_FAILURE = 1, /* Generic failure. */
39 BTA_PENDING = 2, /* API cannot be completed right now */
40 BTA_BUSY = 3,
41 BTA_NO_RESOURCES = 4,
42 BTA_WRONG_MODE = 5,
43 } tBTA_STATUS;
44
bta_status_text(const tBTA_STATUS & status)45 inline std::string bta_status_text(const tBTA_STATUS& status) {
46 switch (status) {
47 CASE_RETURN_TEXT(BTA_SUCCESS);
48 CASE_RETURN_TEXT(BTA_FAILURE);
49 CASE_RETURN_TEXT(BTA_PENDING);
50 CASE_RETURN_TEXT(BTA_BUSY);
51 CASE_RETURN_TEXT(BTA_NO_RESOURCES);
52 CASE_RETURN_TEXT(BTA_WRONG_MODE);
53 default:
54 return base::StringPrintf("UNKNOWN[%d]", status);
55 }
56 }
57
58 typedef struct {
59 RawAddress pairing_bda;
60 RawAddress id_addr;
61 tBLE_ADDR_TYPE id_addr_type;
62 } tBTA_DM_PROC_ID_ADDR;
63
64 typedef struct {
65 RawAddress bd_addr;
66 } tBTA_DM_KEY_MISSING;
67
68 namespace std {
69 template <>
70 struct formatter<tBTA_STATUS> : enum_formatter<tBTA_STATUS> {};
71 } // namespace std
72