Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51ee4ec2 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2CAP: LE Link Layer Options API

Add the API for L2CAP channel user to get/set link layer options, such
as connection parameter update, and get role.

Add the corresponding PTS test case for it. The next step is to
determine the command from remote feature.

Test: cert/run --host
Change-Id: I7a4e046bc59619c43f975267fe806b88a96b289d
parent da320f71
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -56,6 +56,10 @@ class L2capMatchers(object):
    def LeCommandReject():
        return lambda packet: L2capMatchers._is_le_control_frame_with_code(packet, LeCommandCode.COMMAND_REJECT)

    @staticmethod
    def LeConnectionParameterUpdateRequest():
        return lambda packet: L2capMatchers._is_le_control_frame_with_code(packet, LeCommandCode.CONNECTION_PARAMETER_UPDATE_REQUEST)

    @staticmethod
    def CreditBasedConnectionRequest(psm):
        return lambda packet: L2capMatchers._is_matching_credit_based_connection_request(packet, psm)
+16 −0
Original line number Diff line number Diff line
@@ -128,3 +128,19 @@ class PyLeL2cap(Closable):

        return CreditBasedConnectionResponseFutureWrapper(
            response_future, self._device, psm, self._le_l2cap_stream)

    def update_connection_parameter(self,
                                    conn_interval_min=0x20,
                                    conn_interval_max=0x20,
                                    conn_latency=0x20,
                                    supervision_timeout=0x20,
                                    min_ce_length=0x20,
                                    max_ce_length=0x20):
        self._device.l2cap_le.SendConnectionParameterUpdate(
            l2cap_le_facade_pb2.ConnectionParameter(
                conn_interval_min=conn_interval_min,
                conn_interval_max=conn_interval_max,
                conn_latency=conn_latency,
                supervision_timeout=supervision_timeout,
                min_ce_length=min_ce_length,
                max_ce_length=max_ce_length))
+2 −0
Original line number Diff line number Diff line
@@ -24,11 +24,13 @@ filegroup {
        "internal/receiver.cc",
        "internal/scheduler_fifo.cc",
        "internal/sender.cc",
        "le/dynamic_channel.cc",
        "le/dynamic_channel_manager.cc",
        "le/dynamic_channel_service.cc",
        "le/fixed_channel.cc",
        "le/fixed_channel_manager.cc",
        "le/fixed_channel_service.cc",
        "le/link_options.cc",
        "le/internal/dynamic_channel_service_manager_impl.cc",
        "le/internal/fixed_channel_impl.cc",
        "le/internal/fixed_channel_service_manager_impl.cc",
+12 −0
Original line number Diff line number Diff line
@@ -108,6 +108,18 @@ class LeL2capTest(GdBaseTestClass):
        dut_channel = response_future.get_channel()
        return (dut_channel, cert_channel)

    def test_send_connection_parameter_update_request(self):
        """
        L2CAP/LE/CPU/BV-01-C
        NOTE: This is an option feature. Also if both LL master and slave supports 4.1+ connection parameter update, this should happen in LL only, not L2CAP
        NOTE: Currently we need to establish at least one dynamic channel to allow update.
        """
        self._setup_link_from_cert()
        self._open_channel_from_dut()
        self.dut_l2cap.update_connection_parameter()
        assertThat(self.cert_l2cap.get_control_channel()).emits(
            L2capMatchers.LeConnectionParameterUpdateRequest())

    def test_reject_connection_parameter_update_request(self):
        """
        L2CAP/LE/CPU/BI-02-C
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "l2cap/le/dynamic_channel.h"
#include "l2cap/le/internal/link.h"

namespace bluetooth {
namespace l2cap {
namespace le {
LinkOptions* DynamicChannel::GetLinkOptions() {
  return link_->GetLinkOptions();
}

}  // namespace le
}  // namespace l2cap
}  // namespace bluetooth
Loading