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 a bluetooth system that provides basic blurtooth connection and profile functions,
21  *        including A2DP, AVRCP, BLE, GATT, HFP, MAP, PBAP, and SPP, etc.
22  *
23  * @since 6
24  */
25 
26 /**
27  * @file interface_profile_socket.h
28  *
29  * @brief Declares SPP interface profile functions, including basic functions.
30  *
31  * @since 6
32  */
33 
34 #ifndef INTERFACE_PROFILE_SOCKET_H
35 #define INTERFACE_PROFILE_SOCKET_H
36 
37 #include "interface_profile.h"
38 #include "bt_uuid.h"
39 
40 namespace OHOS {
41 namespace bluetooth {
42 /**
43  * @brief Class for IProfileSocket functions.
44  *
45  * @since 6
46  */
47 class IProfileSocket : public IProfile {
48 public:
49     /**
50      * @brief The client initiates the connection.
51      * @details The client queries the SDP and finds the channel to be connected through UUID.
52      *          Client sets security level to GAP.
53      * @param addr addr
54      * @param uuid server record uuid to search scn.
55      * @param securityFlag require the connection to be encrypted and authenticated.
56      * @param type socket type.
57      * @return the upper socket fd that generated by the socketpair .
58      */
59     virtual int Connect(const std::string &addr, const Uuid &uuid, int securityFlag, int type) = 0;
60 
61     /**
62      * @brief The server listen and accept the connection.
63      *
64      * @details The server registers service records to SDP with service name, uuid and server channel
65      *          number that assigned by rfcomm. Server sets security level to GAP.
66      * @param name server service name.
67      * @param uuid server uuid.
68      * @param securityFlag require the connection to be encrypted and authenticated.
69      * @param type socket type.
70      * @return the upper socket fd that generated by the socketpair.
71      */
72     virtual int Listen(const std::string &name, const Uuid &uuid, int securityFlag, int type) = 0;
73 
74 private:
75     using IProfile::Connect;
76 };
77 }  // namespace bluetooth
78 }  // namespace OHOS
79 
80 #endif  // INTERFACE_PROFILE_SOCKET_H