Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 1 | /* |
| 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 Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_INCLUDE_BLE_ADVERTISER_H |
| 18 | #define ANDROID_INCLUDE_BLE_ADVERTISER_H |
| 19 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 20 | #include <base/callback_forward.h> |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 21 | #include <stdint.h> |
| 22 | #include <vector> |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 23 | #include "bt_common_types.h" |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 24 | #include "bt_gatt_types.h" |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 25 | |
| 26 | using std::vector; |
| 27 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 28 | /** Callback invoked when multi-adv operation has completed */ |
| 29 | using BleAdvertiserCb = base::Callback<void(uint8_t /* status */)>; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 30 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 31 | class BleAdvertiserInterface { |
| 32 | public: |
| 33 | virtual ~BleAdvertiserInterface() = default; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 34 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 35 | /** Registers an advertiser with the stack */ |
| 36 | virtual void RegisterAdvertiser( |
| 37 | base::Callback<void(uint8_t /* advertiser_id */, uint8_t /* status */)>) = 0; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 38 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 39 | /* This function disable a Multi-ADV instance */ |
| 40 | virtual void Unregister(uint8_t advertiser_id) = 0; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 41 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 42 | /** Set the advertising data or scan response data */ |
Jakub Pawlowski | 6b76de1 | 2016-10-19 13:51:48 -0700 | [diff] [blame] | 43 | virtual void SetData(bool set_scan_rsp, vector<uint8_t> data) = 0; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 44 | |
Jakub Pawlowski | f82a249 | 2016-10-31 11:14:05 -0700 | [diff] [blame] | 45 | /** Start or stop advertising */ |
| 46 | virtual void Enable(bool start, BleAdvertiserCb cb) = 0; |
| 47 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 48 | /* 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 Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 53 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 54 | /* Setup the data for the specified instance */ |
| 55 | virtual void MultiAdvSetInstData(int advertiser_id, bool set_scan_rsp, |
Jakub Pawlowski | 6b76de1 | 2016-10-19 13:51:48 -0700 | [diff] [blame] | 56 | vector<uint8_t> data, |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 57 | BleAdvertiserCb cb) = 0; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 58 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 59 | /* 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 Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 64 | |
| 65 | #endif /* ANDROID_INCLUDE_BLE_ADVERTISER_H */ |