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 | |
Jakub Pawlowski | a90ebea | 2016-11-17 13:26:53 -0800 | [diff] [blame] | 26 | struct AdvertiseParameters { |
| 27 | uint16_t min_interval; |
| 28 | uint16_t max_interval; |
| 29 | uint8_t adv_type; |
| 30 | uint8_t channel_map; |
| 31 | uint8_t tx_power; |
| 32 | }; |
| 33 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 34 | class BleAdvertiserInterface { |
| 35 | public: |
| 36 | virtual ~BleAdvertiserInterface() = default; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 37 | |
Jakub Pawlowski | 555b8ae | 2016-11-04 12:05:37 -0700 | [diff] [blame] | 38 | /** Callback invoked when multi-adv operation has completed */ |
| 39 | using Callback = base::Callback<void(uint8_t /* status */)>; |
| 40 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 41 | /** Registers an advertiser with the stack */ |
| 42 | virtual void RegisterAdvertiser( |
Jakub Pawlowski | 555b8ae | 2016-11-04 12:05:37 -0700 | [diff] [blame] | 43 | base::Callback<void(uint8_t /* advertiser_id */, |
| 44 | uint8_t /* status */)>) = 0; |
Jakub Pawlowski | f82a249 | 2016-10-31 11:14:05 -0700 | [diff] [blame] | 45 | |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 46 | /* Set the parameters as per spec, user manual specified values */ |
Jakub Pawlowski | 555b8ae | 2016-11-04 12:05:37 -0700 | [diff] [blame] | 47 | virtual void SetParameters(int advertiser_id, int min_interval, |
| 48 | int max_interval, int adv_type, int chnl_map, |
| 49 | int tx_power, Callback cb) = 0; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 50 | |
Jakub Pawlowski | 555b8ae | 2016-11-04 12:05:37 -0700 | [diff] [blame] | 51 | /* Setup the data */ |
| 52 | virtual void SetData(int advertiser_id, bool set_scan_rsp, |
| 53 | std::vector<uint8_t> data, Callback cb) = 0; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 54 | |
Jakub Pawlowski | 555b8ae | 2016-11-04 12:05:37 -0700 | [diff] [blame] | 55 | /* Enable the advertising instance */ |
| 56 | virtual void Enable(uint8_t advertiser_id, bool enable, Callback cb, |
| 57 | int timeout_s, Callback timeout_cb) = 0; |
| 58 | |
| 59 | /* Unregisters an advertiser */ |
| 60 | virtual void Unregister(uint8_t advertiser_id) = 0; |
Jakub Pawlowski | a90ebea | 2016-11-17 13:26:53 -0800 | [diff] [blame] | 61 | |
| 62 | virtual void StartAdvertising(uint8_t advertiser_id, Callback cb, |
| 63 | AdvertiseParameters params, |
| 64 | std::vector<uint8_t> advertise_data, |
| 65 | std::vector<uint8_t> scan_response_data, |
| 66 | int timeout_s, Callback timeout_cb) = 0; |
Jakub Pawlowski | 4a63528 | 2016-10-06 16:53:23 -0700 | [diff] [blame] | 67 | }; |
Jakub Pawlowski | 6ecdb8c | 2016-07-13 11:53:55 -0700 | [diff] [blame] | 68 | |
| 69 | #endif /* ANDROID_INCLUDE_BLE_ADVERTISER_H */ |