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

Commit 143c0b9b authored by Hansong Zhang's avatar Hansong Zhang
Browse files

LE signalling manager scaffolding

Implemented LE Dynamic Channel open and close.

Connection parameter update is not implemented.

Test: bluetooth_test_gd and run_cert.sh
Bug: 141558315
Change-Id: I0a01d6c417e4fd18eaed9da0c69bc80417c93dac
parent 69b02132
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ filegroup {
        "le/internal/fixed_channel_service_manager_impl.cc",
        "le/internal/link.cc",
        "le/internal/link_manager.cc",
        "le/internal/signalling_manager.cc",
        "le/l2cap_le_module.cc",
    ],
}
+5 −3
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ void Link::Disconnect() {

std::shared_ptr<FixedChannelImpl> Link::AllocateFixedChannel(Cid cid, SecurityPolicy security_policy) {
  auto channel = fixed_channel_allocator_.AllocateChannel(cid, security_policy);
  data_pipeline_manager_.AttachChannel(cid, channel);
  data_pipeline_manager_.AttachChannel(cid, channel, l2cap::internal::DataPipelineManager::ChannelMode::BASIC);
  return channel;
}

@@ -91,7 +91,8 @@ std::shared_ptr<l2cap::internal::DynamicChannelImpl> Link::AllocateDynamicChanne
                                                                                  SecurityPolicy security_policy) {
  auto channel = dynamic_channel_allocator_.AllocateChannel(psm, remote_cid, security_policy);
  if (channel != nullptr) {
    data_pipeline_manager_.AttachChannel(channel->GetCid(), channel);
    data_pipeline_manager_.AttachChannel(channel->GetCid(), channel,
                                         l2cap::internal::DataPipelineManager::ChannelMode::BASIC);
    RefreshRefCount();
  }
  channel->local_initiated_ = false;
@@ -102,7 +103,8 @@ std::shared_ptr<l2cap::internal::DynamicChannelImpl> Link::AllocateReservedDynam
    Cid reserved_cid, Psm psm, Cid remote_cid, SecurityPolicy security_policy) {
  auto channel = dynamic_channel_allocator_.AllocateReservedChannel(reserved_cid, psm, remote_cid, security_policy);
  if (channel != nullptr) {
    data_pipeline_manager_.AttachChannel(channel->GetCid(), channel);
    data_pipeline_manager_.AttachChannel(channel->GetCid(), channel,
                                         l2cap::internal::DataPipelineManager::ChannelMode::BASIC);
    RefreshRefCount();
  }
  channel->local_initiated_ = true;
+2 −1
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ void ClassicSignallingManager::OnCommandReject(CommandRejectView command_reject_
    LOG_WARN("Unknown command reject");
    return;
  }
  alarm_.Cancel();
  handle_send_next_command();

  LOG_INFO("Command rejected");
@@ -214,6 +215,7 @@ void ClassicSignallingManager::OnConnectionResponse(SignalId signal_id, Cid remo
    handle_send_next_command();
    return;
  }
  alarm_.Cancel();
  if (result != ConnectionResponseResult::SUCCESS) {
    handle_send_next_command();
    return;
@@ -225,7 +227,6 @@ void ClassicSignallingManager::OnConnectionResponse(SignalId signal_id, Cid remo
    handle_send_next_command();
    return;
  }
  alarm_.Cancel();

  auto& configuration_state = channel_configuration_[new_channel->GetCid()];
  auto initial_config = link_->GetConfigurationForInitialConfiguration(new_channel->GetCid());
+3 −2
Original line number Diff line number Diff line
@@ -20,16 +20,17 @@
#include "l2cap/internal/channel_impl.h"
#include "l2cap/internal/data_controller.h"
#include "l2cap/internal/data_pipeline_manager.h"
#include "l2cap/internal/sender.h"
#include "os/log.h"

namespace bluetooth {
namespace l2cap {
namespace internal {

void DataPipelineManager::AttachChannel(Cid cid, std::shared_ptr<ChannelImpl> channel) {
void DataPipelineManager::AttachChannel(Cid cid, std::shared_ptr<ChannelImpl> channel, ChannelMode mode) {
  ASSERT(sender_map_.find(cid) == sender_map_.end());
  sender_map_.emplace(std::piecewise_construct, std::forward_as_tuple(cid),
                      std::forward_as_tuple(handler_, link_, scheduler_.get(), channel));
                      std::forward_as_tuple(handler_, link_, scheduler_.get(), channel, mode));
}

void DataPipelineManager::DetachChannel(Cid cid) {
+3 −1
Original line number Diff line number Diff line
@@ -59,7 +59,9 @@ class DataPipelineManager {
      : handler_(handler), link_(link), scheduler_(std::make_unique<Fifo>(this, link_queue_up_end, handler)),
        receiver_(link_queue_up_end, handler, this) {}

  virtual void AttachChannel(Cid cid, std::shared_ptr<ChannelImpl> channel);
  using ChannelMode = Sender::ChannelMode;

  virtual void AttachChannel(Cid cid, std::shared_ptr<ChannelImpl> channel, ChannelMode mode);
  virtual void DetachChannel(Cid cid);
  virtual DataController* GetDataController(Cid cid);
  virtual void OnPacketSent(Cid cid);
Loading