• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 bluetooth {
49 /**
50  * @brief profile service name Define
51  */
52 const std::string PROFILE_NAME_GATT_CLIENT = "GattClientService";
53 const std::string PROFILE_NAME_GATT_SERVER = "GattServerService";
54 const std::string PROFILE_NAME_A2DP_SRC = "A2dpSrcService";
55 const std::string PROFILE_NAME_A2DP_SINK = "A2dpSnkService";
56 const std::string PROFILE_NAME_AVRCP_CT = "AvrcpCtService";
57 const std::string PROFILE_NAME_AVRCP_TG = "AvrcpTgService";
58 const std::string PROFILE_NAME_HFP_AG = "HfpAgService";
59 const std::string PROFILE_NAME_HFP_HF = "HfpHfService";
60 const std::string PROFILE_NAME_MAP_MCE = "MapMceService";
61 const std::string PROFILE_NAME_MAP_MSE = "MapMseService";
62 const std::string PROFILE_NAME_PBAP_PCE = "PbapPceService";
63 const std::string PROFILE_NAME_PBAP_PSE = "PbapPseService";
64 const std::string PROFILE_NAME_SPP = "SocketService";
65 const std::string PROFILE_NAME_DI = "DIService";
66 
67 /**
68  * @brief profile connect state define, using to GetConnectState()...
69  */
70 const uint8_t PROFILE_STATE_CONNECTED = 0x08;
71 const uint8_t PROFILE_STATE_CONNECTING = 0x04;
72 const uint8_t PROFILE_STATE_DISCONNECTING = 0x02;
73 const uint8_t PROFILE_STATE_DISCONNECTED = 0x01;
74 
75 /**
76  * @brief Represents basic profile for each profile service, including the common functions.
77  *
78  * @since 6
79  */
80 class IProfile {
81 public:
82     /**
83      * @brief A destructor used to delete the <b>IProfile</b> instance.
84      *
85      * @since 6
86      */
87     virtual ~IProfile() = default;
88 
89     /**
90      * @brief Connect with device.
91      *
92      * @param device Remote device address.
93      * @return Returns Result for connect operation.
94      * @since 6
95      */
96     virtual int Connect(const RawAddress &device) = 0;
97 
98     /**
99      * @brief Disconnect with device.
100      *
101      * @param device Remote device address.
102      * @return Returns Result for disconnect operation.
103      * @since 6
104      */
105     virtual int Disconnect(const RawAddress &device) = 0;
106 
107     /**
108      * @brief Get connected devices.
109      *
110      * @return Returns List for connected devices.
111      * @since 6
112      */
113     virtual std::list<RawAddress> GetConnectDevices() = 0;
114 
115     /**
116      * @brief Get connect state.
117      *
118      * @return Returns connect state for profile service.
119      * @since 6
120      */
121     virtual int GetConnectState() = 0;
122 
123     /**
124      * @brief Get max number profile can connect.
125      *
126      * @return Returns max number profile can connect.
127      * @since 6
128      */
129     virtual int GetMaxConnectNum() = 0;
130 
131     /**
132      * @brief Get utility::Context pointer for each profile service.
133      *
134      * @return Returns the pointer for adapter.
135      * @since 6
136      */
137     virtual utility::Context *GetContext() = 0;
138 };
139 }  // namespace bluetooth
140 
141 #endif  // INTERFACE_PROFILE_H