diff --git a/include/hardware/ble_advertiser.h b/include/hardware/ble_advertiser.h new file mode 100644 index 00000000..e7c169ce --- /dev/null +++ b/include/hardware/ble_advertiser.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef ANDROID_INCLUDE_BLE_ADVERTISER_H +#define ANDROID_INCLUDE_BLE_ADVERTISER_H + +#include +#include +#include "bt_gatt_types.h" +#include "bt_common_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 enable operation has completed */ +typedef void (*multi_adv_enable_callback)(int advertiser_id, int status); + +/** Callback invoked when multi-adv param update operation has completed */ +typedef void (*multi_adv_update_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 disable operation has completed */ +typedef void (*multi_adv_disable_callback)(int advertiser_id, int status); + +typedef struct { + register_advertiser_callback register_advertiser_cb; + multi_adv_enable_callback multi_adv_enable_cb; + multi_adv_update_callback multi_adv_update_cb; + multi_adv_data_callback multi_adv_data_cb; + multi_adv_disable_callback multi_adv_disable_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 manufacturer_data, + vector service_data, + vector service_uuid); + + /* Set up the parameters as per spec, user manual specified values and enable multi ADV */ + bt_status_t (*multi_adv_enable)(int advertiser_id, int min_interval,int max_interval,int adv_type, + int chnl_map, int tx_power, int timeout_s); + + /* Update the parameters as per spec, user manual specified values and restart multi ADV */ + bt_status_t (*multi_adv_update)(int advertiser_id, int min_interval,int max_interval,int adv_type, + int chnl_map, int tx_power, int timeout_s); + + /* 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 manufacturer_data, + vector service_data, vector service_uuid); + + /* Disable the multi adv instance */ + bt_status_t (*multi_adv_disable)(int advertiser_id); + +} ble_advertiser_interface_t; + +__END_DECLS + +#endif /* ANDROID_INCLUDE_BLE_ADVERTISER_H */ diff --git a/include/hardware/bt_gatt.h b/include/hardware/bt_gatt.h index 42e14c2f..343e5fa9 100644 --- a/include/hardware/bt_gatt.h +++ b/include/hardware/bt_gatt.h @@ -19,6 +19,7 @@ #define ANDROID_INCLUDE_BT_GATT_H #include +#include "ble_advertiser.h" #include "bt_gatt_client.h" #include "bt_gatt_server.h" @@ -34,6 +35,9 @@ 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. */ @@ -54,6 +58,9 @@ typedef struct { /** Pointer to the GATT server interface methods.*/ const btgatt_server_interface_t* server; + + /** Pointer to the advertiser interface methods.*/ + const ble_advertiser_interface_t* advertiser; } btgatt_interface_t; __END_DECLS diff --git a/include/hardware/bt_gatt_client.h b/include/hardware/bt_gatt_client.h index f5df21c6..6cd8394a 100644 --- a/include/hardware/bt_gatt_client.h +++ b/include/hardware/bt_gatt_client.h @@ -187,18 +187,6 @@ typedef void (*scan_filter_param_callback)(int action, int client_if, int status /** Callback invoked when a scan filter configuration command has completed */ typedef void (*scan_filter_status_callback)(int enable, int client_if, int status); -/** Callback invoked when multi-adv enable operation has completed */ -typedef void (*multi_adv_enable_callback)(int client_if, int status); - -/** Callback invoked when multi-adv param update operation has completed */ -typedef void (*multi_adv_update_callback)(int client_if, int status); - -/** Callback invoked when multi-adv instance data set operation has completed */ -typedef void (*multi_adv_data_callback)(int client_if, int status); - -/** Callback invoked when multi-adv disable operation has completed */ -typedef void (*multi_adv_disable_callback)(int client_if, int status); - /** * Callback notifying an application that a remote device connection is currently congested * and cannot receive any more data. An application should avoid sending more data until @@ -253,10 +241,6 @@ typedef struct { scan_filter_cfg_callback scan_filter_cfg_cb; scan_filter_param_callback scan_filter_param_cb; scan_filter_status_callback scan_filter_status_cb; - multi_adv_enable_callback multi_adv_enable_cb; - multi_adv_update_callback multi_adv_update_cb; - multi_adv_data_callback multi_adv_data_cb; - multi_adv_disable_callback multi_adv_disable_cb; congestion_callback congestion_cb; batchscan_cfg_storage_callback batchscan_cfg_storage_cb; batchscan_enable_disable_callback batchscan_enb_disable_cb; @@ -355,13 +339,6 @@ typedef struct { /** Determine the type of the remote device (LE, BR/EDR, Dual-mode) */ int (*get_device_type)( const bt_bdaddr_t *bd_addr ); - /** Set the advertising data or scan response data */ - bt_status_t (*set_adv_data)(int client_if, bool set_scan_rsp, bool include_name, - bool include_txpower, int min_interval, int max_interval, int appearance, - vector manufacturer_data, - vector service_data, - vector service_uuid); - /** Configure the MTU for a given connection */ bt_status_t (*configure_mtu)(int conn_id, int mtu); @@ -372,22 +349,6 @@ typedef struct { /** Sets the LE scan interval and window in units of N*0.625 msec */ bt_status_t (*set_scan_parameters)(int client_if, int scan_interval, int scan_window); - /* Setup the parameters as per spec, user manual specified values and enable multi ADV */ - bt_status_t (*multi_adv_enable)(int client_if, int min_interval,int max_interval,int adv_type, - int chnl_map, int tx_power, int timeout_s); - - /* Update the parameters as per spec, user manual specified values and restart multi ADV */ - bt_status_t (*multi_adv_update)(int client_if, int min_interval,int max_interval,int adv_type, - int chnl_map, int tx_power, int timeout_s); - - /* Setup the data for the specified instance */ - bt_status_t (*multi_adv_set_inst_data)(int client_if, bool set_scan_rsp, bool include_name, - bool incl_txpower, int appearance, vector manufacturer_data, - vector service_data, vector service_uuid); - - /* Disable the multi adv instance */ - bt_status_t (*multi_adv_disable)(int client_if); - /* Configure the batchscan storage */ bt_status_t (*batchscan_cfg_storage)(int client_if, int batch_scan_full_max, int batch_scan_trunc_max, int batch_scan_notify_threshold);