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 #ifndef OHOS_BLUETOOTH_STANDARD_BLE_ADVERTISER_SERVER_H
16 #define OHOS_BLUETOOTH_STANDARD_BLE_ADVERTISER_SERVER_H
17 
18 #include "bluetooth_ble_advertiser_stub.h"
19 #include "bluetooth_types.h"
20 #include "i_bluetooth_ble_advertiser.h"
21 #include "if_system_ability_manager.h"
22 #include "iservice_registry.h"
23 #include "system_ability.h"
24 
25 namespace OHOS {
26 namespace Bluetooth {
27 class BluetoothBleAdvertiserServer : public BluetoothBleAdvertiserStub {
28 public:
29     BluetoothBleAdvertiserServer();
30     ~BluetoothBleAdvertiserServer() override;
31 
32     virtual void RegisterBleAdvertiserCallback(const sptr<IBluetoothBleAdvertiseCallback> &callback) override;
33     virtual void DeregisterBleAdvertiserCallback(const sptr<IBluetoothBleAdvertiseCallback> &callback) override;
34     virtual int StartAdvertising(const BluetoothBleAdvertiserSettings &settings,
35         const BluetoothBleAdvertiserData &advData, const BluetoothBleAdvertiserData &scanResponse,
36         int32_t advHandle, uint16_t duration, bool isRawData) override;
37     virtual int EnableAdvertising(uint8_t advHandle, uint16_t duration) override;
38     virtual int DisableAdvertising(uint8_t advHandle) override;
39     virtual int StopAdvertising(int32_t advHandle) override;
40     virtual void Close(int32_t advHandle) override;
41     virtual int32_t GetAdvertiserHandle(int32_t &advHandle) override;
42     void SetAdvertisingData(const BluetoothBleAdvertiserData &advData,
43         const BluetoothBleAdvertiserData &scanResponse, int32_t advHandle) override;
44 
45 private:
46     std::recursive_mutex mutex_ {};
47     BLUETOOTH_DECLARE_IMPL();
48     BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(BluetoothBleAdvertiserServer);
49 };
50 }  // namespace Bluetooth
51 }  // namespace OHOS
52 #endif  // OHOS_BLUETOOTH_STANDARD_BLE_ADVERTISER_SERVER_H