aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2021-11-17 05:37:02 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-11-17 05:37:02 +0000
commitee9f5c59e8ab3074511a7d827f696197e69f508c (patch)
tree8a3745a276a34f4d26d76c67ca703fd460f09156
parentbddb986a0f7f1ae29826fd00dd2f1a0f8a542191 (diff)
parent985c11f7fb57f13b5c63fe35befbcdfdf7ac5193 (diff)
Merge "GD: Reenable advertising when terminated"
-rw-r--r--system/gd/hci/le_advertising_manager.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/system/gd/hci/le_advertising_manager.cc b/system/gd/hci/le_advertising_manager.cc
index fb868c992b..ab8c46c4d7 100644
--- a/system/gd/hci/le_advertising_manager.cc
+++ b/system/gd/hci/le_advertising_manager.cc
@@ -13,15 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "hci/le_advertising_manager.h"
+
#include <memory>
#include <mutex>
+#include "common/init_flags.h"
#include "hci/acl_manager.h"
#include "hci/controller.h"
#include "hci/hci_layer.h"
#include "hci/hci_packets.h"
#include "hci/le_advertising_interface.h"
-#include "hci/le_advertising_manager.h"
#include "module.h"
#include "os/handler.h"
#include "os/log.h"
@@ -56,6 +58,7 @@ struct Advertiser {
uint8_t max_extended_advertising_events;
bool started = false;
bool connectable = false;
+ bool directed = false;
std::unique_ptr<os::Alarm> address_rotation_alarm;
};
@@ -168,6 +171,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
LOG_INFO("Dropping invalid advertising event");
return;
}
+ LOG_VERBOSE("Received LE Advertising Set Terminated with status %s", ErrorCodeText(event_view.GetStatus()).c_str());
uint8_t advertiser_id = event_view.GetAdvertisingHandle();
@@ -181,6 +185,15 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
acl_manager_->OnAdvertisingSetTerminated(
event_view.GetStatus(), event_view.GetConnectionHandle(), advertiser_address);
+
+ if (!advertising_sets_[advertiser_id].directed) {
+ // TODO calculate remaining duration and advertising events
+ if (advertising_sets_[advertiser_id].duration == 0 &&
+ advertising_sets_[advertiser_id].max_extended_advertising_events == 0) {
+ LOG_INFO("Reenable advertising");
+ enable_advertiser(advertiser_id, true, 0, 0);
+ }
+ }
}
AdvertiserId allocate_advertiser() {
@@ -460,6 +473,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
void set_parameters(AdvertiserId advertiser_id, ExtendedAdvertisingConfig config) {
advertising_sets_[advertiser_id].connectable = config.connectable;
advertising_sets_[advertiser_id].tx_power = config.tx_power;
+ advertising_sets_[advertiser_id].directed = config.directed;
switch (advertising_api_type_) {
case (AdvertisingApiType::LEGACY): {