1 /*
2  * Copyright (C) 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 NAPI_BLUETOOTH_CONNECTION_OBSERVER_H
17 #define NAPI_BLUETOOTH_CONNECTION_OBSERVER_H
18 
19 #include "bluetooth_host.h"
20 #include "napi_async_callback.h"
21 #include "napi_bluetooth_utils.h"
22 #include "napi_event_subscribe_module.h"
23 
24 namespace OHOS {
25 namespace Bluetooth {
26 class NapiBluetoothConnectionObserver : public BluetoothHostObserver {
27 public:
28     NapiBluetoothConnectionObserver();
29     ~NapiBluetoothConnectionObserver() override = default;
30 
OnStateChanged(const int transport,const int status)31     void OnStateChanged(const int transport, const int status) override{};
32     void OnDiscoveryStateChanged(int status) override;
33     void OnDiscoveryResult(
34         const BluetoothRemoteDevice &device, int rssi, const std::string deviceName, int deviceClass) override;
35     void OnPairRequested(const BluetoothRemoteDevice &device) override;
36     void OnPairConfirmed(const BluetoothRemoteDevice &device, int reqType, int number) override;
37     void OnScanModeChanged(int mode) override;
38     void OnDeviceNameChanged(const std::string &deviceName) override;
39     void OnDeviceAddrChanged(const std::string &address) override;
40 
41     NapiEventSubscribeModule eventSubscribe_;
42 
43 private:
44     void OnPairConfirmedCallBack(const std::shared_ptr<PairConfirmedCallBackInfo> &pairConfirmInfo);
45     void OnDiscoveryResultCallBack(const BluetoothRemoteDevice &device);
46     void OnDiscoveryResultCallBack(
47         const BluetoothRemoteDevice &device, int rssi, const std::string &deviceName, int deviceClass);
48 };
49 }  // namespace Bluetooth
50 }  // namespace OHOS
51 #endif  // NAPI_BLUETOOTH_HOST_OBSERVER_H
52