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

Commit ba633a67 authored by Chris Manton's avatar Chris Manton Committed by android-build-merger
Browse files

Legacy portion of btm shim layer

am: dd9fc8b9

Change-Id: I1f18d5f99b246f6e6533f3e7679034f89a569860
parents 6b6275eb dd9fc8b9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ filegroup {
        "bte_init_cpp_logging.cc",
        "bte_logmsg.cc",
        "bte_main.cc",
        "shim/btm.cc",
        "shim/btm_api.cc",
        "shim/controller.cc",
        "shim/entry.cc",
        "shim/hci_layer.cc",
+187 −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.
 */

#define LOG_TAG "bt_shim_btm"

#include "main/shim/btm.h"
#include "osi/include/log.h"

bluetooth::shim::Btm::Btm() {}

void bluetooth::shim::Btm::SetLeDiscoverabilityOff() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  le_.mode = kDiscoverableModeOff;
}

void bluetooth::shim::Btm::SetLeLimitedDiscoverability() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  le_.mode = kLimitedDiscoverableMode;
}

void bluetooth::shim::Btm::SetLeGeneralDiscoverability() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  le_.mode = kGeneralDiscoverableMode;
  return DoSetDiscoverability();
}

// private
void bluetooth::shim::Btm::DoSetDiscoverability() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  // TODO(cmanton) actually set discoverability here
}

DiscoverabilityState bluetooth::shim::Btm::GetLeDiscoverabilityState() const {
  return le_;
}

void bluetooth::shim::Btm::SetClassicDiscoverabilityOff() {
  classic_.mode = kDiscoverableModeOff;
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
}

void bluetooth::shim::Btm::SetClassicLimitedDiscoverability(uint16_t window,
                                                            uint16_t interval) {
  classic_.mode = kLimitedDiscoverableMode;
  classic_.window = window;
  classic_.interval = interval;
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
}

void bluetooth::shim::Btm::SetClassicGeneralDiscoverability(uint16_t window,
                                                            uint16_t interval) {
  classic_.mode = kGeneralDiscoverableMode;
  classic_.window = window;
  classic_.interval = interval;
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
}

DiscoverabilityState bluetooth::shim::Btm::GetClassicDiscoverabilityState()
    const {
  return classic_;
}

bool bluetooth::shim::Btm::IsInterlacedScanSupported() const {
  // TODO(cmanton) Check controller to ensure interlaced scan is actually
  // supported
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return true;
}

bool bluetooth::shim::Btm::SetInterlacedInquiryScan() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

bool bluetooth::shim::Btm::SetStandardInquiryScan() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

bool bluetooth::shim::Btm::SetInterlacedPageScan() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

bool bluetooth::shim::Btm::SetStandardPageScan() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

bool bluetooth::shim::Btm::SetStandardInquiryMode() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return DoSetInquiryMode();
}

bool bluetooth::shim::Btm::SetInquiryModeWithRssi() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return DoSetInquiryMode();
}

bool bluetooth::shim::Btm::SetExtendedInquiryMode() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return DoSetInquiryMode();
}

// private
bool bluetooth::shim::Btm::DoSetInquiryMode() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

bool bluetooth::shim::Btm::IsInquiryActive() const {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

bool bluetooth::shim::Btm::ClearInquiryFilter() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return DoSetEventFilter();
}

bool bluetooth::shim::Btm::SetFilterInquiryOnDevice() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return DoSetEventFilter();
}

bool bluetooth::shim::Btm::SetFilterInquiryOnAddress() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return DoSetEventFilter();
}

bool bluetooth::shim::Btm::CancelPeriodicInquiry() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

// private
bool bluetooth::shim::Btm::DoSetEventFilter() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  // TODO(cmanton) Actually set/clear event filter here
  return false;
}

bool bluetooth::shim::Btm::SetClassicConnectibleOff() {
  return DoSetConnectible();
}

