1 // Copyright 2023 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 15 #pragma once 16 #include <unordered_map> 17 18 #include "pw_bluetooth_sapphire/internal/host/l2cap/signaling_channel.h" 19 20 namespace bt::l2cap::internal { 21 22 // Implements packet processing for the BR/EDR signaling channel (CID = 1). 23 // Callbacks will be run on the thread where packet reception occurs, which is 24 // the L2CAP thread in production. 25 class BrEdrSignalingChannel final : public SignalingChannel { 26 public: 27 BrEdrSignalingChannel(Channel::WeakPtr chan, 28 pw::bluetooth::emboss::ConnectionRole role, 29 pw::async::Dispatcher& dispatcher); 30 ~BrEdrSignalingChannel() override = default; 31 32 // Test the link using an Echo Request command that can have an arbitrary 33 // payload. The callback will be invoked with the remote's Echo Response 34 // payload (if any) on the L2CAP thread, or with an empty buffer if the 35 // remote responded with a rejection. Returns false if the request failed to 36 // send. 37 // 38 // This is implemented as v5.0 Vol 3, Part A Section 4.8: "These requests may 39 // be used for testing the link or for passing vendor specific information 40 // using the optional data field." 41 bool TestLink(const ByteBuffer& data, DataCallback callback); 42 43 private: 44 // SignalingChannel overrides 45 void DecodeRxUnit(ByteBufferPtr sdu, 46 const SignalingPacketHandler& cb) override; 47 bool IsSupportedResponse(CommandCode code) const override; 48 }; 49 50 } // namespace bt::l2cap::internal 51