blob: fe64fa712519c467023b6dc46e4ce9ba2f503f6e [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 {
20constexpr static int kVendorUciVersion = 1;
21}
22
Roshan Pius80c3cc62021-08-27 12:55:02 -070023namespace android {
24namespace hardware {
25namespace uwb {
26namespace impl {
27using namespace ::aidl::android::hardware::uwb;
28
Roshan Pius90f51712021-09-21 11:09:12 -070029UwbChip::UwbChip(const std::string& name) : name_(name), mClientCallback(nullptr) {}
Roshan Pius80c3cc62021-08-27 12:55:02 -070030UwbChip::~UwbChip() {}
31
32::ndk::ScopedAStatus UwbChip::getName(std::string* name) {
33 *name = name_;
34 return ndk::ScopedAStatus::ok();
35}
36
Roshan Pius90f51712021-09-21 11:09:12 -070037::ndk::ScopedAStatus UwbChip::open(const std::shared_ptr<IUwbClientCallback>& clientCallback) {
38 mClientCallback = clientCallback;
39 mClientCallback->onHalEvent(UwbEvent::OPEN_CPLT, UwbStatus::OK);
40 return ndk::ScopedAStatus::ok();
Roshan Pius80c3cc62021-08-27 12:55:02 -070041}
42
43::ndk::ScopedAStatus UwbChip::close() {
Roshan Pius90f51712021-09-21 11:09:12 -070044 mClientCallback->onHalEvent(UwbEvent::CLOSE_CPLT, UwbStatus::OK);
45 mClientCallback = nullptr;
46 return ndk::ScopedAStatus::ok();
Roshan Pius80c3cc62021-08-27 12:55:02 -070047}
48
49::ndk::ScopedAStatus UwbChip::coreInit() {
Roshan Pius90f51712021-09-21 11:09:12 -070050 return ndk::ScopedAStatus::ok();
Roshan Pius80c3cc62021-08-27 12:55:02 -070051}
52
Roshan Pius90f51712021-09-21 11:09:12 -070053::ndk::ScopedAStatus UwbChip::getSupportedVendorUciVersion(int32_t* version) {
54 *version = kVendorUciVersion;
55 return ndk::ScopedAStatus::ok();
Roshan Pius80c3cc62021-08-27 12:55:02 -070056}
57
58::ndk::ScopedAStatus UwbChip::sendUciMessage(const std::vector<uint8_t>& /* data */,
59 int32_t* /* bytes_written */) {
Roshan Pius90f51712021-09-21 11:09:12 -070060 // TODO(b/195992658): Need emulator support for UCI stack.
Roshan Pius80c3cc62021-08-27 12:55:02 -070061 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
62}
63} // namespace impl
64} // namespace uwb
65} // namespace hardware
66} // namespace android