blob: 10dbdb6e5b64d9b71d285adcadc51b7774624d40 [file] [log] [blame]
Roshan Pius80c3cc62021-08-27 12:55:02 -07001/*
2 * Copyright 2021, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "uwb.h"
18
Roshan Pius90f51712021-09-21 11:09:12 -070019namespace {
Roshan Pius1e1c8422021-11-04 12:59:07 -070020constexpr static int32_t kAndroidUciVersion = 1;
21constexpr static int64_t kAndroidCapabilities = 0;
Roshan Pius90f51712021-09-21 11:09:12 -070022}
23
Roshan Pius80c3cc62021-08-27 12:55:02 -070024namespace android {
25namespace hardware {
26namespace uwb {
27namespace impl {
28using namespace ::aidl::android::hardware::uwb;
29
Roshan Pius90f51712021-09-21 11:09:12 -070030UwbChip::UwbChip(const std::string& name) : name_(name), mClientCallback(nullptr) {}
Roshan Pius80c3cc62021-08-27 12:55:02 -070031UwbChip::~UwbChip() {}
32
33::ndk::ScopedAStatus UwbChip::getName(std::string* name) {
34 *name = name_;
35 return ndk::ScopedAStatus::ok();
36}
37
Roshan Pius90f51712021-09-21 11:09:12 -070038::ndk::ScopedAStatus UwbChip::open(const std::shared_ptr<IUwbClientCallback>& clientCallback) {
39 mClientCallback = clientCallback;
40 mClientCallback->onHalEvent(UwbEvent::OPEN_CPLT, UwbStatus::OK);
41 return ndk::ScopedAStatus::ok();
Roshan Pius80c3cc62021-08-27 12:55:02 -070042}
43
44::ndk::ScopedAStatus UwbChip::close() {
Roshan Pius90f51712021-09-21 11:09:12 -070045 mClientCallback->onHalEvent(UwbEvent::CLOSE_CPLT, UwbStatus::OK);
46 mClientCallback = nullptr;
47 return ndk::ScopedAStatus::ok();
Roshan Pius80c3cc62021-08-27 12:55:02 -070048}
49
50::ndk::ScopedAStatus UwbChip::coreInit() {
Roshan Pius90f51712021-09-21 11:09:12 -070051 return ndk::ScopedAStatus::ok();
Roshan Pius80c3cc62021-08-27 12:55:02 -070052}
53
Roshan Pius1e1c8422021-11-04 12:59:07 -070054::ndk::ScopedAStatus UwbChip::getSupportedAndroidUciVersion(int32_t* version) {
55 *version = kAndroidUciVersion;
56 return ndk::ScopedAStatus::ok();
57}
58
59::ndk::ScopedAStatus UwbChip::getSupportedAndroidCapabilities(int64_t* capabilities) {
60 *capabilities = kAndroidCapabilities;
Roshan Pius90f51712021-09-21 11:09:12 -070061 return ndk::ScopedAStatus::ok();
Roshan Pius80c3cc62021-08-27 12:55:02 -070062}
63
64::ndk::ScopedAStatus UwbChip::sendUciMessage(const std::vector<uint8_t>& /* data */,
65 int32_t* /* bytes_written */) {
Roshan Pius90f51712021-09-21 11:09:12 -070066 // TODO(b/195992658): Need emulator support for UCI stack.
Roshan Pius80c3cc62021-08-27 12:55:02 -070067 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
68}
69} // namespace impl
70} // namespace uwb
71} // namespace hardware
72} // namespace android