1 /*
2  * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup Bluetooth
18  * @{
19  *
20  * @brief Defines basic profile for profile service.
21  *
22  * @since 6
23  */
24 
25 /**
26  * @file interface_profile.h
27  *
28  * @brief basic profile interface.
29  *
30  * @since 6
31  */
32 
33 #ifndef INTERFACE_PROFILE_H
34 #define INTERFACE_PROFILE_H
35 
36 #include <list>
37 
38 #include "bt_def.h"
39 #include "raw_address.h"
40 
41 /**
42  * @brief forward declaration for class Context in namespace utility
43  */
44 namespace utility {
45 class Context;
46 }
47 
48 namespace OHOS {
49 namespace bluetooth {
50 /**
51  * @brief profile service name Define
52  */
53 const std::string PROFILE_NAME_GATT_CLIENT = "GattClientService";
54 const std::string PROFILE_NAME_GATT_SERVER = "GattServerService";
55 const std::string PROFILE_NAME_A2DP_SRC = "A2dpSrcService";
56 const std::string PROFILE_NAME_A2DP_SINK = "A2dpSnkService";
57 const std::string PROFILE_NAME_AVRCP_CT = "AvrcpCtService";
58 const std::string PROFILE_NAME_AVRCP_TG = "AvrcpTgService";
59 const std::string PROFILE_NAME_HFP_AG = "HfpAgService";
60 const std::string PROFILE_NAME_HFP_HF = "HfpHfService";
61 const std::string PROFILE_NAME_MAP_MCE = "MapMceService";
62 const std::string PROFILE_NAME_MAP_MSE = "MapMseService";
63 const std::string PROFILE_NAME_PAN = "PanService";
64 const std::string PROFILE_NAME_OPP = "OppService";
65 const std::string PROFILE_NAME_PBAP_PCE = "PbapPceService";
66 const std::string PROFILE_NAME_PBAP_PSE = "PbapPseService";
67 const std::string PROFILE_NAME_SPP = "SocketService";
68 const std::string PROFILE_NAME_DI = "DIService";
69 const std::string PROFILE_NAME_HID_HOST = "HidHostService";
70 
71 /**
72  * @brief profile connect state define, using to GetConnectState()...
73  */
74 const uint8_t PROFILE_STATE_CONNECTED = 0x08;
75 const uint8_t PROFILE_STATE_CONNECTING = 0x04;
76 const uint8_t PROFILE_STATE_DISCONNECTING = 0x02;
77 const uint8_t PROFILE_STATE_DISCONNECTED = 0x01;
78 
79 /**
80  * @brief Represents basic profile for each profile service, including the common functions.
81  *
82  * @since 6
83  */
84 class IProfile {
85 public:
86     /**
87      * @brief A destructor used to delete the <b>IProfile</b> instance.
88      *
89      * @since 6
90      */
91     virtual ~IProfile() = default;
92 
93     /**
94      * @brief Connect with device.
95      *
96      * @param device Remote device address.
97      * @return Returns Result for connect operation.
98      * @since 6
99      */
100     virtual int Connect(const RawAddress &device) = 0;
101 
102     /**
103      * @brief Disconnect with device.
104      *
105      * @param device Remote device address.
106      * @return Returns Result for disconnect operation.
107      * @since 6
108      */
109     virtual int Disconnect(const RawAddress &device) = 0;
110 
111     /**
112      * @brief Get connected devices.
113      *
114      * @return Returns List for connected devices.
115      * @since 6
116      */
117     virtual std::list<RawAddress> GetConnectDevices() = 0;
118 
119     /**
120      * @brief Get connect state.
121      *
122      * @return Returns connect state for profile service.
123      * @since 6
124      */
125     virtual int GetConnectState() = 0;
126 
127     /**
128      * @brief Get max number profile can connect.
129      *
130      * @return Returns max number profile can connect.
131      * @since 6
132      */
133     virtual int GetMaxConnectNum() = 0;
134 
135     /**
136      * @brief Get utility::Context pointer for each profile service.
137      *
138      * @return Returns the pointer for adapter.
139      * @since 6
140      */
141     virtual utility::Context *GetContext() = 0;
142 };
143 }  // namespace bluetooth
144 }  // namespace OHOS
145 
146 #endif  // INTERFACE_PROFILE_H