From efc9bf61a76323c587e04bf557da25af7937fa68 Mon Sep 17 00:00:00 2001 From: Austin Foxley Date: Fri, 8 Nov 2024 23:06:37 +0000 Subject: [PATCH] pw_bluetooth: Add L2cap connection request/response definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie9e0ee857c31e43696d42c72008e197559171ecb Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/246432 Commit-Queue: Auto-Submit Reviewed-by: David Rees Lint: Lint 🤖 Reviewed-by: Ben Lawson Pigweed-Auto-Submit: Austin Foxley Docs-Not-Needed: Austin Foxley Presubmit-Verified: CQ Bot Account --- .../public/pw_bluetooth/l2cap_frames.emb | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/pw_bluetooth/public/pw_bluetooth/l2cap_frames.emb b/pw_bluetooth/public/pw_bluetooth/l2cap_frames.emb index 37d94e99a..08ca3407c 100644 --- a/pw_bluetooth/public/pw_bluetooth/l2cap_frames.emb +++ b/pw_bluetooth/public/pw_bluetooth/l2cap_frames.emb @@ -205,6 +205,58 @@ struct L2capCommandRejectRsp: 8 [+2] UInt remote_endpoint -- The source CID from the rejected command. +struct L2capConnectionReq: + -- Section 4.2 + -- L2CAP_CONNECTION_REQ packets are sent to create an L2CAP channel between + -- two devices. + + [requires: command_header.code == L2capSignalingPacketCode.CONNECTION_REQ] + + 0 [+L2capSignalingCommandHeader.$size_in_bytes] L2capSignalingCommandHeader command_header + $next [+2] UInt psm + -- Protocol/Service Multiplexer. + + $next [+2] UInt source_cid + -- The channel endpoint on the device sending the request. + +enum L2capConnectionRspResultCode: + -- Reported in L2CAP_CONNECTION_RSP packets. + [maximum_bits: 16] + SUCCESSFUL = 0x0000 + PENDING = 0x0001 + PSM_NOT_SUPPORTED = 0x0002 + SECURITY_BLOCK = 0x0003 + NO_RESOURCES_AVAILABLE = 0x0004 + INVALID_SOURCE_CID = 0x0005 + SOURCE_CID_ALREADY_ALLOCATED = 0x0006 + +enum L2capConnectionRspStatusCode: + -- Reported in L2CAP_CONNECTION_RSP packets if result is PENDING. + [maximum_bits: 16] + NO_INFORMATION = 0x0000 + AUTHENTICATION_PENDING = 0x0001 + AUTHORIZATION_PENDING = 0x0002 + +struct L2capConnectionRsp: + -- Section 4.3 + -- L2CAP_CONNECTION_RSP packets are sent in response to a L2CAP_CONNECTION_REQ + -- packet. + + [requires: command_header.code == L2capSignalingPacketCode.CONNECTION_RSP] + + 0 [+L2capSignalingCommandHeader.$size_in_bytes] L2capSignalingCommandHeader command_header + $next [+2] UInt destination_cid + -- The channel endpoint on the device sending this response packet. + + $next [+2] UInt source_cid + -- The channel endpoint on the device receiving the packet. + + $next [+2] L2capConnectionRspResultCode result + -- The outcome of the connection request. + + if result == L2capConnectionRspResultCode.PENDING: + $next [+2] L2capConnectionRspStatusCode status + -- The status of the connection. struct L2capDisconnectionRsp: -- Section 4.7