Bluetooth 5 AdvertisingSet implementation (4/4)

This patch wires up fist methods of AdvertisingSet, making it possible
to start advertising and stop advertising. It also replaces legacy
implemementation with calls to new implementation.

Bug: 30622771
Test: sl4a ConcurrentBleAdvertisingTest

Change-Id: I4a2739528fe114547f747d9719a4d47de7ce5589
This commit is contained in:
Jakub Pawlowski 2017-03-13 11:13:51 -07:00
parent 69606698b2
commit 0d0b7d1757

View file

@ -34,41 +34,59 @@ struct AdvertiseParameters {
uint8_t scan_request_notification_enable;
};
struct PeriodicAdvertisingParameters {
uint8_t enable;
uint16_t min_interval;
uint16_t max_interval;
uint16_t periodic_advertising_properties;
};
class BleAdvertiserInterface {
public:
virtual ~BleAdvertiserInterface() = default;
/** Callback invoked when multi-adv operation has completed */
using Callback = base::Callback<void(uint8_t /* status */)>;
using StatusCallback = base::Callback<void(uint8_t /* status */)>;
using IdStatusCallback =
base::Callback<void(uint8_t /* advertiser_id */, uint8_t /* status */)>;
/** Registers an advertiser with the stack */
virtual void RegisterAdvertiser(
base::Callback<void(uint8_t /* advertiser_id */,
uint8_t /* status */)>) = 0;
virtual void RegisterAdvertiser(IdStatusCallback) = 0;
/* Set the parameters as per spec, user manual specified values */
virtual void SetParameters(
uint8_t advertiser_id, uint16_t advertising_event_properties,
uint32_t min_interval, uint32_t max_interval, int chnl_map, int tx_power,
uint8_t primary_advertising_phy, uint8_t secondary_advertising_phy,
uint8_t scan_request_notification_enable, Callback cb) = 0;
uint8_t scan_request_notification_enable, StatusCallback cb) = 0;
/* Setup the data */
virtual void SetData(int advertiser_id, bool set_scan_rsp,
std::vector<uint8_t> data, Callback cb) = 0;
std::vector<uint8_t> data, StatusCallback cb) = 0;
/* Enable the advertising instance */
virtual void Enable(uint8_t advertiser_id, bool enable, Callback cb,
int timeout_s, Callback timeout_cb) = 0;
virtual void Enable(uint8_t advertiser_id, bool enable, StatusCallback cb,
int timeout_s, StatusCallback timeout_cb) = 0;
/* Unregisters an advertiser */
virtual void Unregister(uint8_t advertiser_id) = 0;
virtual void StartAdvertising(uint8_t advertiser_id, Callback cb,
virtual void StartAdvertising(uint8_t advertiser_id, StatusCallback cb,
AdvertiseParameters params,
std::vector<uint8_t> advertise_data,
std::vector<uint8_t> scan_response_data,
int timeout_s, Callback timeout_cb) = 0;
int timeout_s, StatusCallback timeout_cb) = 0;
/** Start the advertising set. This include registering, setting all
* parameters and data, and enabling it. |register_cb| is called when the set
* is advertising. |timeout_cb| is called when the timeout_s have passed */
virtual void StartAdvertisingSet(
IdStatusCallback register_cb, AdvertiseParameters params,
std::vector<uint8_t> advertise_data,
std::vector<uint8_t> scan_response_data,
PeriodicAdvertisingParameters periodic_params,
std::vector<uint8_t> periodic_data, int timeout_s,
IdStatusCallback timeout_cb) = 0;
};
#endif /* ANDROID_INCLUDE_BLE_ADVERTISER_H */