bool bluetooth::shim::Btm::SetClassicConnectibleOn() {
  return DoSetConnectible();
}

bool bluetooth::shim::Btm::SetLeConnectibleOff() { return DoSetConnectible(); }

bool bluetooth::shim::Btm::SetLeConnectibleOn() { return DoSetConnectible(); }

ConnectibilityState bluetooth::shim::Btm::GetClassicConnectibilityState()
    const {
  return le_connectibility_state_;
}

ConnectibilityState bluetooth::shim::Btm::GetLeConnectibilityState() const {
  return classic_connectibility_state_;
}

bool bluetooth::shim::Btm::StartInquiry() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  return false;
}

// private
bool bluetooth::shim::Btm::DoSetConnectible() {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s", __func__);
  // TODO(cmanton) Actually set/clear connectibility here
  return false;
}

system/main/shim/btm.h

0 → 100644
+114 −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.
 */

#pragma once

#include <cstdint>
#include <unordered_map>

#include "stack/include/l2c_api.h"

/* Discoverable modes */
static constexpr int kDiscoverableModeOff = 0;
static constexpr int kLimitedDiscoverableMode = 1;
static constexpr int kGeneralDiscoverableMode = 2;

/* Connectable modes */
static constexpr int kConnectibleModeOff = 0;
static constexpr int kConnectibleModeOn = 1;

/* Inquiry and page scan modes */
static constexpr int kStandardScanType = 0;
static constexpr int kInterlacedScanType = 1;

/* Inquiry result modes */
static constexpr int kStandardInquiryResult = 0;
static constexpr int kInquiryResultWithRssi = 1;
static constexpr int kExtendedInquiryResult = 2;

/* Inquiry filter types */
static constexpr int kClearInquiryFilter = 0;
static constexpr int kFilterOnDeviceClass = 1;
static constexpr int kFilterOnAddress = 2;

using DiscoverabilityState = struct {
  int mode;
  uint16_t window;
  uint16_t interval;
};
using ConnectibilityState = DiscoverabilityState;

namespace bluetooth {
namespace shim {

class Btm {
 public:
  Btm();

  void SetLeDiscoverabilityOff();
  void SetLeLimitedDiscoverability();
  void SetLeGeneralDiscoverability();

  void SetClassicDiscoverabilityOff();
  void SetClassicLimitedDiscoverability(uint16_t window, uint16_t interval);
  void SetClassicGeneralDiscoverability(uint16_t window, uint16_t interval);

  bool IsInterlacedScanSupported() const;

  bool SetInterlacedInquiryScan();
  bool SetStandardInquiryScan();

  bool SetInterlacedPageScan();
  bool SetStandardPageScan();

  bool SetStandardInquiryMode();
  bool SetInquiryModeWithRssi();
  bool SetExtendedInquiryMode();

  bool IsInquiryActive() const;
  bool CancelPeriodicInquiry();
  bool ClearInquiryFilter();
  bool SetFilterInquiryOnDevice();
  bool SetFilterInquiryOnAddress();

  DiscoverabilityState GetClassicDiscoverabilityState() const;
  DiscoverabilityState GetLeDiscoverabilityState() const;

  ConnectibilityState GetClassicConnectibilityState() const;
  ConnectibilityState GetLeConnectibilityState() const;

  bool SetClassicConnectibleOff();
  bool SetClassicConnectibleOn();
  bool SetLeConnectibleOff();
  bool SetLeConnectibleOn();

  bool StartInquiry();

 private:
  DiscoverabilityState classic_;
  DiscoverabilityState le_;

  ConnectibilityState classic_connectibility_state_;
  ConnectibilityState le_connectibility_state_;

  bool DoSetEventFilter();
  bool DoSetConnectible();
  void DoSetDiscoverability();
  bool DoSetInquiryMode();
};

}  // namespace shim
}  // namespace bluetooth
+1320 −0

File added.

Preview size limit exceeded, changes collapsed.

+2754 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading