From 0d0b7d1757a9e72e0cfd8fcffedeff6cbb23a73a Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Mon, 13 Mar 2017 11:13:51 -0700 Subject: [PATCH] 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 --- include/hardware/ble_advertiser.h | 38 +++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/include/hardware/ble_advertiser.h b/include/hardware/ble_advertiser.h index 45282aaa..122f407e 100644 --- a/include/hardware/ble_advertiser.h +++ b/include/hardware/ble_advertiser.h @@ -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; + using StatusCallback = base::Callback; + using IdStatusCallback = + base::Callback; /** Registers an advertiser with the stack */ - virtual void RegisterAdvertiser( - base::Callback) = 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 data, Callback cb) = 0; + std::vector 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 advertise_data, std::vector 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 advertise_data, + std::vector scan_response_data, + PeriodicAdvertisingParameters periodic_params, + std::vector periodic_data, int timeout_s, + IdStatusCallback timeout_cb) = 0; }; #endif /* ANDROID_INCLUDE_BLE_ADVERTISER_H */