Skip to content

Commit

Permalink
pw_bluetooth_sapphire: Remove unnecessary handle tracking
Browse files Browse the repository at this point in the history
Discoveriing a handle for the service changed characteristic is used to
decide whether to attempt to send indications, but is never cleared when
there are no subscribers, so will likely be on after the systems runs
for any reasonable length of time. Instead continue to use the set of
subscribed peers directly.

Test: code removal only; fx test bt-host-gatt-tests
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1009175
GitOrigin-RevId: 01c53083ebf40906508a6126e143651a8c5f94db
Change-Id: If92008476343df83eb052515037112626356b80f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/235316
Docs-Not-Needed: Ben Lawson <[email protected]>
Commit-Queue: Ben Lawson <[email protected]>
Lint: Lint 🤖 <[email protected]>
Pigweed-Auto-Submit: Ben Lawson <[email protected]>
Reviewed-by: Faraaz Sareshwala <[email protected]>
Reviewed-by: Ben Lawson <[email protected]>
  • Loading branch information
jamuraa authored and CQ Bot Account committed Sep 12, 2024
1 parent d63a18b commit 55ff480
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 25 deletions.
2 changes: 0 additions & 2 deletions pw_bluetooth_sapphire/host/gatt/gatt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@

#include <unordered_map>

#include "pw_bluetooth_sapphire/internal/host/att/bearer.h"
#include "pw_bluetooth_sapphire/internal/host/common/assert.h"
#include "pw_bluetooth_sapphire/internal/host/common/log.h"
#include "pw_bluetooth_sapphire/internal/host/gatt/client.h"
#include "pw_bluetooth_sapphire/internal/host/gatt/connection.h"
#include "pw_bluetooth_sapphire/internal/host/gatt/generic_attribute_service.h"
#include "pw_bluetooth_sapphire/internal/host/gatt/remote_service.h"
#include "pw_bluetooth_sapphire/internal/host/gatt/server.h"
#include "pw_bluetooth_sapphire/internal/host/l2cap/channel.h"

namespace bt::gatt {

Expand Down
18 changes: 0 additions & 18 deletions pw_bluetooth_sapphire/host/gatt/generic_attribute_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,6 @@ void GenericAttributeService::Register() {
bool indicate) {
BT_DEBUG_ASSERT(chrc_id == 0u);

// Discover the handle assigned to this characteristic if necessary.
if (svc_changed_handle_ == att::kInvalidHandle) {
LocalServiceManager::ClientCharacteristicConfig config;
if (!local_service_manager_->GetCharacteristicConfig(
service_id, chrc_id, peer_id, &config)) {
bt_log(DEBUG,
"gatt",
"service: Peer has not configured characteristic: %s",
bt_str(peer_id));
return;
}
svc_changed_handle_ = config.handle;
}
SetServiceChangedIndicationSubscription(peer_id, indicate);
if (persist_service_changed_ccc_callback_) {
ServiceChangedCCCPersistedData persisted = {.notify = notify,
Expand Down Expand Up @@ -144,11 +131,6 @@ void GenericAttributeService::SetServiceChangedIndicationSubscription(
void GenericAttributeService::OnServiceChanged(IdType service_id,
att::Handle start,
att::Handle end) {
// Service Changed not yet configured for indication.
if (svc_changed_handle_ == att::kInvalidHandle) {
return;
}

// Don't send indications for this service's removal.
if (service_id_ == service_id) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ class GenericAttributeService final {
// Peers that have subscribed to indications.
std::unordered_set<PeerId> subscribed_peers_;

// Handle for the Service Changed characteristic that is read when it is first
// configured for indications.
att::Handle svc_changed_handle_ = att::kInvalidHandle;

// Local service ID; hidden because registration is tied to instance lifetime.
IdType service_id_ = kInvalidId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#pragma once
#include <unordered_map>

#include "pw_bluetooth_sapphire/internal/host/att/attribute.h"
#include "pw_bluetooth_sapphire/internal/host/att/database.h"
#include "pw_bluetooth_sapphire/internal/host/common/macros.h"
#include "pw_bluetooth_sapphire/internal/host/common/weak_self.h"
Expand Down

0 comments on commit 55ff480

Please sign in to comment.