Roshan Pius | 80c3cc6 | 2021-08-27 12:55:02 -0700 | [diff] [blame] | 1 | /* |
| 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 Pius | 90f5171 | 2021-09-21 11:09:12 -0700 | [diff] [blame] | 19 | namespace { |
Roshan Pius | 1e1c842 | 2021-11-04 12:59:07 -0700 | [diff] [blame^] | 20 | constexpr static int32_t kAndroidUciVersion = 1; |
| 21 | constexpr static int64_t kAndroidCapabilities = 0; |
Roshan Pius | 90f5171 | 2021-09-21 11:09:12 -0700 | [diff] [blame] | 22 | } |
| 23 | |
Roshan Pius | 80c3cc6 | 2021-08-27 12:55:02 -0700 | [diff] [blame] | 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace uwb { |
| 27 | namespace impl { |
| 28 | using namespace ::aidl::android::hardware::uwb; |
| 29 | |
Roshan Pius | 90f5171 | 2021-09-21 11:09:12 -0700 | [diff] [blame] | 30 | UwbChip::UwbChip(const std::string& name) : name_(name), mClientCallback(nullptr) {} |
Roshan Pius | 80c3cc6 | 2021-08-27 12:55:02 -0700 | [diff] [blame] | 31 | UwbChip::~UwbChip() {} |
| 32 | |
| 33 | ::ndk::ScopedAStatus UwbChip::getName(std::string* name) { |
| 34 | *name = name_; |
| 35 | return ndk::ScopedAStatus::ok(); |
| 36 | } |
| 37 | |
Roshan Pius | 90f5171 | 2021-09-21 11:09:12 -0700 | [diff] [blame] | 38 | ::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 Pius | 80c3cc6 | 2021-08-27 12:55:02 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | ::ndk::ScopedAStatus UwbChip::close() { |
Roshan Pius | 90f5171 | 2021-09-21 11:09:12 -0700 | [diff] [blame] | 45 | mClientCallback->onHalEvent(UwbEvent::CLOSE_CPLT, UwbStatus::OK); |
| 46 | mClientCallback = nullptr; |
| 47 | return ndk::ScopedAStatus::ok(); |
Roshan Pius | 80c3cc6 | 2021-08-27 12:55:02 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | ::ndk::ScopedAStatus UwbChip::coreInit() { |
Roshan Pius | 90f5171 | 2021-09-21 11:09:12 -0700 | [diff] [blame] | 51 | return ndk::ScopedAStatus::ok(); |
Roshan Pius | 80c3cc6 | 2021-08-27 12:55:02 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Roshan Pius | 1e1c842 | 2021-11-04 12:59:07 -0700 | [diff] [blame^] | 54 | ::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 Pius | 90f5171 | 2021-09-21 11:09:12 -0700 | [diff] [blame] | 61 | return ndk::ScopedAStatus::ok(); |
Roshan Pius | 80c3cc6 | 2021-08-27 12:55:02 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | ::ndk::ScopedAStatus UwbChip::sendUciMessage(const std::vector<uint8_t>& /* data */, |
| 65 | int32_t* /* bytes_written */) { |
Roshan Pius | 90f5171 | 2021-09-21 11:09:12 -0700 | [diff] [blame] | 66 | // TODO(b/195992658): Need emulator support for UCI stack. |
Roshan Pius | 80c3cc6 | 2021-08-27 12:55:02 -0700 | [diff] [blame] | 67 | return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); |
| 68 | } |
| 69 | } // namespace impl |
| 70 | } // namespace uwb |
| 71 | } // namespace hardware |
| 72 | } // namespace android |