ble_advertiser_hci_interface.h revision 06325e3d5ddb863230f57e60bebac71ef7cb7ccc
1/****************************************************************************** 2 * 3 * Copyright (C) 2016 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19#ifndef BLE_ADVERTISER_HCI_INTERFACE_H 20#define BLE_ADVERTISER_HCI_INTERFACE_H 21 22#include <base/bind.h> 23#include "stack/include/bt_types.h" 24 25/* This class is an abstraction of HCI commands used for managing 26 * advertisements. Please see VSC HCI SPEC at 27 * https://static.googleusercontent.com/media/source.android.com/en//devices/Android-6.0-Bluetooth-HCI-Reqs.pdf 28 * for more details */ 29class BleAdvertiserHciInterface { 30 public: 31 using status_cb = base::Callback<void(uint8_t /* status */)>; 32 33 static void Initialize(); 34 static BleAdvertiserHciInterface *Get(); 35 static void CleanUp(); 36 37 virtual ~BleAdvertiserHciInterface() = default; 38 39 class AdvertisingEventObserver { 40 public: 41 virtual ~AdvertisingEventObserver() = default; 42 virtual void OnAdvertisingStateChanged(uint8_t inst_id, 43 uint8_t state_change_reason, 44 uint16_t connection_handle) = 0; 45 }; 46 47 virtual void SetAdvertisingEventObserver(AdvertisingEventObserver *observer) = 0; 48 virtual void ReadInstanceCount(base::Callback<void(uint8_t /* inst_cnt*/)> cb) = 0; 49 virtual void SetParameters(uint8_t adv_int_min, uint8_t adv_int_max, 50 uint8_t advertising_type, uint8_t own_address_type, 51 BD_ADDR own_address, uint8_t direct_address_type, 52 BD_ADDR direct_address, uint8_t channel_map, 53 uint8_t filter_policy, uint8_t inst_id, 54 uint8_t tx_power, status_cb command_complete) = 0; 55 virtual void SetAdvertisingData(uint8_t data_length, uint8_t *data, 56 uint8_t inst_id, 57 status_cb command_complete) = 0; 58 virtual void SetScanResponseData(uint8_t scan_response_data_length, 59 uint8_t *scan_response_data, uint8_t inst_id, 60 status_cb command_complete) = 0; 61 virtual void SetRandomAddress(BD_ADDR random_address, uint8_t inst_id, 62 status_cb command_complete) = 0; 63 virtual void Enable(uint8_t advertising_enable, uint8_t inst_id, 64 status_cb command_complete) = 0; 65}; 66 67#endif // BLE_ADVERTISER_HCI_INTERFACE_H 68