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