diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2016-10-10 22:34:50 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-10-10 22:34:50 +0000 |
commit | 68669afe4d396ce29e98fcedd909551df8658590 (patch) | |
tree | f2ec86f77288c855c46ce645e3276a622d0b1da9 | |
parent | e1582496f98865c1d5f965916e629c370c77fcfb (diff) | |
parent | 4a635288b832d49aca5e04a5da8fc112bc090fb6 (diff) | |
download | libhardware-68669afe4d396ce29e98fcedd909551df8658590.tar.gz |
Merge "Convert advertising HAL from struct into class (1/3)"android-n-mr1-preview-2android-n-mr1-preview-1
-rw-r--r-- | include/hardware/ble_advertiser.h | 97 | ||||
-rw-r--r-- | include/hardware/bt_gatt.h | 5 |
2 files changed, 44 insertions, 58 deletions
diff --git a/include/hardware/ble_advertiser.h b/include/hardware/ble_advertiser.h index 389bdbb4..acd9169b 100644 --- a/include/hardware/ble_advertiser.h +++ b/include/hardware/ble_advertiser.h @@ -14,68 +14,57 @@ * limitations under the License. */ - #ifndef ANDROID_INCLUDE_BLE_ADVERTISER_H #define ANDROID_INCLUDE_BLE_ADVERTISER_H +#include <base/callback_forward.h> #include <stdint.h> #include <vector> -#include "bt_gatt_types.h" #include "bt_common_types.h" +#include "bt_gatt_types.h" using std::vector; -__BEGIN_DECLS - -/** Callback invoked in response to register_advertiser */ -typedef void (*register_advertiser_callback)(int status, int advertiser_id, - bt_uuid_t *uuid); - -/** Callback invoked when multi-adv param set_params operation has completed */ -typedef void (*multi_adv_set_params_callback)(int advertiser_id, int status); - -/** Callback invoked when multi-adv instance data set operation has completed */ -typedef void (*multi_adv_data_callback)(int advertiser_id, int status); - -/** Callback invoked when multi-adv enable operation has completed */ -typedef void (*multi_adv_enable_callback)(int advertiser_id, int status, bool enable); - -typedef struct { - register_advertiser_callback register_advertiser_cb; - multi_adv_set_params_callback multi_adv_set_params_cb; - multi_adv_data_callback multi_adv_data_cb; - multi_adv_enable_callback multi_adv_enable_cb; -} ble_advertiser_callbacks_t; - -typedef struct { - /** Registers an advertiser with the stack */ - bt_status_t (*register_advertiser)(bt_uuid_t *uuid); - - /** Unregister a advertiser from the stack */ - bt_status_t (*unregister_advertiser)(int advertiser_id); - - /** Set the advertising data or scan response data */ - bt_status_t (*set_adv_data)(int advertiser_id, bool set_scan_rsp, bool include_name, - bool include_txpower, int min_interval, int max_interval, int appearance, - vector<uint8_t> manufacturer_data, - vector<uint8_t> service_data, - vector<uint8_t> service_uuid); - - /* Set the parameters as per spec, user manual specified values */ - bt_status_t (*multi_adv_set_params)(int advertiser_id, int min_interval,int max_interval,int adv_type, - int chnl_map, int tx_power); - - - /* Setup the data for the specified instance */ - bt_status_t (*multi_adv_set_inst_data)(int advertiser_id, bool set_scan_rsp, bool include_name, - bool incl_txpower, int appearance, vector<uint8_t> manufacturer_data, - vector<uint8_t> service_data, vector<uint8_t> service_uuid); - - /* Enable the advertising instance as per spec */ - bt_status_t (*multi_adv_enable)(int advertiser_id, bool enable, int timeout_s); - -} ble_advertiser_interface_t; - -__END_DECLS +/** Callback invoked when multi-adv operation has completed */ +using BleAdvertiserCb = base::Callback<void(uint8_t /* status */)>; + +class BleAdvertiserInterface { + public: + virtual ~BleAdvertiserInterface() = default; + + /** Registers an advertiser with the stack */ + virtual void RegisterAdvertiser( + base::Callback<void(uint8_t /* advertiser_id */, uint8_t /* status */)>) = 0; + + /* This function disable a Multi-ADV instance */ + virtual void Unregister(uint8_t advertiser_id) = 0; + + /** Set the advertising data or scan response data */ + virtual void SetData(int advertiser_id, bool set_scan_rsp, bool include_name, + bool include_txpower, int min_interval, int max_interval, + int appearance, vector<uint8_t> manufacturer_data, + vector<uint8_t> service_data, + vector<uint8_t> service_uuid) = 0; + + /* Set the parameters as per spec, user manual specified values */ + virtual void MultiAdvSetParameters(int advertiser_id, int min_interval, + int max_interval, int adv_type, + int chnl_map, int tx_power, + BleAdvertiserCb cb) = 0; + + /* Setup the data for the specified instance */ + virtual void MultiAdvSetInstData(int advertiser_id, bool set_scan_rsp, + bool include_name, bool incl_txpower, + int appearance, + vector<uint8_t> manufacturer_data, + vector<uint8_t> service_data, + vector<uint8_t> service_uuid, + BleAdvertiserCb cb) = 0; + + /* Enable the advertising instance as per spec */ + virtual void MultiAdvEnable(uint8_t advertiser_id, bool enable, + BleAdvertiserCb cb, int timeout_s, + BleAdvertiserCb timeout_cb) = 0; +}; #endif /* ANDROID_INCLUDE_BLE_ADVERTISER_H */ diff --git a/include/hardware/bt_gatt.h b/include/hardware/bt_gatt.h index 343e5fa9..5d59f96e 100644 --- a/include/hardware/bt_gatt.h +++ b/include/hardware/bt_gatt.h @@ -35,9 +35,6 @@ typedef struct { /** GATT Server callbacks */ const btgatt_server_callbacks_t* server; - - /** Advertiser callbacks */ - const ble_advertiser_callbacks_t* advertiser; } btgatt_callbacks_t; /** Represents the standard Bluetooth GATT interface. */ @@ -60,7 +57,7 @@ typedef struct { const btgatt_server_interface_t* server; /** Pointer to the advertiser interface methods.*/ - const ble_advertiser_interface_t* advertiser; + BleAdvertiserInterface* advertiser; } btgatt_interface_t; __END_DECLS |