1 /*
2  * Copyright (C) 2021-2023 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 #ifndef OHOS_BLUETOOTH_STANDARD_SOCKET_INTERFACE_H
17 #define OHOS_BLUETOOTH_STANDARD_SOCKET_INTERFACE_H
18 
19 #include <string>
20 
21 #include "bluetooth_service_ipc_interface_code.h"
22 #include "../common/bt_uuid.h"
23 #include "bluetooth_socket_coc.h"
24 #include "iremote_broker.h"
25 #include "i_bluetooth_socket_observer.h"
26 
27 namespace OHOS {
28 namespace Bluetooth {
29 struct ListenSocketParam {
30     std::string name;
31     bluetooth::Uuid uuid;
32     int32_t securityFlag;
33     int32_t type;
34     sptr<IBluetoothServerSocketObserver> observer;
35 };
36 
37 struct ConnectSocketParam {
38     std::string addr;
39     bluetooth::Uuid uuid;
40     int32_t securityFlag;
41     int32_t type;
42     int32_t psm;
43 };
44 
45 class IBluetoothSocket : public OHOS::IRemoteBroker {
46 public:
47     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.ipc.IBluetoothSocket");
48 
49     virtual int Connect(ConnectSocketParam &param, int &fd) = 0;
50     virtual int Listen(ListenSocketParam &param, int &fd) = 0;
51     virtual int DeregisterServerObserver(const sptr<IBluetoothServerSocketObserver> &observer) = 0;
52     virtual int RegisterClientObserver(const BluetoothRawAddress &dev, const bluetooth::Uuid uuid,
53         const sptr<IBluetoothClientSocketObserver> &observer) = 0;
54     virtual int DeregisterClientObserver(const BluetoothRawAddress &dev, const bluetooth::Uuid uuid,
55         const sptr<IBluetoothClientSocketObserver> &observer) = 0;
56     virtual int UpdateCocConnectionParams(const BluetoothSocketCocInfo &info) = 0;
57 };
58 }  // namespace Bluetooth
59 }  // namespace OHOS
60 #endif  // OHOS_BLUETOOTH_STANDARD_SOCKET_INTERFACE_H