blob: f486ed83aec22d332f390a9d7257777baf954302 [file] [log] [blame]
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070017#ifndef ANDROID_INCLUDE_BLE_ADVERTISER_H
18#define ANDROID_INCLUDE_BLE_ADVERTISER_H
19
Jakub Pawlowski4a635282016-10-06 16:53:23 -070020#include <base/callback_forward.h>
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070021#include <stdint.h>
22#include <vector>
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070023#include "bt_common_types.h"
Jakub Pawlowski4a635282016-10-06 16:53:23 -070024#include "bt_gatt_types.h"
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070025
26using std::vector;
27
Jakub Pawlowski4a635282016-10-06 16:53:23 -070028/** Callback invoked when multi-adv operation has completed */
29using BleAdvertiserCb = base::Callback<void(uint8_t /* status */)>;
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070030
Jakub Pawlowski4a635282016-10-06 16:53:23 -070031class BleAdvertiserInterface {
32 public:
33 virtual ~BleAdvertiserInterface() = default;
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070034
Jakub Pawlowski4a635282016-10-06 16:53:23 -070035 /** Registers an advertiser with the stack */
36 virtual void RegisterAdvertiser(
37 base::Callback<void(uint8_t /* advertiser_id */, uint8_t /* status */)>) = 0;
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070038
Jakub Pawlowski4a635282016-10-06 16:53:23 -070039 /* This function disable a Multi-ADV instance */
40 virtual void Unregister(uint8_t advertiser_id) = 0;
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070041
Jakub Pawlowski4a635282016-10-06 16:53:23 -070042 /** Set the advertising data or scan response data */
Jakub Pawlowski6b76de12016-10-19 13:51:48 -070043 virtual void SetData(bool set_scan_rsp, vector<uint8_t> data) = 0;
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070044
Jakub Pawlowskif82a2492016-10-31 11:14:05 -070045 /** Start or stop advertising */
46 virtual void Enable(bool start, BleAdvertiserCb cb) = 0;
47
Jakub Pawlowski4a635282016-10-06 16:53:23 -070048 /* Set the parameters as per spec, user manual specified values */
49 virtual void MultiAdvSetParameters(int advertiser_id, int min_interval,
50 int max_interval, int adv_type,
51 int chnl_map, int tx_power,
52 BleAdvertiserCb cb) = 0;
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070053
Jakub Pawlowski4a635282016-10-06 16:53:23 -070054 /* Setup the data for the specified instance */
55 virtual void MultiAdvSetInstData(int advertiser_id, bool set_scan_rsp,
Jakub Pawlowski6b76de12016-10-19 13:51:48 -070056 vector<uint8_t> data,
Jakub Pawlowski4a635282016-10-06 16:53:23 -070057 BleAdvertiserCb cb) = 0;
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070058
Jakub Pawlowski4a635282016-10-06 16:53:23 -070059 /* Enable the advertising instance as per spec */
60 virtual void MultiAdvEnable(uint8_t advertiser_id, bool enable,
61 BleAdvertiserCb cb, int timeout_s,
62 BleAdvertiserCb timeout_cb) = 0;
63};
Jakub Pawlowski6ecdb8c2016-07-13 11:53:55 -070064
65#endif /* ANDROID_INCLUDE_BLE_ADVERTISER_H */