From aa3dd95c8b3089faa78ae793e9f9a2fc94fbe207 Mon Sep 17 00:00:00 2001 From: Josh Conner Date: Thu, 23 Jan 2025 14:34:44 -0800 Subject: [PATCH] pw_bluetooth_sapphire: Add LE L2CAP channel request metric MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an Inspect metrics for LE L2CAP channel requests. Test: Builds Change-Id: Iacebb12b7280d44bbc29f671c4ab81067a67240c Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/262432 Lint: Lint 🤖 Reviewed-by: Jason Graffius Commit-Queue: Josh Conner Presubmit-Verified: CQ Bot Account --- pw_bluetooth_sapphire/host/README.md | 1 + pw_bluetooth_sapphire/host/gap/adapter.cc | 4 ++++ pw_bluetooth_sapphire/host/gap/adapter_test.cc | 1 + 3 files changed, 6 insertions(+) diff --git a/pw_bluetooth_sapphire/host/README.md b/pw_bluetooth_sapphire/host/README.md index c100ba01f1..82b98bd396 100644 --- a/pw_bluetooth_sapphire/host/README.md +++ b/pw_bluetooth_sapphire/host/README.md @@ -94,6 +94,7 @@ adapter: set_connectable_false_events set_connectable_true_events le: + open_l2cap_channel_requests outgoing_connection_requests pair_requests start_advertising_events diff --git a/pw_bluetooth_sapphire/host/gap/adapter.cc b/pw_bluetooth_sapphire/host/gap/adapter.cc index f724a21611..db843531c3 100644 --- a/pw_bluetooth_sapphire/host/gap/adapter.cc +++ b/pw_bluetooth_sapphire/host/gap/adapter.cc @@ -112,6 +112,7 @@ class AdapterImpl final : public Adapter { l2cap::ChannelParameters params, sm::SecurityLevel security_level, l2cap::ChannelCallback cb) override { + adapter_->metrics_.le.open_l2cap_channel_requests.Add(); adapter_->le_connection_manager_->OpenL2capChannel( peer_id, psm, params, security_level, std::move(cb)); } @@ -509,6 +510,7 @@ class AdapterImpl final : public Adapter { inspect::Node metrics_le_node_; struct AdapterMetrics { struct LeMetrics { + UintMetricCounter open_l2cap_channel_requests; UintMetricCounter outgoing_connection_requests; UintMetricCounter pair_requests; UintMetricCounter start_advertising_events; @@ -852,6 +854,8 @@ void AdapterImpl::AttachInspect(inspect::Node& parent, std::string name) { metrics_node_ = adapter_node_.CreateChild(kMetricsInspectNodeName); metrics_le_node_ = metrics_node_.CreateChild("le"); + metrics_.le.open_l2cap_channel_requests.AttachInspect( + metrics_le_node_, "open_l2cap_channel_requests"); metrics_.le.outgoing_connection_requests.AttachInspect( metrics_le_node_, "outgoing_connection_requests"); metrics_.le.pair_requests.AttachInspect(metrics_le_node_, "pair_requests"); diff --git a/pw_bluetooth_sapphire/host/gap/adapter_test.cc b/pw_bluetooth_sapphire/host/gap/adapter_test.cc index e2f0a649b9..797a480ca0 100644 --- a/pw_bluetooth_sapphire/host/gap/adapter_test.cc +++ b/pw_bluetooth_sapphire/host/gap/adapter_test.cc @@ -1158,6 +1158,7 @@ TEST_F(AdapterTest, InspectHierarchy) { auto le_matcher = AllOf(NodeMatches(AllOf(NameMatches("le"), PropertyList(UnorderedElementsAre( + UintIs("open_l2cap_channel_requests", 0), UintIs("outgoing_connection_requests", 0), UintIs("pair_requests", 0), UintIs("start_advertising_events", 0),