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 */