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/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 base::StringPrintf("UNKNOWN[%d]", status);
54   }
55 }
56 
57 typedef struct {
58   RawAddress pairing_bda;
59   RawAddress id_addr;
60 } tBTA_DM_PROC_ID_ADDR;
61 
62 typedef struct {
63   RawAddress bd_addr;
64 } tBTA_DM_KEY_MISSING;
65 
66 namespace fmt {
67 template <>
68 struct formatter<tBTA_STATUS> : enum_formatter<tBTA_STATUS> {};
69 }  // namespace fmt
70