merge from upstream/master into main at 2023-05-29T19:32:05.771546Z
Change-Id: Ic3111b7e1371cbaf98a2e0329d1f89f09485cf52
diff --git a/.gitignore b/.gitignore
index eeea1db..ceb2dd7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
# Ignore the artifacts generated by cargo.
**/Cargo.lock
**/target/
+
+# vscode
+.vscode/*
\ No newline at end of file
diff --git a/CleanSpec.mk b/CleanSpec.mk
deleted file mode 100755
index ffac166..0000000
--- a/CleanSpec.mk
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright (C) 2012 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.
-#
-
-# If you don't need to do a full clean build but would like to touch
-# a file or delete some intermediate files, add a clean step to the end
-# of the list. These steps will only be run once, if they haven't been
-# run before.
-#
-# E.g.:
-# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
-# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
-#
-# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
-# files that are missing or have been moved.
-#
-# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
-# Use $(OUT_DIR) to refer to the "out" directory.
-#
-# If you need to re-do something that's already mentioned, just copy
-# the command and add it to the bottom of the list. E.g., if a change
-# that you made last week required touching a file and a change you
-# made today requires touching the same file, just copy the old
-# touch step and add it to the end of the list.
-#
-# ************************************************
-# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
-# ************************************************
-
-# For example:
-#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
-#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
-#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
-#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
-$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libuwb-uci_intermediates)
-
-# ************************************************
-# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
-# ************************************************
diff --git a/src/TEST_MAPPING b/src/TEST_MAPPING
index 94263af..4676de2 100644
--- a/src/TEST_MAPPING
+++ b/src/TEST_MAPPING
@@ -1,10 +1,5 @@
{
"presubmit": [
- // TODO(b/245028544): Disable the presubmit check temporarily.
- // {
- // "name": "libuwb_core_cargo_test",
- // "host": true
- // },
{
"name": "libuwb_uci_packet_tests"
},
diff --git a/src/adaptation/UwbAdaptation.cc b/src/adaptation/UwbAdaptation.cc
deleted file mode 100755
index fa78e45..0000000
--- a/src/adaptation/UwbAdaptation.cc
+++ /dev/null
@@ -1,566 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-
-#include "UwbAdaptation.h"
-
-#include <aidl/android/hardware/uwb/BnUwb.h>
-#include <aidl/android/hardware/uwb/BnUwbClientCallback.h>
-#include <aidl/android/hardware/uwb/IUwb.h>
-#include <aidl/android/hardware/uwb/IUwbChip.h>
-#include <android-base/logging.h>
-#include <android/binder_ibinder.h>
-#include <android/binder_manager.h>
-#include <android/binder_process.h>
-#include <binder/IMemory.h>
-#include <binder/IServiceManager.h>
-#include <binder/MemoryDealer.h>
-#include <cutils/properties.h>
-#include <pthread.h>
-
-#include <algorithm>
-
-#include "uci_log.h"
-#include "uwa_api.h"
-#include "uwb_config.h"
-#include "uwb_hal_int.h"
-#include "uwb_int.h"
-#include "uwb_target.h"
-
-using IUwbV1_0 = aidl::android::hardware::uwb::IUwb;
-using IUwbChipV1_0 = aidl::android::hardware::uwb::IUwbChip;
-using UwbStatus = aidl::android::hardware::uwb::UwbStatus;
-using aidl::android::hardware::uwb::BnUwbClientCallback;
-using aidl::android::hardware::uwb::IUwbClientCallback;
-
-std::string UWB_HAL_SERVICE_NAME = "android.hardware.uwb.IUwb/default";
-extern bool uwb_debug_enabled;
-
-bool uwb_debug_enabled = false;
-bool IsdebugLogEnabled = false;
-
-extern void phUwb_GKI_shutdown();
-
-UwbAdaptation* UwbAdaptation::mpInstance = NULL;
-ThreadMutex UwbAdaptation::sLock;
-ThreadMutex UwbAdaptation::sIoctlLock;
-std::mutex sIoctlMutex;
-
-tHAL_UWB_CBACK* UwbAdaptation::mHalCallback = NULL;
-tHAL_UWB_DATA_CBACK* UwbAdaptation::mHalDataCallback = NULL;
-std::shared_ptr<IUwbChipV1_0> mHal = nullptr;
-
-namespace {
-void initializeGlobalDebugEnabledFlag() {
- uwb_debug_enabled = true;
-
- UCI_TRACE_I("%s: Debug log is enabled =%u", __func__, uwb_debug_enabled);
-}
-
-std::shared_ptr<IUwbChipV1_0> getHalService() {
- ::ndk::SpAIBinder binder(AServiceManager_getService(UWB_HAL_SERVICE_NAME.c_str()));
- std::shared_ptr<IUwbV1_0> iUwb = IUwbV1_0::fromBinder(binder);
- if (iUwb == nullptr) {
- ALOGE("Failed to connect to the AIDL HAL service.");
- return nullptr;
- }
- std::vector<std::string> chipNames;
- ndk::ScopedAStatus status = iUwb->getChips(&chipNames);
- if (!status.isOk() || chipNames.empty()) {
- ALOGE("Failed to retrieve the HAL chip names");
- return nullptr;
- }
- // TODO (b/197638976): We pick the first chip here. Need to fix this
- // for supporting multiple chips in the future.
- std::shared_ptr<IUwbChipV1_0> iUwbChip;
- status = iUwb->getChip(chipNames.front(), &iUwbChip);
- if (!status.isOk() || iUwbChip == nullptr) {
- ALOGE("Failed to retrieve the HAL chip");
- return nullptr;
- }
- return iUwbChip;
-}
-
-} // namespace
-
-class UwbClientCallback
- : public aidl::android::hardware::uwb::BnUwbClientCallback {
- public:
- UwbClientCallback(tHAL_UWB_CBACK* eventCallback,
- tHAL_UWB_DATA_CBACK dataCallback) {
- mEventCallback = eventCallback;
- mDataCallback = dataCallback;
- };
- virtual ~UwbClientCallback() = default;
-
- ::ndk::ScopedAStatus onHalEvent(
- aidl::android::hardware::uwb::UwbEvent event,
- aidl::android::hardware::uwb::UwbStatus event_status) override {
- mEventCallback((uint8_t)event, (uint16_t)event_status);
- return ::ndk::ScopedAStatus::ok();
- };
-
- ::ndk::ScopedAStatus onUciMessage(const std::vector<uint8_t>& data) override {
- std::vector<uint8_t> copy = data;
- mDataCallback(copy.size(), ©[0]);
- return ::ndk::ScopedAStatus::ok();
- };
-
- private:
- tHAL_UWB_CBACK* mEventCallback;
- tHAL_UWB_DATA_CBACK* mDataCallback;
-};
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::UwbAdaptation()
-**
-** Description: class constructor
-**
-** Returns: none
-**
-*******************************************************************************/
-UwbAdaptation::UwbAdaptation() {
- memset(&mHalEntryFuncs, 0, sizeof(mHalEntryFuncs));
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::~UwbAdaptation()
-**
-** Description: class destructor
-**
-** Returns: none
-**
-*******************************************************************************/
-UwbAdaptation::~UwbAdaptation() { mpInstance = NULL; }
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::GetInstance()
-**
-** Description: access class singleton
-**
-** Returns: pointer to the singleton object
-**
-*******************************************************************************/
-UwbAdaptation& UwbAdaptation::GetInstance() {
- AutoThreadMutex a(sLock);
-
- if (!mpInstance) mpInstance = new UwbAdaptation;
- CHECK(mpInstance);
- return *mpInstance;
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::Initialize()
-**
-** Description: class initializer
-**
-** Returns: none
-**
-*******************************************************************************/
-void UwbAdaptation::Initialize() {
- const char* func = "UwbAdaptation::Initialize";
- UNUSED(func);
- UCI_TRACE_I("%s: enter", func);
- initializeGlobalDebugEnabledFlag();
- phUwb_GKI_init();
- phUwb_GKI_enable();
- phUwb_GKI_create_task((TASKPTR)UWBA_TASK, BTU_TASK, (int8_t*)"UWBA_TASK", 0,
- 0, (pthread_cond_t*)NULL, NULL);
- {
- AutoThreadMutex guard(mCondVar);
- phUwb_GKI_create_task((TASKPTR)Thread, MMI_TASK, (int8_t*)"UWBA_THREAD", 0,
- 0, (pthread_cond_t*)NULL, NULL);
- mCondVar.wait();
- }
-
- mHalCallback = NULL;
- memset(&mHalEntryFuncs, 0, sizeof(mHalEntryFuncs));
- InitializeHalDeviceContext();
- UCI_TRACE_I("%s: exit", func);
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::Finalize(bool exitStatus)
-**
-** Description: class finalizer
-**
-** Returns: none
-**
-*******************************************************************************/
-void UwbAdaptation::Finalize(bool graceExit) {
- const char* func = "UwbAdaptation::Finalize";
- UNUSED(func);
- AutoThreadMutex a(sLock);
-
- UCI_TRACE_I("%s: enter, graceful: %d", func, graceExit);
- phUwb_GKI_shutdown();
-
- memset(&mHalEntryFuncs, 0, sizeof(mHalEntryFuncs));
- if (graceExit) {
- UwbConfig::clear();
- }
-
- UCI_TRACE_I("%s: exit", func);
- delete this;
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::signal()
-**
-** Description: signal the CondVar to release the thread that is waiting
-**
-** Returns: none
-**
-*******************************************************************************/
-void UwbAdaptation::signal() { mCondVar.signal(); }
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::UWBA_TASK()
-**
-** Description: UWBA_TASK runs the GKI main task
-**
-** Returns: none
-**
-*******************************************************************************/
-uint32_t UwbAdaptation::UWBA_TASK(__attribute__((unused)) uint32_t arg) {
- const char* func = "UwbAdaptation::UWBA_TASK";
- UNUSED(func);
- UCI_TRACE_I("%s: enter", func);
- phUwb_GKI_run(0);
- UCI_TRACE_I("%s: exit", func);
- return 0;
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::Thread()
-**
-** Description: Creates work threads
-**
-** Returns: none
-**
-*******************************************************************************/
-uint32_t UwbAdaptation::Thread(__attribute__((unused)) uint32_t arg) {
- const char* func = "UwbAdaptation::Thread";
- UNUSED(func);
- UCI_TRACE_I("%s: enter", func);
-
- {
- ThreadCondVar CondVar;
- AutoThreadMutex guard(CondVar);
- phUwb_GKI_create_task((TASKPTR)uwb_task, UWB_TASK, (int8_t*)"UWB_TASK", 0,
- 0, (pthread_cond_t*)CondVar,
- (pthread_mutex_t*)CondVar);
- CondVar.wait();
- }
-
- UwbAdaptation::GetInstance().signal();
-
- phUwb_GKI_exit_task(phUwb_GKI_get_taskid());
- UCI_TRACE_I("%s: exit", func);
- return 0;
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::GetHalEntryFuncs()
-**
-** Description: Get the set of HAL entry points.
-**
-** Returns: Functions pointers for HAL entry points.
-**
-*******************************************************************************/
-tHAL_UWB_ENTRY* UwbAdaptation::GetHalEntryFuncs() { return &mHalEntryFuncs; }
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::InitializeHalDeviceContext
-**
-** Description: Ask the generic Android HAL to find the Broadcom-specific HAL.
-**
-** Returns: None.
-**
-*******************************************************************************/
-void UwbAdaptation::InitializeHalDeviceContext() {
- const char* func = "UwbAdaptation::InitializeHalDeviceContext";
- UNUSED(func);
- UCI_TRACE_I("%s: enter", func);
-
- mHalEntryFuncs.open = HalOpen;
- mHalEntryFuncs.close = HalClose;
- mHalEntryFuncs.write = HalWrite;
- mHalEntryFuncs.CoreInitialization = CoreInitialization;
- mHalEntryFuncs.SessionInitialization = SessionInitialization;
- mHal = getHalService();
- if (mHal == nullptr) {
- UCI_TRACE_I("%s: Failed to retrieve the UWB HAL!", func);
- } else {
- UCI_TRACE_I("%s: IUwb::getService() returned %p (%s)", func, mHal.get(),
- (mHal->isRemote() ? "remote" : "local"));
- }
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::HalOpen
-**
-** Description: Turn on controller, download firmware.
-**
-** Returns: None.
-**
-*******************************************************************************/
-void UwbAdaptation::HalOpen(tHAL_UWB_CBACK* p_hal_cback,
- tHAL_UWB_DATA_CBACK* p_data_cback) {
- const char* func = "UwbAdaptation::HalOpen";
- UNUSED(func);
- UCI_TRACE_I("%s", func);
- ndk::ScopedAStatus status;
- std::shared_ptr<IUwbClientCallback> mCallback;
- mCallback =
- ndk::SharedRefBase::make<UwbClientCallback>(p_hal_cback, p_data_cback);
-
- if (mHal != nullptr) {
- status = mHal->open(mCallback);
- } else {
- UCI_TRACE_E("%s mHal is NULL", func);
- }
-}
-/*******************************************************************************
-**
-** Function: UwbAdaptation::HalClose
-**
-** Description: Turn off controller.
-**
-** Returns: None.
-**
-*******************************************************************************/
-void UwbAdaptation::HalClose() {
- const char* func = "UwbAdaptation::HalClose";
- UNUSED(func);
- ndk::ScopedAStatus status;
- UCI_TRACE_I("%s HalClose Enter", func);
- if (mHal != nullptr) status = mHal->close();
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::HalWrite
-**
-** Description: Write UCI message to the controller.
-**
-** Returns: None.
-**
-*******************************************************************************/
-void UwbAdaptation::HalWrite(__attribute__((unused)) uint16_t data_len,
- __attribute__((unused)) uint8_t* p_data) {
- const char* func = "UwbAdaptation::HalWrite";
- UNUSED(func);
- UCI_TRACE_I("%s: Enter", func);
- std::vector<uint8_t> data;
- if (p_data == NULL) {
- UCI_TRACE_E("p_data is null");
- return;
- }
- int ret;
- copy(&p_data[0], &p_data[data_len], back_inserter(data));
- if (mHal != nullptr) {
- mHal->sendUciMessage(data, &ret);
- } else {
- UCI_TRACE_E("mHal is NULL");
- }
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::CoreInitialization
-**
-** Description: Performs UWB CoreInitialization.
-**
-** Returns: UwbStatus::OK on success and UwbStatus::FAILED on error.
-**
-*******************************************************************************/
-tUWB_STATUS UwbAdaptation::CoreInitialization() {
- const char* func = "UwbAdaptation::CoreInitialization";
- UNUSED(func);
- UCI_TRACE_I("%s: enter", func);
- if (mHal != nullptr) {
- if (!mHal->coreInit().isOk()) return UWB_STATUS_FAILED;
- } else {
- UCI_TRACE_E("mHal is NULL");
- return UWB_STATUS_FAILED;
- }
- return UWB_STATUS_OK;
-}
-
-/*******************************************************************************
-**
-** Function: UwbAdaptation::SessionInitialization
-**
-** Description: Performs UWB SessionInitialization.
-**
-** Returns: UwbStatus::OK on success and UwbStatus::FAILED on error.
-**
-*******************************************************************************/
-tUWB_STATUS UwbAdaptation::SessionInitialization(int sessionId) {
- const char* func = "UwbAdaptation::SessionInitialization";
- UNUSED(func);
- UCI_TRACE_I("%s: enter", func);
- if (mHal != nullptr) {
- if (!mHal->sessionInit(sessionId).isOk()) return UWB_STATUS_FAILED;
- } else {
- UCI_TRACE_E("mHal is NULL");
- return UWB_STATUS_FAILED;
- }
- return UWB_STATUS_OK;
-}
-
-/*******************************************************************************
-**
-** Function: ThreadMutex::ThreadMutex()
-**
-** Description: class constructor
-**
-** Returns: none
-**
-*******************************************************************************/
-ThreadMutex::ThreadMutex() {
- pthread_mutexattr_t mutexAttr;
-
- pthread_mutexattr_init(&mutexAttr);
- pthread_mutex_init(&mMutex, &mutexAttr);
- pthread_mutexattr_destroy(&mutexAttr);
-}
-
-/*******************************************************************************
-**
-** Function: ThreadMutex::~ThreadMutex()
-**
-** Description: class destructor
-**
-** Returns: none
-**
-*******************************************************************************/
-ThreadMutex::~ThreadMutex() { pthread_mutex_destroy(&mMutex); }
-
-/*******************************************************************************
-**
-** Function: ThreadMutex::lock()
-**
-** Description: lock the mutex
-**
-** Returns: none
-**
-*******************************************************************************/
-void ThreadMutex::lock() { pthread_mutex_lock(&mMutex); }
-
-/*******************************************************************************
-**
-** Function: ThreadMutex::unblock()
-**
-** Description: unlock the mutex
-**
-** Returns: none
-**
-*******************************************************************************/
-void ThreadMutex::unlock() { pthread_mutex_unlock(&mMutex); }
-
-/*******************************************************************************
-**
-** Function: ThreadCondVar::ThreadCondVar()
-**
-** Description: class constructor
-**
-** Returns: none
-**
-*******************************************************************************/
-ThreadCondVar::ThreadCondVar() {
- pthread_condattr_t CondAttr;
-
- pthread_condattr_init(&CondAttr);
- pthread_cond_init(&mCondVar, &CondAttr);
-
- pthread_condattr_destroy(&CondAttr);
-}
-
-/*******************************************************************************
-**
-** Function: ThreadCondVar::~ThreadCondVar()
-**
-** Description: class destructor
-**
-** Returns: none
-**
-*******************************************************************************/
-ThreadCondVar::~ThreadCondVar() { pthread_cond_destroy(&mCondVar); }
-
-/*******************************************************************************
-**
-** Function: ThreadCondVar::wait()
-**
-** Description: wait on the mCondVar
-**
-** Returns: none
-**
-*******************************************************************************/
-void ThreadCondVar::wait() {
- pthread_cond_wait(&mCondVar, *this);
- pthread_mutex_unlock(*this);
-}
-
-/*******************************************************************************
-**
-** Function: ThreadCondVar::signal()
-**
-** Description: signal the mCondVar
-**
-** Returns: none
-**
-*******************************************************************************/
-void ThreadCondVar::signal() {
- AutoThreadMutex a(*this);
- pthread_cond_signal(&mCondVar);
-}
-
-/*******************************************************************************
-**
-** Function: AutoThreadMutex::AutoThreadMutex()
-**
-** Description: class constructor, automatically lock the mutex
-**
-** Returns: none
-**
-*******************************************************************************/
-AutoThreadMutex::AutoThreadMutex(ThreadMutex& m) : mm(m) { mm.lock(); }
-
-/*******************************************************************************
-**
-** Function: AutoThreadMutex::~AutoThreadMutex()
-**
-** Description: class destructor, automatically unlock the mutex
-**
-** Returns: none
-**
-*******************************************************************************/
-AutoThreadMutex::~AutoThreadMutex() { mm.unlock(); }
diff --git a/src/adaptation/config.cc b/src/adaptation/config.cc
deleted file mode 100755
index 36e0d10..0000000
--- a/src/adaptation/config.cc
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2017 The Android Open Source Project
- * Copyright 2018-2019 NXP
- *
- * 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.
- */
-#include "config.h"
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/parseint.h>
-#include <android-base/strings.h>
-
-#include "uwb_config.h"
-
-using namespace ::std;
-using namespace ::android::base;
-
-namespace {
-
-bool parseBytesString(std::string in, std::vector<uint8_t>& out) {
- vector<string> values = Split(in, ":");
- if (values.size() == 0) return false;
- for (string value : values) {
- if (value.length() != 2) return false;
- uint8_t tmp = 0;
- string hexified = "0x";
- hexified.append(value);
- if (!ParseUint(hexified.c_str(), &tmp)) return false;
- out.push_back(tmp);
- }
- return true;
-}
-
-} // namespace
-
-ConfigValue::ConfigValue() {}
-
-ConfigValue::ConfigValue(std::string value) {
- // Don't allow empty strings
- CHECK(!(value.empty()));
- type_ = STRING;
- value_string_ = value;
-}
-
-ConfigValue::ConfigValue(unsigned value) {
- type_ = UNSIGNED;
- value_unsigned_ = value;
-}
-
-ConfigValue::ConfigValue(std::vector<uint8_t> value) {
- CHECK(!(value.empty()));
- type_ = BYTES;
- value_bytes_ = value;
-}
-
-ConfigValue::Type ConfigValue::getType() const { return type_; }
-
-std::string ConfigValue::getString() const {
- CHECK(type_ == STRING);
- return value_string_;
-};
-
-unsigned ConfigValue::getUnsigned() const {
- CHECK(type_ == UNSIGNED);
- return value_unsigned_;
-};
-
-std::vector<uint8_t> ConfigValue::getBytes() const {
- CHECK(type_ == BYTES);
- return value_bytes_;
-};
-
-bool ConfigValue::parseFromString(std::string in) {
- if (in.length() > 1 && in[0] == '"' && in[in.length() - 1] == '"') {
- CHECK(in.length() > 2); // Don't allow empty strings
- type_ = STRING;
- value_string_ = in.substr(1, in.length() - 2);
- return true;
- }
-
- if (in.length() > 1 && in[0] == '{' && in[in.length() - 1] == '}') {
- CHECK(in.length() >= 4); // Needs at least one byte
- type_ = BYTES;
- return parseBytesString(in.substr(1, in.length() - 2), value_bytes_);
- }
-
- unsigned tmp = 0;
- if (ParseUint(in.c_str(), &tmp)) {
- type_ = UNSIGNED;
- value_unsigned_ = tmp;
- return true;
- }
-
- return false;
-}
-
-void ConfigFile::addConfig(const std::string& key, ConfigValue& value) {
- CHECK(!hasKey(key));
- values_.emplace(key, value);
-}
-
-void ConfigFile::parseFromFile(const std::string& file_name) {
- string config;
- bool config_read = ReadFileToString(file_name, &config);
- CHECK(config_read);
- LOG(INFO) << "ConfigFile - Parsing file '" << file_name << "'";
- parseFromString(config);
-}
-
-void ConfigFile::parseFromString(const std::string& config) {
- stringstream ss(config);
- string line;
- while (getline(ss, line)) {
- line = Trim(line);
- if (line.empty()) continue;
- if (line.at(0) == '#') continue;
- if (line.at(0) == 0) continue;
-
- auto search = line.find('=');
- CHECK(search != string::npos);
-
- string key(Trim(line.substr(0, search)));
- string value_string(Trim(line.substr(search + 1, string::npos)));
-
- ConfigValue value;
- bool value_parsed = value.parseFromString(value_string);
- CHECK(value_parsed);
- addConfig(key, value);
-
- LOG(INFO) << "ConfigFile - [" << key << "] = " << value_string;
- }
-}
-
-bool ConfigFile::hasKey(const std::string& key) {
- return values_.count(key) != 0;
-}
-
-ConfigValue& ConfigFile::getValue(const std::string& key) {
- CHECK(values_.find(key) != values_.end());
- auto search = values_.find(key);
- return search->second;
-}
-
-std::string ConfigFile::getString(const std::string& key) {
- return getValue(key).getString();
-}
-
-unsigned ConfigFile::getUnsigned(const std::string& key) {
- return getValue(key).getUnsigned();
-}
-
-std::vector<uint8_t> ConfigFile::getBytes(const std::string& key) {
- return getValue(key).getBytes();
-}
-
-bool ConfigFile::isEmpty() { return values_.empty(); }
-void ConfigFile::clear() { values_.clear(); }
diff --git a/src/adaptation/uwb_config.cc b/src/adaptation/uwb_config.cc
deleted file mode 100755
index 3707cc6..0000000
--- a/src/adaptation/uwb_config.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2017 The Android Open Source Project
- * Copyright 2018-2019 NXP
- *
- * 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.
- */
-#include "uwb_config.h"
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/parseint.h>
-#include <android-base/strings.h>
-#include <config.h>
-
-#include "UwbAdaptation.h"
-
-using namespace ::std;
-using namespace ::android::base;
-
-namespace {
-
-std::string findConfigPath() {
- const vector<string> search_path = {"/odm/etc/", "/vendor/etc/",
- "/product/etc/", "/etc/"};
- const string file_name = "libuwb-uci.conf";
-
- for (string path : search_path) {
- path.append(file_name);
- struct stat file_stat;
- if (stat(path.c_str(), &file_stat) != 0) continue;
- if (S_ISREG(file_stat.st_mode)) return path;
- }
- return "";
-}
-
-} // namespace
-
-void UwbConfig::loadConfig() {
- string config_path = findConfigPath();
- CHECK(config_path != "");
- config_.parseFromFile(config_path);
-}
-
-UwbConfig::UwbConfig() { loadConfig(); }
-
-UwbConfig& UwbConfig::getInstance() {
- static UwbConfig theInstance;
- if (theInstance.config_.isEmpty()) {
- theInstance.loadConfig();
- }
- return theInstance;
-}
-
-bool UwbConfig::hasKey(const std::string& key) {
- return getInstance().config_.hasKey(key);
-}
-
-std::string UwbConfig::getString(const std::string& key) {
- return getInstance().config_.getString(key);
-}
-
-std::string UwbConfig::getString(const std::string& key,
- std::string default_value) {
- if (hasKey(key)) return getString(key);
- return default_value;
-}
-
-unsigned UwbConfig::getUnsigned(const std::string& key) {
- return getInstance().config_.getUnsigned(key);
-}
-
-unsigned UwbConfig::getUnsigned(const std::string& key,
- unsigned default_value) {
- if (hasKey(key)) return getUnsigned(key);
- return default_value;
-}
-
-std::vector<uint8_t> UwbConfig::getBytes(const std::string& key) {
- return getInstance().config_.getBytes(key);
-}
-
-void UwbConfig::clear() { getInstance().config_.clear(); }
diff --git a/src/gki/common/uwb_gki.h b/src/gki/common/uwb_gki.h
deleted file mode 100755
index 3451093..0000000
--- a/src/gki/common/uwb_gki.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#ifndef UWB_GKI_H
-#define UWB_GKI_H
-
-#include <string>
-
-#include "uwb_gki_target.h"
-#include "uwb_target.h"
-
-/* Error codes */
-#define GKI_SUCCESS 0x00
-#define GKI_FAILURE 0x01
-#define GKI_INVALID_TASK 0xF0
-#define GKI_INVALID_POOL 0xFF
-
-/************************************************************************
-** Mailbox definitions. Each task has 4 mailboxes that are used to
-** send buffers to the task.
-*/
-#define TASK_MBOX_0 0
-#define TASK_MBOX_2 2
-
-#define NUM_TASK_MBOX 4
-
-/************************************************************************
-** Event definitions.
-**
-** There are 4 reserved events used to signal messages rcvd in task mailboxes.
-** There are 4 reserved events used to signal timeout events.
-** There are 8 general purpose events available for applications.
-*/
-
-#define TASK_MBOX_0_EVT_MASK 0x0001
-#define TASK_MBOX_1_EVT_MASK 0x0002
-#define TASK_MBOX_2_EVT_MASK 0x0004
-#define TASK_MBOX_3_EVT_MASK 0x0008
-
-#define TIMER_0 0
-#define TIMER_1 1
-#define TIMER_2 2
-#define TIMER_3 3
-
-#define TIMER_0_EVT_MASK 0x0010
-#define TIMER_1_EVT_MASK 0x0020
-#define TIMER_2_EVT_MASK 0x0040
-#define TIMER_3_EVT_MASK 0x0080
-
-#define APPL_EVT_0 8
-#define APPL_EVT_7 15
-
-#define EVENT_MASK(evt) ((uint16_t)(0x0001 << (evt)))
-
-/************************************************************************
-** Max Time Queue
-**/
-#ifndef GKI_MAX_TIMER_QUEUES
-#define GKI_MAX_TIMER_QUEUES 3
-#endif
-
-/************************************************************************
-** Utility macros for timer conversion
-**/
-#ifdef TICKS_PER_SEC
-#define GKI_MS_TO_TICKS(x) ((x) / (1000 / TICKS_PER_SEC))
-#define GKI_SECS_TO_TICKS(x) ((x) * (TICKS_PER_SEC))
-#define GKI_TICKS_TO_MS(x) ((x) * (1000 / TICKS_PER_SEC))
-#define GKI_TICKS_TO_SECS(x) ((x) * (1 / TICKS_PER_SEC))
-#endif
-
-#ifndef GKI_SHUTDOWN_EVT
-#define GKI_SHUTDOWN_EVT APPL_EVT_7
-#endif
-
-/* Timer list entry callback type
- */
-struct TIMER_LIST_ENT;
-typedef void(TIMER_CBACK)(TIMER_LIST_ENT* p_tle);
-
-/* Define a timer list entry
- */
-struct TIMER_LIST_ENT {
- TIMER_LIST_ENT* p_next;
- TIMER_LIST_ENT* p_prev;
- TIMER_CBACK* p_cback;
- int32_t ticks;
- uintptr_t param;
- uint16_t event;
- uint8_t in_use;
-};
-
-/* Define a timer list queue
- */
-typedef struct {
- TIMER_LIST_ENT* p_first;
- TIMER_LIST_ENT* p_last;
- int32_t last_ticks;
-} TIMER_LIST_Q;
-
-/***********************************************************************
-** This queue is a general purpose buffer queue, for application use.
-*/
-typedef struct {
- void* p_first;
- void* p_last;
- uint16_t count;
-} BUFFER_Q;
-
-typedef struct {
- BUFFER_Q tx_data_pkt_q;
- uint32_t session_id;
- uint8_t credit_available;
-} DATA_BUFFER_Q;
-
-/* Task constants
- */
-#ifndef TASKPTR
-typedef uint32_t (*TASKPTR)(uint32_t);
-#endif
-
-/* General pool accessible to GKI_getbuf() */
-#define GKI_RESTRICTED_POOL 1 /* Inaccessible pool to GKI_getbuf() */
-
-/***********************************************************************
-** Function prototypes
-*/
-
-/* Task management
- */
-extern uint8_t phUwb_GKI_create_task(TASKPTR, uint8_t, int8_t*, uint16_t*,
- uint16_t, void*, void*);
-extern void phUwb_GKI_exit_task(uint8_t);
-extern uint8_t phUwb_GKI_get_taskid(void);
-extern void phUwb_GKI_init(void);
-extern void phUwb_GKI_run(void*);
-
-/* To send buffers and events between tasks
- */
-extern uint8_t phUwb_GKI_isend_event(uint8_t, uint16_t);
-extern void* phUwb_GKI_read_mbox(uint8_t);
-extern void phUwb_GKI_send_msg(uint8_t, uint8_t, void*);
-extern uint8_t phUwb_GKI_send_event(uint8_t, uint16_t);
-
-/* To get and release buffers, change owner and get size
- */
-extern void phUwb_GKI_freebuf(void*);
-extern void* phUwb_GKI_getbuf(uint16_t);
-extern uint16_t phUwb_GKI_get_buf_size(void*);
-extern void* phUwb_GKI_getpoolbuf(uint8_t);
-
-/* User buffer queue management
- */
-extern void* phUwb_GKI_dequeue(BUFFER_Q*);
-extern void phUwb_GKI_enqueue(BUFFER_Q*, void*);
-extern void phUwb_GKI_init_q(BUFFER_Q*);
-
-/* Timer management
- */
-extern void phUwb_GKI_add_to_timer_list(TIMER_LIST_Q*, TIMER_LIST_ENT*);
-extern uint32_t phUwb_GKI_get_tick_count(void);
-extern void phUwb_GKI_init_timer_list(TIMER_LIST_Q*);
-extern void phUwb_GKI_remove_from_timer_list(TIMER_LIST_Q*, TIMER_LIST_ENT*);
-extern void phUwb_GKI_start_timer(uint8_t, int32_t, bool);
-extern void phUwb_GKI_stop_timer(uint8_t, int);
-extern void phUwb_GKI_timer_update(uint32_t);
-extern uint16_t phUwb_GKI_update_timer_list(TIMER_LIST_Q*, uint32_t);
-extern uint32_t phUwb_GKI_get_remaining_ticks(TIMER_LIST_Q*, TIMER_LIST_ENT*);
-extern uint16_t phUwb_GKI_wait(uint16_t, uint32_t);
-
-/* Start and Stop system time tick callback
- * true for start system tick if time queue is not empty
- * false to stop system tick if time queue is empty
- */
-typedef void(SYSTEM_TICK_CBACK)(bool);
-
-/* Time queue management for system ticks
- */
-extern void phUwb_GKI_timer_queue_register_callback(SYSTEM_TICK_CBACK*);
-
-/* Disable Interrupts, Enable Interrupts
- */
-extern void phUwb_GKI_enable(void);
-extern void phUwb_GKI_disable(void);
-
-/* Allocate (Free) memory from an OS
- */
-extern void* phUwb_GKI_os_malloc(uint32_t);
-extern void phUwb_GKI_os_free(void*);
-
-/* Exception handling
- */
-extern void phUwb_GKI_exception(uint16_t, std::string);
-
-#endif
diff --git a/src/gki/common/uwb_gki_buffer.cc b/src/gki/common/uwb_gki_buffer.cc
deleted file mode 100755
index 566b31d..0000000
--- a/src/gki/common/uwb_gki_buffer.cc
+++ /dev/null
@@ -1,643 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#include "uwb_gki.h"
-#include "uwb_gki_common.h"
-#include "uwb_gki_int.h"
-
-#if (GKI_NUM_TOTAL_BUF_POOLS > 16)
-#error Number of pools out of range (16 Max)!
-#endif
-
-#include "uci_log.h"
-
-/*******************************************************************************
-**
-** Function phUwb_phUwb_gki_init_free_queue
-**
-** Description Internal function called at startup to initialize a free
-** queue. It is called once for each free queue.
-**
-** Returns void
-**
-*******************************************************************************/
-static void phUwb_gki_init_free_queue(uint8_t id, uint16_t size, uint16_t total,
- void* p_mem) {
- uint16_t i;
- uint16_t act_size;
- BUFFER_HDR_T* hdr;
- BUFFER_HDR_T* hdr1 = NULL;
- uint32_t* magic;
- int32_t tempsize = size;
- tGKI_COM_CB* p_cb = &gki_cb.com;
-
- /* Ensure an even number of longwords */
- tempsize = (int32_t)ALIGN_POOL(size);
- act_size = (uint16_t)(tempsize + BUFFER_PADDING_SIZE);
-
- /* Remember pool start and end addresses */
- if (p_mem) {
- p_cb->pool_start[id] = (uint8_t*)p_mem;
- p_cb->pool_end[id] = (uint8_t*)p_mem + (act_size * total);
- }
-
- p_cb->pool_size[id] = act_size;
-
- p_cb->freeq[id].size = (uint16_t)tempsize;
- p_cb->freeq[id].total = total;
- p_cb->freeq[id].cur_cnt = 0;
- p_cb->freeq[id].max_cnt = 0;
-
- /* Initialize index table */
- if (p_mem) {
- hdr = (BUFFER_HDR_T*)p_mem;
- p_cb->freeq[id].p_first = hdr;
- for (i = 0; i < total; i++) {
- hdr->task_id = GKI_INVALID_TASK;
- hdr->q_id = id;
- hdr->status = BUF_STATUS_FREE;
- magic = (uint32_t*)((uint8_t*)hdr + BUFFER_HDR_SIZE + tempsize);
- *magic = MAGIC_NO;
- hdr1 = hdr;
- hdr = (BUFFER_HDR_T*)((uint8_t*)hdr + act_size);
- hdr1->p_next = hdr;
- }
- if (hdr1 != NULL) hdr = hdr1;
- hdr->p_next = NULL;
- p_cb->freeq[id].p_last = hdr;
- }
- return;
-}
-
-static bool phUwb_gki_alloc_free_queue(uint8_t id) {
- FREE_QUEUE_T* Q;
- tGKI_COM_CB* p_cb = &gki_cb.com;
-
- Q = &p_cb->freeq[p_cb->pool_list[id]];
-
- if (Q->p_first == 0) {
- uint32_t requested_size;
- bool overflow = __builtin_mul_overflow(Q->size + BUFFER_PADDING_SIZE,
- Q->total, &requested_size);
- if (overflow) {
- phUwb_GKI_exception(GKI_ERROR_BUF_SIZE_TOOBIG,
- "gki_alloc_free_queue: Buffer overflow");
- return false;
- }
- void* p_mem =
- phUwb_GKI_os_malloc(requested_size);
- if (p_mem) {
- // re-initialize the queue with allocated memory
- phUwb_gki_init_free_queue(id, Q->size, Q->total, p_mem);
- return true;
- }
- phUwb_GKI_exception(GKI_ERROR_BUF_SIZE_TOOBIG,
- "gki_alloc_free_queue: Not enough memory");
- }
- return false;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_gki_buffer_init
-**
-** Description Called once internally by GKI at startup to initialize all
-** buffers and free buffer pools.
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_gki_buffer_init(void) {
- uint8_t i, tt, mb;
- tGKI_COM_CB* p_cb = &gki_cb.com;
-
- /* Initialize mailboxes */
- for (tt = 0; tt < GKI_MAX_TASKS; tt++) {
- for (mb = 0; mb < NUM_TASK_MBOX; mb++) {
- p_cb->OSTaskQFirst[tt][mb] = NULL;
- p_cb->OSTaskQLast[tt][mb] = NULL;
- }
- }
-
- for (tt = 0; tt < GKI_NUM_TOTAL_BUF_POOLS; tt++) {
- p_cb->pool_start[tt] = NULL;
- p_cb->pool_end[tt] = NULL;
- p_cb->pool_size[tt] = 0;
-
- p_cb->freeq[tt].p_first = 0;
- p_cb->freeq[tt].p_last = 0;
- p_cb->freeq[tt].size = 0;
- p_cb->freeq[tt].total = 0;
- p_cb->freeq[tt].cur_cnt = 0;
- p_cb->freeq[tt].max_cnt = 0;
- }
-
- /* Use default from target.h */
- p_cb->pool_access_mask = GKI_DEF_BUFPOOL_PERM_MASK;
-
-#if (GKI_NUM_FIXED_BUF_POOLS > 0)
- phUwb_gki_init_free_queue(0, GKI_BUF0_SIZE, GKI_BUF0_MAX, p_cb->bufpool0);
-#endif
-
-#if (GKI_NUM_FIXED_BUF_POOLS > 1)
- phUwb_gki_init_free_queue(1, GKI_BUF1_SIZE, GKI_BUF1_MAX, p_cb->bufpool1);
-#endif
-
-#if (GKI_NUM_FIXED_BUF_POOLS > 2)
- phUwb_gki_init_free_queue(2, GKI_BUF2_SIZE, GKI_BUF2_MAX, p_cb->bufpool2);
-#endif
-
-#if (GKI_NUM_FIXED_BUF_POOLS > 3)
- phUwb_gki_init_free_queue(3, GKI_BUF3_SIZE, GKI_BUF3_MAX, p_cb->bufpool3);
-#endif
-
- /* add pools to the pool_list which is arranged in the order of size */
- for (i = 0; i < GKI_NUM_FIXED_BUF_POOLS; i++) {
- p_cb->pool_list[i] = i;
- }
-
- p_cb->curr_total_no_of_pools = GKI_NUM_FIXED_BUF_POOLS;
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_init_q
-**
-** Description Called by an application to initialize a buffer queue.
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_init_q(BUFFER_Q* p_q) {
- p_q->p_first = p_q->p_last = NULL;
- p_q->count = 0;
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_getbuf
-**
-** Description Called by an application to get a free buffer which
-** is of size greater or equal to the requested size.
-**
-** Note: This routine only takes buffers from public pools.
-** It will not use any buffers from pools
-** marked GKI_RESTRICTED_POOL.
-**
-** Parameters size - (input) number of bytes needed.
-**
-** Returns A pointer to the buffer, or NULL if none available
-**
-*******************************************************************************/
-void* phUwb_GKI_getbuf(uint16_t size) {
- uint8_t i;
- FREE_QUEUE_T* Q;
- BUFFER_HDR_T* p_hdr;
- tGKI_COM_CB* p_cb = &gki_cb.com;
-
- if (size == 0) {
- phUwb_GKI_exception(GKI_ERROR_BUF_SIZE_ZERO, "getbuf: Size is zero");
- return (NULL);
- }
-
- /* Find the first buffer pool that is public that can hold the desired size */
- for (i = 0; i < p_cb->curr_total_no_of_pools; i++) {
- if (size <= p_cb->freeq[p_cb->pool_list[i]].size) break;
- }
-
- if (i == p_cb->curr_total_no_of_pools) {
- phUwb_GKI_exception(GKI_ERROR_BUF_SIZE_TOOBIG, "getbuf: Size is too big");
- return (NULL);
- }
-
- /* Make sure the buffers aren't disturbed til finished with allocation */
- phUwb_GKI_disable();
-
- /* search the public buffer pools that are big enough to hold the size
- * until a free buffer is found */
- for (; i < p_cb->curr_total_no_of_pools; i++) {
- /* Only look at PUBLIC buffer pools (bypass RESTRICTED pools) */
- if (((uint16_t)1 << p_cb->pool_list[i]) & p_cb->pool_access_mask) continue;
-
- Q = &p_cb->freeq[p_cb->pool_list[i]];
- if (Q->cur_cnt < Q->total) {
- if (Q->p_first == 0 && phUwb_gki_alloc_free_queue(i) != true) {
- UCI_TRACE_E("out of buffer");
- phUwb_GKI_enable();
- return NULL;
- }
-
- if (Q->p_first == 0) {
- /* phUwb_gki_alloc_free_queue() failed to alloc memory */
- UCI_TRACE_E("fail alloc free queue");
- phUwb_GKI_enable();
- return NULL;
- }
-
- p_hdr = Q->p_first;
- Q->p_first = p_hdr->p_next;
-
- if (!Q->p_first) Q->p_last = NULL;
-
- if (++Q->cur_cnt > Q->max_cnt) Q->max_cnt = Q->cur_cnt;
-
- phUwb_GKI_enable();
-
- p_hdr->task_id = phUwb_GKI_get_taskid();
-
- p_hdr->status = BUF_STATUS_UNLINKED;
- p_hdr->p_next = NULL;
- p_hdr->Type = 0;
- return ((void*)((uint8_t*)p_hdr + BUFFER_HDR_SIZE));
- }
- }
-
- UCI_TRACE_E("unable to allocate buffer!!!!!");
-
- phUwb_GKI_enable();
-
- return (NULL);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_getpoolbuf
-**
-** Description Called by an application to get a free buffer from
-** a specific buffer pool.
-**
-** Note: If there are no more buffers available from the pool,
-** the public buffers are searched for an available
-** buffer.
-**
-** Parameters pool_id - (input) pool ID to get a buffer out of.
-**
-** Returns A pointer to the buffer, or NULL if none available
-**
-*******************************************************************************/
-void* phUwb_GKI_getpoolbuf(uint8_t pool_id) {
- FREE_QUEUE_T* Q;
- BUFFER_HDR_T* p_hdr;
- tGKI_COM_CB* p_cb = &gki_cb.com;
-
- if (pool_id >= GKI_NUM_TOTAL_BUF_POOLS) return (NULL);
-
- /* Make sure the buffers aren't disturbed til finished with allocation */
- phUwb_GKI_disable();
-
- Q = &p_cb->freeq[pool_id];
- if (Q->cur_cnt < Q->total) {
- if (Q->p_first == 0 && phUwb_gki_alloc_free_queue(pool_id) != true)
- return NULL;
-
- if (Q->p_first == 0) {
- /* gki_alloc_free_queue() failed to alloc memory */
- UCI_TRACE_E("fail alloc free queue");
- return NULL;
- }
-
- p_hdr = Q->p_first;
- Q->p_first = p_hdr->p_next;
-
- if (!Q->p_first) Q->p_last = NULL;
-
- if (++Q->cur_cnt > Q->max_cnt) Q->max_cnt = Q->cur_cnt;
-
- phUwb_GKI_enable();
-
- p_hdr->task_id = phUwb_GKI_get_taskid();
-
- p_hdr->status = BUF_STATUS_UNLINKED;
- p_hdr->p_next = NULL;
- p_hdr->Type = 0;
-
- return ((void*)((uint8_t*)p_hdr + BUFFER_HDR_SIZE));
- }
-
- /* If here, no buffers in the specified pool */
- phUwb_GKI_enable();
-
- /* try for free buffers in public pools */
- return (phUwb_GKI_getbuf(p_cb->freeq[pool_id].size));
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_freebuf
-**
-** Description Called by an application to return a buffer to the free
-** pool.
-**
-** Parameters p_buf - (input) address of the beginning of a buffer.
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_freebuf(void* p_buf) {
- FREE_QUEUE_T* Q;
- BUFFER_HDR_T* p_hdr;
-
-#if (GKI_ENABLE_BUF_CORRUPTION_CHECK == TRUE)
- if (!p_buf || phUwb_gki_chk_buf_damage(p_buf)) {
- phUwb_GKI_exception(GKI_ERROR_BUF_CORRUPTED, "Free - Buf Corrupted");
- return;
- }
-#endif
-
- p_hdr = (BUFFER_HDR_T*)((uint8_t*)p_buf - BUFFER_HDR_SIZE);
-
- if (p_hdr->status != BUF_STATUS_UNLINKED) {
- phUwb_GKI_exception(GKI_ERROR_FREEBUF_BUF_LINKED, "Freeing Linked Buf");
- return;
- }
-
- if (p_hdr->q_id >= GKI_NUM_TOTAL_BUF_POOLS) {
- phUwb_GKI_exception(GKI_ERROR_FREEBUF_BAD_QID, "Bad Buf QId");
- return;
- }
-
- phUwb_GKI_disable();
-
- /*
- ** Release the buffer
- */
- Q = &gki_cb.com.freeq[p_hdr->q_id];
- if (Q->p_last)
- Q->p_last->p_next = p_hdr;
- else
- Q->p_first = p_hdr;
-
- Q->p_last = p_hdr;
- p_hdr->p_next = NULL;
- p_hdr->status = BUF_STATUS_FREE;
- p_hdr->task_id = GKI_INVALID_TASK;
- if (Q->cur_cnt > 0) Q->cur_cnt--;
-
- phUwb_GKI_enable();
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_get_buf_size
-**
-** Description Called by an application to get the size of a buffer.
-**
-** Parameters p_buf - (input) address of the beginning of a buffer.
-**
-** Returns the size of the buffer
-**
-*******************************************************************************/
-uint16_t phUwb_GKI_get_buf_size(void* p_buf) {
- BUFFER_HDR_T* p_hdr;
-
- p_hdr = (BUFFER_HDR_T*)((uint8_t*)p_buf - BUFFER_HDR_SIZE);
-
- if ((uintptr_t)p_hdr & 1) return (0);
-
- if (p_hdr->q_id < GKI_NUM_TOTAL_BUF_POOLS) {
- return (gki_cb.com.freeq[p_hdr->q_id].size);
- }
-
- return (0);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_gki_chk_buf_damage
-**
-** Description Called internally by OSS to check for buffer corruption.
-**
-** Returns TRUE if there is a problem, else FALSE
-**
-*******************************************************************************/
-bool phUwb_gki_chk_buf_damage(void* p_buf) {
-#if (GKI_ENABLE_BUF_CORRUPTION_CHECK == TRUE)
-
- uint32_t* magic;
- magic = (uint32_t*)((uint8_t*)p_buf + phUwb_GKI_get_buf_size(p_buf));
-
- if ((uintptr_t)magic & 1) return true;
-
- if (*magic == MAGIC_NO) return false;
-
- return true;
-
-#else
-
- return false;
-
-#endif
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_send_msg
-**
-** Description Called by applications to send a buffer to a task
-**
-** Returns Nothing
-**
-*******************************************************************************/
-void phUwb_GKI_send_msg(uint8_t task_id, uint8_t mbox, void* msg) {
- BUFFER_HDR_T* p_hdr;
- tGKI_COM_CB* p_cb = &gki_cb.com;
-
- /* If task non-existant or not started, drop buffer */
- if ((task_id >= GKI_MAX_TASKS) || (mbox >= NUM_TASK_MBOX) ||
- (p_cb->OSRdyTbl[task_id] == TASK_DEAD)) {
- phUwb_GKI_exception(GKI_ERROR_SEND_MSG_BAD_DEST, "Sending to unknown dest");
- phUwb_GKI_freebuf(msg);
- return;
- }
-
-#if (GKI_ENABLE_BUF_CORRUPTION_CHECK == TRUE)
- if (phUwb_gki_chk_buf_damage(msg)) {
- phUwb_GKI_exception(GKI_ERROR_BUF_CORRUPTED, "Send - Buffer corrupted");
- return;
- }
-#endif
-
- p_hdr = (BUFFER_HDR_T*)((uint8_t*)msg - BUFFER_HDR_SIZE);
-
- if (p_hdr->status != BUF_STATUS_UNLINKED) {
- phUwb_GKI_exception(GKI_ERROR_SEND_MSG_BUF_LINKED, "Send - buffer linked");
- return;
- }
-
- phUwb_GKI_disable();
-
- if (p_cb->OSTaskQFirst[task_id][mbox])
- p_cb->OSTaskQLast[task_id][mbox]->p_next = p_hdr;
- else
- p_cb->OSTaskQFirst[task_id][mbox] = p_hdr;
-
- p_cb->OSTaskQLast[task_id][mbox] = p_hdr;
-
- p_hdr->p_next = NULL;
- p_hdr->status = BUF_STATUS_QUEUED;
- p_hdr->task_id = task_id;
-
- phUwb_GKI_enable();
-
- phUwb_GKI_send_event(task_id, (uint16_t)EVENT_MASK(mbox));
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_read_mbox
-**
-** Description Called by applications to read a buffer from one of
-** the task mailboxes. A task can only read its own mailbox.
-**
-** Parameters: mbox - (input) mailbox ID to read (0, 1, 2, or 3)
-**
-** Returns NULL if the mailbox was empty, else the address of a buffer
-**
-*******************************************************************************/
-void* phUwb_GKI_read_mbox(uint8_t mbox) {
- uint8_t task_id = phUwb_GKI_get_taskid();
- void* p_buf = NULL;
- BUFFER_HDR_T* p_hdr;
-
- if ((task_id >= GKI_MAX_TASKS) || (mbox >= NUM_TASK_MBOX)) return (NULL);
-
- phUwb_GKI_disable();
-
- if (gki_cb.com.OSTaskQFirst[task_id][mbox]) {
- p_hdr = gki_cb.com.OSTaskQFirst[task_id][mbox];
- gki_cb.com.OSTaskQFirst[task_id][mbox] = p_hdr->p_next;
-
- p_hdr->p_next = NULL;
- p_hdr->status = BUF_STATUS_UNLINKED;
-
- p_buf = (uint8_t*)p_hdr + BUFFER_HDR_SIZE;
- }
-
- phUwb_GKI_enable();
-
- return (p_buf);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_enqueue
-**
-** Description Enqueue a buffer at the tail of the queue
-**
-** Parameters: p_q - (input) pointer to a queue.
-** p_buf - (input) address of the buffer to enqueue
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_enqueue(BUFFER_Q* p_q, void* p_buf) {
- BUFFER_HDR_T* p_hdr;
-
-#if (GKI_ENABLE_BUF_CORRUPTION_CHECK == TRUE)
- if (phUwb_gki_chk_buf_damage(p_buf)) {
- phUwb_GKI_exception(GKI_ERROR_BUF_CORRUPTED, "Enqueue - Buffer corrupted");
- return;
- }
-#endif
-
- p_hdr = (BUFFER_HDR_T*)((uint8_t*)p_buf - BUFFER_HDR_SIZE);
-
- if (p_hdr->status != BUF_STATUS_UNLINKED) {
- phUwb_GKI_exception(GKI_ERROR_ENQUEUE_BUF_LINKED,
- "Eneueue - buf already linked");
- return;
- }
-
- phUwb_GKI_disable();
-
- /* Since the queue is exposed (C vs C++), keep the pointers in exposed format
- */
- if (p_q->p_first) {
- BUFFER_HDR_T* p_last_hdr =
- (BUFFER_HDR_T*)((uint8_t*)p_q->p_last - BUFFER_HDR_SIZE);
- p_last_hdr->p_next = p_hdr;
- } else
- p_q->p_first = p_buf;
-
- p_q->p_last = p_buf;
- p_q->count++;
-
- p_hdr->p_next = NULL;
- p_hdr->status = BUF_STATUS_QUEUED;
-
- phUwb_GKI_enable();
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_dequeue
-**
-** Description Dequeues a buffer from the head of a queue
-**
-** Parameters: p_q - (input) pointer to a queue.
-**
-** Returns NULL if queue is empty, else buffer
-**
-*******************************************************************************/
-void* phUwb_GKI_dequeue(BUFFER_Q* p_q) {
- BUFFER_HDR_T* p_hdr;
-
- phUwb_GKI_disable();
-
- if (!p_q || !p_q->count) {
- phUwb_GKI_enable();
- return (NULL);
- }
-
- p_hdr = (BUFFER_HDR_T*)((uint8_t*)p_q->p_first - BUFFER_HDR_SIZE);
-
- /* Keep buffers such that GKI header is invisible
- */
- if (p_hdr->p_next)
- p_q->p_first = ((uint8_t*)p_hdr->p_next + BUFFER_HDR_SIZE);
- else {
- p_q->p_first = NULL;
- p_q->p_last = NULL;
- }
-
- p_q->count--;
-
- p_hdr->p_next = NULL;
- p_hdr->status = BUF_STATUS_UNLINKED;
-
- phUwb_GKI_enable();
-
- return ((uint8_t*)p_hdr + BUFFER_HDR_SIZE);
-}
-
-/********************************************************
- * The following functions are not needed for light stack
- *********************************************************/
-#ifndef BTU_STACK_LITE_ENABLED
-#define BTU_STACK_LITE_ENABLED FALSE
-#endif
diff --git a/src/gki/common/uwb_gki_common.h b/src/gki/common/uwb_gki_common.h
deleted file mode 100755
index 31621c6..0000000
--- a/src/gki/common/uwb_gki_common.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#ifndef UWB_GKI_COMMON_H
-#define UWB_GKI_COMMON_H
-
-#include "uwb_gki.h"
-
-/* Task States: (For OSRdyTbl) */
-#define TASK_DEAD 0 /* b0000 */
-#define TASK_READY 1 /* b0001 */
-
-/********************************************************************
-** Internal Error codes
-*********************************************************************/
-#define GKI_ERROR_BUF_CORRUPTED 0xFFFF
-#define GKI_ERROR_NOT_BUF_OWNER 0xFFFE
-#define GKI_ERROR_FREEBUF_BAD_QID 0xFFFD
-#define GKI_ERROR_FREEBUF_BUF_LINKED 0xFFFC
-#define GKI_ERROR_SEND_MSG_BAD_DEST 0xFFFB
-#define GKI_ERROR_SEND_MSG_BUF_LINKED 0xFFFA
-#define GKI_ERROR_ENQUEUE_BUF_LINKED 0xFFF9
-#define GKI_ERROR_DELETE_POOL_BAD_QID 0xFFF8
-#define GKI_ERROR_BUF_SIZE_TOOBIG 0xFFF7
-#define GKI_ERROR_BUF_SIZE_ZERO 0xFFF6
-
-/********************************************************************
-** Misc constants
-*********************************************************************/
-
-#define GKI_MAX_INT32 (0x7fffffffL)
-
-/********************************************************************
-** Buffer Management Data Structures
-*********************************************************************/
-
-typedef struct _buffer_hdr {
- struct _buffer_hdr* p_next; /* next buffer in the queue */
- uint8_t q_id; /* id of the queue */
- uint8_t task_id; /* task which allocated the buffer*/
- uint8_t status; /* FREE, UNLINKED or QUEUED */
- uint8_t Type;
-} BUFFER_HDR_T;
-
-typedef struct _free_queue {
- BUFFER_HDR_T* p_first; /* first buffer in the queue */
- BUFFER_HDR_T* p_last; /* last buffer in the queue */
- uint16_t size; /* size of the buffers in the pool */
- uint16_t total; /* toatal number of buffers */
- uint16_t cur_cnt; /* number of buffers currently allocated */
- uint16_t max_cnt; /* maximum number of buffers allocated at any time */
-} FREE_QUEUE_T;
-
-/* Buffer related defines
- */
-#define ALIGN_POOL(pl_size) \
- ((((pl_size) + 3) / sizeof(uint32_t)) * sizeof(uint32_t))
-/* Offset past header */
-#define BUFFER_HDR_SIZE (sizeof(BUFFER_HDR_T))
-/* Header + Magic Number */
-#define BUFFER_PADDING_SIZE (sizeof(BUFFER_HDR_T) + sizeof(uint32_t))
-/* pool size must allow for header */
-#define MAX_USER_BUF_SIZE ((uint16_t)0xffff - BUFFER_PADDING_SIZE)
-#define MAGIC_NO 0xDDBADDBA
-
-#define BUF_STATUS_FREE 0
-#define BUF_STATUS_UNLINKED 1
-#define BUF_STATUS_QUEUED 2
-
-/* Put all GKI variables into one control block
- */
-typedef struct {
- /* Task management variables
- */
- /* The stack and stack size are not used on Windows
- */
-
-#if (GKI_NUM_FIXED_BUF_POOLS > 0)
- uint8_t bufpool0[(ALIGN_POOL(GKI_BUF0_SIZE) + BUFFER_PADDING_SIZE) *
- GKI_BUF0_MAX];
-#endif
-
-#if (GKI_NUM_FIXED_BUF_POOLS > 1)
- uint8_t bufpool1[(ALIGN_POOL(GKI_BUF1_SIZE) + BUFFER_PADDING_SIZE) *
- GKI_BUF1_MAX];
-#endif
-
-#if (GKI_NUM_FIXED_BUF_POOLS > 2)
- uint8_t bufpool2[(ALIGN_POOL(GKI_BUF2_SIZE) + BUFFER_PADDING_SIZE) *
- GKI_BUF2_MAX];
-#endif
-
-#if (GKI_NUM_FIXED_BUF_POOLS > 3)
- uint8_t bufpool3[(ALIGN_POOL(GKI_BUF3_SIZE) + BUFFER_PADDING_SIZE) *
- GKI_BUF3_MAX];
-#endif
-
- uint8_t* OSStack[GKI_MAX_TASKS]; /* pointer to beginning of stack */
- uint16_t OSStackSize[GKI_MAX_TASKS]; /* stack size available to each task */
-
- int8_t* OSTName[GKI_MAX_TASKS]; /* name of the task */
-
- uint8_t OSRdyTbl[GKI_MAX_TASKS]; /* current state of the task */
- uint16_t OSWaitEvt[GKI_MAX_TASKS]; /* events that have to be processed by the
- task */
- uint16_t OSWaitForEvt[GKI_MAX_TASKS]; /* events the task is waiting for*/
-
- uint32_t OSTicks; /* system ticks from start */
- uint32_t OSIdleCnt; /* idle counter */
- int16_t
- OSDisableNesting; /* counter to keep track of interrupt disable nesting */
- int16_t OSLockNesting; /* counter to keep track of sched lock nesting */
- int16_t OSIntNesting; /* counter to keep track of interrupt nesting */
-
- /* Timer related variables
- */
- int32_t OSTicksTilExp; /* Number of ticks till next timer expires */
-#if (GKI_DELAY_STOP_SYS_TICK > 0)
- uint32_t OSTicksTilStop; /* inactivity delay timer; OS Ticks till stopping
- system tick */
-#endif
- int32_t OSNumOrigTicks; /* Number of ticks between last timer expiration to
- the next one */
-
- int32_t OSWaitTmr[GKI_MAX_TASKS]; /* ticks the task has to wait, for specific
- events */
-
-/* Only take up space timers used in the system (GKI_NUM_TIMERS defined in
- * target.h) */
-#if (GKI_NUM_TIMERS > 0)
- int32_t OSTaskTmr0[GKI_MAX_TASKS];
- int32_t OSTaskTmr0R[GKI_MAX_TASKS];
-#endif
-
-#if (GKI_NUM_TIMERS > 1)
- int32_t OSTaskTmr1[GKI_MAX_TASKS];
- int32_t OSTaskTmr1R[GKI_MAX_TASKS];
-#endif
-
-#if (GKI_NUM_TIMERS > 2)
- int32_t OSTaskTmr2[GKI_MAX_TASKS];
- int32_t OSTaskTmr2R[GKI_MAX_TASKS];
-#endif
-
-#if (GKI_NUM_TIMERS > 3)
- int32_t OSTaskTmr3[GKI_MAX_TASKS];
- int32_t OSTaskTmr3R[GKI_MAX_TASKS];
-#endif
-
- /* Buffer related variables
- */
- BUFFER_HDR_T* OSTaskQFirst[GKI_MAX_TASKS]
- [NUM_TASK_MBOX]; /* array of pointers to the first
- event in the task mailbox */
- BUFFER_HDR_T* OSTaskQLast[GKI_MAX_TASKS]
- [NUM_TASK_MBOX]; /* array of pointers to the last
- event in the task mailbox */
-
- /* Define the buffer pool management variables
- */
- FREE_QUEUE_T freeq[GKI_NUM_TOTAL_BUF_POOLS];
-
- uint16_t pool_buf_size[GKI_NUM_TOTAL_BUF_POOLS];
- uint16_t pool_max_count[GKI_NUM_TOTAL_BUF_POOLS];
- uint16_t pool_additions[GKI_NUM_TOTAL_BUF_POOLS];
-
- /* Define the buffer pool start addresses
- */
- uint8_t* pool_start[GKI_NUM_TOTAL_BUF_POOLS]; /* array of pointers to the
- start of each buffer pool */
- uint8_t* pool_end[GKI_NUM_TOTAL_BUF_POOLS]; /* array of pointers to the end of
- each buffer pool */
- uint16_t pool_size[GKI_NUM_TOTAL_BUF_POOLS]; /* actual size of the buffers in
- a pool */
-
- /* Define the buffer pool access control variables */
- void* p_user_mempool; /* User O/S memory pool */
- uint16_t pool_access_mask; /* Bits are set if the corresponding buffer pool is
- a restricted pool */
- uint8_t pool_list[GKI_NUM_TOTAL_BUF_POOLS]; /* buffer pools arranged in the
- order of size */
- uint8_t curr_total_no_of_pools; /* number of fixed buf pools + current number
- of dynamic pools */
-
- bool timer_nesting; /* flag to prevent timer interrupt nesting */
-
- /* Time queue arrays */
- TIMER_LIST_Q* timer_queues[GKI_MAX_TIMER_QUEUES];
- /* System tick callback */
- SYSTEM_TICK_CBACK* p_tick_cb;
- bool system_tick_running; /* TRUE if system tick is running. Valid only if
- p_tick_cb is not NULL */
-
-} tGKI_COM_CB;
-
-/* Internal GKI function prototypes
- */
-extern bool phUwb_gki_chk_buf_damage(void*);
-extern void phUwb_gki_buffer_init(void);
-extern void phUwb_gki_timers_init(void);
-extern void phUwb_gki_adjust_timer_count(int32_t);
-
-#endif
diff --git a/src/gki/common/uwb_gki_time.cc b/src/gki/common/uwb_gki_time.cc
deleted file mode 100755
index ad314a0..0000000
--- a/src/gki/common/uwb_gki_time.cc
+++ /dev/null
@@ -1,873 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#include "uwb_gki.h"
-#include "uwb_gki_int.h"
-
-/* Make sure that this has been defined in target.h */
-#ifndef GKI_NUM_TIMERS
-#error NO TIMERS: Must define at least 1 timer in the system!
-#endif
-
-/* Largest signed positive timer count */
-#define GKI_NO_NEW_TMRS_STARTED (0x7fffffffL)
-/* Marks an unused timer list entry (initial value) */
-#define GKI_UNUSED_LIST_ENTRY (0x80000000L)
-#define GKI_MAX_INT32 (0x7fffffffL)
-
-#include "uci_log.h"
-
-/*******************************************************************************
-**
-** Function phUwb_gki_timers_init
-**
-** Description This internal function is called once at startup to
-** initialize all the timer structures.
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_gki_timers_init(void) {
- uint8_t tt;
-
- gki_cb.com.OSTicksTilExp =
- 0; /* Remaining time (of OSTimeCurTimeout) before next timer expires */
- gki_cb.com.OSNumOrigTicks = 0;
-#if (GKI_DELAY_STOP_SYS_TICK > 0)
- gki_cb.com.OSTicksTilStop = 0; /* clear inactivity delay timer */
-#endif
-
- for (tt = 0; tt < GKI_MAX_TASKS; tt++) {
- gki_cb.com.OSWaitTmr[tt] = 0;
-
-#if (GKI_NUM_TIMERS > 0)
- gki_cb.com.OSTaskTmr0[tt] = 0;
- gki_cb.com.OSTaskTmr0R[tt] = 0;
-#endif
-
-#if (GKI_NUM_TIMERS > 1)
- gki_cb.com.OSTaskTmr1[tt] = 0;
- gki_cb.com.OSTaskTmr1R[tt] = 0;
-#endif
-
-#if (GKI_NUM_TIMERS > 2)
- gki_cb.com.OSTaskTmr2[tt] = 0;
- gki_cb.com.OSTaskTmr2R[tt] = 0;
-#endif
-
-#if (GKI_NUM_TIMERS > 3)
- gki_cb.com.OSTaskTmr3[tt] = 0;
- gki_cb.com.OSTaskTmr3R[tt] = 0;
-#endif
- }
-
- for (tt = 0; tt < GKI_MAX_TIMER_QUEUES; tt++) {
- gki_cb.com.timer_queues[tt] = NULL;
- }
-
- gki_cb.com.p_tick_cb = NULL;
- gki_cb.com.system_tick_running = false;
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_gki_timers_is_timer_running
-**
-** Description This internal function is called to test if any gki timer
-** are running
-**
-**
-** Returns TRUE if at least one time is running in the system, FALSE
-** else.
-**
-*******************************************************************************/
-bool phUwb_gki_timers_is_timer_running(void) {
- uint8_t tt;
- for (tt = 0; tt < GKI_MAX_TASKS; tt++) {
-#if (GKI_NUM_TIMERS > 0)
- if (gki_cb.com.OSTaskTmr0[tt]) {
- return true;
- }
-#endif
-
-#if (GKI_NUM_TIMERS > 1)
- if (gki_cb.com.OSTaskTmr1[tt]) {
- return true;
- }
-#endif
-
-#if (GKI_NUM_TIMERS > 2)
- if (gki_cb.com.OSTaskTmr2[tt]) {
- return true;
- }
-#endif
-
-#if (GKI_NUM_TIMERS > 3)
- if (gki_cb.com.OSTaskTmr3[tt]) {
- return true;
- }
-#endif
- }
-
- return false;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_get_tick_count
-**
-** Description This function returns the current system ticks
-**
-** Returns The current number of system ticks
-**
-*******************************************************************************/
-uint32_t phUwb_GKI_get_tick_count(void) { return gki_cb.com.OSTicks; }
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_start_timer
-**
-** Description An application can call this function to start one of
-** it's four general purpose timers. Any of the four timers
-** can be 1-shot or continuous. If a timer is already running,
-** it will be reset to the new parameters.
-**
-** Parameters tnum - (input) timer number to be started
-** (TIMER_0, TIMER_1, TIMER_2, or
-** TIMER_3)
-** ticks - (input) the number of system ticks til the
-** timer expires.
-** is_continuous - (input) TRUE if timer restarts
-** automatically, else FALSE if it is
-** a 'one-shot'.
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_start_timer(uint8_t tnum, int32_t ticks, bool is_continuous) {
- int32_t reload;
- int32_t orig_ticks;
- uint8_t task_id = phUwb_GKI_get_taskid();
- bool bad_timer = false;
-
- if (ticks <= 0) ticks = 1;
-
- orig_ticks = ticks; /* save the ticks in case adjustment is necessary */
-
- /* If continuous timer, set reload, else set it to 0 */
- if (is_continuous)
- reload = ticks;
- else
- reload = 0;
-
- phUwb_GKI_disable();
-
- if (phUwb_gki_timers_is_timer_running() == false) {
-#if (GKI_DELAY_STOP_SYS_TICK > 0)
- /* if inactivity delay timer is not running, start system tick */
- if (gki_cb.com.OSTicksTilStop == 0) {
-#endif
- if (gki_cb.com.p_tick_cb) {
- /* start system tick */
- gki_cb.com.system_tick_running = true;
- (gki_cb.com.p_tick_cb)(true);
- }
-#if (GKI_DELAY_STOP_SYS_TICK > 0)
- } else {
- /* clear inactivity delay timer */
- gki_cb.com.OSTicksTilStop = 0;
- }
-#endif
- }
- /* Add the time since the last task timer update.
- ** Note that this works when no timers are active since
- ** both OSNumOrigTicks and OSTicksTilExp are 0.
- */
- if (GKI_MAX_INT32 - (gki_cb.com.OSNumOrigTicks - gki_cb.com.OSTicksTilExp) >
- ticks) {
- ticks += gki_cb.com.OSNumOrigTicks - gki_cb.com.OSTicksTilExp;
- } else
- ticks = GKI_MAX_INT32;
-
- switch (tnum) {
-#if (GKI_NUM_TIMERS > 0)
- case TIMER_0:
- gki_cb.com.OSTaskTmr0R[task_id] = reload;
- gki_cb.com.OSTaskTmr0[task_id] = ticks;
- break;
-#endif
-
-#if (GKI_NUM_TIMERS > 1)
- case TIMER_1:
- gki_cb.com.OSTaskTmr1R[task_id] = reload;
- gki_cb.com.OSTaskTmr1[task_id] = ticks;
- break;
-#endif
-
-#if (GKI_NUM_TIMERS > 2)
- case TIMER_2:
- gki_cb.com.OSTaskTmr2R[task_id] = reload;
- gki_cb.com.OSTaskTmr2[task_id] = ticks;
- break;
-#endif
-
-#if (GKI_NUM_TIMERS > 3)
- case TIMER_3:
- gki_cb.com.OSTaskTmr3R[task_id] = reload;
- gki_cb.com.OSTaskTmr3[task_id] = ticks;
- break;
-#endif
- default:
- bad_timer = true; /* Timer number is bad, so do not use */
- }
-
- /* Update the expiration timeout if a legitimate timer */
- if (!bad_timer) {
- /* Only update the timeout value if it is less than any other newly started
- * timers */
- phUwb_gki_adjust_timer_count(orig_ticks);
- }
-
- phUwb_GKI_enable();
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_stop_timer
-**
-** Description An application can call this function to stop one of
-** it's four general purpose timers. There is no harm in
-** stopping a timer that is already stopped.
-**
-** Parameters tnum - (input) timer number to be started (TIMER_0,
-** TIMER_1, TIMER_2, or TIMER_3)
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_stop_timer(uint8_t tnum, int value) {
- uint8_t task_id = phUwb_GKI_get_taskid();
- value = 0;
- phUwb_GKI_disable();
-
- switch (tnum) {
-#if (GKI_NUM_TIMERS > 0)
- case TIMER_0:
- gki_cb.com.OSTaskTmr0R[task_id] = 0;
- gki_cb.com.OSTaskTmr0[task_id] = 0;
- break;
-#endif
-
-#if (GKI_NUM_TIMERS > 1)
- case TIMER_1:
- gki_cb.com.OSTaskTmr1R[task_id] = 0;
- gki_cb.com.OSTaskTmr1[task_id] = 0;
- break;
-#endif
-
-#if (GKI_NUM_TIMERS > 2)
- case TIMER_2:
- gki_cb.com.OSTaskTmr2R[task_id] = 0;
- gki_cb.com.OSTaskTmr2[task_id] = 0;
- break;
-#endif
-
-#if (GKI_NUM_TIMERS > 3)
- case TIMER_3:
- gki_cb.com.OSTaskTmr3R[task_id] = 0;
- gki_cb.com.OSTaskTmr3[task_id] = 0;
- break;
-#endif
- }
-
- if (phUwb_gki_timers_is_timer_running() == false) {
- if (gki_cb.com.p_tick_cb) {
-#if (GKI_DELAY_STOP_SYS_TICK > 0)
- /* if inactivity delay timer is not running */
- if ((gki_cb.com.system_tick_running) &&
- (gki_cb.com.OSTicksTilStop == 0)) {
- /* set inactivity delay timer */
- /* when timer expires, system tick will be stopped */
- gki_cb.com.OSTicksTilStop = GKI_DELAY_STOP_SYS_TICK;
- }
-#else
- gki_cb.com.system_tick_running = false;
- (gki_cb.com.p_tick_cb)(false); /* stop system tick */
-#endif
- }
- }
-
- phUwb_GKI_enable();
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_timer_update
-**
-** Description This function is called by an OS to drive the GKI's timers.
-** It is typically called at every system tick to
-** update the timers for all tasks, and check for timeouts.
-**
-** Note: It has been designed to also allow for variable tick
-** updates so that systems with strict power savings
-** requirements can have the update occur at variable
-** intervals.
-**
-** Parameters: ticks_since_last_update - (input) This is the number of
-** TICKS that have occurred since the last time
-** GKI_timer_update was called.
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_timer_update(uint32_t ticks_since_last_update) {
- uint8_t task_id;
- int32_t next_expiration; /* Holds the next soonest expiration time after this
- update */
-
- /* Increment the number of ticks used for time stamps */
- gki_cb.com.OSTicks += ticks_since_last_update;
-
- /* If any timers are running in any tasks, decrement the remaining time til
- * the timer updates need to take place (next expiration occurs)
- */
- gki_cb.com.OSTicksTilExp -= ticks_since_last_update;
-
- /* Don't allow timer interrupt nesting */
- if (gki_cb.com.timer_nesting) return;
-
- gki_cb.com.timer_nesting = 1;
-
- phUwb_GKI_disable();
-
-#if (GKI_DELAY_STOP_SYS_TICK > 0)
- /* if inactivity delay timer is set and expired */
- if (gki_cb.com.OSTicksTilStop) {
- if (gki_cb.com.OSTicksTilStop <= (uint32_t)ticks_since_last_update) {
- if (gki_cb.com.p_tick_cb) {
- gki_cb.com.system_tick_running = false;
- (gki_cb.com.p_tick_cb)(false); /* stop system tick */
- }
- gki_cb.com.OSTicksTilStop = 0; /* clear inactivity delay timer */
- gki_cb.com.timer_nesting = 0;
- phUwb_GKI_enable();
- return;
- } else
- gki_cb.com.OSTicksTilStop -= ticks_since_last_update;
- }
-#endif
-
- /* No need to update the ticks if no timeout has occurred */
- if (gki_cb.com.OSTicksTilExp > 0) {
- gki_cb.com.timer_nesting = 0;
- phUwb_GKI_enable();
- return;
- }
-
- next_expiration = GKI_NO_NEW_TMRS_STARTED;
-
- /* If here then gki_cb.com.OSTicksTilExp <= 0. If negative, then increase
- gki_cb.com.OSNumOrigTicks
- to account for the difference so timer updates below are decremented by the
- full number
- of ticks. gki_cb.com.OSNumOrigTicks is reset at the bottom of this function
- so changing this
- value only affects the timer updates below
- */
- gki_cb.com.OSNumOrigTicks -= gki_cb.com.OSTicksTilExp;
-
- /* Check for OS Task Timers */
- for (task_id = 0; task_id < GKI_MAX_TASKS; task_id++) {
- if (gki_cb.com.OSRdyTbl[task_id] == TASK_DEAD) {
- // task is shutdown do not try to service timers
- continue;
- }
-
- if (gki_cb.com.OSWaitTmr[task_id] > 0) /* If timer is running */
- {
- gki_cb.com.OSWaitTmr[task_id] -= gki_cb.com.OSNumOrigTicks;
- if (gki_cb.com.OSWaitTmr[task_id] <= 0) {
- /* Timer Expired */
- gki_cb.com.OSRdyTbl[task_id] = TASK_READY;
- }
- }
-
-#if (GKI_NUM_TIMERS > 0)
- /* If any timer is running, decrement */
- if (gki_cb.com.OSTaskTmr0[task_id] > 0) {
- gki_cb.com.OSTaskTmr0[task_id] -= gki_cb.com.OSNumOrigTicks;
-
- if (gki_cb.com.OSTaskTmr0[task_id] <= 0) {
-/* Set Timer 0 Expired event mask and reload timer */
-#if (GKI_TIMER_UPDATES_FROM_ISR == TRUE)
- phUwb_GKI_isend_event(task_id, TIMER_0_EVT_MASK);
-#else
- phUwb_GKI_send_event(task_id, TIMER_0_EVT_MASK);
-#endif
- gki_cb.com.OSTaskTmr0[task_id] = gki_cb.com.OSTaskTmr0R[task_id];
- }
- }
-
- /* Check to see if this timer is the next one to expire */
- if (gki_cb.com.OSTaskTmr0[task_id] > 0 &&
- gki_cb.com.OSTaskTmr0[task_id] < next_expiration)
- next_expiration = gki_cb.com.OSTaskTmr0[task_id];
-#endif
-
-#if (GKI_NUM_TIMERS > 1)
- /* If any timer is running, decrement */
- if (gki_cb.com.OSTaskTmr1[task_id] > 0) {
- gki_cb.com.OSTaskTmr1[task_id] -= gki_cb.com.OSNumOrigTicks;
-
- if (gki_cb.com.OSTaskTmr1[task_id] <= 0) {
-/* Set Timer 1 Expired event mask and reload timer */
-#if (GKI_TIMER_UPDATES_FROM_ISR == TRUE)
- phUwb_GKI_isend_event(task_id, TIMER_1_EVT_MASK);
-#else
- phUwb_GKI_send_event(task_id, TIMER_1_EVT_MASK);
-#endif
- gki_cb.com.OSTaskTmr1[task_id] = gki_cb.com.OSTaskTmr1R[task_id];
- }
- }
-
- /* Check to see if this timer is the next one to expire */
- if (gki_cb.com.OSTaskTmr1[task_id] > 0 &&
- gki_cb.com.OSTaskTmr1[task_id] < next_expiration)
- next_expiration = gki_cb.com.OSTaskTmr1[task_id];
-#endif
-
-#if (GKI_NUM_TIMERS > 2)
- /* If any timer is running, decrement */
- if (gki_cb.com.OSTaskTmr2[task_id] > 0) {
- gki_cb.com.OSTaskTmr2[task_id] -= gki_cb.com.OSNumOrigTicks;
-
- if (gki_cb.com.OSTaskTmr2[task_id] <= 0) {
-/* Set Timer 2 Expired event mask and reload timer */
-#if (GKI_TIMER_UPDATES_FROM_ISR == TRUE)
- phUwb_GKI_isend_event(task_id, TIMER_2_EVT_MASK);
-#else
- phUwb_GKI_send_event(task_id, TIMER_2_EVT_MASK);
-#endif
- gki_cb.com.OSTaskTmr2[task_id] = gki_cb.com.OSTaskTmr2R[task_id];
- }
- }
-
- /* Check to see if this timer is the next one to expire */
- if (gki_cb.com.OSTaskTmr2[task_id] > 0 &&
- gki_cb.com.OSTaskTmr2[task_id] < next_expiration)
- next_expiration = gki_cb.com.OSTaskTmr2[task_id];
-#endif
-
-#if (GKI_NUM_TIMERS > 3)
- /* If any timer is running, decrement */
- if (gki_cb.com.OSTaskTmr3[task_id] > 0) {
- gki_cb.com.OSTaskTmr3[task_id] -= gki_cb.com.OSNumOrigTicks;
-
- if (gki_cb.com.OSTaskTmr3[task_id] <= 0) {
-/* Set Timer 3 Expired event mask and reload timer */
-#if (GKI_TIMER_UPDATES_FROM_ISR == TRUE)
- phUwb_GKI_isend_event(task_id, TIMER_3_EVT_MASK);
-#else
- phUwb_GKI_send_event(task_id, TIMER_3_EVT_MASK);
-#endif
- gki_cb.com.OSTaskTmr3[task_id] = gki_cb.com.OSTaskTmr3R[task_id];
- }
- }
-
- /* Check to see if this timer is the next one to expire */
- if (gki_cb.com.OSTaskTmr3[task_id] > 0 &&
- gki_cb.com.OSTaskTmr3[task_id] < next_expiration)
- next_expiration = gki_cb.com.OSTaskTmr3[task_id];
-#endif
- }
-
- /* Set the next timer experation value if there is one to start */
- if (next_expiration < GKI_NO_NEW_TMRS_STARTED) {
- gki_cb.com.OSTicksTilExp = gki_cb.com.OSNumOrigTicks = next_expiration;
- } else {
- gki_cb.com.OSTicksTilExp = gki_cb.com.OSNumOrigTicks = 0;
- }
-
- gki_cb.com.timer_nesting = 0;
-
- phUwb_GKI_enable();
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_timer_queue_register_callback
-**
-** Description This function is called by applications to register system
-** tick start/stop callback for time queues
-**
-**
-** Parameters p_callback - (input) pointer to the system tick callback
-**
-** Returns bool
-**
-*******************************************************************************/
-void phUwb_GKI_timer_queue_register_callback(SYSTEM_TICK_CBACK* p_callback) {
- gki_cb.com.p_tick_cb = p_callback;
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_init_timer_list
-**
-** Description This function is called by applications when they
-** want to initialize a timer list.
-**
-** Parameters p_timer_listq - (input) pointer to the timer list queue
-** object
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_init_timer_list(TIMER_LIST_Q* p_timer_listq) {
- p_timer_listq->p_first = NULL;
- p_timer_listq->p_last = NULL;
- p_timer_listq->last_ticks = 0;
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_update_timer_list
-**
-** Description This function is called by the applications when they
-** want to update a timer list. This should be at every
-** timer list unit tick, e.g. once per sec, once per minute
-** etc.
-**
-** Parameters p_timer_listq - (input) pointer to the timer list queue
-** object
-** num_units_since_last_update - (input) number of units since
-** the last update (allows for variable unit update)
-**
-** NOTE: The following timer list update routines should not be used for exact
-** time critical purposes. The timer tasks should be used when exact
-** timing is needed.
-**
-** Returns the number of timers that have expired
-**
-*******************************************************************************/
-uint16_t phUwb_GKI_update_timer_list(TIMER_LIST_Q* p_timer_listq,
- uint32_t num_units_since_last_update) {
- TIMER_LIST_ENT* p_tle;
- uint16_t num_time_out = 0;
- uint32_t rem_ticks;
- uint32_t temp_ticks;
-
- p_tle = p_timer_listq->p_first;
-
- /* First, get the guys who have previously timed out */
- /* Note that the tick value of the timers should always be '0' */
- while ((p_tle) && (p_tle->ticks <= 0)) {
- num_time_out++;
- p_tle = p_tle->p_next;
- }
-
- /* Timer entriy tick values are relative to the preceeding entry */
- rem_ticks = num_units_since_last_update;
-
- /* Now, adjust remaining timer entries */
- while ((p_tle != NULL) && (rem_ticks > 0)) {
- temp_ticks = p_tle->ticks;
- p_tle->ticks -= rem_ticks;
-
- /* See if this timer has just timed out */
- if (p_tle->ticks <= 0) {
- /* We set the number of ticks to '0' so that the legacy code
- * that assumes a '0' or nonzero value will still work as coded. */
- p_tle->ticks = 0;
-
- num_time_out++;
- }
-
- rem_ticks -= temp_ticks; /* Decrement the remaining ticks to process */
- p_tle = p_tle->p_next;
- }
-
- if (p_timer_listq->last_ticks > 0) {
- p_timer_listq->last_ticks -= num_units_since_last_update;
-
- /* If the last timer has expired set last_ticks to 0 so that other list
- * update
- * functions will calculate correctly
- */
- if (p_timer_listq->last_ticks < 0) p_timer_listq->last_ticks = 0;
- }
-
- return (num_time_out);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_get_remaining_ticks
-**
-** Description This function is called by an application to get remaining
-** ticks to expire
-**
-** Parameters p_timer_listq - (input) pointer to the timer list queue
-** object
-** p_target_tle - (input) pointer to a timer list queue entry
-**
-** Returns 0 if timer is not used or timer is not in the list
-** remaining ticks if success
-**
-*******************************************************************************/
-uint32_t phUwb_GKI_get_remaining_ticks(TIMER_LIST_Q* p_timer_listq,
- TIMER_LIST_ENT* p_target_tle) {
- TIMER_LIST_ENT* p_tle;
- uint32_t rem_ticks = 0;
-
- if (p_target_tle->in_use) {
- p_tle = p_timer_listq->p_first;
-
- /* adding up all of ticks in previous entries */
- while ((p_tle) && (p_tle != p_target_tle)) {
- rem_ticks += p_tle->ticks;
- p_tle = p_tle->p_next;
- }
-
- /* if found target entry */
- if (p_tle == p_target_tle) {
- rem_ticks += p_tle->ticks;
- } else {
- UCI_TRACE_E("GKI_get_remaining_ticks: No timer entry in the list");
- return (0);
- }
- } else {
- UCI_TRACE_E("GKI_get_remaining_ticks: timer entry is not active");
- }
-
- return (rem_ticks);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_add_to_timer_list
-**
-** Description This function is called by an application to add a timer
-** entry to a timer list.
-**
-** Note: A timer value of '0' will effectively insert an
-** already expired event. Negative tick values will be
-** ignored.
-**
-** Parameters p_timer_listq - (input) pointer to the timer list queue
-** object
-** p_tle - (input) pointer to a timer list queue entry
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_add_to_timer_list(TIMER_LIST_Q* p_timer_listq,
- TIMER_LIST_ENT* p_tle) {
- uint32_t nr_ticks_total;
- uint8_t tt;
- TIMER_LIST_ENT* p_temp;
- if (p_tle == NULL || p_timer_listq == NULL) {
- UCI_TRACE_I("%s: invalid argument %p, %p****************************<<",
- __func__, p_timer_listq, p_tle);
- return;
- }
-
- /* Only process valid tick values */
- if (p_tle->ticks >= 0) {
- /* If this entry is the last in the list */
- if (p_tle->ticks >= p_timer_listq->last_ticks) {
- /* If this entry is the only entry in the list */
- if (p_timer_listq->p_first == NULL)
- p_timer_listq->p_first = p_tle;
- else {
- /* Insert the entry onto the end of the list */
- if (p_timer_listq->p_last != NULL)
- p_timer_listq->p_last->p_next = p_tle;
-
- p_tle->p_prev = p_timer_listq->p_last;
- }
-
- p_tle->p_next = NULL;
- p_timer_listq->p_last = p_tle;
- nr_ticks_total = p_tle->ticks;
- p_tle->ticks -= p_timer_listq->last_ticks;
-
- p_timer_listq->last_ticks = nr_ticks_total;
- } else /* This entry needs to be inserted before the last entry */
- {
- /* Find the entry that the new one needs to be inserted in front of */
- p_temp = p_timer_listq->p_first;
- while (p_tle->ticks > p_temp->ticks) {
- /* Update the tick value if looking at an unexpired entry */
- if (p_temp->ticks > 0) p_tle->ticks -= p_temp->ticks;
-
- p_temp = p_temp->p_next;
- }
-
- /* The new entry is the first in the list */
- if (p_temp == p_timer_listq->p_first) {
- p_tle->p_next = p_timer_listq->p_first;
- p_timer_listq->p_first->p_prev = p_tle;
- p_timer_listq->p_first = p_tle;
- } else {
- p_temp->p_prev->p_next = p_tle;
- p_tle->p_prev = p_temp->p_prev;
- p_temp->p_prev = p_tle;
- p_tle->p_next = p_temp;
- }
- p_temp->ticks -= p_tle->ticks;
- }
-
- p_tle->in_use = true;
-
- /* if we already add this timer queue to the array */
- for (tt = 0; tt < GKI_MAX_TIMER_QUEUES; tt++) {
- if (gki_cb.com.timer_queues[tt] == p_timer_listq) return;
- }
- /* add this timer queue to the array */
- for (tt = 0; tt < GKI_MAX_TIMER_QUEUES; tt++) {
- if (gki_cb.com.timer_queues[tt] == NULL) break;
- }
- if (tt < GKI_MAX_TIMER_QUEUES) {
- gki_cb.com.timer_queues[tt] = p_timer_listq;
- }
- }
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_remove_from_timer_list
-**
-** Description This function is called by an application to remove a timer
-** entry from a timer list.
-**
-** Parameters p_timer_listq - (input) pointer to the timer list queue
-** object
-** p_tle - (input) pointer to a timer list queue entry
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_remove_from_timer_list(TIMER_LIST_Q* p_timer_listq,
- TIMER_LIST_ENT* p_tle) {
- uint8_t tt;
-
- /* Verify that the entry is valid */
- if (p_tle == NULL || p_tle->in_use == false ||
- p_timer_listq->p_first == NULL) {
- return;
- }
-
- /* Add the ticks remaining in this timer (if any) to the next guy in the list.
- ** Note: Expired timers have a tick value of '0'.
- */
- if (p_tle->p_next != NULL) {
- p_tle->p_next->ticks += p_tle->ticks;
- } else {
- p_timer_listq->last_ticks -= p_tle->ticks;
- }
-
- /* Unlink timer from the list.
- */
- if (p_timer_listq->p_first == p_tle) {
- p_timer_listq->p_first = p_tle->p_next;
-
- if (p_timer_listq->p_first != NULL) p_timer_listq->p_first->p_prev = NULL;
-
- if (p_timer_listq->p_last == p_tle) p_timer_listq->p_last = NULL;
- } else {
- if (p_timer_listq->p_last == p_tle) {
- p_timer_listq->p_last = p_tle->p_prev;
-
- if (p_timer_listq->p_last != NULL) p_timer_listq->p_last->p_next = NULL;
- } else {
- if (p_tle->p_next != NULL && p_tle->p_next->p_prev == p_tle)
- p_tle->p_next->p_prev = p_tle->p_prev;
- else {
- /* Error case - chain messed up ?? */
- return;
- }
-
- if (p_tle->p_prev != NULL && p_tle->p_prev->p_next == p_tle)
- p_tle->p_prev->p_next = p_tle->p_next;
- else {
- /* Error case - chain messed up ?? */
- return;
- }
- }
- }
-
- p_tle->p_next = p_tle->p_prev = NULL;
- p_tle->ticks = GKI_UNUSED_LIST_ENTRY;
- p_tle->in_use = false;
-
- /* if timer queue is empty */
- if (p_timer_listq->p_first == NULL && p_timer_listq->p_last == NULL) {
- for (tt = 0; tt < GKI_MAX_TIMER_QUEUES; tt++) {
- if (gki_cb.com.timer_queues[tt] == p_timer_listq) {
- gki_cb.com.timer_queues[tt] = NULL;
- break;
- }
- }
- }
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_gki_adjust_timer_count
-**
-** Description This function is called whenever a new timer or GKI_wait
-** occurs to adjust (if necessary) the current time til the
-** first expiration. This only needs to make an adjustment if
-** the new timer (in ticks) is less than the number of ticks
-** remaining on the current timer.
-**
-** Parameters: ticks - (input) number of system ticks of the new timer
-** entry
-**
-** NOTE: This routine MUST be called while interrupts are
-** disabled to avoid updates while adjusting the timer
-** variables.
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_gki_adjust_timer_count(int32_t ticks) {
- if (ticks > 0) {
- /* See if the new timer expires before the current first expiration */
- if (gki_cb.com.OSNumOrigTicks == 0 ||
- (ticks < gki_cb.com.OSTicksTilExp && gki_cb.com.OSTicksTilExp > 0)) {
- gki_cb.com.OSNumOrigTicks =
- (gki_cb.com.OSNumOrigTicks - gki_cb.com.OSTicksTilExp) + ticks;
- gki_cb.com.OSTicksTilExp = ticks;
- }
- }
-
- return;
-}
diff --git a/src/gki/ulinux/data_types.h b/src/gki/ulinux/data_types.h
deleted file mode 100755
index bbc478f..0000000
--- a/src/gki/ulinux/data_types.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#ifndef DATA_TYPES_H
-#define DATA_TYPES_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#ifndef false
-#define false 0
-#endif
-
-#ifndef true
-#define true (!false)
-#endif
-#ifndef NULL
-#define NULL 0
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-#ifdef __arm
-#define PACKED __packed
-#define INLINE __inline
-#else
-#define PACKED
-#define INLINE
-#endif
-
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN FALSE
-#endif
-
-#endif
diff --git a/src/gki/ulinux/uwb_gki_int.h b/src/gki/ulinux/uwb_gki_int.h
deleted file mode 100755
index 9915ae0..0000000
--- a/src/gki/ulinux/uwb_gki_int.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#ifndef UWB_GKI_INT_H
-#define UWB_GKI_INT_H
-
-#include <pthread.h>
-
-#include "uwb_gki_common.h"
-
-/**********************************************************************
-** OS specific definitions
-*/
-#ifdef ANDROID
-#include <sys/times.h>
-#endif
-
-typedef struct {
- pthread_mutex_t GKI_mutex;
- pthread_t thread_id[GKI_MAX_TASKS];
- pthread_mutex_t thread_evt_mutex[GKI_MAX_TASKS];
- pthread_cond_t thread_evt_cond[GKI_MAX_TASKS];
- pthread_mutex_t thread_timeout_mutex[GKI_MAX_TASKS];
- pthread_cond_t thread_timeout_cond[GKI_MAX_TASKS];
- int no_timer_suspend; /* 1: no suspend, 0 stop calling GKI_timer_update() */
- pthread_mutex_t gki_timer_mutex;
- pthread_cond_t gki_timer_cond;
- int gki_timer_wake_lock_on;
-} tGKI_OS;
-
-/* condition to exit or continue GKI_run() timer loop */
-#define GKI_TIMER_TICK_RUN_COND 1
-#define GKI_TIMER_TICK_STOP_COND 0
-#define GKI_TIMER_TICK_EXIT_COND 2
-
-extern void phUwb_gki_system_tick_start_stop_cback(bool start);
-
-/* Contains common control block as well as OS specific variables */
-typedef struct {
- tGKI_OS os;
- tGKI_COM_CB com;
-} tGKI_CB;
-
-extern tGKI_CB gki_cb;
-
-#endif
diff --git a/src/gki/ulinux/uwb_gki_ulinux.cc b/src/gki/ulinux/uwb_gki_ulinux.cc
deleted file mode 100755
index 084ca07..0000000
--- a/src/gki/ulinux/uwb_gki_ulinux.cc
+++ /dev/null
@@ -1,759 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2019,2022 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#include <errno.h>
-#include <malloc.h>
-#include <pthread.h> /* must be 1st header defined */
-
-#include "uci_log.h"
-#include "uwb_gki_int.h"
-
-/* Temp android logging...move to android tgt config file */
-
-#ifndef LINUX_NATIVE
-#else
-#define LOGV(format, ...) fprintf(stdout, LOG_TAG format, ##__VA_ARGS__)
-#define LOGE(format, ...) fprintf(stderr, LOG_TAG format, ##__VA_ARGS__)
-#define LOGI(format, ...) fprintf(stdout, LOG_TAG format, ##__VA_ARGS__)
-
-#define SCHED_NORMAL 0
-#define SCHED_FIFO 1
-#define SCHED_RR 2
-#define SCHED_BATCH 3
-
-#endif
-
-/* Define the structure that holds the GKI variables
- */
-tGKI_CB gki_cb;
-
-#define NANOSEC_PER_MILLISEC (1000000)
-#define NSEC_PER_SEC (1000 * NANOSEC_PER_MILLISEC)
-
-/* works only for 1ms to 1000ms heart beat ranges */
-#define LINUX_SEC (1000 / TICKS_PER_SEC)
-// #define GKI_TICK_TIMER_DEBUG
-
-/* this kind of mutex go into tGKI_OS control block!!!! */
-/* static pthread_mutex_t GKI_sched_mutex; */
-/*static pthread_mutex_t thread_delay_mutex;
-static pthread_cond_t thread_delay_cond;
-static pthread_mutex_t gki_timer_update_mutex;
-static pthread_cond_t gki_timer_update_cond;
-*/
-
-typedef struct {
- uint8_t task_id; /* GKI task id */
- TASKPTR task_entry; /* Task entry function*/
- uint32_t params; /* Extra params to pass to task entry function */
- pthread_cond_t* pCond; /* for android*/
- pthread_mutex_t* pMutex; /* for android*/
-} gki_pthread_info_t;
-gki_pthread_info_t gki_pthread_info[GKI_MAX_TASKS];
-
-/*******************************************************************************
-**
-** Function phUwb_gki_task_entry
-**
-** Description entry point of GKI created tasks
-**
-** Returns void
-**
-*******************************************************************************/
-void* phUwb_gki_task_entry(void* params) {
- pthread_t thread_id = pthread_self();
- gki_pthread_info_t* p_pthread_info = (gki_pthread_info_t*)params;
- UCI_TRACE_I(
- "gki_task_entry task_id=%i, thread_id=%lx/%lx, pCond/pMutex=%p/%p",
- p_pthread_info->task_id, gki_cb.os.thread_id[p_pthread_info->task_id],
- pthread_self(), p_pthread_info->pCond, p_pthread_info->pMutex);
-
- gki_cb.os.thread_id[p_pthread_info->task_id] = thread_id;
- /* Call the actual thread entry point */
- (p_pthread_info->task_entry)(p_pthread_info->params);
-
- UCI_TRACE_E("gki_task task_id=%i terminating", p_pthread_info->task_id);
- gki_cb.os.thread_id[p_pthread_info->task_id] = 0;
-
- return NULL;
-}
-/* end android */
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_init
-**
-** Description This function is called once at startup to initialize
-** all the timer structures.
-**
-** Returns void
-**
-*******************************************************************************/
-
-void phUwb_GKI_init(void) {
- pthread_mutexattr_t attr;
- tGKI_OS* p_os;
-
- memset(&gki_cb, 0, sizeof(gki_cb));
-
- phUwb_gki_buffer_init();
- phUwb_gki_timers_init();
- gki_cb.com.OSTicks = (uint32_t)times(0);
-
- pthread_mutexattr_init(&attr);
- p_os = &gki_cb.os;
- pthread_mutex_init(&p_os->GKI_mutex, &attr);
- /* pthread_mutex_init(&GKI_sched_mutex, NULL); */
- /* pthread_mutex_init(&thread_delay_mutex, NULL); */ /* used in GKI_delay */
- /* pthread_cond_init (&thread_delay_cond, NULL); */
-
- /* Initialiase GKI_timer_update suspend variables & mutexes to be in running
- * state.
- * this works too even if GKI_NO_TICK_STOP is defined in btld.txt */
- p_os->no_timer_suspend = GKI_TIMER_TICK_RUN_COND;
- pthread_mutex_init(&p_os->gki_timer_mutex, NULL);
- pthread_cond_init(&p_os->gki_timer_cond, NULL);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_create_task
-**
-** Description This function is called to create a new OSS task.
-**
-** Parameters: task_entry - (input) pointer to the entry function of the
-** task
-** task_id - (input) Task id is mapped to priority
-** taskname - (input) name given to the task
-** stack - (input) pointer to the top of the stack
-** (highest memory location)
-** stacksize - (input) size of the stack allocated for the
-** task
-**
-** Returns GKI_SUCCESS if all OK, GKI_FAILURE if any problem
-**
-** NOTE This function take some parameters that may not be needed
-** by your particular OS. They are here for compatability
-** of the function prototype.
-**
-*******************************************************************************/
-uint8_t phUwb_GKI_create_task(TASKPTR task_entry, uint8_t task_id,
- int8_t* taskname, uint16_t* stack,
- uint16_t stacksize, void* pCondVar,
- void* pMutex) {
- struct sched_param param;
- int policy, ret = 0;
- pthread_condattr_t attr;
- pthread_attr_t attr1;
-
- pthread_condattr_init(&attr);
- pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
- UCI_TRACE_I(
- "GKI_create_task func=0x%p id=%d name=%s stack=0x%p stackSize=%d",
- task_entry, task_id, taskname, stack, stacksize);
-
- if (task_id >= GKI_MAX_TASKS) {
- UCI_TRACE_I("Error! task ID > max task allowed");
- return (GKI_FAILURE);
- }
-
- gki_cb.com.OSRdyTbl[task_id] = TASK_READY;
- gki_cb.com.OSTName[task_id] = taskname;
- gki_cb.com.OSWaitTmr[task_id] = 0;
- gki_cb.com.OSWaitEvt[task_id] = 0;
-
- /* Initialize mutex and condition variable objects for events and timeouts */
- pthread_mutex_init(&gki_cb.os.thread_evt_mutex[task_id], NULL);
- pthread_cond_init(&gki_cb.os.thread_evt_cond[task_id], &attr);
- pthread_mutex_init(&gki_cb.os.thread_timeout_mutex[task_id], NULL);
- pthread_cond_init(&gki_cb.os.thread_timeout_cond[task_id], &attr);
-
- pthread_attr_init(&attr1);
-/* by default, pthread creates a joinable thread */
-#if (FALSE == GKI_PTHREAD_JOINABLE)
- pthread_attr_setdetachstate(&attr1, PTHREAD_CREATE_DETACHED);
-
- UCI_TRACE_I("GKI creating task %i, pCond/pMutex=%p/%p", task_id, pCondVar,
- pMutex);
-#else
- UCI_TRACE_I("GKI creating JOINABLE task %i", task_id);
-#endif
-
- /* On Android, the new tasks starts running before
- * 'gki_cb.os.thread_id[task_id]' is initialized */
- /* Pass task_id to new task so it can initialize gki_cb.os.thread_id[task_id]
- * for it calls GKI_wait */
- gki_pthread_info[task_id].task_id = task_id;
- gki_pthread_info[task_id].task_entry = task_entry;
- gki_pthread_info[task_id].params = 0;
- gki_pthread_info[task_id].pCond = (pthread_cond_t*)pCondVar;
- gki_pthread_info[task_id].pMutex = (pthread_mutex_t*)pMutex;
-
- ret = pthread_create(&gki_cb.os.thread_id[task_id], &attr1,
- phUwb_gki_task_entry, &gki_pthread_info[task_id]);
-
- if (ret != 0) {
- UCI_TRACE_I("pthread_create failed(%d), %s!", ret, taskname);
- return GKI_FAILURE;
- }
-
- if (pthread_getschedparam(gki_cb.os.thread_id[task_id], &policy, ¶m) ==
- 0) {
- {
- policy = SCHED_RR;
- param.sched_priority = 30 - task_id - 2;
- }
- pthread_setschedparam(gki_cb.os.thread_id[task_id], policy, ¶m);
- }
-
- UCI_TRACE_I("Leaving GKI_create_task %p %d %lx %s %p %d", task_entry, task_id,
- gki_cb.os.thread_id[task_id], taskname, stack, stacksize);
-
- return (GKI_SUCCESS);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_shutdown
-**
-** Description shutdowns the GKI tasks/threads in from max task id to 0 and
-** frees pthread resources!
-** IMPORTANT: in case of join method, GKI_shutdown must be
-** called outside a GKI thread context!
-**
-** Returns void
-**
-*******************************************************************************/
-#define WAKE_LOCK_ID "brcm_uwba"
-#define PARTIAL_WAKE_LOCK 1
-extern "C" int acquire_wake_lock(int lock, const char* id);
-extern "C" int release_wake_lock(const char* id);
-
-void phUwb_GKI_shutdown(void) {
- uint8_t task_id;
- volatile int* p_run_cond = &gki_cb.os.no_timer_suspend;
- int oldCOnd = 0;
-#if (FALSE != GKI_PTHREAD_JOINABLE)
- int result;
-#endif
-
- /* release threads and set as TASK_DEAD. going from low to high priority fixes
- * GKI_exception problem due to btu->hci sleep request events */
- for (task_id = GKI_MAX_TASKS; task_id > 0; task_id--) {
- if (gki_cb.com.OSRdyTbl[task_id - 1] != TASK_DEAD) {
- gki_cb.com.OSRdyTbl[task_id - 1] = TASK_DEAD;
-
- /* paranoi settings, make sure that we do not execute any mailbox events
- */
- gki_cb.com.OSWaitEvt[task_id - 1] &=
- ~(TASK_MBOX_0_EVT_MASK | TASK_MBOX_1_EVT_MASK | TASK_MBOX_2_EVT_MASK |
- TASK_MBOX_3_EVT_MASK);
- phUwb_GKI_send_event(task_id - 1, EVENT_MASK(GKI_SHUTDOWN_EVT));
-
-#if (FALSE == GKI_PTHREAD_JOINABLE)
- int i = 0;
- if((task_id - 1) != BTU_TASK) {
- while ((gki_cb.com.OSWaitEvt[task_id - 1] != 0) && (++i < 10))
- usleep(50 * 1000);
- } else {
- usleep(50 * 1000);
- UCI_TRACE_D("%s: Wait not needed for UWBA_TASK with task id %d", __func__,(task_id - 1));
- }
-#else
- /* wait for proper Arnold Schwarzenegger task state */
- result = pthread_join(gki_cb.os.thread_id[task_id - 1], NULL);
- if (result < 0) {
- UCI_TRACE_I("FAILED: result: %d", result);
- }
-#endif
- UCI_TRACE_I("task %s dead", gki_cb.com.OSTName[task_id - 1]);
- phUwb_GKI_exit_task(task_id - 1);
- }
- }
-/* pthread_mutex_destroy(&GKI_sched_mutex); */
-/* pthread_mutex_destroy(&thread_delay_mutex);
- pthread_cond_destroy (&thread_delay_cond); */
- if (gki_cb.os.gki_timer_wake_lock_on) {
- UCI_TRACE_I("GKI_shutdown : release_wake_lock(brcm_btld)");
- release_wake_lock(WAKE_LOCK_ID);
- gki_cb.os.gki_timer_wake_lock_on = 0;
- }
- oldCOnd = *p_run_cond;
- *p_run_cond = GKI_TIMER_TICK_EXIT_COND;
- if (oldCOnd == GKI_TIMER_TICK_STOP_COND)
- pthread_cond_signal(&gki_cb.os.gki_timer_cond);
- /* Destroy mutex and condition variable objects */
- pthread_mutex_destroy(&gki_cb.os.GKI_mutex);
-}
-
-/*******************************************************************************
- **
- ** Function phUwb_GKI_run
- **
- ** Description This function runs a task
- **
- ** Parameters: start: TRUE start system tick (again), FALSE stop
- **
- ** Returns void
- **
- ******************************************************************************/
-void phUwb_gki_system_tick_start_stop_cback(bool start) {
- tGKI_OS* p_os = &gki_cb.os;
- volatile int* p_run_cond = &p_os->no_timer_suspend;
-#ifdef GKI_TICK_TIMER_DEBUG
- static volatile int wake_lock_count;
-#endif
- if (start == false) {
- /* this can lead to a race condition. however as we only read this variable
- * in the timer loop
- * we should be fine with this approach. otherwise uncomment below mutexes.
- */
- /* GKI_disable(); */
- *p_run_cond = GKI_TIMER_TICK_STOP_COND;
-/* GKI_enable(); */
-#ifdef GKI_TICK_TIMER_DEBUG
- UCI_TRACE_I(">>> STOP wake_lock_count:%d", --wake_lock_count);
-#endif
- release_wake_lock(WAKE_LOCK_ID);
- gki_cb.os.gki_timer_wake_lock_on = 0;
- } else {
- /* restart GKI_timer_update() loop */
- acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
- gki_cb.os.gki_timer_wake_lock_on = 1;
- *p_run_cond = GKI_TIMER_TICK_RUN_COND;
- pthread_mutex_lock(&p_os->gki_timer_mutex);
- pthread_cond_signal(&p_os->gki_timer_cond);
- pthread_mutex_unlock(&p_os->gki_timer_mutex);
-
-#ifdef GKI_TICK_TIMER_DEBUG
- UCI_TRACE_I(">>> START wake_lock_count:%d", ++wake_lock_count);
-#endif
- }
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_run
-**
-** Description This function runs a task
-**
-** Parameters: p_task_id - (input) pointer to task id
-**
-** Returns void
-**
-** NOTE This function is only needed for operating systems where
-** starting a task is a 2-step process. Most OS's do it in
-** one step, If your OS does it in one step, this function
-** should be empty.
-*******************************************************************************/
-void phUwb_GKI_run(__attribute__((unused)) void* p_task_id) {
- UCI_TRACE_I("%s enter", __func__);
- struct timespec delay;
- int err = 0;
- volatile int* p_run_cond = &gki_cb.os.no_timer_suspend;
-
-#ifndef GKI_NO_TICK_STOP
- /* register start stop function which disable timer loop in GKI_run() when no
- * timers are
- * in any GKI/BTA/BTU this should save power when BTLD is idle! */
- phUwb_GKI_timer_queue_register_callback(
- phUwb_gki_system_tick_start_stop_cback);
- UCI_TRACE_I("Start/Stop GKI_timer_update_registered!");
-#endif
- UCI_TRACE_I("GKI_run, run_cond(%p)=%d ", p_run_cond, *p_run_cond);
- for (; GKI_TIMER_TICK_EXIT_COND != *p_run_cond;) {
- do {
- /* adjust hear bit tick in btld by changning TICKS_PER_SEC!!!!! this
- * formula works only for
- * 1-1000ms heart beat units! */
- delay.tv_sec = LINUX_SEC / 1000;
- delay.tv_nsec = 1000 * 1000 * (LINUX_SEC % 1000);
-
- /* [u]sleep can't be used because it uses SIGALRM */
- do {
- err = nanosleep(&delay, &delay);
- } while (err < 0 && errno == EINTR);
-
- if (GKI_TIMER_TICK_RUN_COND != *p_run_cond) break; // GKI has shutdown
-
- /* the unit should be alsways 1 (1 tick). only if you vary for some reason
- * heart beat tick
- * e.g. power saving you may want to provide more ticks
- */
- phUwb_GKI_timer_update(1);
- } while (GKI_TIMER_TICK_RUN_COND == *p_run_cond);
-
-/* currently on reason to exit above loop is no_timer_suspend ==
- * GKI_TIMER_TICK_STOP_COND
- * block timer main thread till re-armed by */
-#ifdef GKI_TICK_TIMER_DEBUG
- UCI_TRACE_I(">>> SUSPENDED");
-#endif
- if (GKI_TIMER_TICK_EXIT_COND != *p_run_cond) {
- pthread_mutex_lock(&gki_cb.os.gki_timer_mutex);
- pthread_cond_wait(&gki_cb.os.gki_timer_cond, &gki_cb.os.gki_timer_mutex);
- pthread_mutex_unlock(&gki_cb.os.gki_timer_mutex);
- }
- /* potentially we need to adjust os gki_cb.com.OSTicks */
-
-#ifdef GKI_TICK_TIMER_DEBUG
- UCI_TRACE_I(">>> RESTARTED run_cond: %d", *p_run_cond);
-#endif
- } /* for */
- UCI_TRACE_I("%s exit", __func__);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_wait
-**
-** Description This function is called by tasks to wait for a specific
-** event or set of events. The task may specify the duration
-** that it wants to wait for, or 0 if infinite.
-**
-** Parameters: flag - (input) the event or set of events to wait for
-** timeout - (input) the duration that the task wants to wait
-** for the specific events (in system ticks)
-**
-**
-** Returns the event mask of received events or zero if timeout
-**
-*******************************************************************************/
-uint16_t phUwb_GKI_wait(uint16_t flag, uint32_t timeout) {
- uint16_t evt;
- uint8_t rtask;
- struct timespec abstime = {0, 0};
- int sec;
- int nano_sec;
-
- rtask = phUwb_GKI_get_taskid();
- if (rtask >= GKI_MAX_TASKS) {
- UCI_TRACE_E("%s() Exiting thread; rtask %d >= %d", __func__, rtask,
- GKI_MAX_TASKS);
- return EVENT_MASK(GKI_SHUTDOWN_EVT);
- }
-
- gki_pthread_info_t* p_pthread_info = &gki_pthread_info[rtask];
- if (p_pthread_info->pCond != NULL && p_pthread_info->pMutex != NULL) {
- int ret;
- UCI_TRACE_I("GKI_wait task=%i, pCond/pMutex = %p/%p", rtask,
- p_pthread_info->pCond, p_pthread_info->pMutex);
- ret = pthread_mutex_lock(p_pthread_info->pMutex);
- ret = pthread_cond_signal(p_pthread_info->pCond);
- ret = pthread_mutex_unlock(p_pthread_info->pMutex);
- p_pthread_info->pMutex = NULL;
- p_pthread_info->pCond = NULL;
- }
- gki_cb.com.OSWaitForEvt[rtask] = flag;
-
- /* protect OSWaitEvt[rtask] from modification from an other thread */
- pthread_mutex_lock(&gki_cb.os.thread_evt_mutex[rtask]);
-
- if (!(gki_cb.com.OSWaitEvt[rtask] & flag)) {
- if (timeout) {
- if (clock_gettime(CLOCK_MONOTONIC, &abstime) == -1) {
- UCI_TRACE_E("phUwb_GKI_wait: fail get time");
- } else {
- /* add timeout */
- sec = timeout / 1000;
- nano_sec = (timeout % 1000) * NANOSEC_PER_MILLISEC;
- abstime.tv_nsec += nano_sec;
- if (abstime.tv_nsec > NSEC_PER_SEC) {
- abstime.tv_sec += (abstime.tv_nsec / NSEC_PER_SEC);
- abstime.tv_nsec = abstime.tv_nsec % NSEC_PER_SEC;
- }
- abstime.tv_sec += sec;
- }
-
- int waitResult =
- pthread_cond_timedwait(&gki_cb.os.thread_evt_cond[rtask],
- &gki_cb.os.thread_evt_mutex[rtask], &abstime);
- if ((waitResult != 0) && (waitResult != ETIMEDOUT))
- UCI_TRACE_E("phUwb_GKI_wait::wait: fail timed wait; error=0x%X",
- waitResult);
-
- } else {
- pthread_cond_wait(&gki_cb.os.thread_evt_cond[rtask],
- &gki_cb.os.thread_evt_mutex[rtask]);
- }
-
- /* TODO: check, this is probably neither not needed depending on
- phtread_cond_wait() implmentation,
- e.g. it looks like it is implemented as a counter in which case multiple
- cond_signal
- should NOT be lost! */
- // we are waking up after waiting for some events, so refresh variables
- // no need to call GKI_disable() here as we know that we will have some
- // events as we've been waking up after condition pending or timeout
- if (gki_cb.com.OSTaskQFirst[rtask][0])
- gki_cb.com.OSWaitEvt[rtask] |= TASK_MBOX_0_EVT_MASK;
- if (gki_cb.com.OSTaskQFirst[rtask][1])
- gki_cb.com.OSWaitEvt[rtask] |= TASK_MBOX_1_EVT_MASK;
- if (gki_cb.com.OSTaskQFirst[rtask][2])
- gki_cb.com.OSWaitEvt[rtask] |= TASK_MBOX_2_EVT_MASK;
- if (gki_cb.com.OSTaskQFirst[rtask][3])
- gki_cb.com.OSWaitEvt[rtask] |= TASK_MBOX_3_EVT_MASK;
-
- if (gki_cb.com.OSRdyTbl[rtask] == TASK_DEAD) {
- gki_cb.com.OSWaitEvt[rtask] = 0;
- /* unlock thread_evt_mutex as pthread_cond_wait() does auto lock when cond
- * is met */
- pthread_mutex_unlock(&gki_cb.os.thread_evt_mutex[rtask]);
- UCI_TRACE_E("GKI TASK_DEAD received. exit thread %d...", rtask);
-
- gki_cb.os.thread_id[rtask] = 0;
- return (EVENT_MASK(GKI_SHUTDOWN_EVT));
- }
- }
-
- /* Clear the wait for event mask */
- gki_cb.com.OSWaitForEvt[rtask] = 0;
-
- /* Return only those bits which user wants... */
- evt = gki_cb.com.OSWaitEvt[rtask] & flag;
-
- /* Clear only those bits which user wants... */
- gki_cb.com.OSWaitEvt[rtask] &= ~flag;
-
- /* unlock thread_evt_mutex as pthread_cond_wait() does auto lock mutex when
- * cond is met */
- pthread_mutex_unlock(&gki_cb.os.thread_evt_mutex[rtask]);
- return (evt);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_send_event
-**
-** Description This function is called by tasks to send events to other
-** tasks. Tasks can also send events to themselves.
-**
-** Parameters: task_id - (input) The id of the task to which the event has
-** to be sent
-** event - (input) The event that has to be sent
-**
-**
-** Returns GKI_SUCCESS if all OK, else GKI_FAILURE
-**
-*******************************************************************************/
-uint8_t phUwb_GKI_send_event(uint8_t task_id, uint16_t event) {
- /* use efficient coding to avoid pipeline stalls */
- if (task_id < GKI_MAX_TASKS) {
- /* protect OSWaitEvt[task_id] from manipulation in GKI_wait() */
- pthread_mutex_lock(&gki_cb.os.thread_evt_mutex[task_id]);
-
- /* Set the event bit */
- gki_cb.com.OSWaitEvt[task_id] |= event;
-
- pthread_cond_signal(&gki_cb.os.thread_evt_cond[task_id]);
-
- pthread_mutex_unlock(&gki_cb.os.thread_evt_mutex[task_id]);
-
- return (GKI_SUCCESS);
- }
- return (GKI_FAILURE);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_isend_event
-**
-** Description This function is called from ISRs to send events to other
-** tasks. The only difference between this function and
-** GKI_send_event is that this function assumes interrupts are
-** already disabled.
-**
-** Parameters: task_id - (input) The destination task Id for the event.
-** event - (input) The event flag
-**
-** Returns GKI_SUCCESS if all OK, else GKI_FAILURE
-**
-** NOTE This function is NOT called by the Widcomm stack and
-** profiles. If you want to use it in your own implementation,
-** put your code here, otherwise you can delete the entire
-** body of the function.
-**
-*******************************************************************************/
-uint8_t phUwb_GKI_isend_event(uint8_t task_id, uint16_t event) {
- UCI_TRACE_I("GKI_isend_event %d %x", task_id, event);
- UCI_TRACE_I("GKI_isend_event %d %x done", task_id, event);
- return phUwb_GKI_send_event(task_id, event);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_get_taskid
-**
-** Description This function gets the currently running task ID.
-**
-** Returns task ID
-**
-** NOTE The Widcomm upper stack and profiles may run as a single
-** task. If you only have one GKI task, then you can hard-code
-** this function to return a '1'. Otherwise, you should have
-** some OS-specific method to determine the current task.
-**
-*******************************************************************************/
-uint8_t phUwb_GKI_get_taskid(void) {
- uint8_t i;
- pthread_t thread_id = pthread_self();
- for (i = 0; i < GKI_MAX_TASKS; i++) {
- if (gki_cb.os.thread_id[i] == thread_id) {
- return (i);
- }
- }
- return (0xFF);
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_enable
-**
-** Description This function enables interrupts.
-**
-** Returns void
-**
-*******************************************************************************/
-void phUwb_GKI_enable(void) {
- pthread_mutex_unlock(&gki_cb.os.GKI_mutex);
- /* pthread_mutex_xx is nesting save, no need for this: already_disabled =
- * 0; */
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_disable
-**
-** Description This function disables interrupts.
-**
-** Returns void
-**
-*******************************************************************************/
-
-void phUwb_GKI_disable(void) {
- pthread_mutex_lock(&gki_cb.os.GKI_mutex);
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_exception
-**
-** Description This function throws an exception.
-** This is normally only called for a nonrecoverable error.
-**
-** Parameters: code - (input) The code for the error
-** msg - (input) The message that has to be logged
-**
-** Returns void
-**
-*******************************************************************************/
-
-void phUwb_GKI_exception(uint16_t code, std::string msg) {
- uint8_t task_id;
-
- UCI_TRACE_E("Task State Table");
-
- for (task_id = 0; task_id < GKI_MAX_TASKS; task_id++) {
- UCI_TRACE_E("TASK ID [%d] task name [%s] state [%d]", task_id,
- gki_cb.com.OSTName[task_id], gki_cb.com.OSRdyTbl[task_id]);
- }
-
- UCI_TRACE_E("%d %s", code, msg.c_str());
- UCI_TRACE_E(
- "********************************************************************");
- UCI_TRACE_E("* %d %s", code, msg.c_str());
- UCI_TRACE_E(
- "********************************************************************");
-
- UCI_TRACE_E("%d %s done", code, msg.c_str());
-
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_os_malloc
-**
-** Description This function allocates memory
-**
-** Parameters: size - (input) The size of the memory that has to be
-** allocated
-**
-** Returns the address of the memory allocated, or NULL if failed
-**
-** NOTE This function is called by the Widcomm stack when
-** dynamic memory allocation is used.
-**
-*******************************************************************************/
-void* phUwb_GKI_os_malloc(uint32_t size) { return (malloc(size)); }
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_os_free
-**
-** Description This function frees memory
-**
-** Parameters: size - (input) The address of the memory that has to be
-** freed
-**
-** Returns void
-**
-** NOTE This function is NOT called by the Widcomm stack and
-** profiles. It is only called from within GKI if dynamic
-**
-*******************************************************************************/
-void phUwb_GKI_os_free(void* p_mem) {
- if (p_mem != NULL) free(p_mem);
- return;
-}
-
-/*******************************************************************************
-**
-** Function phUwb_GKI_exit_task
-**
-** Description This function is called to stop a GKI task.
-**
-** Parameters: task_id - (input) the id of the task that has to be stopped
-**
-** Returns void
-**
-** NOTE This function is NOT called by the Widcomm stack and
-** profiles. If you want to use it in your own implementation,
-** put specific code here to kill a task.
-**
-*******************************************************************************/
-void phUwb_GKI_exit_task(uint8_t task_id) {
- if (task_id >= GKI_MAX_TASKS) {
- return;
- }
- phUwb_GKI_disable();
- gki_cb.com.OSRdyTbl[task_id] = TASK_DEAD;
-
- /* Destroy mutex and condition variable objects */
- pthread_mutex_destroy(&gki_cb.os.thread_evt_mutex[task_id]);
- pthread_cond_destroy(&gki_cb.os.thread_evt_cond[task_id]);
- pthread_mutex_destroy(&gki_cb.os.thread_timeout_mutex[task_id]);
- pthread_cond_destroy(&gki_cb.os.thread_timeout_cond[task_id]);
-
- phUwb_GKI_enable();
-
- UCI_TRACE_I("GKI_exit_task %d done", task_id);
- return;
-}
diff --git a/src/include/UwbAdaptation.h b/src/include/UwbAdaptation.h
deleted file mode 100755
index 0b65baf..0000000
--- a/src/include/UwbAdaptation.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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 <pthread.h>
-#include <utils/RefBase.h>
-
-#include "config.h"
-#include "hal_uwb.h"
-#include "uwb_hal_api.h"
-#include "uwb_hal_int.h"
-#include "uwb_target.h"
-
-class ThreadMutex {
- public:
- ThreadMutex();
- virtual ~ThreadMutex();
- void lock();
- void unlock();
- operator pthread_mutex_t*() { return &mMutex; }
-
- private:
- pthread_mutex_t mMutex;
-};
-
-class ThreadCondVar : public ThreadMutex {
- public:
- ThreadCondVar();
- virtual ~ThreadCondVar();
- void signal();
- void wait();
- operator pthread_cond_t*() { return &mCondVar; }
- operator pthread_mutex_t*() {
- return ThreadMutex::operator pthread_mutex_t*();
- }
-
- private:
- pthread_cond_t mCondVar;
-};
-
-class AutoThreadMutex {
- public:
- AutoThreadMutex(ThreadMutex& m);
- virtual ~AutoThreadMutex();
- operator ThreadMutex&() { return mm; }
- operator pthread_mutex_t*() { return (pthread_mutex_t*)mm; }
-
- private:
- ThreadMutex& mm;
-};
-
-class UwbAdaptation {
- public:
- virtual ~UwbAdaptation();
- void Initialize();
- void Finalize(bool graceExit);
- static UwbAdaptation& GetInstance();
- tHAL_UWB_ENTRY* GetHalEntryFuncs();
- static tUWB_STATUS CoreInitialization();
- static tUWB_STATUS SessionInitialization(int sessionId);
-
- private:
- UwbAdaptation();
- void signal();
- static UwbAdaptation* mpInstance;
- static ThreadMutex sLock;
- static ThreadMutex sIoctlLock;
- ThreadCondVar mCondVar;
- tHAL_UWB_ENTRY mHalEntryFuncs; // function pointers for HAL entry points
-
- static tHAL_UWB_CBACK* mHalCallback;
- static tHAL_UWB_DATA_CBACK* mHalDataCallback;
-
- static uint32_t UWBA_TASK(uint32_t arg);
- static uint32_t Thread(uint32_t arg);
- void InitializeHalDeviceContext();
- static void HalOpen(tHAL_UWB_CBACK* p_hal_cback,
- tHAL_UWB_DATA_CBACK* p_data_cback);
- static void HalClose();
- static void HalWrite(uint16_t data_len, uint8_t* p_data);
-};
diff --git a/src/include/config.h b/src/include/config.h
deleted file mode 100755
index 1c852f4..0000000
--- a/src/include/config.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2017 The Android Open Source Project
- * Copyright 2018-2019 NXP
- *
- * 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 <map>
-#include <string>
-#include <vector>
-
-class ConfigValue {
- public:
- enum Type { UNSIGNED, STRING, BYTES };
-
- ConfigValue();
- ConfigValue(std::string);
- ConfigValue(unsigned);
- ConfigValue(std::vector<uint8_t>);
- Type getType() const;
- std::string getString() const;
- unsigned getUnsigned() const;
- std::vector<uint8_t> getBytes() const;
-
- bool parseFromString(std::string in);
-
- private:
- Type type_;
- std::string value_string_;
- unsigned value_unsigned_;
- std::vector<uint8_t> value_bytes_;
-};
-
-class ConfigFile {
- public:
- void parseFromFile(const std::string& file_name);
- void parseFromString(const std::string& config);
- void addConfig(const std::string& config, ConfigValue& value);
-
- bool hasKey(const std::string& key);
- std::string getString(const std::string& key);
- unsigned getUnsigned(const std::string& key);
- std::vector<uint8_t> getBytes(const std::string& key);
-
- bool isEmpty();
- void clear();
-
- private:
- ConfigValue& getValue(const std::string& key);
-
- std::map<std::string, ConfigValue> values_;
-};
diff --git a/src/include/hal_uwb.h b/src/include/hal_uwb.h
deleted file mode 100755
index 5d098a5..0000000
--- a/src/include/hal_uwb.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/******************************************************************************
- *
- * Copyright 2018-2020 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#ifndef ANDROID_HARDWARE_HAL_NXPUWB_V1_0_H
-#define ANDROID_HARDWARE_HAL_NXPUWB_V1_0_H
-#include <string>
-#include <vector>
-
-enum {
- HAL_UWB_STATUS_OK = 0x00,
- HAL_UWB_STATUS_ERR_TRANSPORT = 0x01,
- HAL_UWB_STATUS_ERR_CMD_TIMEOUT = 0x02
-};
-
-enum NxpUwbHalStatus {
- /** In case of an error, HCI network needs to be re-initialized */
- HAL_STATUS_OK = 0x00,
-};
-
-#endif // ANDROID_HARDWARE_HAL_NXPUWB_V1_0_H
diff --git a/src/include/uwb_config.h b/src/include/uwb_config.h
deleted file mode 100755
index bec8b9a..0000000
--- a/src/include/uwb_config.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2017 The Android Open Source Project
- * Copyright 2018-2020 NXP
- *
- * 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 <config.h>
-
-#include <string>
-#include <vector>
-
-#define NAME_UWB_CORE_DEVICE_DEFAULT_CONFIG "UWB_CORE_DEVICE_DEFAULT_CONFIG"
-#define NAME_UWB_LOW_POWER_MODE "UWB_LOW_POWER_MODE"
-#define NAME_UWB_DPD_ENTRY_TIMEOUT "UWB_DPD_ENTRY_TIMEOUT"
-
-#define CHECK_RETURN(condition, str, ret) \
- do { \
- if (condition) { \
- return ret; \
- } \
- } while (0)
-#define CHECK_RETURN_VOID(condition, str) \
- do { \
- if (condition) { \
- return; \
- } \
- } while (0)
-class UwbConfig {
- public:
- static bool hasKey(const std::string& key);
- static std::string getString(const std::string& key);
- static std::string getString(const std::string& key,
- std::string default_value);
- static unsigned getUnsigned(const std::string& key);
- static unsigned getUnsigned(const std::string& key, unsigned default_value);
- static std::vector<uint8_t> getBytes(const std::string& key);
- static void clear();
-
- private:
- void loadConfig();
- static UwbConfig& getInstance();
- UwbConfig();
-
- ConfigFile config_;
-};
diff --git a/src/include/uwb_gki_target.h b/src/include/uwb_gki_target.h
deleted file mode 100755
index 9b1b1c5..0000000
--- a/src/include/uwb_gki_target.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#ifndef UWB_GKI_TARGET_H
-#define UWB_GKI_TARGET_H
-
-#include "data_types.h"
-
-/******************************************************************************
-**
-** Task configuration
-**
-******************************************************************************/
-
-/* Definitions of task IDs for inter-task messaging */
-#ifndef MMI_TASK
-#define MMI_TASK 0
-#endif
-
-#ifndef HCISU_TASK
-#define HCISU_TASK 1
-#endif
-
-#ifndef UCIT_TASK
-#define UCIT_TASK 2
-#endif
-
-#ifndef UWB_TASK
-#define UWB_TASK 3
-#endif
-
-#ifndef BTU_TASK
-#define BTU_TASK 4
-#endif
-
-/* The number of GKI tasks in the software system. */
-#ifndef GKI_MAX_TASKS
-#define GKI_MAX_TASKS 5
-#endif
-
-/******************************************************************************
-**
-** Timer configuration
-**
-******************************************************************************/
-
-/* The number of GKI timers in the software system. */
-#ifndef GKI_NUM_TIMERS
-#define GKI_NUM_TIMERS 3
-#endif
-
-/* A conversion value for translating ticks to calculate GKI timer. */
-#ifndef TICKS_PER_SEC
-#define TICKS_PER_SEC 100
-#endif
-
-/* delay in ticks before stopping system tick. */
-#ifndef GKI_DELAY_STOP_SYS_TICK
-#define GKI_DELAY_STOP_SYS_TICK 10
-#endif
-
-/******************************************************************************
-**
-** Buffer configuration
-**
-******************************************************************************/
-#define GKI_ENABLE_BUF_CORRUPTION_CHECK TRUE
-#define GKI_DEF_BUFPOOL_PERM_MASK 0xfff0
-#define GKI_NUM_TOTAL_BUF_POOLS 10
-#define GKI_NUM_FIXED_BUF_POOLS 4
-
-/* The size of the buffers in pool 0 */
-#define GKI_POOL_ID_0 0
-#define GKI_BUF0_SIZE 268
-#define GKI_BUF0_MAX 40
-
-/* The size of the buffers in pool 1 */
-#define GKI_POOL_ID_1
-#define GKI_BUF1_SIZE 428
-#define GKI_BUF1_MAX 26
-
-/* The size of the buffers in pool 2 */
-#define GKI_POOL_ID_2 2
-#define GKI_BUF2_SIZE 4200
-#define GKI_BUF2_MAX 50
-
-/* The size of the buffers in pool 3 */
-#define GKI_POOL_ID_3 3
-#define GKI_BUF3_SIZE 4200
-#define GKI_BUF3_MAX 30
-
-#endif /* UWB_GKI_TARGET_H */
diff --git a/src/include/uwb_hal_api.h b/src/include/uwb_hal_api.h
deleted file mode 100755
index 88ac1a5..0000000
--- a/src/include/uwb_hal_api.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2014 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-/******************************************************************************
- *
- * UWB Hardware Abstraction Layer API
- *
- ******************************************************************************/
-#ifndef UWB_HAL_API_H
-#define UWB_HAL_API_H
-#include "data_types.h"
-#include "hal_uwb.h"
-
-typedef uint8_t tUWB_STATUS;
-typedef void(tHAL_UWB_CBACK)(uint8_t event, tUWB_STATUS status);
-typedef void(tHAL_UWB_DATA_CBACK)(uint16_t data_len, uint8_t* p_data);
-
-/*******************************************************************************
-** tHAL_UWB_ENTRY HAL entry-point lookup table
-*******************************************************************************/
-typedef void(tHAL_API_OPEN)(tHAL_UWB_CBACK* p_hal_cback,
- tHAL_UWB_DATA_CBACK* p_data_cback);
-typedef void(tHAL_API_CLOSE)(void);
-typedef tUWB_STATUS(tHAL_API_CORE_INIT)();
-typedef tUWB_STATUS(tHAL_API_SESSION_INIT)(int);
-typedef void(tHAL_API_WRITE)(uint16_t data_len, uint8_t* p_data);
-typedef tUWB_STATUS(tHAL_API_IOCTL)(long arg, void* p_data);
-
-typedef struct {
- tHAL_API_OPEN* open;
- tHAL_API_CLOSE* close;
- tHAL_API_WRITE* write;
- tHAL_API_IOCTL* ioctl;
- tHAL_API_CORE_INIT* CoreInitialization;
- tHAL_API_SESSION_INIT* SessionInitialization;
-} tHAL_UWB_ENTRY;
-
-typedef struct {
- tHAL_UWB_ENTRY* hal_entry_func;
-} tHAL_UWB_CONTEXT;
-
-#endif /* UWB_HAL_API_H */
diff --git a/src/include/uwb_hal_int.h b/src/include/uwb_hal_int.h
deleted file mode 100755
index f328b9e..0000000
--- a/src/include/uwb_hal_int.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2014 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-/******************************************************************************
- *
- * this file contains the UCI transport internal definitions and functions.
- *
- ******************************************************************************/
-
-#ifndef UWB_HAL_INT_H
-#define UWB_HAL_INT_H
-
-#include "uci_defs.h"
-#include "uwb_gki.h"
-#include "uwb_hal_api.h"
-
-enum {
- HAL_UWB_OPEN_CPLT_EVT = 0x00,
- HAL_UWB_CLOSE_CPLT_EVT = 0x01,
- HAL_UWB_INIT_CPLT_EVT = 0x02,
- HAL_UWB_ERROR_EVT = 0x03,
- HAL_UWB_HW_RESET = 0x04
-};
-
-typedef uint8_t uwb_event_t;
-typedef uint8_t uwb_status_t;
-
-/*`
- * The callback passed in from the UWB stack that the HAL
- * can use to pass events back to the stack.
- */
-typedef void(uwb_stack_callback_t)(uwb_event_t event,
- uwb_status_t event_status);
-
-/*
- * The callback passed in from the UWB stack that the HAL
- * can use to pass incoming data to the stack.
- */
-typedef void(uwb_stack_data_callback_t)(uint16_t data_len, uint8_t* p_data);
-
-#endif /* UWB_HAL_INT_H */
diff --git a/src/include/uwb_osal_common.h b/src/include/uwb_osal_common.h
deleted file mode 100755
index 5f89831..0000000
--- a/src/include/uwb_osal_common.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021 NXP.
- *
- * 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.
- */
-
-#include <pthread.h>
-
-extern void phUwb_GKI_shutdown();
-/*Function call context*/
-#define ADAPTATION_INIT 1
diff --git a/src/include/uwb_target.h b/src/include/uwb_target.h
deleted file mode 100755
index bd7db51..0000000
--- a/src/include/uwb_target.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2020 NXP
- *
- * 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.
- *
- ******************************************************************************/
-
-#ifndef UWB_TARGET_H
-#define UWB_TARGET_H
-
-#include "data_types.h"
-
-#ifndef USERIAL_DEBUG
-#define USERIAL_DEBUG false
-#endif
-
-/* Include common GKI definitions used by this platform */
-#include "uwb_gki_target.h"
-
-/* UCI Command, Notification or Data*/
-#define BT_EVT_TO_UWB_UCI 0x4000
-/* messages between UWB and UCI task */
-#define BT_EVT_TO_UWB_MSGS 0x4300
-
-/* start timer */
-#define BT_EVT_TO_START_TIMER 0x3c00
-
-/* start quick timer */
-#define BT_EVT_TO_START_QUICK_TIMER 0x3e00
-
-/******************************************************************************
-**
-** GKI Mail Box and Timer
-**
-******************************************************************************/
-
-/* Mailbox event mask for UWB stack */
-#ifndef UWB_MBOX_EVT_MASK
-#define UWB_MBOX_EVT_MASK (TASK_MBOX_0_EVT_MASK)
-#endif
-
-/* Mailbox ID for UWB stack */
-#ifndef UWB_MBOX_ID
-#define UWB_MBOX_ID (TASK_MBOX_0)
-#endif
-
-/* Mailbox event mask for UWA */
-#ifndef UWA_MBOX_EVT_MASK
-#define UWA_MBOX_EVT_MASK (TASK_MBOX_2_EVT_MASK)
-#endif
-
-/* Mailbox ID for UWA */
-#ifndef UWA_MBOX_ID
-#define UWA_MBOX_ID (TASK_MBOX_2)
-#endif
-
-/* GKI timer id used for protocol timer in UWB stack */
-#ifndef UWB_TIMER_ID
-#define UWB_TIMER_ID (TIMER_0)
-#endif
-
-/* GKI timer event mask used for protocol timer in UWB stack */
-#ifndef UWB_TIMER_EVT_MASK
-#define UWB_TIMER_EVT_MASK (TIMER_0_EVT_MASK)
-#endif
-
-/* GKI timer id used for quick timer in UWB stack */
-#ifndef UWB_QUICK_TIMER_ID
-#define UWB_QUICK_TIMER_ID (TIMER_1)
-#endif
-
-/* GKI timer event mask used for quick timer in UWB stack */
-#ifndef UWB_QUICK_TIMER_EVT_MASK
-#define UWB_QUICK_TIMER_EVT_MASK (TIMER_1_EVT_MASK)
-#endif
-
-/* GKI timer id used for protocol timer in UWA */
-#ifndef UWA_TIMER_ID
-#define UWA_TIMER_ID (TIMER_2)
-#endif
-
-/* GKI timer event mask used for protocol timer in UWA */
-#ifndef UWA_TIMER_EVT_MASK
-#define UWA_TIMER_EVT_MASK (TIMER_2_EVT_MASK)
-#endif
-
-/* Quick Timer */
-#ifndef QUICK_TIMER_TICKS_PER_SEC
-#define QUICK_TIMER_TICKS_PER_SEC 100 /* 10ms timer */
-#endif
-
-/******************************************************************************
-**
-** GKI Buffer Pools
-**
-******************************************************************************/
-
-/* UCI command/notification/data */
-#ifndef UWB_UCI_POOL_ID
-#define UWB_UCI_POOL_ID GKI_POOL_ID_2
-#endif
-
-/******************************************************************************
-**
-** UCI Transport definitions
-**
-******************************************************************************/
-/* offset of the first UCI packet in buffer for outgoing */
-#ifndef UCI_MSG_OFFSET_SIZE
-#define UCI_MSG_OFFSET_SIZE 1
-#endif
-
-/******************************************************************************
-**
-** UWB
-**
-******************************************************************************/
-
-/* Timeout for receiving response to UCI command in case of retry */
-#ifndef UWB_CMD_RETRY_TIMEOUT
-#define UWB_CMD_RETRY_TIMEOUT 75 // 75ms
-#endif
-
-/* Timeout for receiving response to UCI command */
-#ifndef UWB_CMD_CMPL_TIMEOUT
-#define UWB_CMD_CMPL_TIMEOUT 100 // 100ms
-#endif
-
-/* Maximum number of UCI commands that the UWBC accepts without needing to wait
- * for response */
-#ifndef UCI_MAX_CMD_WINDOW
-#define UCI_MAX_CMD_WINDOW 1
-#endif
-
-#ifndef UCI_CMD_MAX_RETRY_COUNT
-#define UCI_CMD_MAX_RETRY_COUNT 10
-#endif
-
-/*****************************************************************************
-** Define HAL_WRITE depending on whether HAL is using shared GKI resources
-** as the UWB stack.
-*****************************************************************************/
-#ifndef HAL_WRITE
-#define HAL_WRITE(p) \
- { \
- uwb_cb.p_hal->write(p->len, (uint8_t*)(p + 1) + p->offset); \
- phUwb_GKI_freebuf(p); \
- }
-#define HAL_RE_WRITE(p) \
- { uwb_cb.p_hal->write(p->len, (uint8_t*)(p + 1) + p->offset); }
-
-#define HAL_UCI_CMD_WRITE(len, buf) \
- { uwb_cb.p_hal->write(len, (uint8_t*)buf); }
-/* Mem allocation with 8 byte alignment */
-#define HAL_MALLOC(x) malloc(((x - 1) | 7) + 1)
-#endif /* HAL_WRITE */
-
-#endif /* UWB_TARGET_H */
diff --git a/src/include/uwb_types.h b/src/include/uwb_types.h
deleted file mode 100755
index 5e141b2..0000000
--- a/src/include/uwb_types.h
+++ /dev/null
@@ -1,377 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2014 Broadcom Corporation
- * Copyright 2018-2020 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#ifndef UWB_TYPES_H
-#define UWB_TYPES_H
-#if __cplusplus > 199711L
-#define register // Deprecated in C++11.
-#endif // #if __cplusplus > 199711L
-/****************************************************************************
-** UWB_HDR header definition for UWB messages
-*****************************************************************************/
-typedef struct {
- uint16_t event;
- uint16_t len;
- uint16_t offset;
- uint16_t layer_specific;
-} UWB_HDR;
-#define UWB_HDR_SIZE (sizeof(UWB_HDR))
-
-/* Mask for UWB_HDR event field */
-#define UWB_EVT_MASK 0xFF00
-#define UWB_SUB_EVT_MASK 0x00FF
-
-/****************************************************************************
-** UWB_HAL_TASK definitions
-*****************************************************************************/
-
-/* UWB_HAL_TASK event messages */
-/* UCI message for sending to UWBC */
-#define UWB_HAL_EVT_TO_UWB_UCI 0x0100
-/* Request to start UCIT quick timer */
-#define UWB_HAL_EVT_POST_CORE_RESET 0x0200
-/* Request to start chip-specific config */
-#define UWB_HAL_EVT_TO_START_QUICK_TIMER 0x0300
-/* UCI message for hci persistency data */
-#define UWB_HAL_EVT_HCI 0x0400
-/* UCI message to issue prediscover config */
-#define UWB_HAL_EVT_PRE_DISCOVER 0x0500
-/* permission to send commands queued in HAL*/
-#define UWB_HAL_EVT_CONTROL_GRANTED 0x0600
-
-/* UWB_HAL_TASK sub event messages */
-#define UWB_HAL_HCI_RSP_NV_READ_EVT (0x01 | UWB_HAL_EVT_HCI)
-#define UWB_HAL_HCI_RSP_NV_WRITE_EVT (0x02 | UWB_HAL_EVT_HCI)
-#define UWB_HAL_HCI_VSC_TIMEOUT_EVT (0x03 | UWB_HAL_EVT_HCI)
-
-/* Event masks for UWB_TASK messages */
-/* UCI message for sending to host stack */
-#define UWB_EVT_TO_UWB_UCI 0x4000
-/* Error notification to UWB Task */
-#define UWB_EVT_TO_UWB_ERR 0x4100
-/* Messages between UWB and UCI task */
-#define UWB_EVT_TO_UWB_MSGS 0x4200
-
-/*****************************************************************************
-** Macros to get and put bytes to and from a stream (Little Endian format).
-*****************************************************************************/
-
-#define UINT32_TO_STREAM(p, u32) \
- { \
- *(p)++ = (uint8_t)(u32); \
- *(p)++ = (uint8_t)((u32) >> 8); \
- *(p)++ = (uint8_t)((u32) >> 16); \
- *(p)++ = (uint8_t)((u32) >> 24); \
- }
-#define UINT24_TO_STREAM(p, u24) \
- { \
- *(p)++ = (uint8_t)(u24); \
- *(p)++ = (uint8_t)((u24) >> 8); \
- *(p)++ = (uint8_t)((u24) >> 16); \
- }
-#define UINT16_TO_STREAM(p, u16) \
- { \
- *(p)++ = (uint8_t)(u16); \
- *(p)++ = (uint8_t)((u16) >> 8); \
- }
-#define UINT8_TO_STREAM(p, u8) \
- { *(p)++ = (uint8_t)(u8); }
-#define INT8_TO_STREAM(p, u8) \
- { *(p)++ = (int8_t)(u8); }
-#define ARRAY32_TO_STREAM(p, a) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < 32; ijk++) *(p)++ = (uint8_t)a[31 - ijk]; \
- }
-#define ARRAY16_TO_STREAM(p, a) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < 16; ijk++) *(p)++ = (uint8_t)a[15 - ijk]; \
- }
-#define ARRAY8_TO_STREAM(p, a) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < 8; ijk++) *(p)++ = (uint8_t)a[7 - ijk]; \
- }
-#define BDADDR_TO_STREAM(p, a) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) \
- *(p)++ = (uint8_t)a[BD_ADDR_LEN - 1 - ijk]; \
- }
-#define LAP_TO_STREAM(p, a) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < LAP_LEN; ijk++) \
- *(p)++ = (uint8_t)a[LAP_LEN - 1 - ijk]; \
- }
-#define DEVCLASS_TO_STREAM(p, a) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) \
- *(p)++ = (uint8_t)a[DEV_CLASS_LEN - 1 - ijk]; \
- }
-#define ARRAY_TO_STREAM(p, a, len) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < len; ijk++) *(p)++ = (uint8_t)a[ijk]; \
- }
-#define REVERSE_ARRAY_TO_STREAM(p, a, len) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < len; ijk++) *(p)++ = (uint8_t)a[len - 1 - ijk]; \
- }
-
-#define STREAM_TO_UINT8(u8, p) \
- { \
- u8 = (uint8_t)(*(p)); \
- (p) += 1; \
- }
-#define STREAM_TO_UINT16(u16, p) \
- { \
- u16 = (uint16_t)((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); \
- (p) += 2; \
- }
-#define STREAM_TO_INT16(i16, p) \
- { \
- i16 = (int16_t)((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); \
- (p) += 2; \
- }
-#define STREAM_TO_UINT24(u32, p) \
- { \
- u32 = (((uint32_t)(*(p))) + ((((uint32_t)(*((p) + 1)))) << 8) + \
- ((((uint32_t)(*((p) + 2)))) << 16)); \
- (p) += 3; \
- }
-#define STREAM_TO_UINT32(u32, p) \
- { \
- u32 = (((uint32_t)(*(p))) + ((((uint32_t)(*((p) + 1)))) << 8) + \
- ((((uint32_t)(*((p) + 2)))) << 16) + \
- ((((uint32_t)(*((p) + 3)))) << 24)); \
- (p) += 4; \
- }
-#define STREAM_TO_UINT40(u40, p) \
- { \
- u40 = (((uint64_t)(*(p))) + ((((uint64_t)(*((p) + 1)))) << 8) + \
- ((((uint64_t)(*((p) + 2)))) << 16) + \
- ((((uint64_t)(*((p) + 3)))) << 24) + \
- ((((uint64_t)(*((p) + 4)))) << 32)); \
- (p) += 5; \
- }
-#define STREAM_TO_UINT64(u64, p) \
- { \
- u64 = (((uint64_t)(*(p))) + ((((uint64_t)(*((p) + 1)))) << 8) + \
- ((((uint64_t)(*((p) + 2)))) << 16) + \
- ((((uint64_t)(*((p) + 3)))) << 24) + \
- ((((uint64_t)(*((p) + 4)))) << 32) + \
- ((((uint64_t)(*((p) + 5)))) << 40) + \
- ((((uint64_t)(*((p) + 6)))) << 48) + \
- ((((uint64_t)(*((p) + 7)))) << 56)); \
- (p) += 8; \
- }
-#define STREAM_TO_BDADDR(a, p) \
- { \
- register int ijk; \
- register uint8_t* pbda = (uint8_t*)a + BD_ADDR_LEN - 1; \
- for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *pbda-- = *p++; \
- }
-#define STREAM_TO_ARRAY32(a, p) \
- { \
- register int ijk; \
- register uint8_t* _pa = (uint8_t*)a + 31; \
- for (ijk = 0; ijk < 32; ijk++) *_pa-- = *p++; \
- }
-#define STREAM_TO_ARRAY16(a, p) \
- { \
- register int ijk; \
- register uint8_t* _pa = (uint8_t*)a + 15; \
- for (ijk = 0; ijk < 16; ijk++) *_pa-- = *p++; \
- }
-#define STREAM_TO_ARRAY8(a, p) \
- { \
- register int ijk; \
- register uint8_t* _pa = (uint8_t*)a + 7; \
- for (ijk = 0; ijk < 8; ijk++) *_pa-- = *p++; \
- }
-#define STREAM_TO_DEVCLASS(a, p) \
- { \
- register int ijk; \
- register uint8_t* _pa = (uint8_t*)a + DEV_CLASS_LEN - 1; \
- for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) *_pa-- = *p++; \
- }
-#define STREAM_TO_LAP(a, p) \
- { \
- register int ijk; \
- register uint8_t* plap = (uint8_t*)a + LAP_LEN - 1; \
- for (ijk = 0; ijk < LAP_LEN; ijk++) *plap-- = *p++; \
- }
-#define STREAM_TO_ARRAY(a, p, len) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < len; ijk++) ((uint8_t*)a)[ijk] = *p++; \
- }
-#define REVERSE_STREAM_TO_ARRAY(a, p, len) \
- { \
- register int ijk; \
- register uint8_t* _pa = (uint8_t*)a + len - 1; \
- for (ijk = 0; ijk < len; ijk++) *_pa-- = *p++; \
- }
-
-/*****************************************************************************
-** Macros to get and put bytes to and from a field (Little Endian format).
-** These are the same as to stream, except the pointer is not incremented.
-*****************************************************************************/
-
-#define UINT32_TO_FIELD(p, u32) \
- { \
- *(uint8_t*)(p) = (uint8_t)(u32); \
- *((uint8_t*)(p) + 1) = (uint8_t)((u32) >> 8); \
- *((uint8_t*)(p) + 2) = (uint8_t)((u32) >> 16); \
- *((uint8_t*)(p) + 3) = (uint8_t)((u32) >> 24); \
- }
-#define UINT24_TO_FIELD(p, u24) \
- { \
- *(uint8_t*)(p) = (uint8_t)(u24); \
- *((uint8_t*)(p) + 1) = (uint8_t)((u24) >> 8); \
- *((uint8_t*)(p) + 2) = (uint8_t)((u24) >> 16); \
- }
-#define UINT16_TO_FIELD(p, u16) \
- { \
- *(uint8_t*)(p) = (uint8_t)(u16); \
- *((uint8_t*)(p) + 1) = (uint8_t)((u16) >> 8); \
- }
-#define UINT8_TO_FIELD(p, u8) \
- { *(uint8_t*)(p) = (uint8_t)(u8); }
-
-/*****************************************************************************
-** Macros to get and put bytes to and from a stream (Big Endian format)
-*****************************************************************************/
-
-#define UINT32_TO_BE_STREAM(p, u32) \
- { \
- *(p)++ = (uint8_t)((u32) >> 24); \
- *(p)++ = (uint8_t)((u32) >> 16); \
- *(p)++ = (uint8_t)((u32) >> 8); \
- *(p)++ = (uint8_t)(u32); \
- }
-#define UINT24_TO_BE_STREAM(p, u24) \
- { \
- *(p)++ = (uint8_t)((u24) >> 16); \
- *(p)++ = (uint8_t)((u24) >> 8); \
- *(p)++ = (uint8_t)(u24); \
- }
-#define UINT16_TO_BE_STREAM(p, u16) \
- { \
- *(p)++ = (uint8_t)((u16) >> 8); \
- *(p)++ = (uint8_t)(u16); \
- }
-#define UINT8_TO_BE_STREAM(p, u8) \
- { *(p)++ = (uint8_t)(u8); }
-#define ARRAY_TO_BE_STREAM(p, a, len) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < len; ijk++) *(p)++ = (uint8_t)a[ijk]; \
- }
-
-#define BE_STREAM_TO_UINT8(u8, p) \
- { \
- u8 = (uint8_t)(*(p)); \
- (p) += 1; \
- }
-#define BE_STREAM_TO_UINT16(u16, p) \
- { \
- u16 = (uint16_t)(((uint16_t)(*(p)) << 8) + (uint16_t)(*((p) + 1))); \
- (p) += 2; \
- }
-#define BE_STREAM_TO_UINT24(u32, p) \
- { \
- u32 = (((uint32_t)(*((p) + 2))) + ((uint32_t)(*((p) + 1)) << 8) + \
- ((uint32_t)(*(p)) << 16)); \
- (p) += 3; \
- }
-#define BE_STREAM_TO_UINT32(u32, p) \
- { \
- u32 = ((uint32_t)(*((p) + 3)) + ((uint32_t)(*((p) + 2)) << 8) + \
- ((uint32_t)(*((p) + 1)) << 16) + ((uint32_t)(*(p)) << 24)); \
- (p) += 4; \
- }
-#define BE_STREAM_TO_ARRAY(p, a, len) \
- { \
- register int ijk; \
- for (ijk = 0; ijk < len; ijk++) ((uint8_t*)a)[ijk] = *p++; \
- }
-
-/*****************************************************************************
-** Macros to get and put bytes to and from a field (Big Endian format).
-** These are the same as to stream, except the pointer is not incremented.
-*****************************************************************************/
-
-#define UINT32_TO_BE_FIELD(p, u32) \
- { \
- *(uint8_t*)(p) = (uint8_t)((u32) >> 24); \
- *((uint8_t*)(p) + 1) = (uint8_t)((u32) >> 16); \
- *((uint8_t*)(p) + 2) = (uint8_t)((u32) >> 8); \
- *((uint8_t*)(p) + 3) = (uint8_t)(u32); \
- }
-#define UINT24_TO_BE_FIELD(p, u24) \
- { \
- *(uint8_t*)(p) = (uint8_t)((u24) >> 16); \
- *((uint8_t*)(p) + 1) = (uint8_t)((u24) >> 8); \
- *((uint8_t*)(p) + 2) = (uint8_t)(u24); \
- }
-#define UINT16_TO_BE_FIELD(p, u16) \
- { \
- *(uint8_t*)(p) = (uint8_t)((u16) >> 8); \
- *((uint8_t*)(p) + 1) = (uint8_t)(u16); \
- }
-#define UINT8_TO_BE_FIELD(p, u8) \
- { *(uint8_t*)(p) = (uint8_t)(u8); }
-
-/*****************************************************************************
-** Define trace levels
-*****************************************************************************/
-
-/* No trace messages to be generated */
-#define BT_TRACE_LEVEL_NONE 0
-/* Error condition trace messages */
-#define BT_TRACE_LEVEL_ERROR 1
-/* Warning condition trace messages */
-#define BT_TRACE_LEVEL_WARNING 2
-/* API traces */
-#define BT_TRACE_LEVEL_API 3
-/* Debug messages for events */
-#define BT_TRACE_LEVEL_EVENT 4
-/* Full debug messages */
-#define BT_TRACE_LEVEL_DEBUG 5
-
-#define TRACE_CTRL_GENERAL 0x00000000
-#define TRACE_LAYER_UCI 0x00280000
-#define TRACE_LAYER_HAL 0x00310000
-#define TRACE_LAYER_GKI 0x001a0000
-#define TRACE_ORG_STACK 0x00000000
-#define TRACE_ORG_GKI 0x00000400
-
-#define TRACE_TYPE_ERROR 0x00000000
-#define TRACE_TYPE_WARNING 0x00000001
-#define TRACE_TYPE_API 0x00000002
-#define TRACE_TYPE_EVENT 0x00000003
-#define TRACE_TYPE_DEBUG 0x00000004
-
-#define TRACE_TYPE_GENERIC 0x00000008
-
-#endif /* UWB_TYPES_H */
diff --git a/src/log/uci_log.h b/src/log/uci_log.h
deleted file mode 100755
index 87d79b9..0000000
--- a/src/log/uci_log.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021 NXP.
- *
- * 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.
- */
-
-#ifndef UWB_UCI_LOG_H_
-#define UWB_UCI_LOG_H_
-
-#include <log/log.h>
-
-/* global log level Ref */
-extern bool uwb_debug_enabled;
-
-static const char* UWB_UCI_CORE_LOG = "UwbUciCore";
-
-#ifndef UNUSED
-#define UNUSED(X) (void)X;
-#endif
-
-/* define log module included when compile */
-#define ENABLE_UCI_LOGGING TRUE
-
-/* ############## Logging APIs of actual modules ################# */
-/* Logging APIs used by UCI module */
-#if (ENABLE_UCI_LOGGING == TRUE)
-#define UCI_TRACE_D(...) \
- { \
- if (uwb_debug_enabled) \
- LOG_PRI(ANDROID_LOG_DEBUG, UWB_UCI_CORE_LOG, __VA_ARGS__); \
- }
-#define UCI_TRACE_I(...) \
- { \
- if (uwb_debug_enabled) \
- LOG_PRI(ANDROID_LOG_INFO, UWB_UCI_CORE_LOG, __VA_ARGS__); \
- }
-#define UCI_TRACE_W(...) \
- { \
- if (uwb_debug_enabled) \
- LOG_PRI(ANDROID_LOG_WARN, UWB_UCI_CORE_LOG, __VA_ARGS__); \
- }
-#define UCI_TRACE_E(...) \
- { \
- if (uwb_debug_enabled) \
- LOG_PRI(ANDROID_LOG_ERROR, UWB_UCI_CORE_LOG, __VA_ARGS__); \
- }
-#else
-#define UCI_TRACE_D(...)
-#define UCI_TRACE_I(...)
-#define UCI_TRACE_W(...)
-#define UCI_TRACE_E(...)
-#endif /* Logging APIs used by UCI module */
-
-#endif /* UWB_UCI_LOG_H_ */
diff --git a/src/rust/uwb_core/protos/uwb_service.proto b/src/rust/uwb_core/protos/uwb_service.proto
index 3d51c4d..944f82e 100644
--- a/src/rust/uwb_core/protos/uwb_service.proto
+++ b/src/rust/uwb_core/protos/uwb_service.proto
@@ -95,8 +95,7 @@
UCI_STATUS_RANGING_RX_MAC_IE_MISSING = 39;
UCI_STATUS_ERROR_ROUND_INDEX_NOT_ACTIVATED = 40;
UCI_STATUS_ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED = 41;
- UCI_STATUS_ERROR_ROUND_INDEX_NOT_SET_AS_INITIATOR = 42;
- UCI_STATUS_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST = 43;
+ UCI_STATUS_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST = 42;
UCI_STATUS_DATA_MAX_TX_PSDU_SIZE_EXCEEDED = 48;
UCI_STATUS_DATA_RX_CRC_ERROR = 49;
@@ -108,12 +107,6 @@
UCI_STATUS_RFU_OR_VENDOR_SPECIFIC = 255;
}
-// Represents uwb_uci_packets::OwrAoaStatusCode
-enum OwrAoaStatusCode {
- UCI_STATUS_SUCCESS = 0;
- UCI_STATUS_INTER_FRAME_INTERVAL_TIMEOUT = 1;
-}
-
// Represent uwb_uci_packets::DeviceState.
enum DeviceState {
DEVICE_STATE_READY = 0;
@@ -451,7 +444,7 @@
// uwb_uci_packets::ExtendedAddressOwrAoaRangingMeasurement.
message OwrAoaRangingMeasurement {
uint64 mac_address = 1;
- OwrAoaStatusCode owr_aoa_status_code = 2;
+ StatusCode status = 2;
uint32 nlos = 3;
uint32 block_index = 4;
uint32 frame_sequence_number = 5;
diff --git a/src/rust/uwb_core/src/params/uci_packets.rs b/src/rust/uwb_core/src/params/uci_packets.rs
index 2e0941e..5cd5822 100644
--- a/src/rust/uwb_core/src/params/uci_packets.rs
+++ b/src/rust/uwb_core/src/params/uci_packets.rs
@@ -24,11 +24,10 @@
Controlee, ControleeStatus, Controlees, CreditAvailability, DataRcvStatusCode,
DataTransferNtfStatusCode, DeviceConfigId, DeviceConfigStatus, DeviceConfigTlv, DeviceState,
ExtendedAddressDlTdoaRangingMeasurement, ExtendedAddressOwrAoaRangingMeasurement,
- ExtendedAddressTwoWayRangingMeasurement, FiraComponent, GroupId, MessageType,
- MulticastUpdateStatusCode, OwrAoaStatusCode, PowerStats, RangingMeasurementType, ReasonCode,
- ResetConfig, SessionState, SessionType, ShortAddressDlTdoaRangingMeasurement,
- ShortAddressOwrAoaRangingMeasurement, ShortAddressTwoWayRangingMeasurement, StatusCode,
- UpdateMulticastListAction,
+ ExtendedAddressTwoWayRangingMeasurement, GroupId, MessageType, MulticastUpdateStatusCode,
+ PowerStats, RangingMeasurementType, ReasonCode, ResetConfig, SessionState, SessionType,
+ ShortAddressDlTdoaRangingMeasurement, ShortAddressOwrAoaRangingMeasurement,
+ ShortAddressTwoWayRangingMeasurement, StatusCode, UpdateMulticastListAction,
};
pub(crate) use uwb_uci_packets::{UciControlPacket, UciDataPacket, UciDataPacketHal};
@@ -38,6 +37,10 @@
pub type SessionId = u32;
/// The type of the sub-session identifier.
pub type SubSessionId = u32;
+/// The type of the session handle.
+pub type SessionHandle = u32;
+/// Generic type used to represent either a session id or session handle.
+pub type SessionToken = u32;
/// Wrap the original AppConfigTlv type to redact the PII fields when logging.
#[derive(Clone, PartialEq)]
diff --git a/src/rust/uwb_core/src/proto/mappings.rs b/src/rust/uwb_core/src/proto/mappings.rs
index 0d21c09..cb0e078 100644
--- a/src/rust/uwb_core/src/proto/mappings.rs
+++ b/src/rust/uwb_core/src/proto/mappings.rs
@@ -29,8 +29,8 @@
};
use crate::params::uci_packets::{
Controlee, DeviceState, ExtendedAddressDlTdoaRangingMeasurement,
- ExtendedAddressOwrAoaRangingMeasurement, ExtendedAddressTwoWayRangingMeasurement,
- OwrAoaStatusCode, PowerStats, RangingMeasurementType, ReasonCode, SessionState, SessionType,
+ ExtendedAddressOwrAoaRangingMeasurement, ExtendedAddressTwoWayRangingMeasurement, PowerStats,
+ RangingMeasurementType, ReasonCode, SessionState, SessionType,
ShortAddressDlTdoaRangingMeasurement, ShortAddressOwrAoaRangingMeasurement,
ShortAddressTwoWayRangingMeasurement, StatusCode, UpdateMulticastListAction,
};
@@ -42,8 +42,7 @@
FiraAppConfigParams as ProtoFiraAppConfigParams, HoppingMode as ProtoHoppingMode,
KeyRotation as ProtoKeyRotation, MacAddressMode as ProtoMacAddressMode,
MacFcsType as ProtoMacFcsType, MultiNodeMode as ProtoMultiNodeMode,
- OwrAoaRangingMeasurement as ProtoOwrAoaRangingMeasurement,
- OwrAoaStatusCode as ProtoOwrAoaStatusCode, PowerStats as ProtoPowerStats,
+ OwrAoaRangingMeasurement as ProtoOwrAoaRangingMeasurement, PowerStats as ProtoPowerStats,
PreambleDuration as ProtoPreambleDuration, PrfMode as ProtoPrfMode,
PsduDataRate as ProtoPsduDataRate, RangeDataNtfConfig as ProtoRangeDataNtfConfig,
RangingMeasurementType as ProtoRangingMeasurementType,
@@ -167,9 +166,6 @@
ProtoStatusCode::UCI_STATUS_ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED => {
StatusCode::UciStatusErrorNumberOfActiveRangingRoundsExceeded
}
- ProtoStatusCode::UCI_STATUS_ERROR_ROUND_INDEX_NOT_SET_AS_INITIATOR => {
- StatusCode::UciStatusErrorRoundIndexNotSetAsInitiator
- }
ProtoStatusCode::UCI_STATUS_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST =>
StatusCode::UciStatusErrorDlTdoaDeviceAddressNotMatchingInReplyTimeList,
ProtoStatusCode::UCI_STATUS_DATA_MAX_TX_PSDU_SIZE_EXCEEDED => {
@@ -256,9 +252,6 @@
StatusCode::UciStatusErrorNumberOfActiveRangingRoundsExceeded => {
ProtoStatusCode::UCI_STATUS_ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED
}
- StatusCode::UciStatusErrorRoundIndexNotSetAsInitiator => {
- ProtoStatusCode::UCI_STATUS_ERROR_ROUND_INDEX_NOT_SET_AS_INITIATOR
- }
StatusCode::UciStatusErrorDlTdoaDeviceAddressNotMatchingInReplyTimeList => {
ProtoStatusCode::UCI_STATUS_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST
}
@@ -283,12 +276,6 @@
}
enum_mapping! {
- ProtoOwrAoaStatusCode => OwrAoaStatusCode,
- UCI_STATUS_SUCCESS => UciStatusSuccess,
- UCI_STATUS_INTER_FRAME_INTERVAL_TIMEOUT => UciStatusInterFrameIntervalTimeout,
-}
-
-enum_mapping! {
ProtoDeviceState => DeviceState,
DEVICE_STATE_READY => DeviceStateReady,
DEVICE_STATE_ACTIVE => DeviceStateActive,
@@ -766,7 +753,7 @@
fn from(item: ShortAddressOwrAoaRangingMeasurement) -> Self {
let mut result = Self::new();
result.set_mac_address(item.mac_address.into());
- result.set_owr_aoa_status_code(item.status.into());
+ result.set_status(item.status.into());
result.set_nlos(item.nlos.into());
result.set_block_index(item.block_index.into());
result.set_frame_sequence_number(item.frame_sequence_number.into());
@@ -782,7 +769,7 @@
fn from(item: ExtendedAddressOwrAoaRangingMeasurement) -> Self {
let mut result = Self::new();
result.set_mac_address(item.mac_address);
- result.set_owr_aoa_status_code(item.status.into());
+ result.set_status(item.status.into());
result.set_nlos(item.nlos.into());
result.set_block_index(item.block_index.into());
result.set_frame_sequence_number(item.frame_sequence_number.into());
@@ -876,7 +863,7 @@
fn from(item: SessionRangeData) -> Self {
let mut result = Self::new();
result.set_sequence_number(item.sequence_number);
- result.set_session_id(item.session_id);
+ result.set_session_id(item.session_token);
result.set_current_ranging_interval_ms(item.current_ranging_interval_ms);
result.set_ranging_measurement_type(item.ranging_measurement_type.into());
match to_proto_ranging_measurements(item.ranging_measurements) {
@@ -971,8 +958,7 @@
type Error = String;
fn try_from(item: ProtoControlee) -> std::result::Result<Self, Self::Error> {
Ok(Self {
- short_address: item
- .short_address
+ short_address: item.short_address.to_ne_bytes()[0..2]
.try_into()
.map_err(|_| "Failed to convert short_address")?,
subsession_id: item.subsession_id,
diff --git a/src/rust/uwb_core/src/service/uwb_service.rs b/src/rust/uwb_core/src/service/uwb_service.rs
index a2ecb85..ce00f95 100644
--- a/src/rust/uwb_core/src/service/uwb_service.rs
+++ b/src/rust/uwb_core/src/service/uwb_service.rs
@@ -709,7 +709,8 @@
let session_type = SessionType::FiraRangingSession;
let params = generate_params();
let action = UpdateMulticastListAction::AddControlee;
- let controlees = vec![Controlee { short_address: 0x13, subsession_id: 0x24 }];
+ let short_address: [u8; 2] = [0x12, 0x34];
+ let controlees = vec![Controlee { short_address, subsession_id: 0x24 }];
let uci_manager = MockUciManager::new();
let (service, _, _runtime) = setup_uwb_service(uci_manager);
diff --git a/src/rust/uwb_core/src/session/session_manager.rs b/src/rust/uwb_core/src/session/session_manager.rs
index e9432ba..2c9a711 100644
--- a/src/rust/uwb_core/src/session/session_manager.rs
+++ b/src/rust/uwb_core/src/session/session_manager.rs
@@ -294,7 +294,7 @@
fn handle_uci_notification(&mut self, notf: UciSessionNotification) {
match notf {
- UciSessionNotification::Status { session_id, session_state, reason_code } => {
+ UciSessionNotification::Status { session_token, session_state, reason_code } => {
let reason_code = match ReasonCode::try_from(reason_code) {
Ok(r) => r,
Err(_) => {
@@ -306,21 +306,21 @@
}
};
if session_state == SessionState::SessionStateDeinit {
- debug!("Session {} is deinitialized", session_id);
- let _ = self.active_sessions.remove(&session_id);
+ debug!("Session {} is deinitialized", session_token);
+ let _ = self.active_sessions.remove(&session_token);
let _ = self.session_notf_sender.send(SessionNotification::SessionState {
- session_id,
+ session_id: session_token,
session_state,
reason_code,
});
return;
}
- match self.active_sessions.get_mut(&session_id) {
+ match self.active_sessions.get_mut(&session_token) {
Some(session) => {
session.on_session_status_changed(session_state);
let _ = self.session_notf_sender.send(SessionNotification::SessionState {
- session_id,
+ session_id: session_token,
session_state,
reason_code,
});
@@ -328,36 +328,36 @@
None => {
warn!(
"Received notification of the unknown Session {}: {:?}, {:?}",
- session_id, session_state, reason_code
+ session_token, session_state, reason_code
);
}
}
}
UciSessionNotification::UpdateControllerMulticastList {
- session_id,
+ session_token,
remaining_multicast_list_size: _,
status_list,
- } => match self.active_sessions.get_mut(&session_id) {
+ } => match self.active_sessions.get_mut(&session_token) {
Some(session) => session.on_controller_multicast_list_udpated(status_list),
None => {
warn!(
"Received the notification of the unknown Session {}: {:?}",
- session_id, status_list
+ session_token, status_list
);
}
},
UciSessionNotification::SessionInfo(range_data) => {
- if self.active_sessions.get(&range_data.session_id).is_some() {
+ if self.active_sessions.get(&range_data.session_token).is_some() {
let _ = self.session_notf_sender.send(SessionNotification::RangeData {
- session_id: range_data.session_id,
+ session_id: range_data.session_token,
range_data,
});
} else {
warn!("Received range data of the unknown Session: {:?}", range_data);
}
}
- UciSessionNotification::DataCredit { session_id, credit_availability: _ } => {
- match self.active_sessions.get(&session_id) {
+ UciSessionNotification::DataCredit { session_token, credit_availability: _ } => {
+ match self.active_sessions.get(&session_token) {
Some(_) => {
/*
* TODO(b/270443790): Handle the DataCredit notification in the new
@@ -367,17 +367,17 @@
None => {
warn!(
"Received the Data Credit notification for an unknown Session {}",
- session_id
+ session_token
);
}
}
}
UciSessionNotification::DataTransferStatus {
- session_id,
+ session_token,
uci_sequence_number: _,
status: _,
} => {
- match self.active_sessions.get(&session_id) {
+ match self.active_sessions.get(&session_token) {
Some(_) => {
/*
* TODO(b/270443790): Handle the DataTransferStatus notification in the
@@ -387,7 +387,7 @@
None => {
warn!(
"Received a Data Transfer Status notification for unknown Session {}",
- session_id
+ session_token
);
}
}
@@ -481,7 +481,7 @@
pub(crate) fn session_range_data(session_id: SessionId) -> SessionRangeData {
SessionRangeData {
sequence_number: 1,
- session_id,
+ session_token: session_id,
current_ranging_interval_ms: 3,
ranging_measurement_type: RangingMeasurementType::TwoWay,
ranging_measurements: RangingMeasurements::ShortAddressTwoWay(vec![
@@ -512,7 +512,7 @@
session_state: SessionState,
) -> UciNotification {
UciNotification::Session(UciSessionNotification::Status {
- session_id,
+ session_token: session_id,
session_state,
reason_code: ReasonCode::StateChangeWithSessionManagementCommands.into(),
})
@@ -773,17 +773,18 @@
let params = generate_params();
let tlvs = params.generate_tlvs();
let action = UpdateMulticastListAction::AddControlee;
- let controlees = vec![Controlee { short_address: 0x13, subsession_id: 0x24 }];
+ let short_address: [u8; 2] = [0x12, 0x34];
+ let controlees = vec![Controlee { short_address, subsession_id: 0x24 }];
let controlees_clone = controlees.clone();
let (mut session_manager, mut mock_uci_manager, _) =
setup_session_manager(move |uci_manager| {
let multicast_list_notf = vec![UciNotification::Session(
UciSessionNotification::UpdateControllerMulticastList {
- session_id,
+ session_token: session_id,
remaining_multicast_list_size: 1,
status_list: vec![ControleeStatus {
- mac_address: 0x13,
+ mac_address: [0x34, 0x12],
subsession_id: 0x24,
status: MulticastUpdateStatusCode::StatusOkMulticastListUpdate,
}],
@@ -830,7 +831,8 @@
let params = generate_ccc_params();
let tlvs = params.generate_tlvs();
let action = UpdateMulticastListAction::AddControlee;
- let controlees = vec![Controlee { short_address: 0x13, subsession_id: 0x24 }];
+ let short_address: [u8; 2] = [0x12, 0x34];
+ let controlees = vec![Controlee { short_address, subsession_id: 0x24 }];
let (mut session_manager, mut mock_uci_manager, _) =
setup_session_manager(move |uci_manager| {
@@ -869,7 +871,8 @@
let params = generate_params();
let tlvs = params.generate_tlvs();
let action = UpdateMulticastListAction::AddControlee;
- let controlees = vec![Controlee { short_address: 0x13, subsession_id: 0x24 }];
+ let short_address: [u8; 2] = [0x12, 0x34];
+ let controlees = vec![Controlee { short_address, subsession_id: 0x24 }];
let controlees_clone = controlees.clone();
let (mut session_manager, mut mock_uci_manager, _) =
diff --git a/src/rust/uwb_core/src/session/uwb_session.rs b/src/rust/uwb_core/src/session/uwb_session.rs
index 91bd6ce..37fcba4 100644
--- a/src/rust/uwb_core/src/session/uwb_session.rs
+++ b/src/rust/uwb_core/src/session/uwb_session.rs
@@ -178,6 +178,8 @@
async fn initialize(&mut self, params: AppConfigParams) -> Result<Response> {
debug_assert!(*self.state_receiver.borrow() == SessionState::SessionStateDeinit);
+ // TODO(b/279669973): Support CR-461 fully here. Need to wait for session init rsp.
+ // But, that does not seem to be fully plumbed up in session_manager yet.
self.uci_manager.session_init(self.session_id, self.session_type).await?;
self.wait_state(SessionState::SessionStateInit).await?;
diff --git a/src/rust/uwb_core/src/uci/command.rs b/src/rust/uwb_core/src/uci/command.rs
index dc06dab..2afb5a8 100644
--- a/src/rust/uwb_core/src/uci/command.rs
+++ b/src/rust/uwb_core/src/uci/command.rs
@@ -20,7 +20,7 @@
use crate::error::{Error, Result};
use crate::params::uci_packets::{
AppConfigTlv, AppConfigTlvType, Controlees, CountryCode, DeviceConfigId, DeviceConfigTlv,
- ResetConfig, SessionId, SessionType, UpdateMulticastListAction,
+ ResetConfig, SessionId, SessionToken, SessionType, UpdateMulticastListAction,
};
use uwb_uci_packets::{build_session_update_controller_multicast_list_cmd, GroupId, MessageType};
@@ -39,45 +39,46 @@
CoreGetConfig {
cfg_id: Vec<DeviceConfigId>,
},
+ CoreQueryTimeStamp,
SessionInit {
session_id: SessionId,
session_type: SessionType,
},
SessionDeinit {
- session_id: SessionId,
+ session_token: SessionToken,
},
SessionSetAppConfig {
- session_id: SessionId,
+ session_token: SessionToken,
config_tlvs: Vec<AppConfigTlv>,
},
SessionGetAppConfig {
- session_id: SessionId,
+ session_token: SessionToken,
app_cfg: Vec<AppConfigTlvType>,
},
SessionGetCount,
SessionGetState {
- session_id: SessionId,
+ session_token: SessionToken,
},
SessionUpdateControllerMulticastList {
- session_id: SessionId,
+ session_token: SessionToken,
action: UpdateMulticastListAction,
controlees: Controlees,
},
SessionUpdateDtTagRangingRounds {
- session_id: u32,
+ session_token: u32,
ranging_round_indexes: Vec<u8>,
},
SessionQueryMaxDataSize {
- session_id: SessionId,
+ session_token: SessionToken,
},
SessionStart {
- session_id: SessionId,
+ session_token: SessionToken,
},
SessionStop {
- session_id: SessionId,
+ session_token: SessionToken,
},
SessionGetRangingCount {
- session_id: SessionId,
+ session_token: SessionToken,
},
AndroidSetCountryCode {
country_code: CountryCode,
@@ -99,21 +100,27 @@
UciCommand::SessionInit { session_id, session_type } => {
uwb_uci_packets::SessionInitCmdBuilder { session_id, session_type }.build().into()
}
- UciCommand::SessionDeinit { session_id } => {
- uwb_uci_packets::SessionDeinitCmdBuilder { session_id }.build().into()
+ UciCommand::SessionDeinit { session_token } => {
+ uwb_uci_packets::SessionDeinitCmdBuilder { session_token }.build().into()
}
UciCommand::CoreGetDeviceInfo => {
uwb_uci_packets::GetDeviceInfoCmdBuilder {}.build().into()
}
UciCommand::CoreGetCapsInfo => uwb_uci_packets::GetCapsInfoCmdBuilder {}.build().into(),
- UciCommand::SessionGetState { session_id } => {
- uwb_uci_packets::SessionGetStateCmdBuilder { session_id }.build().into()
+ UciCommand::SessionGetState { session_token } => {
+ uwb_uci_packets::SessionGetStateCmdBuilder { session_token }.build().into()
}
- UciCommand::SessionUpdateControllerMulticastList { session_id, action, controlees } => {
- build_session_update_controller_multicast_list_cmd(session_id, action, controlees)
- .map_err(|_| Error::BadParameters)?
- .into()
- }
+ UciCommand::SessionUpdateControllerMulticastList {
+ session_token,
+ action,
+ controlees,
+ } => build_session_update_controller_multicast_list_cmd(
+ session_token,
+ action,
+ controlees,
+ )
+ .map_err(|_| Error::BadParameters)?
+ .into(),
UciCommand::CoreSetConfig { config_tlvs } => {
uwb_uci_packets::SetConfigCmdBuilder { tlvs: config_tlvs }.build().into()
}
@@ -122,30 +129,34 @@
}
.build()
.into(),
- UciCommand::SessionSetAppConfig { session_id, config_tlvs } => {
+ UciCommand::CoreQueryTimeStamp {} => {
+ uwb_uci_packets::CoreQueryTimeStampCmdBuilder {}.build().into()
+ }
+ UciCommand::SessionSetAppConfig { session_token, config_tlvs } => {
uwb_uci_packets::SessionSetAppConfigCmdBuilder {
- session_id,
+ session_token,
tlvs: config_tlvs.into_iter().map(|tlv| tlv.into_inner()).collect(),
}
.build()
.into()
}
- UciCommand::SessionGetAppConfig { session_id, app_cfg } => {
+ UciCommand::SessionGetAppConfig { session_token, app_cfg } => {
uwb_uci_packets::SessionGetAppConfigCmdBuilder {
- session_id,
+ session_token,
app_cfg: app_cfg.into_iter().map(u8::from).collect(),
}
.build()
.into()
}
- UciCommand::SessionUpdateDtTagRangingRounds { session_id, ranging_round_indexes } => {
- uwb_uci_packets::SessionUpdateDtTagRangingRoundsCmdBuilder {
- session_id,
- ranging_round_indexes,
- }
- .build()
- .into()
+ UciCommand::SessionUpdateDtTagRangingRounds {
+ session_token,
+ ranging_round_indexes,
+ } => uwb_uci_packets::SessionUpdateDtTagRangingRoundsCmdBuilder {
+ session_token,
+ ranging_round_indexes,
}
+ .build()
+ .into(),
UciCommand::AndroidGetPowerStats => {
uwb_uci_packets::AndroidGetPowerStatsCmdBuilder {}.build().into()
}
@@ -166,17 +177,17 @@
uwb_uci_packets::DeviceResetCmdBuilder { reset_config }.build().into()
}
// UCI Session Control Commands
- UciCommand::SessionStart { session_id } => {
- uwb_uci_packets::SessionStartCmdBuilder { session_id }.build().into()
+ UciCommand::SessionStart { session_token } => {
+ uwb_uci_packets::SessionStartCmdBuilder { session_token }.build().into()
}
- UciCommand::SessionStop { session_id } => {
- uwb_uci_packets::SessionStopCmdBuilder { session_id }.build().into()
+ UciCommand::SessionStop { session_token } => {
+ uwb_uci_packets::SessionStopCmdBuilder { session_token }.build().into()
}
- UciCommand::SessionGetRangingCount { session_id } => {
- uwb_uci_packets::SessionGetRangingCountCmdBuilder { session_id }.build().into()
+ UciCommand::SessionGetRangingCount { session_token } => {
+ uwb_uci_packets::SessionGetRangingCountCmdBuilder { session_token }.build().into()
}
- UciCommand::SessionQueryMaxDataSize { session_id } => {
- uwb_uci_packets::SessionQueryMaxDataSizeCmdBuilder { session_id }.build().into()
+ UciCommand::SessionQueryMaxDataSize { session_token } => {
+ uwb_uci_packets::SessionQueryMaxDataSizeCmdBuilder { session_token }.build().into()
}
};
Ok(packet)
@@ -266,27 +277,27 @@
.into()
);
- cmd = UciCommand::SessionDeinit { session_id: 1 };
+ cmd = UciCommand::SessionDeinit { session_token: 1 };
packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
assert_eq!(
packet,
- uwb_uci_packets::SessionDeinitCmdBuilder { session_id: 1 }.build().into()
+ uwb_uci_packets::SessionDeinitCmdBuilder { session_token: 1 }.build().into()
);
- cmd = UciCommand::SessionSetAppConfig { session_id: 1, config_tlvs: vec![] };
+ cmd = UciCommand::SessionSetAppConfig { session_token: 1, config_tlvs: vec![] };
packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
assert_eq!(
packet,
- uwb_uci_packets::SessionSetAppConfigCmdBuilder { session_id: 1, tlvs: vec![] }
+ uwb_uci_packets::SessionSetAppConfigCmdBuilder { session_token: 1, tlvs: vec![] }
.build()
.into()
);
- cmd = UciCommand::SessionGetAppConfig { session_id: 1, app_cfg: vec![] };
+ cmd = UciCommand::SessionGetAppConfig { session_token: 1, app_cfg: vec![] };
packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
assert_eq!(
packet,
- uwb_uci_packets::SessionGetAppConfigCmdBuilder { session_id: 1, app_cfg: vec![] }
+ uwb_uci_packets::SessionGetAppConfigCmdBuilder { session_token: 1, app_cfg: vec![] }
.build()
.into()
);
@@ -295,15 +306,15 @@
packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
assert_eq!(packet, uwb_uci_packets::SessionGetCountCmdBuilder {}.build().into());
- cmd = UciCommand::SessionGetState { session_id: 1 };
+ cmd = UciCommand::SessionGetState { session_token: 1 };
packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
assert_eq!(
packet,
- uwb_uci_packets::SessionGetStateCmdBuilder { session_id: 1 }.build().into()
+ uwb_uci_packets::SessionGetStateCmdBuilder { session_token: 1 }.build().into()
);
cmd = UciCommand::SessionUpdateControllerMulticastList {
- session_id: 1,
+ session_token: 1,
action: UpdateMulticastListAction::AddControlee,
controlees: Controlees::NoSessionKey(vec![]),
};
@@ -321,43 +332,46 @@
);
cmd = UciCommand::SessionUpdateDtTagRangingRounds {
- session_id: 1,
+ session_token: 1,
ranging_round_indexes: vec![0],
};
packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
assert_eq!(
packet,
uwb_uci_packets::SessionUpdateDtTagRangingRoundsCmdBuilder {
- session_id: 1,
+ session_token: 1,
ranging_round_indexes: vec![0]
}
.build()
.into()
);
- cmd = UciCommand::SessionQueryMaxDataSize { session_id: 1 };
+ cmd = UciCommand::SessionQueryMaxDataSize { session_token: 1 };
packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
assert_eq!(
packet,
- uwb_uci_packets::SessionQueryMaxDataSizeCmdBuilder { session_id: 1 }.build().into()
+ uwb_uci_packets::SessionQueryMaxDataSizeCmdBuilder { session_token: 1 }.build().into()
);
- cmd = UciCommand::SessionStart { session_id: 1 };
+ cmd = UciCommand::SessionStart { session_token: 1 };
packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
assert_eq!(
packet,
- uwb_uci_packets::SessionStartCmdBuilder { session_id: 1 }.build().into()
+ uwb_uci_packets::SessionStartCmdBuilder { session_token: 1 }.build().into()
);
- cmd = UciCommand::SessionStop { session_id: 1 };
- packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
- assert_eq!(packet, uwb_uci_packets::SessionStopCmdBuilder { session_id: 1 }.build().into());
-
- cmd = UciCommand::SessionGetRangingCount { session_id: 1 };
+ cmd = UciCommand::SessionStop { session_token: 1 };
packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
assert_eq!(
packet,
- uwb_uci_packets::SessionGetRangingCountCmdBuilder { session_id: 1 }.build().into()
+ uwb_uci_packets::SessionStopCmdBuilder { session_token: 1 }.build().into()
+ );
+
+ cmd = UciCommand::SessionGetRangingCount { session_token: 1 };
+ packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap();
+ assert_eq!(
+ packet,
+ uwb_uci_packets::SessionGetRangingCountCmdBuilder { session_token: 1 }.build().into()
);
let country_code: [u8; 2] = [85, 83];
diff --git a/src/rust/uwb_core/src/uci/mock_uci_hal.rs b/src/rust/uwb_core/src/uci/mock_uci_hal.rs
index 7e7cfc0..4b170f1 100644
--- a/src/rust/uwb_core/src/uci/mock_uci_hal.rs
+++ b/src/rust/uwb_core/src/uci/mock_uci_hal.rs
@@ -17,6 +17,7 @@
use std::time::Duration;
use async_trait::async_trait;
+use log::error;
use tokio::sync::{mpsc, Notify};
use tokio::time::timeout;
@@ -28,7 +29,8 @@
/// The mock implementation of UciHal.
#[derive(Default, Clone)]
pub struct MockUciHal {
- packet_sender: Option<mpsc::UnboundedSender<UciHalPacket>>,
+ // Wrap inside Arc<Mutex<>> so that the MockUciHal.clone(s) refer to the same object.
+ packet_sender: Arc<Mutex<Option<mpsc::UnboundedSender<UciHalPacket>>>>,
expected_calls: Arc<Mutex<VecDeque<ExpectedCall>>>,
expect_call_consumed: Arc<Notify>,
}
@@ -92,6 +94,19 @@
}
true
}
+
+ // Receive a UCI packet (eg: UCI DATA_MESSAGE_RCV), from UWBS to Host.
+ pub fn receive_packet(&mut self, packet: UciHalPacket) -> Result<()> {
+ if let Some(ref ps) = *self.packet_sender.lock().unwrap() {
+ match ps.send(packet) {
+ Ok(_) => Ok(()),
+ Err(_) => Err(Error::Unknown),
+ }
+ } else {
+ error!("MockUciHal unable to Rx packet from HAL as channel closed");
+ Err(Error::MockUndefined)
+ }
+ }
}
#[async_trait]
@@ -107,7 +122,7 @@
}
}
if out.is_ok() {
- self.packet_sender.replace(packet_sender);
+ self.packet_sender.lock().unwrap().replace(packet_sender);
}
out
}
@@ -125,7 +140,7 @@
Some(ExpectedCall::Close { out }) => {
self.expect_call_consumed.notify_one();
if out.is_ok() {
- self.packet_sender = None;
+ *self.packet_sender.lock().unwrap() = None;
}
out
}
@@ -144,7 +159,8 @@
if expected_cmd == cmd =>
{
self.expect_call_consumed.notify_one();
- let packet_sender = self.packet_sender.as_mut().unwrap();
+ let mut packet_sender_opt = self.packet_sender.lock().unwrap();
+ let packet_sender = packet_sender_opt.as_mut().unwrap();
for msg in packets.into_iter() {
let _ = packet_sender.send(msg);
}
@@ -166,7 +182,8 @@
if expected_packet_tx == packet_tx =>
{
self.expect_call_consumed.notify_one();
- let packet_sender = self.packet_sender.as_mut().unwrap();
+ let mut packet_sender_opt = self.packet_sender.lock().unwrap();
+ let packet_sender = packet_sender_opt.as_mut().unwrap();
for msg in inject_packets_rx.into_iter() {
let _ = packet_sender.send(msg);
}
diff --git a/src/rust/uwb_core/src/uci/mock_uci_manager.rs b/src/rust/uwb_core/src/uci/mock_uci_manager.rs
index a206392..21e1ddb 100644
--- a/src/rust/uwb_core/src/uci/mock_uci_manager.rs
+++ b/src/rust/uwb_core/src/uci/mock_uci_manager.rs
@@ -28,10 +28,9 @@
use crate::error::{Error, Result};
use crate::params::uci_packets::{
app_config_tlvs_eq, device_config_tlvs_eq, AppConfigTlv, AppConfigTlvType, CapTlv, Controlees,
- CoreSetConfigResponse, CountryCode, DeviceConfigId, DeviceConfigTlv, FiraComponent,
- GetDeviceInfoResponse, PowerStats, RawUciMessage, ResetConfig, SessionId, SessionState,
- SessionType, SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse,
- UpdateMulticastListAction,
+ CoreSetConfigResponse, CountryCode, DeviceConfigId, DeviceConfigTlv, GetDeviceInfoResponse,
+ PowerStats, RawUciMessage, ResetConfig, SessionId, SessionState, SessionToken, SessionType,
+ SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse, UpdateMulticastListAction,
};
use crate::uci::notification::{
CoreNotification, DataRcvNotification, SessionNotification, UciNotification,
@@ -146,6 +145,13 @@
.push_back(ExpectedCall::CoreGetConfig { expected_config_ids, out });
}
+ /// Prepare Mock to expect core_query_uwb_timestamp.
+ ///
+ /// MockUciManager expects call with parameters, returns out as response.
+ pub fn expect_core_query_uwb_timestamp(&mut self, out: Result<u64>) {
+ self.expected_calls.lock().unwrap().push_back(ExpectedCall::CoreQueryTimeStamp { out });
+ }
+
/// Prepare Mock to expect session_init.
///
/// MockUciManager expects call with parameters, returns out as response, followed by notfs
@@ -389,15 +395,13 @@
&mut self,
expected_session_id: SessionId,
expected_address: Vec<u8>,
- expected_dest_end_point: FiraComponent,
- expected_uci_sequence_num: u8,
+ expected_uci_sequence_num: u16,
expected_app_payload_data: Vec<u8>,
out: Result<()>,
) {
self.expected_calls.lock().unwrap().push_back(ExpectedCall::SendDataPacket {
expected_session_id,
expected_address,
- expected_dest_end_point,
expected_uci_sequence_num,
expected_app_payload_data,
out,
@@ -576,6 +580,21 @@
}
}
+ async fn core_query_uwb_timestamp(&self) -> Result<u64> {
+ let mut expected_calls = self.expected_calls.lock().unwrap();
+ match expected_calls.pop_front() {
+ Some(ExpectedCall::CoreQueryTimeStamp { out }) => {
+ self.expect_call_consumed.notify_one();
+ out
+ }
+ Some(call) => {
+ expected_calls.push_front(call);
+ Err(Error::MockUndefined)
+ }
+ None => Err(Error::MockUndefined),
+ }
+ }
+
async fn session_init(&self, session_id: SessionId, session_type: SessionType) -> Result<()> {
let mut expected_calls = self.expected_calls.lock().unwrap();
match expected_calls.pop_front() {
@@ -889,8 +908,7 @@
&self,
session_id: SessionId,
address: Vec<u8>,
- dest_end_point: FiraComponent,
- uci_sequence_num: u8,
+ uci_sequence_num: u16,
app_payload_data: Vec<u8>,
) -> Result<()> {
let mut expected_calls = self.expected_calls.lock().unwrap();
@@ -898,13 +916,11 @@
Some(ExpectedCall::SendDataPacket {
expected_session_id,
expected_address,
- expected_dest_end_point,
expected_uci_sequence_num,
expected_app_payload_data,
out,
}) if expected_session_id == session_id
&& expected_address == address
- && expected_dest_end_point == dest_end_point
&& expected_uci_sequence_num == uci_sequence_num
&& expected_app_payload_data == app_payload_data =>
{
@@ -918,6 +934,13 @@
None => Err(Error::MockUndefined),
}
}
+
+ async fn get_session_token_from_session_id(
+ &self,
+ _session_id: SessionId,
+ ) -> Result<SessionToken> {
+ Ok(1) // No uci call here, no mock required.
+ }
}
#[derive(Clone)]
@@ -948,6 +971,9 @@
expected_config_ids: Vec<DeviceConfigId>,
out: Result<Vec<DeviceConfigTlv>>,
},
+ CoreQueryTimeStamp {
+ out: Result<u64>,
+ },
SessionInit {
expected_session_id: SessionId,
expected_session_type: SessionType,
@@ -1024,8 +1050,7 @@
SendDataPacket {
expected_session_id: SessionId,
expected_address: Vec<u8>,
- expected_dest_end_point: FiraComponent,
- expected_uci_sequence_num: u8,
+ expected_uci_sequence_num: u16,
expected_app_payload_data: Vec<u8>,
out: Result<()>,
},
diff --git a/src/rust/uwb_core/src/uci/notification.rs b/src/rust/uwb_core/src/uci/notification.rs
index 8007158..2158850 100644
--- a/src/rust/uwb_core/src/uci/notification.rs
+++ b/src/rust/uwb_core/src/uci/notification.rs
@@ -22,9 +22,9 @@
use crate::params::uci_packets::{
ControleeStatus, CreditAvailability, DataRcvStatusCode, DataTransferNtfStatusCode, DeviceState,
ExtendedAddressDlTdoaRangingMeasurement, ExtendedAddressOwrAoaRangingMeasurement,
- ExtendedAddressTwoWayRangingMeasurement, FiraComponent, RangingMeasurementType, RawUciMessage,
- SessionId, SessionState, ShortAddressDlTdoaRangingMeasurement,
- ShortAddressOwrAoaRangingMeasurement, ShortAddressTwoWayRangingMeasurement, StatusCode,
+ ExtendedAddressTwoWayRangingMeasurement, RangingMeasurementType, RawUciMessage, SessionState,
+ SessionToken, ShortAddressDlTdoaRangingMeasurement, ShortAddressOwrAoaRangingMeasurement,
+ ShortAddressTwoWayRangingMeasurement, StatusCode,
};
/// enum of all UCI notifications with structured fields.
@@ -52,8 +52,8 @@
pub enum SessionNotification {
/// SessionStatusNtf equivalent.
Status {
- /// SessionId : u32
- session_id: SessionId,
+ /// SessionToken : u32
+ session_token: SessionToken,
/// uwb_uci_packets::SessionState.
session_state: SessionState,
/// uwb_uci_packets::Reasoncode.
@@ -61,8 +61,8 @@
},
/// SessionUpdateControllerMulticastListNtf equivalent.
UpdateControllerMulticastList {
- /// SessionId : u32
- session_id: SessionId,
+ /// SessionToken : u32
+ session_token: SessionToken,
/// count of controlees: u8
remaining_multicast_list_size: usize,
/// list of controlees.
@@ -72,15 +72,15 @@
SessionInfo(SessionRangeData),
/// DataCreditNtf equivalent.
DataCredit {
- /// SessionId : u32
- session_id: SessionId,
+ /// SessionToken : u32
+ session_token: SessionToken,
/// Credit Availability (for sending Data packets on UWB Session)
credit_availability: CreditAvailability,
},
/// DataTransferStatusNtf equivalent.
DataTransferStatus {
- /// SessionId : u32
- session_id: SessionId,
+ /// SessionToken : u32
+ session_token: SessionToken,
/// Sequence Number: u8
uci_sequence_number: u8,
/// Data Transfer Status Code
@@ -95,7 +95,7 @@
pub sequence_number: u32,
/// The identifier of the session.
- pub session_id: SessionId,
+ pub session_token: SessionToken,
/// The current ranging interval setting in the unit of ms.
pub current_ranging_interval_ms: u32,
@@ -137,26 +137,20 @@
}
/// The DATA_RCV packet
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, std::cmp::PartialEq)]
pub struct DataRcvNotification {
/// The identifier of the session on which data transfer is happening.
- pub session_id: SessionId,
+ pub session_token: SessionToken,
/// The status of the data rx.
pub status: DataRcvStatusCode,
/// The sequence number of the data packet.
- pub uci_sequence_num: u32,
+ pub uci_sequence_num: u16,
/// MacAddress of the sender of the application data.
pub source_address: UwbAddress,
- /// Identifier for the source FiraComponent.
- pub source_fira_component: FiraComponent,
-
- /// Identifier for the destination FiraComponent.
- pub dest_fira_component: FiraComponent,
-
/// Application Payload Data
pub payload: Vec<u8>,
}
@@ -166,12 +160,10 @@
fn try_from(evt: uwb_uci_packets::UciDataPacket) -> std::result::Result<Self, Self::Error> {
match evt.specialize() {
uwb_uci_packets::UciDataPacketChild::UciDataRcv(evt) => Ok(DataRcvNotification {
- session_id: evt.get_session_id(),
+ session_token: evt.get_session_token(),
status: evt.get_status(),
uci_sequence_num: evt.get_uci_sequence_number(),
source_address: UwbAddress::Extended(evt.get_source_mac_address().to_le_bytes()),
- source_fira_component: evt.get_source_fira_component(),
- dest_fira_component: evt.get_dest_fira_component(),
payload: evt.get_data().to_vec(),
}),
_ => {
@@ -242,13 +234,13 @@
use uwb_uci_packets::SessionConfigNotificationChild;
match evt.specialize() {
SessionConfigNotificationChild::SessionStatusNtf(evt) => Ok(Self::Status {
- session_id: evt.get_session_id(),
+ session_token: evt.get_session_token(),
session_state: evt.get_session_state(),
reason_code: evt.get_reason_code(),
}),
SessionConfigNotificationChild::SessionUpdateControllerMulticastListNtf(evt) => {
Ok(Self::UpdateControllerMulticastList {
- session_id: evt.get_session_id(),
+ session_token: evt.get_session_token(),
remaining_multicast_list_size: evt.get_remaining_multicast_list_size() as usize,
status_list: evt.get_controlee_status().clone(),
})
@@ -270,12 +262,12 @@
match evt.specialize() {
SessionControlNotificationChild::SessionInfoNtf(evt) => evt.try_into(),
SessionControlNotificationChild::DataCreditNtf(evt) => Ok(Self::DataCredit {
- session_id: evt.get_session_id(),
+ session_token: evt.get_session_token(),
credit_availability: evt.get_credit_availability(),
}),
SessionControlNotificationChild::DataTransferStatusNtf(evt) => {
Ok(Self::DataTransferStatus {
- session_id: evt.get_session_id(),
+ session_token: evt.get_session_token(),
uci_sequence_number: evt.get_uci_sequence_number(),
status: evt.get_status(),
})
@@ -307,7 +299,16 @@
SessionInfoNtfChild::ShortMacOwrAoaSessionInfoNtf(evt) => {
if evt.get_owr_aoa_ranging_measurements().clone().len() == 1 {
RangingMeasurements::ShortAddressOwrAoa(
- evt.get_owr_aoa_ranging_measurements().clone().pop().unwrap(),
+ match evt.get_owr_aoa_ranging_measurements().clone().pop() {
+ Some(r) => r,
+ None => {
+ error!(
+ "Unable to parse ShortAddress OwrAoA measurement: {:?}",
+ evt
+ );
+ return Err(Error::BadParameters);
+ }
+ },
)
} else {
error!("Wrong count of OwrAoA ranging measurements {:?}", evt);
@@ -317,7 +318,16 @@
SessionInfoNtfChild::ExtendedMacOwrAoaSessionInfoNtf(evt) => {
if evt.get_owr_aoa_ranging_measurements().clone().len() == 1 {
RangingMeasurements::ExtendedAddressOwrAoa(
- evt.get_owr_aoa_ranging_measurements().clone().pop().unwrap(),
+ match evt.get_owr_aoa_ranging_measurements().clone().pop() {
+ Some(r) => r,
+ None => {
+ error!(
+ "Unable to parse ExtendedAddress OwrAoA measurement: {:?}",
+ evt
+ );
+ return Err(Error::BadParameters);
+ }
+ },
)
} else {
error!("Wrong count of OwrAoA ranging measurements {:?}", evt);
@@ -363,7 +373,7 @@
};
Ok(Self::SessionInfo(SessionRangeData {
sequence_number: evt.get_sequence_number(),
- session_id: evt.get_session_id(),
+ session_token: evt.get_session_token(),
current_ranging_interval_ms: evt.get_current_ranging_interval(),
ranging_measurement_type: evt.get_ranging_measurement_type(),
ranging_measurements,
@@ -450,7 +460,6 @@
#[cfg(test)]
mod tests {
use super::*;
- use crate::params::uci_packets::OwrAoaStatusCode;
#[test]
fn test_ranging_measurements_trait() {
@@ -538,7 +547,7 @@
let extended_two_way_session_info_ntf =
uwb_uci_packets::ExtendedMacTwoWaySessionInfoNtfBuilder {
sequence_number: 0x10,
- session_id: 0x11,
+ session_token: 0x11,
rcr_indicator: 0x12,
current_ranging_interval: 0x13,
two_way_ranging_measurements: vec![extended_measurement.clone()],
@@ -556,7 +565,7 @@
uci_notification_from_extended_two_way_session_info_ntf,
UciNotification::Session(SessionNotification::SessionInfo(SessionRangeData {
sequence_number: 0x10,
- session_id: 0x11,
+ session_token: 0x11,
ranging_measurement_type: uwb_uci_packets::RangingMeasurementType::TwoWay,
current_ranging_interval_ms: 0x13,
ranging_measurements: RangingMeasurements::ExtendedAddressTwoWay(vec![
@@ -588,7 +597,7 @@
};
let short_two_way_session_info_ntf = uwb_uci_packets::ShortMacTwoWaySessionInfoNtfBuilder {
sequence_number: 0x10,
- session_id: 0x11,
+ session_token: 0x11,
rcr_indicator: 0x12,
current_ranging_interval: 0x13,
two_way_ranging_measurements: vec![short_measurement.clone()],
@@ -606,7 +615,7 @@
uci_notification_from_short_two_way_session_info_ntf,
UciNotification::Session(SessionNotification::SessionInfo(SessionRangeData {
sequence_number: 0x10,
- session_id: 0x11,
+ session_token: 0x11,
ranging_measurement_type: uwb_uci_packets::RangingMeasurementType::TwoWay,
current_ranging_interval_ms: 0x13,
ranging_measurements: RangingMeasurements::ShortAddressTwoWay(vec![
@@ -622,7 +631,7 @@
fn test_session_notification_casting_from_extended_mac_owr_aoa_session_info_ntf() {
let extended_measurement = uwb_uci_packets::ExtendedAddressOwrAoaRangingMeasurement {
mac_address: 0x1234_5678_90ab,
- status: OwrAoaStatusCode::UciStatusSuccess,
+ status: StatusCode::UciStatusOk,
nlos: 0,
frame_sequence_number: 1,
block_index: 1,
@@ -634,7 +643,7 @@
let extended_owr_aoa_session_info_ntf =
uwb_uci_packets::ExtendedMacOwrAoaSessionInfoNtfBuilder {
sequence_number: 0x10,
- session_id: 0x11,
+ session_token: 0x11,
rcr_indicator: 0x12,
current_ranging_interval: 0x13,
owr_aoa_ranging_measurements: vec![extended_measurement.clone()],
@@ -652,7 +661,7 @@
uci_notification_from_extended_owr_aoa_session_info_ntf,
UciNotification::Session(SessionNotification::SessionInfo(SessionRangeData {
sequence_number: 0x10,
- session_id: 0x11,
+ session_token: 0x11,
ranging_measurement_type: uwb_uci_packets::RangingMeasurementType::OwrAoa,
current_ranging_interval_ms: 0x13,
ranging_measurements: RangingMeasurements::ExtendedAddressOwrAoa(
@@ -668,7 +677,7 @@
fn test_session_notification_casting_from_short_mac_owr_aoa_session_info_ntf() {
let short_measurement = uwb_uci_packets::ShortAddressOwrAoaRangingMeasurement {
mac_address: 0x1234,
- status: OwrAoaStatusCode::UciStatusSuccess,
+ status: StatusCode::UciStatusOk,
nlos: 0,
frame_sequence_number: 1,
block_index: 1,
@@ -679,7 +688,7 @@
};
let short_owr_aoa_session_info_ntf = uwb_uci_packets::ShortMacOwrAoaSessionInfoNtfBuilder {
sequence_number: 0x10,
- session_id: 0x11,
+ session_token: 0x11,
rcr_indicator: 0x12,
current_ranging_interval: 0x13,
owr_aoa_ranging_measurements: vec![short_measurement.clone()],
@@ -697,7 +706,7 @@
uci_notification_from_short_owr_aoa_session_info_ntf,
UciNotification::Session(SessionNotification::SessionInfo(SessionRangeData {
sequence_number: 0x10,
- session_id: 0x11,
+ session_token: 0x11,
ranging_measurement_type: uwb_uci_packets::RangingMeasurementType::OwrAoa,
current_ranging_interval_ms: 0x13,
ranging_measurements: RangingMeasurements::ShortAddressOwrAoa(short_measurement),
@@ -710,7 +719,7 @@
#[test]
fn test_session_notification_casting_from_session_status_ntf() {
let session_status_ntf = uwb_uci_packets::SessionStatusNtfBuilder {
- session_id: 0x20,
+ session_token: 0x20,
session_state: uwb_uci_packets::SessionState::SessionStateActive,
reason_code: uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands
.into(),
@@ -725,7 +734,7 @@
assert_eq!(
uci_notification_from_session_status_ntf,
UciNotification::Session(SessionNotification::Status {
- session_id: 0x20,
+ session_token: 0x20,
session_state: uwb_uci_packets::SessionState::SessionStateActive,
reason_code: uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands
.into(),
@@ -737,18 +746,18 @@
fn test_session_notification_casting_from_session_update_controller_multicast_list_ntf_packet()
{
let controlee_status = uwb_uci_packets::ControleeStatus {
- mac_address: 0xc0a8,
+ mac_address: [0x0c, 0xa8],
subsession_id: 0x30,
status: uwb_uci_packets::MulticastUpdateStatusCode::StatusOkMulticastListUpdate,
};
let another_controlee_status = uwb_uci_packets::ControleeStatus {
- mac_address: 0xc0a9,
+ mac_address: [0x0c, 0xa9],
subsession_id: 0x31,
status: uwb_uci_packets::MulticastUpdateStatusCode::StatusErrorKeyFetchFail,
};
let session_update_controller_multicast_list_ntf =
uwb_uci_packets::SessionUpdateControllerMulticastListNtfBuilder {
- session_id: 0x32,
+ session_token: 0x32,
remaining_multicast_list_size: 0x2,
controlee_status: vec![controlee_status.clone(), another_controlee_status.clone()],
}
@@ -764,7 +773,7 @@
assert_eq!(
uci_notification_from_session_update_controller_multicast_list_ntf,
UciNotification::Session(SessionNotification::UpdateControllerMulticastList {
- session_id: 0x32,
+ session_token: 0x32,
remaining_multicast_list_size: 0x2,
status_list: vec![controlee_status, another_controlee_status],
})
diff --git a/src/rust/uwb_core/src/uci/pcapng_uci_logger_factory.rs b/src/rust/uwb_core/src/uci/pcapng_uci_logger_factory.rs
index 04e1ef4..7c191b7 100644
--- a/src/rust/uwb_core/src/uci/pcapng_uci_logger_factory.rs
+++ b/src/rust/uwb_core/src/uci/pcapng_uci_logger_factory.rs
@@ -566,6 +566,7 @@
#[test]
fn test_file_switch_epb_unfit_case() {
let dir = tempdir().unwrap();
+ let last_file_expected = dir.as_ref().to_owned().join("log_2.pcapng");
{
let runtime = Builder::new_multi_thread().enable_all().build().unwrap();
let mut file_manager_140 = PcapngUciLoggerFactoryBuilder::new()
@@ -585,7 +586,15 @@
let packet_2 = UciVendor_A_NotificationBuilder { opcode: 2, payload: None }.build();
logger_0.log_uci_control_packet(packet_2.into());
// Sleep needed to guarantee handling pending logs before runtime goes out of scope.
- thread::sleep(time::Duration::from_millis(10));
+ let mut timeout = 100;
+ let timeout_slice = 10;
+ loop {
+ if last_file_expected.exists() || timeout == 0 {
+ break;
+ }
+ thread::sleep(time::Duration::from_millis(timeout_slice));
+ timeout -= timeout_slice;
+ }
}
// Expect (Old to new):
// File 2: SHB->IDB->EPB->IDB (cannot fit next)
diff --git a/src/rust/uwb_core/src/uci/response.rs b/src/rust/uwb_core/src/uci/response.rs
index b0d5b2b..dfeb6c8 100644
--- a/src/rust/uwb_core/src/uci/response.rs
+++ b/src/rust/uwb_core/src/uci/response.rs
@@ -17,12 +17,12 @@
use crate::error::{Error, Result};
use crate::params::uci_packets::{
AppConfigTlv, CapTlv, CoreSetConfigResponse, DeviceConfigTlv, GetDeviceInfoResponse,
- PowerStats, RawUciMessage, SessionState, SessionUpdateDtTagRangingRoundsResponse,
- SetAppConfigResponse, StatusCode, UciControlPacket,
+ PowerStats, RawUciMessage, SessionHandle, SessionState,
+ SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse, StatusCode, UciControlPacket,
};
use crate::uci::error::status_code_to_result;
-#[derive(Debug)]
+#[derive(Debug, Clone, PartialEq)]
pub(super) enum UciResponse {
SetLoggerMode,
SetNotification,
@@ -33,7 +33,8 @@
CoreGetCapsInfo(Result<Vec<CapTlv>>),
CoreSetConfig(CoreSetConfigResponse),
CoreGetConfig(Result<Vec<DeviceConfigTlv>>),
- SessionInit(Result<()>),
+ CoreQueryTimeStamp(Result<u64>),
+ SessionInit(Result<Option<SessionHandle>>),
SessionDeinit(Result<()>),
SessionSetAppConfig(SetAppConfigResponse),
SessionGetAppConfig(Result<Vec<AppConfigTlv>>),
@@ -59,6 +60,7 @@
Self::CoreGetDeviceInfo(result) => Self::matches_result_retry(result),
Self::CoreGetCapsInfo(result) => Self::matches_result_retry(result),
Self::CoreGetConfig(result) => Self::matches_result_retry(result),
+ Self::CoreQueryTimeStamp(result) => Self::matches_result_retry(result),
Self::SessionInit(result) => Self::matches_result_retry(result),
Self::SessionDeinit(result) => Self::matches_result_retry(result),
Self::SessionGetAppConfig(result) => Self::matches_result_retry(result),
@@ -141,6 +143,9 @@
CoreResponseChild::GetConfigRsp(evt) => Ok(UciResponse::CoreGetConfig(
status_code_to_result(evt.get_status()).map(|_| evt.get_tlvs().clone()),
)),
+ CoreResponseChild::CoreQueryTimeStampRsp(evt) => Ok(UciResponse::CoreQueryTimeStamp(
+ status_code_to_result(evt.get_status()).map(|_| evt.get_timeStamp()),
+ )),
_ => Err(Error::Unknown),
}
}
@@ -154,8 +159,11 @@
use uwb_uci_packets::SessionConfigResponseChild;
match evt.specialize() {
SessionConfigResponseChild::SessionInitRsp(evt) => {
- Ok(UciResponse::SessionInit(status_code_to_result(evt.get_status())))
+ Ok(UciResponse::SessionInit(status_code_to_result(evt.get_status()).map(|_| None)))
}
+ SessionConfigResponseChild::SessionInitRsp_V2(evt) => Ok(UciResponse::SessionInit(
+ status_code_to_result(evt.get_status()).map(|_| Some(evt.get_session_handle())),
+ )),
SessionConfigResponseChild::SessionDeinitRsp(evt) => {
Ok(UciResponse::SessionDeinit(status_code_to_result(evt.get_status())))
}
diff --git a/src/rust/uwb_core/src/uci/uci_hal.rs b/src/rust/uwb_core/src/uci/uci_hal.rs
index 1153872..151a808 100644
--- a/src/rust/uwb_core/src/uci/uci_hal.rs
+++ b/src/rust/uwb_core/src/uci/uci_hal.rs
@@ -32,7 +32,7 @@
/// this trait and inject into the library.
/// Note: Each method should be completed in 1000 ms.
#[async_trait]
-pub trait UciHal: 'static + Send {
+pub trait UciHal: 'static + Send + Sync {
/// Open the UCI HAL and power on the UWB Subsystem.
///
/// All the other API should be called after the open() completes successfully. Once the method
diff --git a/src/rust/uwb_core/src/uci/uci_logger.rs b/src/rust/uwb_core/src/uci/uci_logger.rs
index 5023d7a..7045b43 100644
--- a/src/rust/uwb_core/src/uci/uci_logger.rs
+++ b/src/rust/uwb_core/src/uci/uci_logger.rs
@@ -74,10 +74,12 @@
UciControlPacketChild::UciCommand(control_cmd) => match control_cmd.specialize() {
UciCommandChild::SessionConfigCommand(session_cmd) => match session_cmd.specialize() {
SessionConfigCommandChild::SessionSetAppConfigCmd(set_config_cmd) => {
- let session_id = set_config_cmd.get_session_id();
+ let session_token = set_config_cmd.get_session_token();
let tlvs = set_config_cmd.get_tlvs().to_owned();
let filtered_tlvs = tlvs.into_iter().map(filter_tlv).collect();
- SessionSetAppConfigCmdBuilder { session_id, tlvs: filtered_tlvs }.build().into()
+ SessionSetAppConfigCmdBuilder { session_token, tlvs: filtered_tlvs }
+ .build()
+ .into()
}
_ => session_cmd.into(),
},
@@ -214,7 +216,7 @@
#[test]
fn test_log_command_filter() -> Result<()> {
let set_config_cmd = UciCommand::SessionSetAppConfig {
- session_id: 0x1,
+ session_token: 0x1,
config_tlvs: vec![
// Filtered to 0-filled of same length
AppConfigTlv { cfg_id: AppConfigTlvType::VendorId, v: vec![0, 1, 2] }.into(),
diff --git a/src/rust/uwb_core/src/uci/uci_manager.rs b/src/rust/uwb_core/src/uci/uci_manager.rs
index 9d05224..f2563eb 100644
--- a/src/rust/uwb_core/src/uci/uci_manager.rs
+++ b/src/rust/uwb_core/src/uci/uci_manager.rs
@@ -13,26 +13,27 @@
// limitations under the License.
use std::convert::TryInto;
+use std::sync::Arc;
use std::time::Duration;
use async_trait::async_trait;
-use log::{debug, error, warn};
-use tokio::sync::{mpsc, oneshot};
+use log::{debug, error, info, warn};
+use tokio::sync::{mpsc, oneshot, Mutex};
use crate::uci::command::UciCommand;
//use crate::uci::error::{Error, Result};
use crate::error::{Error, Result};
use crate::params::uci_packets::{
AppConfigTlv, AppConfigTlvType, CapTlv, Controlees, CoreSetConfigResponse, CountryCode,
- CreditAvailability, DeviceConfigId, DeviceConfigTlv, DeviceState, FiraComponent,
- GetDeviceInfoResponse, GroupId, MessageType, PowerStats, RawUciMessage, ResetConfig, SessionId,
- SessionState, SessionType, SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse,
+ CreditAvailability, DeviceConfigId, DeviceConfigTlv, DeviceState, GetDeviceInfoResponse,
+ GroupId, MessageType, PowerStats, RawUciMessage, ResetConfig, SessionId, SessionState,
+ SessionToken, SessionType, SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse,
UciDataPacket, UciDataPacketHal, UpdateMulticastListAction,
};
use crate::params::utils::bytes_to_u64;
use crate::uci::message::UciMessage;
use crate::uci::notification::{
- CoreNotification, DataRcvNotification, SessionNotification, UciNotification,
+ CoreNotification, DataRcvNotification, SessionNotification, SessionRangeData, UciNotification,
};
use crate::uci::response::UciResponse;
use crate::uci::timeout_uci_hal::TimeoutUciHal;
@@ -87,6 +88,7 @@
&self,
config_ids: Vec<DeviceConfigId>,
) -> Result<Vec<DeviceConfigTlv>>;
+ async fn core_query_uwb_timestamp(&self) -> Result<u64>;
async fn session_init(&self, session_id: SessionId, session_type: SessionType) -> Result<()>;
async fn session_deinit(&self, session_id: SessionId) -> Result<()>;
async fn session_set_app_config(
@@ -139,10 +141,15 @@
&self,
session_id: SessionId,
address: Vec<u8>,
- dest_end_point: FiraComponent,
- uci_sequence_number: u8,
+ uci_sequence_number: u16,
app_payload_data: Vec<u8>,
) -> Result<()>;
+
+ // Get Session token from session id
+ async fn get_session_token_from_session_id(
+ &self,
+ session_id: SessionId,
+ ) -> Result<SessionToken>;
}
/// UciManagerImpl is the main implementation of UciManager. Using the actor model, UciManagerImpl
@@ -150,6 +157,11 @@
#[derive(Clone)]
pub struct UciManagerImpl {
cmd_sender: mpsc::UnboundedSender<(UciManagerCmd, oneshot::Sender<Result<UciResponse>>)>,
+
+ // FIRA version 2 introduces a UWBS generated session handle to use as identifier for all
+ // session related commands. This map stores the app provided session id to UWBS generated
+ // session handle mapping if provided, else reuses session id.
+ session_id_to_token_map: Arc<Mutex<HashMap<SessionId, SessionToken>>>,
}
impl UciManagerImpl {
@@ -160,10 +172,18 @@
logger_mode: UciLoggerMode,
) -> Self {
let (cmd_sender, cmd_receiver) = mpsc::unbounded_channel();
- let mut actor = UciManagerActor::new(hal, logger, logger_mode, cmd_receiver);
+ let session_id_to_token_map: Arc<Mutex<HashMap<SessionId, SessionToken>>> =
+ Arc::new(Mutex::new(HashMap::new()));
+ let mut actor = UciManagerActor::new(
+ hal,
+ logger,
+ logger_mode,
+ cmd_receiver,
+ session_id_to_token_map.clone(),
+ );
tokio::spawn(async move { actor.run().await });
- Self { cmd_sender }
+ Self { cmd_sender, session_id_to_token_map }
}
// Send the |cmd| to the UciManagerActor.
@@ -177,6 +197,15 @@
}
}
}
+
+ async fn get_session_token(&self, session_id: &SessionId) -> Result<SessionToken> {
+ self.session_id_to_token_map
+ .lock()
+ .await
+ .get(session_id)
+ .ok_or(Error::BadParameters)
+ .copied()
+ }
}
#[async_trait]
@@ -290,17 +319,27 @@
}
}
+ async fn core_query_uwb_timestamp(&self) -> Result<u64> {
+ let cmd = UciCommand::CoreQueryTimeStamp;
+ match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
+ Ok(UciResponse::CoreQueryTimeStamp(resp)) => resp,
+ Ok(_) => Err(Error::Unknown),
+ Err(e) => Err(e),
+ }
+ }
+
async fn session_init(&self, session_id: SessionId, session_type: SessionType) -> Result<()> {
let cmd = UciCommand::SessionInit { session_id, session_type };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
- Ok(UciResponse::SessionInit(resp)) => resp,
+ Ok(UciResponse::SessionInit(resp)) => resp.map(|_| {}),
Ok(_) => Err(Error::Unknown),
Err(e) => Err(e),
}
}
async fn session_deinit(&self, session_id: SessionId) -> Result<()> {
- let cmd = UciCommand::SessionDeinit { session_id };
+ let cmd =
+ UciCommand::SessionDeinit { session_token: self.get_session_token(&session_id).await? };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionDeinit(resp)) => resp,
Ok(_) => Err(Error::Unknown),
@@ -313,7 +352,10 @@
session_id: SessionId,
config_tlvs: Vec<AppConfigTlv>,
) -> Result<SetAppConfigResponse> {
- let cmd = UciCommand::SessionSetAppConfig { session_id, config_tlvs };
+ let cmd = UciCommand::SessionSetAppConfig {
+ session_token: self.get_session_token(&session_id).await?,
+ config_tlvs,
+ };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionSetAppConfig(resp)) => Ok(resp),
Ok(_) => Err(Error::Unknown),
@@ -326,7 +368,10 @@
session_id: SessionId,
app_cfg: Vec<AppConfigTlvType>,
) -> Result<Vec<AppConfigTlv>> {
- let cmd = UciCommand::SessionGetAppConfig { session_id, app_cfg };
+ let cmd = UciCommand::SessionGetAppConfig {
+ session_token: self.get_session_token(&session_id).await?,
+ app_cfg,
+ };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionGetAppConfig(resp)) => resp,
Ok(_) => Err(Error::Unknown),
@@ -344,7 +389,9 @@
}
async fn session_get_state(&self, session_id: SessionId) -> Result<SessionState> {
- let cmd = UciCommand::SessionGetState { session_id };
+ let cmd = UciCommand::SessionGetState {
+ session_token: self.get_session_token(&session_id).await?,
+ };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionGetState(resp)) => resp,
Ok(_) => Err(Error::Unknown),
@@ -367,8 +414,11 @@
warn!("Number of controlees should be between 1 to 8");
return Err(Error::BadParameters);
}
- let cmd =
- UciCommand::SessionUpdateControllerMulticastList { session_id, action, controlees };
+ let cmd = UciCommand::SessionUpdateControllerMulticastList {
+ session_token: self.get_session_token(&session_id).await?,
+ action,
+ controlees,
+ };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionUpdateControllerMulticastList(resp)) => resp,
Ok(_) => Err(Error::Unknown),
@@ -381,7 +431,10 @@
session_id: u32,
ranging_round_indexes: Vec<u8>,
) -> Result<SessionUpdateDtTagRangingRoundsResponse> {
- let cmd = UciCommand::SessionUpdateDtTagRangingRounds { session_id, ranging_round_indexes };
+ let cmd = UciCommand::SessionUpdateDtTagRangingRounds {
+ session_token: self.get_session_token(&session_id).await?,
+ ranging_round_indexes,
+ };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionUpdateDtTagRangingRounds(resp)) => resp,
Ok(_) => Err(Error::Unknown),
@@ -390,7 +443,9 @@
}
async fn session_query_max_data_size(&self, session_id: SessionId) -> Result<u16> {
- let cmd = UciCommand::SessionQueryMaxDataSize { session_id };
+ let cmd = UciCommand::SessionQueryMaxDataSize {
+ session_token: self.get_session_token(&session_id).await?,
+ };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionQueryMaxDataSize(resp)) => resp,
Ok(_) => Err(Error::Unknown),
@@ -399,7 +454,8 @@
}
async fn range_start(&self, session_id: SessionId) -> Result<()> {
- let cmd = UciCommand::SessionStart { session_id };
+ let cmd =
+ UciCommand::SessionStart { session_token: self.get_session_token(&session_id).await? };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionStart(resp)) => resp,
Ok(_) => Err(Error::Unknown),
@@ -408,7 +464,8 @@
}
async fn range_stop(&self, session_id: SessionId) -> Result<()> {
- let cmd = UciCommand::SessionStop { session_id };
+ let cmd =
+ UciCommand::SessionStop { session_token: self.get_session_token(&session_id).await? };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionStop(resp)) => resp,
Ok(_) => Err(Error::Unknown),
@@ -417,7 +474,9 @@
}
async fn range_get_ranging_count(&self, session_id: SessionId) -> Result<usize> {
- let cmd = UciCommand::SessionGetRangingCount { session_id };
+ let cmd = UciCommand::SessionGetRangingCount {
+ session_token: self.get_session_token(&session_id).await?,
+ };
match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await {
Ok(UciResponse::SessionGetRangingCount(resp)) => resp,
Ok(_) => Err(Error::Unknown),
@@ -463,20 +522,17 @@
&self,
session_id: SessionId,
dest_mac_address_bytes: Vec<u8>,
- dest_fira_component: FiraComponent,
- uci_sequence_number: u8,
+ uci_sequence_number: u16,
data: Vec<u8>,
) -> Result<()> {
debug!(
"send_data_packet(): will Tx a data packet, session_id {}, sequence_number {}",
session_id, uci_sequence_number
);
- let dest_mac_address =
- bytes_to_u64(dest_mac_address_bytes).ok_or(Error::BadParameters).unwrap();
+ let dest_mac_address = bytes_to_u64(dest_mac_address_bytes).ok_or(Error::BadParameters)?;
let data_snd_packet = uwb_uci_packets::UciDataSndBuilder {
- session_id,
+ session_token: self.get_session_token(&session_id).await?,
dest_mac_address,
- dest_fira_component,
uci_sequence_number,
data,
}
@@ -488,6 +544,14 @@
Err(e) => Err(e),
}
}
+
+ // Get session token from session id (no uci call).
+ async fn get_session_token_from_session_id(
+ &self,
+ session_id: SessionId,
+ ) -> Result<SessionToken> {
+ Ok(self.get_session_token(&session_id).await?)
+ }
}
struct UciManagerActor<T: UciHal, U: UciLogger> {
@@ -500,7 +564,7 @@
// Set to true when |hal| is opened successfully.
is_hal_opened: bool,
- // Receive response, notification and data packets from |hal|. Only used when |hal| is opened
+ // Receive response, notification and data packets from |mut hal|. Only used when |hal| is opened
// successfully.
packet_receiver: mpsc::UnboundedReceiver<UciHalPacket>,
// Defrag the UCI packets.
@@ -512,11 +576,11 @@
// Store per-session CreditAvailability. This should be initialized when a UWB session becomes
// ACTIVE, and updated every time a Data packet fragment is sent or a DataCreditNtf is received.
- data_credit_map: HashMap<SessionId, CreditAvailability>,
+ data_credit_map: HashMap<SessionToken, CreditAvailability>,
// Store the Uci Data packet fragments to be sent to the UWBS, keyed by the SessionId. This
// helps to retrieve the next packet fragment to be sent, when the UWBS is ready to accept it.
- data_packet_fragments_map: HashMap<SessionId, VecDeque<UciDataPacketHal>>,
+ data_packet_fragments_map: HashMap<SessionToken, VecDeque<UciDataPacketHal>>,
// The timeout of waiting for the notification of device ready notification.
wait_device_status_timeout: PinSleep,
@@ -541,6 +605,14 @@
session_notf_sender: mpsc::UnboundedSender<SessionNotification>,
vendor_notf_sender: mpsc::UnboundedSender<RawUciMessage>,
data_rcv_notf_sender: mpsc::UnboundedSender<DataRcvNotification>,
+
+ // Used to store the last init session id to help map the session handle sent
+ // in session int response can be correctly mapped.
+ last_init_session_id: Option<SessionId>,
+ // FIRA version 2 introduces a UWBS generated session handle to use as identifier for all
+ // session related commands. This map stores the app provided session id to UWBS generated
+ // session handle mapping if provided, else reuses session id.
+ session_id_to_token_map: Arc<Mutex<HashMap<SessionId, SessionToken>>>,
}
impl<T: UciHal, U: UciLogger> UciManagerActor<T, U> {
@@ -552,6 +624,7 @@
UciManagerCmd,
oneshot::Sender<Result<UciResponse>>,
)>,
+ session_id_to_token_map: Arc<Mutex<HashMap<SessionId, SessionToken>>>,
) -> Self {
Self {
hal: TimeoutUciHal::new(hal),
@@ -572,6 +645,8 @@
session_notf_sender: mpsc::unbounded_channel().0,
vendor_notf_sender: mpsc::unbounded_channel().0,
data_rcv_notf_sender: mpsc::unbounded_channel().0,
+ last_init_session_id: None,
+ session_id_to_token_map,
}
}
@@ -600,7 +675,9 @@
// Timeout waiting for the response of the UCI command.
_ = &mut self.wait_resp_timeout, if self.is_waiting_resp() => {
- self.uci_cmd_retryer.take().unwrap().send_result(Err(Error::Timeout));
+ if let Some(uci_cmd_retryer) = self.uci_cmd_retryer.take() {
+ uci_cmd_retryer.send_result(Err(Error::Timeout));
+ }
}
// Timeout waiting for the notification of the device status.
@@ -619,6 +696,60 @@
}
}
+ async fn insert_session_token(&self, session_id: SessionId, session_token: SessionToken) {
+ self.session_id_to_token_map.lock().await.insert(session_id, session_token);
+ }
+
+ async fn remove_session_token(&self, session_token: &SessionToken) {
+ self.session_id_to_token_map.lock().await.retain(|_, val| *val != *session_token);
+ }
+
+ async fn get_session_id(&self, session_token: &SessionToken) -> Result<SessionId> {
+ self.session_id_to_token_map
+ .lock()
+ .await
+ .iter()
+ .find_map(|(key, &val)| if val == *session_token { Some(key) } else { None })
+ .ok_or(Error::BadParameters)
+ .copied()
+ }
+
+ fn save_session_id_if_init_cmd(&mut self, cmd: &UciCommand) {
+ // Store the last init session id to help map the session handle sent
+ // in session init response.
+ if let UciCommand::SessionInit { session_id, .. } = cmd {
+ self.last_init_session_id = Some(*session_id);
+ }
+ }
+
+ async fn store_session_token_if_init_resp(&mut self, resp: &UciResponse) -> Result<()> {
+ // Store the session_id to session_token mapping for this new session.
+ if let UciResponse::SessionInit(session_init_resp) = resp {
+ let session_id = match self.last_init_session_id.take() {
+ Some(session_id) => session_id,
+ None => {
+ return Err(Error::Unknown);
+ }
+ };
+ if let Ok(opt_session_handle) = session_init_resp {
+ let session_handle = match opt_session_handle {
+ // Session Handle provided by UWBS, use as token for further commands.
+ Some(session_handle) => {
+ info!(
+ "session handle: {:?} provided for session id: {:?}",
+ session_handle, session_id
+ );
+ *session_handle
+ }
+ // Session Handle not provided by UWBS, reuse session id as token for further commands.
+ None => session_id,
+ };
+ self.insert_session_token(session_id, session_handle).await;
+ }
+ }
+ Ok(())
+ }
+
async fn handle_cmd(
&mut self,
cmd: UciManagerCmd,
@@ -697,6 +828,8 @@
UciManagerCmd::SendUciCommand { cmd } => {
debug_assert!(self.uci_cmd_retryer.is_none());
+ self.save_session_id_if_init_cmd(&cmd);
+
// Remember that this command is a raw UCI command, we'll use this later
// to send a raw UCI response.
if let UciCommand::RawUciCmd { mt: _, gid, oid, payload: _ } = cmd.clone() {
@@ -715,14 +848,19 @@
}
self.last_raw_cmd = Some(RawUciControlPacket {
mt: u8::from(MessageType::Command),
- gid: gid_u8.unwrap(),
- oid: oid_u8.unwrap(),
- payload: Vec::new(), // There's no need to store the Raw UCI CMD's payload.
+ gid: gid_u8.unwrap(), // Safe as we check gid_u8.is_err() above.
+ oid: oid_u8.unwrap(), // Safe as we check uid_i8.is_err() above.
+ payload: Vec::new(), // There's no need to store the Raw UCI CMD's payload.
});
}
self.uci_cmd_retryer =
Some(UciCmdRetryer { cmd, result_sender, retry_count: MAX_RETRY_COUNT });
+
+ // Reset DataSndRetryer so if a CORE_GENERIC_ERROR_NTF with STATUS_UCI_PACKET_RETRY
+ // is received, only this UCI CMD packet will be retried.
+ let _ = self.uci_data_snd_retryer.take();
+
self.retry_uci_cmd().await;
}
@@ -756,11 +894,11 @@
async fn retry_uci_data_snd(&mut self) {
if let Some(mut uci_data_snd_retryer) = self.uci_data_snd_retryer.take() {
- let data_packet_session_id = uci_data_snd_retryer.data_packet_session_id;
+ let data_packet_session_token = uci_data_snd_retryer.data_packet_session_token;
if !uci_data_snd_retryer.could_retry() {
error!(
"Out of retries for Uci DataSnd packet, last DataSnd packet session_id:{}",
- data_packet_session_id
+ data_packet_session_token
);
return;
}
@@ -772,7 +910,7 @@
Err(e) => {
error!(
"DataSnd packet fragment session_id:{} retry failed with error:{}",
- data_packet_session_id, e
+ data_packet_session_token, e
);
}
}
@@ -793,14 +931,14 @@
async fn handle_data_snd_packet(&mut self, data_snd_packet: UciDataSnd) -> Result<UciResponse> {
// Verify that there's an entry for the Session in the CreditAvailability map.
- let data_packet_session_id = data_snd_packet.get_session_id();
+ let data_packet_session_token = data_snd_packet.get_session_token();
let data_packet_sequence_number = data_snd_packet.get_uci_sequence_number();
- if !self.data_credit_map.contains_key(&data_packet_session_id) {
+ if !self.data_credit_map.contains_key(&data_packet_session_token) {
error!(
- "DataSnd packet session_id:{}, sequence_number:{} cannot be sent as unknown \
+ "DataSnd packet session_token:{}, sequence_number:{} cannot be sent as unknown \
credit availability for the session",
- data_packet_session_id, data_packet_sequence_number
+ data_packet_session_token, data_packet_sequence_number
);
return Err(Error::PacketTxError);
}
@@ -809,13 +947,13 @@
let mut packet_fragments: Vec<UciDataPacketHal> = data_snd_packet.into();
if packet_fragments.is_empty() {
error!(
- "DataSnd packet session_id:{}, sequence number:{} could not be split into fragments",
- data_packet_session_id, data_packet_sequence_number
+ "DataSnd packet session_token:{}, sequence number:{} could not be split into fragments",
+ data_packet_session_token, data_packet_sequence_number
);
return Err(Error::PacketTxError);
}
- match self.data_packet_fragments_map.get_mut(&data_packet_session_id) {
+ match self.data_packet_fragments_map.get_mut(&data_packet_session_token) {
Some(q) => {
for p in packet_fragments.drain(..) {
q.push_back(p);
@@ -823,29 +961,29 @@
}
None => {
error!(
- "DataSnd packet fragments map not found for session_id:{}",
- data_packet_session_id
+ "DataSnd packet fragments map not found for session_token:{}",
+ data_packet_session_token
);
return Err(Error::PacketTxError);
}
}
- self.send_data_packet_fragment(data_packet_session_id).await
+ self.send_data_packet_fragment(data_packet_session_token).await
}
async fn send_data_packet_fragment(
&mut self,
- data_packet_session_id: SessionId,
+ data_packet_session_token: SessionToken,
) -> Result<UciResponse> {
// Check if a credit is available before sending this data packet fragment. If not, return
// for now, and send this packet later when the credit becomes available (indicated by
// receiving a DataCreditNtf).
- let credit = self.data_credit_map.get(&data_packet_session_id);
+ let credit = self.data_credit_map.get(&data_packet_session_token);
if credit.is_none() {
error!(
- "DataSnd packet fragment cannot be sent for session_id:{} as unknown \
+ "DataSnd packet fragment cannot be sent for session_token:{} as unknown \
credit availability for the session",
- data_packet_session_id
+ data_packet_session_token
);
return Err(Error::PacketTxError);
}
@@ -855,7 +993,7 @@
// We have credit available, let's send the packet to UWBS.
let hal_data_packet_fragment =
- match self.data_packet_fragments_map.get_mut(&data_packet_session_id) {
+ match self.data_packet_fragments_map.get_mut(&data_packet_session_token) {
Some(q) => {
match q.pop_front() {
Some(p) => p,
@@ -873,21 +1011,22 @@
// Create and save a retryer for sending this data packet fragment.
self.uci_data_snd_retryer = Some(UciDataSndRetryer {
data_packet: hal_data_packet_fragment.clone(),
- data_packet_session_id,
+ data_packet_session_token,
retry_count: MAX_RETRY_COUNT,
});
let result = self.hal.send_packet(hal_data_packet_fragment.to_vec()).await;
if result.is_err() {
error!(
- "Result {:?} of sending data packet fragment SessionId: {} to HAL",
- result, data_packet_session_id
+ "Result {:?} of sending data packet fragment SessionToken: {} to HAL",
+ result, data_packet_session_token
);
return Err(Error::PacketTxError);
}
// Update the map after the successful write.
- self.data_credit_map.insert(data_packet_session_id, CreditAvailability::CreditNotAvailable);
+ self.data_credit_map
+ .insert(data_packet_session_token, CreditAvailability::CreditNotAvailable);
Ok(UciResponse::SendUciData(Ok(())))
}
@@ -954,6 +1093,10 @@
self.retry_uci_cmd().await;
return;
}
+ if let Err(_e) = self.store_session_token_if_init_resp(&resp).await {
+ error!("Session init response received without a sesson id stored! Something has gone badly wrong: {:?}", resp);
+ return;
+ }
if let Some(uci_cmd_retryer) = self.uci_cmd_retryer.take() {
uci_cmd_retryer.send_result(Ok(resp));
@@ -986,51 +1129,63 @@
}
let _ = self.core_notf_sender.send(core_notf);
}
- UciNotification::Session(session_notf) => {
- if let SessionNotification::Status { session_id, session_state, reason_code: _ } =
- session_notf
- {
- self.handle_session_state_notification(session_id, session_state).await;
- }
- if let SessionNotification::DataCredit { session_id, credit_availability } =
- session_notf
- {
- if !self.data_credit_map.contains_key(&session_id) {
- // Currently just log, as this is unexpected (the entry should exist once
- // the ranging session is Active and be removed once it is Idle).
- debug!(
- "Received a DataCreditNtf for non-existent session_id: {}",
- session_id
- );
+ UciNotification::Session(orig_session_notf) => {
+ let mod_session_notf = {
+ match self
+ .replace_session_token_with_session_id(orig_session_notf.clone())
+ .await
+ {
+ Ok(session_notf) => session_notf,
+ Err(e) => {
+ error!("Failed to find corresponding session id, discarding session notification {:?}: {:?}", orig_session_notf, e);
+ return;
+ }
}
- self.data_credit_map.insert(session_id, credit_availability);
- if credit_availability == CreditAvailability::CreditAvailable {
- if let Err(e) = self.send_data_packet_fragment(session_id).await {
- error!(
- "Sending data packet fragment failed with Err:{}, after a\
- DataCreditNtf is received, for sessionId:{}",
- e, session_id
+ };
+ match orig_session_notf {
+ SessionNotification::Status {
+ session_token,
+ session_state,
+ reason_code: _,
+ } => self.handle_session_state_notification(session_token, session_state).await,
+ SessionNotification::DataCredit { session_token, credit_availability } => {
+ if !self.data_credit_map.contains_key(&session_token) {
+ // Currently just log, as this is unexpected (the entry should exist once
+ // the ranging session is Active and be removed once it is Idle).
+ debug!(
+ "Received a DataCreditNtf for non-existent session_token: {}",
+ session_token
);
}
- } else {
- // Log as this should usually not happen (it's not an error).
- debug!(
- "Received a DataCreditNtf with no credit available for session_id:{}",
- session_id
+ self.data_credit_map.insert(session_token, credit_availability);
+ if credit_availability == CreditAvailability::CreditAvailable {
+ if let Err(e) = self.send_data_packet_fragment(session_token).await {
+ error!(
+ "Sending data packet fragment failed with Err:{}, after a\
+ DataCreditNtf is received, for session_token:{}",
+ e, session_token
+ );
+ }
+ } else {
+ // Log as this should usually not happen (it's not an error).
+ debug!(
+ "Received a DataCreditNtf with no credit available for session_token:{}",
+ session_token
);
+ }
+ return; // We consume these here and don't need to send to upper layer.
}
- return; // We consume these here and don't need to send to upper layer.
+ SessionNotification::DataTransferStatus {
+ session_token: _,
+ uci_sequence_number: _,
+ status: _,
+ } => {
+ // Reset the UciDataSnd Retryer since we received a DataTransferStatusNtf.
+ let _ = self.uci_data_snd_retryer.take();
+ }
+ _ => {}
}
- if let SessionNotification::DataTransferStatus {
- session_id: _,
- uci_sequence_number: _,
- status: _,
- } = session_notf
- {
- // Reset the UciDataSnd Retryer since we received a DataTransferStatusNtf.
- let _ = self.uci_data_snd_retryer.take();
- }
- let _ = self.session_notf_sender.send(session_notf);
+ let _ = self.session_notf_sender.send(mod_session_notf);
}
UciNotification::Vendor(vendor_notf) => {
let _ = self.vendor_notf_sender.send(vendor_notf);
@@ -1038,26 +1193,82 @@
}
}
+ // Modify session_token field in all session related notifications with session id.
+ // TODO: Sharing of structs across UCI (PDL) & JNI layer like this makes this ugly. Ideally
+ // the struct sent to JNI layer should only contain |session_id| and at uci layer
+ // it could be |session_id| or |session_handle|.
+ async fn replace_session_token_with_session_id(
+ &self,
+ session_notification: SessionNotification,
+ ) -> Result<SessionNotification> {
+ match session_notification {
+ SessionNotification::Status { session_token, session_state, reason_code } => {
+ Ok(SessionNotification::Status {
+ session_token: self.get_session_id(&session_token).await?,
+ session_state,
+ reason_code,
+ })
+ }
+ SessionNotification::UpdateControllerMulticastList {
+ session_token,
+ remaining_multicast_list_size,
+ status_list,
+ } => Ok(SessionNotification::UpdateControllerMulticastList {
+ session_token: self.get_session_id(&session_token).await?,
+ remaining_multicast_list_size,
+ status_list,
+ }),
+ SessionNotification::SessionInfo(session_range_data) => {
+ Ok(SessionNotification::SessionInfo(SessionRangeData {
+ sequence_number: session_range_data.sequence_number,
+ session_token: self.get_session_id(&session_range_data.session_token).await?,
+ current_ranging_interval_ms: session_range_data.current_ranging_interval_ms,
+ ranging_measurement_type: session_range_data.ranging_measurement_type,
+ ranging_measurements: session_range_data.ranging_measurements,
+ rcr_indicator: session_range_data.rcr_indicator,
+ raw_ranging_data: session_range_data.raw_ranging_data,
+ }))
+ }
+ SessionNotification::DataTransferStatus {
+ session_token,
+ uci_sequence_number,
+ status,
+ } => Ok(SessionNotification::DataTransferStatus {
+ session_token: self.get_session_id(&session_token).await?,
+ uci_sequence_number,
+ status,
+ }),
+ SessionNotification::DataCredit { session_token, credit_availability } => {
+ Ok(SessionNotification::DataCredit {
+ session_token: self.get_session_id(&session_token).await?,
+ credit_availability,
+ })
+ }
+ }
+ }
+
async fn handle_session_state_notification(
&mut self,
- session_id: SessionId,
+ session_token: SessionToken,
session_state: SessionState,
) {
match session_state {
SessionState::SessionStateInit => {
- if let Err(e) = self.hal.notify_session_initialized(session_id).await {
+ if let Err(e) = self.hal.notify_session_initialized(session_token).await {
warn!("notify_session_initialized() failed: {:?}", e);
}
}
SessionState::SessionStateActive => {
- self.data_credit_map.insert(session_id, CreditAvailability::CreditAvailable);
- self.data_packet_fragments_map.insert(session_id, VecDeque::new());
+ self.data_credit_map.insert(session_token, CreditAvailability::CreditAvailable);
+ self.data_packet_fragments_map.insert(session_token, VecDeque::new());
}
SessionState::SessionStateIdle => {
- self.data_credit_map.remove(&session_id);
- self.data_packet_fragments_map.remove(&session_id);
+ self.data_credit_map.remove(&session_token);
+ self.data_packet_fragments_map.remove(&session_token);
}
- _ => {}
+ SessionState::SessionStateDeinit => {
+ self.remove_session_token(&session_token).await;
+ }
}
}
@@ -1126,7 +1337,7 @@
// sessions, as there can be outstanding DataSnd packet fragments across them. We could do an
// alternative implementation of sending all of them.
data_packet: UciDataPacketHal,
- data_packet_session_id: u32,
+ data_packet_session_token: SessionToken,
retry_count: usize,
}
@@ -1169,17 +1380,19 @@
},
}
-#[cfg(test)]
+#[cfg(any(test))]
mod tests {
use super::*;
use bytes::Bytes;
+ use tokio::macros::support::Future;
use uwb_uci_packets::{SessionGetCountCmdBuilder, SessionGetCountRspBuilder};
use crate::params::uci_packets::{
- AppConfigStatus, AppConfigTlvType, CapTlvType, Controlee, DataTransferNtfStatusCode,
- StatusCode,
+ AppConfigStatus, AppConfigTlvType, CapTlvType, Controlee, DataRcvStatusCode,
+ DataTransferNtfStatusCode, StatusCode,
};
+ use crate::params::UwbAddress;
use crate::uci::mock_uci_hal::MockUciHal;
use crate::uci::mock_uci_logger::{MockUciLogger, UciLogEvent};
use crate::uci::uci_logger::NopUciLogger;
@@ -1210,24 +1423,14 @@
bytes
}
- async fn setup_uci_manager_with_open_hal<F>(
- setup_hal_fn: F,
- uci_logger_mode: UciLoggerMode,
- log_sender: mpsc::UnboundedSender<UciLogEvent>,
- ) -> (UciManagerImpl, MockUciHal)
- where
- F: FnOnce(&mut MockUciHal),
- {
- init_test_logging();
-
- // Open the hal.
- let mut hal = MockUciHal::new();
+ fn setup_hal_for_open(hal: &mut MockUciHal) {
+ // Setup Open the hal.
let notf = into_uci_hal_packets(uwb_uci_packets::DeviceStatusNtfBuilder {
device_state: uwb_uci_packets::DeviceState::DeviceStateReady,
});
hal.expected_open(Some(notf), Ok(()));
- // Get the device info.
+ // Setup Get the device info.
let cmd = UciCommand::CoreGetDeviceInfo;
let resp = into_uci_hal_packets(uwb_uci_packets::GetDeviceInfoRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
@@ -1238,14 +1441,31 @@
vendor_spec_info: vec![0x1, 0x2],
});
hal.expected_send_command(cmd, resp, Ok(()));
+ }
- setup_hal_fn(&mut hal);
+ async fn setup_uci_manager_with_open_hal<F, Fut>(
+ setup_hal_fn: F,
+ uci_logger_mode: UciLoggerMode,
+ log_sender: mpsc::UnboundedSender<UciLogEvent>,
+ ) -> (UciManagerImpl, MockUciHal)
+ where
+ F: FnOnce(MockUciHal) -> Fut,
+ Fut: Future<Output = ()>,
+ {
+ init_test_logging();
+
+ let mut hal = MockUciHal::new();
+ // Open the hal.
+ setup_hal_for_open(&mut hal);
// Verify open_hal() is working.
let uci_manager =
UciManagerImpl::new(hal.clone(), MockUciLogger::new(log_sender), uci_logger_mode);
let result = uci_manager.open_hal().await;
assert!(result.is_ok());
+ assert!(hal.wait_expected_calls_done().await);
+
+ setup_hal_fn(hal.clone()).await;
(uci_manager, hal)
}
@@ -1267,7 +1487,7 @@
#[tokio::test]
async fn test_close_hal_explicitly() {
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- |hal| {
+ |mut hal| async move {
hal.expected_close(Ok(()));
},
UciLoggerMode::Disabled,
@@ -1283,7 +1503,7 @@
#[tokio::test]
async fn test_close_hal_when_exit() {
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- |hal| {
+ |mut hal| async move {
// UciManager should close the hal if the hal is still opened when exit.
hal.expected_close(Ok(()));
},
@@ -1312,12 +1532,11 @@
#[tokio::test]
async fn test_device_reset_ok() {
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- |hal| {
+ |mut hal| async move {
let cmd = UciCommand::DeviceReset { reset_config: ResetConfig::UwbsReset };
let resp = into_uci_hal_packets(uwb_uci_packets::DeviceResetRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
});
-
hal.expected_send_command(cmd, resp, Ok(()));
},
UciLoggerMode::Disabled,
@@ -1341,7 +1560,7 @@
let vendor_spec_info_clone = vendor_spec_info.clone();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::CoreGetDeviceInfo;
let resp = into_uci_hal_packets(uwb_uci_packets::GetDeviceInfoRspBuilder {
status,
@@ -1377,7 +1596,7 @@
let tlv_clone = tlv.clone();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::CoreGetCapsInfo;
let resp = into_uci_hal_packets(uwb_uci_packets::GetCapsInfoRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
@@ -1408,7 +1627,7 @@
let config_status_clone = config_status.clone();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::CoreSetConfig { config_tlvs: vec![tlv_clone] };
let resp = into_uci_hal_packets(uwb_uci_packets::SetConfigRspBuilder {
status,
@@ -1435,7 +1654,7 @@
let tlv_clone = tlv.clone();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::CoreGetConfig { cfg_id: vec![cfg_id] };
let resp = into_uci_hal_packets(uwb_uci_packets::GetConfigRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
@@ -1455,47 +1674,111 @@
assert!(mock_hal.wait_expected_calls_done().await);
}
+ fn setup_hal_for_session_initialize(
+ hal: &mut MockUciHal,
+ session_type: SessionType,
+ session_id: u32,
+ session_token: u32,
+ ) {
+ // Setup for hal open.
+ setup_hal_for_open(hal);
+
+ // Setup session init.
+ let cmd = UciCommand::SessionInit { session_id, session_type };
+ let mut resp = if session_id == session_token {
+ into_uci_hal_packets(uwb_uci_packets::SessionInitRspBuilder {
+ status: uwb_uci_packets::StatusCode::UciStatusOk,
+ })
+ } else {
+ // This is testing FIRA v2 flow where a session handle is provided by UWBS.
+ into_uci_hal_packets(uwb_uci_packets::SessionInitRsp_V2Builder {
+ status: uwb_uci_packets::StatusCode::UciStatusOk,
+ session_handle: session_token,
+ })
+ };
+ let mut notf = into_uci_hal_packets(uwb_uci_packets::SessionStatusNtfBuilder {
+ session_token,
+ session_state: uwb_uci_packets::SessionState::SessionStateInit,
+ reason_code: uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands
+ .into(),
+ });
+ resp.append(&mut notf);
+ hal.expected_send_command(cmd, resp, Ok(()));
+ hal.expected_notify_session_initialized(session_token, Ok(()));
+ }
+
+ async fn setup_uci_manager_with_session_initialized<F, Fut>(
+ setup_hal_fn: F,
+ uci_logger_mode: UciLoggerMode,
+ log_sender: mpsc::UnboundedSender<UciLogEvent>,
+ session_id: u32,
+ session_token: u32,
+ ) -> (UciManagerImpl, MockUciHal)
+ where
+ F: FnOnce(MockUciHal) -> Fut,
+ Fut: Future<Output = ()>,
+ {
+ let session_type = SessionType::FiraRangingSession;
+
+ init_test_logging();
+
+ let mut hal = MockUciHal::new();
+ setup_hal_for_session_initialize(&mut hal, session_type, session_id, session_token);
+
+ // Verify open_hal() is working.
+ let uci_manager =
+ UciManagerImpl::new(hal.clone(), MockUciLogger::new(log_sender), uci_logger_mode);
+ let result = uci_manager.open_hal().await;
+ assert!(result.is_ok());
+
+ // Verify session is initialized.
+ let result = uci_manager.session_init(session_id, session_type).await;
+ assert!(result.is_ok());
+ assert!(hal.wait_expected_calls_done().await);
+
+ setup_hal_fn(hal.clone()).await;
+
+ (uci_manager, hal)
+ }
+
#[tokio::test]
async fn test_session_init_ok() {
let session_id = 0x123;
- let session_type = SessionType::FiraRangingSession;
+ let session_token = 0x123;
+ let (_, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |_hal| async move {},
+ UciLoggerMode::Disabled,
+ mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
+ )
+ .await;
+ assert!(mock_hal.wait_expected_calls_done().await);
+ }
- let (uci_manager, mut mock_hal) =
- setup_uci_manager_with_open_hal(
- move |hal| {
- let cmd = UciCommand::SessionInit { session_id, session_type };
- let mut resp = into_uci_hal_packets(uwb_uci_packets::SessionInitRspBuilder {
- status: uwb_uci_packets::StatusCode::UciStatusOk,
- });
- let mut notf = into_uci_hal_packets(uwb_uci_packets::SessionStatusNtfBuilder {
- session_id,
- session_state: uwb_uci_packets::SessionState::SessionStateInit,
- reason_code:
- uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands
- .into(),
- });
- resp.append(&mut notf);
-
- hal.expected_send_command(cmd, resp, Ok(()));
- hal.expected_notify_session_initialized(session_id, Ok(()));
- },
- UciLoggerMode::Disabled,
- mpsc::unbounded_channel::<UciLogEvent>().0,
- )
- .await;
-
- let result = uci_manager.session_init(session_id, session_type).await;
- assert!(result.is_ok());
+ #[tokio::test]
+ async fn test_session_init_v2_ok() {
+ let session_id = 0x123;
+ let session_token = 0x321; // different session handle
+ let (_, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |_hal| async move {},
+ UciLoggerMode::Disabled,
+ mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
+ )
+ .await;
assert!(mock_hal.wait_expected_calls_done().await);
}
#[tokio::test]
async fn test_session_deinit_ok() {
let session_id = 0x123;
+ let session_token = 0x123;
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
- let cmd = UciCommand::SessionDeinit { session_id };
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
+ let cmd = UciCommand::SessionDeinit { session_token };
let resp = into_uci_hal_packets(uwb_uci_packets::SessionDeinitRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
});
@@ -1504,6 +1787,34 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
+ )
+ .await;
+
+ let result = uci_manager.session_deinit(session_id).await;
+ assert!(result.is_ok());
+ assert!(mock_hal.wait_expected_calls_done().await);
+ }
+
+ #[tokio::test]
+ async fn test_session_deinit_v2_ok() {
+ let session_id = 0x123;
+ let session_token = 0x321; // different session handle
+
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
+ let cmd = UciCommand::SessionDeinit { session_token };
+ let resp = into_uci_hal_packets(uwb_uci_packets::SessionDeinitRspBuilder {
+ status: uwb_uci_packets::StatusCode::UciStatusOk,
+ });
+
+ hal.expected_send_command(cmd, resp, Ok(()));
+ },
+ UciLoggerMode::Disabled,
+ mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
@@ -1515,13 +1826,14 @@
#[tokio::test]
async fn test_session_set_app_config_ok() {
let session_id = 0x123;
+ let session_token = 0x123;
let config_tlv = AppConfigTlv::new(AppConfigTlvType::DeviceType, vec![0x12, 0x34, 0x56]);
let config_tlv_clone = config_tlv.clone();
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- |hal| {
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
let cmd = UciCommand::SessionSetAppConfig {
- session_id,
+ session_token,
config_tlvs: vec![config_tlv_clone],
};
let resp = into_uci_hal_packets(uwb_uci_packets::SessionSetAppConfigRspBuilder {
@@ -1533,6 +1845,43 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
+ )
+ .await;
+
+ let expected_result =
+ SetAppConfigResponse { status: StatusCode::UciStatusOk, config_status: vec![] };
+ let result =
+ uci_manager.session_set_app_config(session_id, vec![config_tlv]).await.unwrap();
+ assert_eq!(result, expected_result);
+ assert!(mock_hal.wait_expected_calls_done().await);
+ }
+
+ #[tokio::test]
+ async fn test_session_set_app_config_v2_ok() {
+ let session_id = 0x123;
+ let session_token = 0x321;
+ let config_tlv = AppConfigTlv::new(AppConfigTlvType::DeviceType, vec![0x12, 0x34, 0x56]);
+ let config_tlv_clone = config_tlv.clone();
+
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
+ let cmd = UciCommand::SessionSetAppConfig {
+ session_token,
+ config_tlvs: vec![config_tlv_clone],
+ };
+ let resp = into_uci_hal_packets(uwb_uci_packets::SessionSetAppConfigRspBuilder {
+ status: uwb_uci_packets::StatusCode::UciStatusOk,
+ cfg_status: vec![],
+ });
+
+ hal.expected_send_command(cmd, resp, Ok(()));
+ },
+ UciLoggerMode::Disabled,
+ mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
@@ -1547,13 +1896,15 @@
#[tokio::test]
async fn test_session_get_app_config_ok() {
let session_id = 0x123;
+ let session_token = 0x123;
let config_id = AppConfigTlvType::DeviceType;
let tlv = AppConfigTlv::new(AppConfigTlvType::DeviceType, vec![0x12, 0x34, 0x56]);
let tlv_clone = tlv.clone();
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
- let cmd = UciCommand::SessionGetAppConfig { session_id, app_cfg: vec![config_id] };
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
+ let cmd =
+ UciCommand::SessionGetAppConfig { session_token, app_cfg: vec![config_id] };
let resp = into_uci_hal_packets(uwb_uci_packets::SessionGetAppConfigRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
tlvs: vec![tlv_clone.into_inner()],
@@ -1563,6 +1914,8 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
@@ -1577,7 +1930,7 @@
let session_count = 5;
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::SessionGetCount;
let resp = into_uci_hal_packets(uwb_uci_packets::SessionGetCountRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
@@ -1599,11 +1952,12 @@
#[tokio::test]
async fn test_session_get_state_ok() {
let session_id = 0x123;
+ let session_token = 0x123;
let session_state = SessionState::SessionStateActive;
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
- let cmd = UciCommand::SessionGetState { session_id };
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
+ let cmd = UciCommand::SessionGetState { session_token };
let resp = into_uci_hal_packets(uwb_uci_packets::SessionGetStateRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
session_state,
@@ -1613,6 +1967,8 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
@@ -1624,14 +1980,16 @@
#[tokio::test]
async fn test_session_update_controller_multicast_list_ok() {
let session_id = 0x123;
+ let session_token = 0x123;
let action = UpdateMulticastListAction::AddControlee;
- let controlee = Controlee { short_address: 0x4567, subsession_id: 0x90ab };
+ let short_address: [u8; 2] = [0x45, 0x67];
+ let controlee = Controlee { short_address, subsession_id: 0x90ab };
let controlee_clone = controlee.clone();
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
let cmd = UciCommand::SessionUpdateControllerMulticastList {
- session_id,
+ session_token,
action,
controlees: Controlees::NoSessionKey(vec![controlee_clone]),
};
@@ -1645,6 +2003,8 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
@@ -1661,15 +2021,18 @@
#[tokio::test]
async fn test_set_active_dt_tag_ranging_rounds() {
+ let session_id = 0x123;
+ let session_token = 0x123;
+
let ranging_rounds = SessionUpdateDtTagRangingRoundsResponse {
status: StatusCode::UciStatusErrorRoundIndexNotActivated,
ranging_round_indexes: vec![3],
};
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
let cmd = UciCommand::SessionUpdateDtTagRangingRounds {
- session_id: 1,
+ session_token,
ranging_round_indexes: vec![3, 5],
};
let resp = into_uci_hal_packets(
@@ -1683,10 +2046,13 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
- let result = uci_manager.session_update_dt_tag_ranging_rounds(1, vec![3, 5]).await.unwrap();
+ let result =
+ uci_manager.session_update_dt_tag_ranging_rounds(session_id, vec![3, 5]).await.unwrap();
assert_eq!(result, ranging_rounds);
assert!(mock_hal.wait_expected_calls_done().await);
@@ -1695,10 +2061,11 @@
#[tokio::test]
async fn test_range_start_ok() {
let session_id = 0x123;
+ let session_token = 0x123;
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
- let cmd = UciCommand::SessionStart { session_id };
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
+ let cmd = UciCommand::SessionStart { session_token };
let resp = into_uci_hal_packets(uwb_uci_packets::SessionStartRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
});
@@ -1707,6 +2074,8 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
@@ -1718,10 +2087,11 @@
#[tokio::test]
async fn test_range_stop_ok() {
let session_id = 0x123;
+ let session_token = 0x123;
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
- let cmd = UciCommand::SessionStop { session_id };
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
+ let cmd = UciCommand::SessionStop { session_token };
let resp = into_uci_hal_packets(uwb_uci_packets::SessionStopRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
});
@@ -1730,6 +2100,8 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
@@ -1741,11 +2113,12 @@
#[tokio::test]
async fn test_range_get_ranging_count_ok() {
let session_id = 0x123;
+ let session_token = 0x123;
let count = 3;
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
- let cmd = UciCommand::SessionGetRangingCount { session_id };
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_initialized(
+ |mut hal| async move {
+ let cmd = UciCommand::SessionGetRangingCount { session_token };
let resp =
into_uci_hal_packets(uwb_uci_packets::SessionGetRangingCountRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
@@ -1756,6 +2129,8 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
@@ -1770,7 +2145,7 @@
let country_code_clone = country_code.clone();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::AndroidSetCountryCode { country_code: country_code_clone };
let resp = into_uci_hal_packets(uwb_uci_packets::AndroidSetCountryCodeRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
@@ -1800,7 +2175,7 @@
let power_stats_clone = power_stats.clone();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::AndroidGetPowerStats;
let resp = into_uci_hal_packets(uwb_uci_packets::AndroidGetPowerStatsRspBuilder {
stats: power_stats_clone,
@@ -1829,7 +2204,7 @@
let resp_payload_clone = resp_payload.clone();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::RawUciCmd { mt, gid, oid, payload: cmd_payload_clone };
let resp = into_uci_hal_packets(uwb_uci_packets::UciVendor_F_ResponseBuilder {
opcode: oid as u8,
@@ -1863,7 +2238,7 @@
let cfg_status = vec![app_config];
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::RawUciCmd { mt, gid, oid, payload: cmd_payload_clone };
let resp = into_uci_hal_packets(uwb_uci_packets::SessionSetAppConfigRspBuilder {
status,
@@ -1897,7 +2272,7 @@
let cfg_status = vec![app_config];
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::RawUciCmd { mt, gid, oid, payload: cmd_payload_clone };
let resp = into_uci_hal_packets(uwb_uci_packets::SessionSetAppConfigRspBuilder {
status,
@@ -1932,7 +2307,7 @@
let resp_payload_clone = resp_payload.clone();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::RawUciCmd {
mt: cmd_mt.into(),
gid: gid.into(),
@@ -1971,7 +2346,7 @@
resp_payload_expected.extend(resp_payload_fragment_2.clone().into_iter());
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::RawUciCmd {
mt: cmd_mt.into(),
gid: gid.into(),
@@ -2024,7 +2399,7 @@
let cfg_status = vec![app_config];
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::RawUciCmd { mt, gid, oid, payload: cmd_payload_clone };
let resp = into_uci_hal_packets(uwb_uci_packets::SessionSetAppConfigRspBuilder {
status,
@@ -2054,7 +2429,7 @@
let cmd_payload = vec![0x11, 0x22, 0x33, 0x44];
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |_hal| {},
+ move |_hal| async {},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
)
@@ -2077,7 +2452,7 @@
let cmd_payload = vec![0x11, 0x22, 0x33, 0x44];
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |_hal| {},
+ |_hal| async move {},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
)
@@ -2098,13 +2473,13 @@
let oid: u8 = 0x3; // SESSION_SET_APP_CONFIG
let cmd_payload = vec![0x11, 0x22, 0x33, 0x44];
let cmd_payload_clone = cmd_payload.clone();
- let session_id = 0x123;
+ let session_token = 0x123;
let resp_mt: u8 = 0x2;
let resp_payload = vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08];
let resp_payload_clone = resp_payload.clone();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::RawUciCmd {
mt: cmd_mt.into(),
gid: gid.into(),
@@ -2114,7 +2489,7 @@
let raw_resp = build_uci_packet(resp_mt, 0, gid, oid, resp_payload_clone);
let mut responses =
into_uci_hal_packets(uwb_uci_packets::SessionStatusNtfBuilder {
- session_id,
+ session_token,
session_state: uwb_uci_packets::SessionState::SessionStateInit,
reason_code:
uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands
@@ -2149,7 +2524,7 @@
let resp_payload = vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08];
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::RawUciCmd {
mt: cmd_mt.into(),
gid: gid.into(),
@@ -2171,27 +2546,199 @@
assert!(mock_hal.wait_expected_calls_done().await);
}
- fn setup_active_session(hal: &mut MockUciHal, session_id: u32) {
- // First setup the Session to be in Active state.
- let cmd = UciCommand::SessionStart { session_id };
+ fn setup_hal_for_session_active(
+ hal: &mut MockUciHal,
+ session_type: SessionType,
+ session_id: u32,
+ session_token: u32,
+ ) {
+ // Setup session init.
+ setup_hal_for_session_initialize(hal, session_type, session_id, session_token);
+
+ // Setup session active.
+ let cmd = UciCommand::SessionStart { session_token };
let mut responses = into_uci_hal_packets(uwb_uci_packets::SessionStartRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
});
responses.append(&mut into_uci_hal_packets(uwb_uci_packets::SessionStatusNtfBuilder {
- session_id,
+ session_token,
session_state: SessionState::SessionStateActive,
reason_code: 0, /* ReasonCode::StateChangeWithSessionManagementCommands */
}));
hal.expected_send_command(cmd, responses, Ok(()));
}
- // TODO(b/276320369): Listing down the Data Packet Rx scenarios below, will add unit tests
- // for them in subsequent CLs.
+ async fn setup_uci_manager_with_session_active<F, Fut>(
+ setup_hal_fn: F,
+ uci_logger_mode: UciLoggerMode,
+ log_sender: mpsc::UnboundedSender<UciLogEvent>,
+ session_id: u32,
+ session_token: u32,
+ ) -> (UciManagerImpl, MockUciHal)
+ where
+ F: FnOnce(MockUciHal) -> Fut,
+ Fut: Future<Output = ()>,
+ {
+ let session_type = SessionType::FiraRangingSession;
+
+ init_test_logging();
+
+ let mut hal = MockUciHal::new();
+ setup_hal_for_session_active(&mut hal, session_type, session_id, session_token);
+
+ // Verify open_hal() is working.
+ let uci_manager =
+ UciManagerImpl::new(hal.clone(), MockUciLogger::new(log_sender), uci_logger_mode);
+ let result = uci_manager.open_hal().await;
+ assert!(result.is_ok());
+
+ // Verify session is initialized.
+ let result = uci_manager.session_init(session_id, session_type).await;
+ assert!(result.is_ok());
+
+ // Verify session is started.
+ let result = uci_manager.range_start(session_id).await;
+ assert!(result.is_ok());
+ assert!(hal.wait_expected_calls_done().await);
+
+ setup_hal_fn(hal.clone()).await;
+
+ (uci_manager, hal)
+ }
+
+ // Test Data packet receive for a single packet (on an active UWB session).
#[tokio::test]
- async fn test_data_packet_recv_ok() {}
+ async fn test_data_packet_recv_ok() {
+ let mt_data = 0x0;
+ let pbf = 0x0;
+ let dpf = 0x2;
+ let oid = 0x0;
+ let session_id = 0x3;
+ let session_token = 0x5;
+ let uci_sequence_num = 0xa;
+ let source_address = UwbAddress::Extended([0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1]);
+ let app_data = vec![0x01, 0x02, 0x03];
+ let data_rcv_payload = vec![
+ 0x05, 0x00, 0x00, 0x00, // SessionToken
+ 0x00, // DataRcvStatusCode
+ 0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
+ 0x0a, 0x00, // UciSequenceNumber
+ 0x03, 0x00, // AppDataLen
+ 0x01, 0x02, 0x03, // AppData
+ ];
+
+ // Setup the DataPacketRcv (Rx by HAL) and the expected DataRcvNotification.
+ let data_packet_rcv = build_uci_packet(mt_data, pbf, dpf, oid, data_rcv_payload);
+ let expected_data_rcv_notification = DataRcvNotification {
+ session_token,
+ status: DataRcvStatusCode::UciStatusSuccess,
+ uci_sequence_num,
+ source_address,
+ payload: app_data,
+ };
+
+ // Setup an active UWBS session over which the DataPacket will be received by the Host.
+ let (mut uci_manager, mut mock_hal) = setup_uci_manager_with_session_active(
+ |_| async move {},
+ UciLoggerMode::Disabled,
+ mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
+ )
+ .await;
+
+ let (data_rcv_notification_sender, mut data_rcv_notification_receiver) =
+ mpsc::unbounded_channel::<DataRcvNotification>();
+ uci_manager.set_data_rcv_notification_sender(data_rcv_notification_sender).await;
+
+ // Inject the UCI DataPacketRcv into HAL.
+ let result = mock_hal.receive_packet(data_packet_rcv);
+ assert!(result.is_ok());
+
+ // UciManager should send a DataRcvNotification (for the valid Rx packet).
+ let result =
+ tokio::time::timeout(Duration::from_millis(100), data_rcv_notification_receiver.recv())
+ .await;
+ assert!(result.is_ok());
+ assert_eq!(result.unwrap(), Some(expected_data_rcv_notification));
+ assert!(mock_hal.wait_expected_calls_done().await);
+ }
+
+ // Test Data packet receive for two packet fragments (on an active UWB session).
+ #[tokio::test]
+ async fn test_data_packet_recv_fragmented_packets_ok() {
+ let mt_data = 0x0;
+ let pbf_fragment_1 = 0x1;
+ let pbf_fragment_2 = 0x0;
+ let dpf = 0x2;
+ let oid = 0x0;
+ let session_id = 0x3;
+ let session_token = 0x5;
+ let uci_sequence_num = 0xa;
+ let source_address = UwbAddress::Extended([0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1]);
+ let app_data_len = 300;
+ let app_data_fragment_1_len = 200;
+ let mut data_rcv_payload_fragment_1: Vec<u8> = vec![
+ 0x05, 0x00, 0x00, 0x00, // SessionToken
+ 0x00, // DataRcvStatusCode
+ 0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
+ 0x0a, 0x00, // UciSequenceNumber
+ 0x2c, 0x01, // AppData Length (300)
+ ];
+
+ // Setup the application data (payload) for the 2 DataPacketRcv fragments.
+ let mut app_data: Vec<u8> = Vec::new();
+ for i in 0..app_data_len {
+ app_data.push((i & 0xff).try_into().unwrap());
+ }
+ data_rcv_payload_fragment_1.extend_from_slice(&app_data[0..app_data_fragment_1_len]);
+ let mut data_rcv_payload_fragment_2: Vec<u8> = Vec::new();
+ data_rcv_payload_fragment_2.extend_from_slice(&app_data[app_data_fragment_1_len..]);
+
+ // Setup the DataPacketRcv fragments (Rx by HAL) and the expected DataRcvNotification.
+ let data_packet_rcv_fragment_1 =
+ build_uci_packet(mt_data, pbf_fragment_1, dpf, oid, data_rcv_payload_fragment_1);
+ let data_packet_rcv_fragment_2 =
+ build_uci_packet(mt_data, pbf_fragment_2, dpf, oid, data_rcv_payload_fragment_2);
+ let expected_data_rcv_notification = DataRcvNotification {
+ session_token,
+ status: DataRcvStatusCode::UciStatusSuccess,
+ uci_sequence_num,
+ source_address,
+ payload: app_data,
+ };
+
+ // Setup an active UWBS session over which the DataPacket will be received by the Host.
+ let (mut uci_manager, mut mock_hal) = setup_uci_manager_with_session_active(
+ |_| async move {},
+ UciLoggerMode::Disabled,
+ mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
+ )
+ .await;
+
+ let (data_rcv_notification_sender, mut data_rcv_notification_receiver) =
+ mpsc::unbounded_channel::<DataRcvNotification>();
+ uci_manager.set_data_rcv_notification_sender(data_rcv_notification_sender).await;
+
+ // Inject the 2 UCI DataPacketRcv into HAL.
+ let result = mock_hal.receive_packet(data_packet_rcv_fragment_1);
+ assert!(result.is_ok());
+ let result = mock_hal.receive_packet(data_packet_rcv_fragment_2);
+ assert!(result.is_ok());
+
+ // UciManager should send a DataRcvNotification (for the valid Rx packet).
+ let result =
+ tokio::time::timeout(Duration::from_millis(100), data_rcv_notification_receiver.recv())
+ .await;
+ assert!(result.is_ok());
+ assert_eq!(result.unwrap(), Some(expected_data_rcv_notification));
+ assert!(mock_hal.wait_expected_calls_done().await);
+ }
#[tokio::test]
- async fn test_data_packet_recv_fragmented_packet_ok() {}
+ async fn test_data_packet_recv_bad_payload_len_failure() {}
#[tokio::test]
async fn test_data_packet_send_ok() {
@@ -2201,35 +2748,33 @@
let dpf = 0x1;
let oid = 0x0;
let session_id = 0x5;
+ let session_token = 0x5;
let dest_mac_address = vec![0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1];
- let dest_fira_component = FiraComponent::Host;
- let uci_sequence_number = 0xa;
+ let uci_sequence_number: u16 = 0xa;
let app_data = vec![0x01, 0x02, 0x03];
let expected_data_snd_payload = vec![
0x05, 0x00, 0x00, 0x00, // SessionID
0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
- 0x01, // FiraComponent
- 0x0a, // UciSequenceNumber
+ 0x0a, 0x00, // UciSequenceNumber
0x03, 0x00, // AppDataLen
0x01, 0x02, 0x03, // AppData
];
let status = DataTransferNtfStatusCode::UciDataTransferStatusRepetitionOk;
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
- setup_active_session(hal, session_id);
-
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_active(
+ |mut hal| async move {
// Now setup the notifications that should be received after a Data packet send.
let data_packet_snd =
build_uci_packet(mt_data, pbf, dpf, oid, expected_data_snd_payload);
let mut ntfs = into_uci_hal_packets(uwb_uci_packets::DataCreditNtfBuilder {
- session_id,
+ session_token,
credit_availability: CreditAvailability::CreditAvailable,
});
ntfs.append(&mut into_uci_hal_packets(
uwb_uci_packets::DataTransferStatusNtfBuilder {
- session_id,
- uci_sequence_number,
+ session_token,
+ // TODO(b/282230468): Remove the u16-to-u8 conversion once spec is updated.
+ uci_sequence_number: uci_sequence_number.try_into().unwrap(),
status,
},
));
@@ -2237,20 +2782,13 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
- let result = uci_manager.range_start(session_id).await;
- assert!(result.is_ok());
-
let result = uci_manager
- .send_data_packet(
- session_id,
- dest_mac_address,
- dest_fira_component,
- uci_sequence_number,
- app_data,
- )
+ .send_data_packet(session_id, dest_mac_address, uci_sequence_number, app_data)
.await;
assert!(result.is_ok());
assert!(mock_hal.wait_expected_calls_done().await);
@@ -2268,16 +2806,15 @@
let dpf = 0x1;
let oid = 0x0;
let session_id = 0x5;
+ let session_token = 0x5;
let dest_mac_address = vec![0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1];
- let dest_fira_component = FiraComponent::Host;
- let uci_sequence_number = 0xa;
+ let uci_sequence_number: u16 = 0xa;
let app_data_len = 300; // Larger than MAX_PAYLOAD_LEN=255, so fragmentation occurs.
let mut app_data = Vec::new();
let mut expected_data_snd_payload_fragment_1 = vec![
0x05, 0x00, 0x00, 0x00, // SessionID
0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
- 0x01, // FiraComponent
- 0x0a, // UciSequenceNumber
+ 0x0a, 0x00, // UciSequenceNumber
0x2c, 0x01, // AppDataLen = 300
];
let mut expected_data_snd_payload_fragment_2 = Vec::new();
@@ -2294,10 +2831,8 @@
}
}
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
- setup_active_session(hal, session_id);
-
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_active(
+ |mut hal| async move {
// Expected data packet fragment #1 (UCI Header + Initial App data bytes).
let data_packet_snd_fragment_1 = build_uci_packet(
mt_data,
@@ -2307,7 +2842,7 @@
expected_data_snd_payload_fragment_1,
);
let ntfs = into_uci_hal_packets(uwb_uci_packets::DataCreditNtfBuilder {
- session_id,
+ session_token,
credit_availability: CreditAvailability::CreditAvailable,
});
hal.expected_send_packet(data_packet_snd_fragment_1, ntfs, Ok(()));
@@ -2321,13 +2856,14 @@
expected_data_snd_payload_fragment_2,
);
let mut ntfs = into_uci_hal_packets(uwb_uci_packets::DataCreditNtfBuilder {
- session_id,
+ session_token,
credit_availability: CreditAvailability::CreditAvailable,
});
ntfs.append(&mut into_uci_hal_packets(
uwb_uci_packets::DataTransferStatusNtfBuilder {
- session_id,
- uci_sequence_number,
+ session_token,
+ // TODO(b/282230468): Remove the u16-to-u8 conversion once spec is updated.
+ uci_sequence_number: uci_sequence_number.try_into().unwrap(),
status,
},
));
@@ -2335,20 +2871,13 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
- let result = uci_manager.range_start(session_id).await;
- assert!(result.is_ok());
-
let result = uci_manager
- .send_data_packet(
- session_id,
- dest_mac_address,
- dest_fira_component,
- uci_sequence_number,
- app_data,
- )
+ .send_data_packet(session_id, dest_mac_address, uci_sequence_number, app_data)
.await;
assert!(result.is_ok());
assert!(mock_hal.wait_expected_calls_done().await);
@@ -2362,24 +2891,21 @@
let dpf = 0x1;
let oid = 0x0;
let session_id = 0x5;
+ let session_token = 0x5;
let dest_mac_address = vec![0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1];
- let dest_fira_component = FiraComponent::Host;
- let uci_sequence_number = 0xa;
+ let uci_sequence_number: u16 = 0xa;
let app_data = vec![0x01, 0x02, 0x03];
let expected_data_snd_payload = vec![
0x05, 0x00, 0x00, 0x00, // SessionID
0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
- 0x01, // FiraComponent
- 0x0a, // UciSequenceNumber
+ 0x0a, 0x00, // UciSequenceNumber
0x03, 0x00, // AppDataLen
0x01, 0x02, 0x03, // AppData
];
let status = DataTransferNtfStatusCode::UciDataTransferStatusRepetitionOk;
- let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
- setup_active_session(hal, session_id);
-
+ let (uci_manager, mut mock_hal) = setup_uci_manager_with_session_active(
+ |mut hal| async move {
// Setup receiving a CORE_GENERIC_ERROR_NTF with STATUS_COMMAND_RETRY after a
// failed Data packet send attempt.
let data_packet_snd =
@@ -2392,13 +2918,14 @@
// Setup the notifications that should be received after the Data packet send
// is successfully retried.
let mut ntfs = into_uci_hal_packets(uwb_uci_packets::DataCreditNtfBuilder {
- session_id,
+ session_token,
credit_availability: CreditAvailability::CreditAvailable,
});
ntfs.append(&mut into_uci_hal_packets(
uwb_uci_packets::DataTransferStatusNtfBuilder {
- session_id,
- uci_sequence_number,
+ session_token,
+ // TODO(b/282230468): Remove the u16-to-u8 conversion once spec is updated.
+ uci_sequence_number: uci_sequence_number.try_into().unwrap(),
status,
},
));
@@ -2406,20 +2933,13 @@
},
UciLoggerMode::Disabled,
mpsc::unbounded_channel::<UciLogEvent>().0,
+ session_id,
+ session_token,
)
.await;
- let result = uci_manager.range_start(session_id).await;
- assert!(result.is_ok());
-
let result = uci_manager
- .send_data_packet(
- session_id,
- dest_mac_address,
- dest_fira_component,
- uci_sequence_number,
- app_data,
- )
+ .send_data_packet(session_id, dest_mac_address, uci_sequence_number, app_data)
.await;
assert!(result.is_ok());
assert!(mock_hal.wait_expected_calls_done().await);
@@ -2469,7 +2989,7 @@
#[tokio::test]
async fn test_session_get_count_retry_no_response() {
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- |hal| {
+ |mut hal| async move {
let cmd = UciCommand::SessionGetCount;
hal.expected_send_command(cmd, vec![], Ok(()));
},
@@ -2486,7 +3006,7 @@
#[tokio::test]
async fn test_session_get_count_timeout() {
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- |hal| {
+ |mut hal| async move {
let cmd = UciCommand::SessionGetCount;
hal.expected_send_command(cmd, vec![], Err(Error::Timeout));
},
@@ -2503,7 +3023,7 @@
#[tokio::test]
async fn test_session_get_count_retry_too_many_times() {
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- |hal| {
+ |mut hal| async move {
let cmd = UciCommand::SessionGetCount;
let retry_resp = into_uci_hal_packets(uwb_uci_packets::SessionGetCountRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusCommandRetry,
@@ -2529,7 +3049,7 @@
let session_count = 5;
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::SessionGetCount;
let retry_resp = into_uci_hal_packets(uwb_uci_packets::SessionGetCountRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusCommandRetry,
@@ -2558,7 +3078,7 @@
async fn test_log_manager_interaction() {
let (log_sender, mut log_receiver) = mpsc::unbounded_channel::<UciLogEvent>();
let (uci_manager, mut mock_hal) = setup_uci_manager_with_open_hal(
- move |hal| {
+ |mut hal| async move {
let cmd = UciCommand::SessionGetCount;
let resp1 = into_uci_hal_packets(uwb_uci_packets::SessionGetCountRspBuilder {
status: uwb_uci_packets::StatusCode::UciStatusOk,
diff --git a/src/rust/uwb_core/src/uci/uci_manager_sync.rs b/src/rust/uwb_core/src/uci/uci_manager_sync.rs
index 0c62959..4b1cf25 100644
--- a/src/rust/uwb_core/src/uci/uci_manager_sync.rs
+++ b/src/rust/uwb_core/src/uci/uci_manager_sync.rs
@@ -27,9 +27,9 @@
use crate::error::{Error, Result};
use crate::params::{
AppConfigTlv, AppConfigTlvType, CapTlv, CoreSetConfigResponse, CountryCode, DeviceConfigId,
- DeviceConfigTlv, FiraComponent, GetDeviceInfoResponse, PowerStats, RawUciMessage, ResetConfig,
- SessionId, SessionState, SessionType, SessionUpdateDtTagRangingRoundsResponse,
- SetAppConfigResponse, UpdateMulticastListAction,
+ DeviceConfigTlv, GetDeviceInfoResponse, PowerStats, RawUciMessage, ResetConfig, SessionId,
+ SessionState, SessionType, SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse,
+ UpdateMulticastListAction,
};
#[cfg(any(test, feature = "mock-utils"))]
use crate::uci::mock_uci_manager::MockUciManager;
@@ -242,6 +242,11 @@
self.runtime_handle.block_on(self.uci_manager.core_get_config(config_ids))
}
+ /// Send UCI command for getting uwbs timestamp.
+ pub fn core_query_uwb_timestamp(&self) -> Result<u64> {
+ self.runtime_handle.block_on(self.uci_manager.core_query_uwb_timestamp())
+ }
+
/// Send UCI command for initiating session.
pub fn session_init(&self, session_id: SessionId, session_type: SessionType) -> Result<()> {
self.runtime_handle.block_on(self.uci_manager.session_init(session_id, session_type))
@@ -353,18 +358,20 @@
&self,
session_id: SessionId,
address: Vec<u8>,
- dest_end_point: FiraComponent,
- uci_sequence_num: u8,
+ uci_sequence_num: u16,
app_payload_data: Vec<u8>,
) -> Result<()> {
self.runtime_handle.block_on(self.uci_manager.send_data_packet(
session_id,
address,
- dest_end_point,
uci_sequence_num,
app_payload_data,
))
}
+ /// Get session token for session id.
+ pub fn get_session_token(&self, session_id: SessionId) -> Result<u32> {
+ self.runtime_handle.block_on(self.uci_manager.get_session_token_from_session_id(session_id))
+ }
}
impl UciManagerSync<UciManagerImpl> {
@@ -381,6 +388,7 @@
hal: H,
notification_manager_builder: B,
logger: L,
+ logger_mode: UciLoggerMode,
runtime_handle: Handle,
) -> Result<Self>
where
@@ -389,8 +397,8 @@
L: UciLogger,
{
// UciManagerImpl::new uses tokio::spawn, so it is called inside the runtime as async fn.
- let uci_manager = runtime_handle
- .block_on(async { UciManagerImpl::new(hal, logger, UciLoggerMode::Disabled) });
+ let uci_manager =
+ runtime_handle.block_on(async { UciManagerImpl::new(hal, logger, logger_mode) });
let mut uci_manager_sync = UciManagerSync { runtime_handle, uci_manager };
uci_manager_sync.redirect_notification(notification_manager_builder)?;
Ok(uci_manager_sync)
diff --git a/src/rust/uwb_uci_packets/src/lib.rs b/src/rust/uwb_uci_packets/src/lib.rs
index c5bb3f5..38b0910 100644
--- a/src/rust/uwb_uci_packets/src/lib.rs
+++ b/src/rust/uwb_uci_packets/src/lib.rs
@@ -716,7 +716,7 @@
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct ParsedDiagnosticNtfPacket {
- session_id: u32,
+ session_token: u32,
sequence_number: u32,
frame_reports: Vec<ParsedFrameReport>,
}
@@ -733,7 +733,7 @@
}
pub fn parse_diagnostics_ntf(evt: AndroidRangeDiagnosticsNtf) -> Result<ParsedDiagnosticNtfPacket> {
- let session_id = evt.get_session_id();
+ let session_token = evt.get_session_token();
let sequence_number = evt.get_sequence_number();
let mut parsed_frame_reports = Vec::new();
for report in evt.get_frame_reports() {
@@ -773,7 +773,7 @@
});
}
Ok(ParsedDiagnosticNtfPacket {
- session_id,
+ session_token,
sequence_number,
frame_reports: parsed_frame_reports,
})
@@ -789,8 +789,7 @@
// TODO(ziyiw): Replace these functions after making uwb_uci_packets::Controlee::write_to() public.
pub fn write_controlee(controlee: &Controlee) -> BytesMut {
let mut buffer = BytesMut::new();
- let short_address = controlee.short_address;
- buffer.extend_from_slice(&short_address.to_le_bytes()[0..2]);
+ buffer.extend_from_slice(&controlee.short_address);
let subsession_id = controlee.subsession_id;
buffer.extend_from_slice(&subsession_id.to_le_bytes()[0..4]);
buffer
@@ -798,8 +797,7 @@
pub fn write_controlee_2_0_16byte(controlee: &Controlee_V2_0_16_Byte_Version) -> BytesMut {
let mut buffer = BytesMut::new();
- let short_address = controlee.short_address;
- buffer.extend_from_slice(&short_address.to_le_bytes()[0..2]);
+ buffer.extend_from_slice(&controlee.short_address);
let subsession_id = controlee.subsession_id;
buffer.extend_from_slice(&subsession_id.to_le_bytes()[0..4]);
buffer.extend_from_slice(&controlee.subsession_key);
@@ -808,8 +806,7 @@
pub fn write_controlee_2_0_32byte(controlee: &Controlee_V2_0_32_Byte_Version) -> BytesMut {
let mut buffer = BytesMut::new();
- let short_address = controlee.short_address;
- buffer.extend_from_slice(&short_address.to_le_bytes()[0..2]);
+ buffer.extend_from_slice(&controlee.short_address);
let subsession_id = controlee.subsession_id;
buffer.extend_from_slice(&subsession_id.to_le_bytes()[0..4]);
buffer.extend_from_slice(&controlee.subsession_key);
@@ -821,7 +818,7 @@
/// This function can build the packet with/without message control, which
/// is indicated by action parameter.
pub fn build_session_update_controller_multicast_list_cmd(
- session_id: u32,
+ session_token: u32,
action: UpdateMulticastListAction,
controlees: Controlees,
) -> Result<SessionUpdateControllerMulticastListCmd> {
@@ -855,7 +852,7 @@
_ => return Err(Error::InvalidPacketError),
}
Ok(SessionUpdateControllerMulticastListCmdBuilder {
- session_id,
+ session_token,
action,
payload: Some(controlees_buf.freeze()),
}
@@ -903,9 +900,12 @@
let frame_report =
FrameReport { uwb_msg_id: 1, action: 1, antenna_set: 1, frame_report_tlvs: tlvs };
frame_reports.push(frame_report);
- let packet =
- AndroidRangeDiagnosticsNtfBuilder { session_id: 1, sequence_number: 1, frame_reports }
- .build();
+ let packet = AndroidRangeDiagnosticsNtfBuilder {
+ session_token: 1,
+ sequence_number: 1,
+ frame_reports,
+ }
+ .build();
let mut parsed_packet = parse_diagnostics_ntf(packet).unwrap();
let parsed_frame_report = parsed_packet.frame_reports.pop().unwrap();
assert_eq!(rssi_vec, parsed_frame_report.rssi);
@@ -916,7 +916,8 @@
#[test]
fn test_write_controlee() {
- let controlee: Controlee = Controlee { short_address: 2, subsession_id: 3 };
+ let short_address: [u8; 2] = [2, 3];
+ let controlee: Controlee = Controlee { short_address, subsession_id: 3 };
let bytes = write_controlee(&controlee);
let parsed_controlee = Controlee::parse(&bytes).unwrap();
assert_eq!(controlee, parsed_controlee);
@@ -924,7 +925,8 @@
#[test]
fn test_build_multicast_update_packet() {
- let controlee = Controlee { short_address: 0x1234, subsession_id: 0x1324_3546 };
+ let short_address: [u8; 2] = [0x12, 0x34];
+ let controlee = Controlee { short_address, subsession_id: 0x1324_3546 };
let packet: UciControlPacket = build_session_update_controller_multicast_list_cmd(
0x1425_3647,
UpdateMulticastListAction::AddControlee,
@@ -939,7 +941,7 @@
vec![
0x21, 0x07, 0x00, 0x0c, // 2(packet info), RFU, payload length(12)
0x47, 0x36, 0x25, 0x14, // 4(session id (LE))
- 0x00, 0x01, 0x34, 0x12, // action, # controlee, 2(short address (LE))
+ 0x00, 0x01, 0x12, 0x34, // action, # controlee, 2(short address (LE))
0x46, 0x35, 0x24, 0x13, // 4(subsession id (LE))
]
);
diff --git a/src/rust/uwb_uci_packets/uci_packets.pdl b/src/rust/uwb_uci_packets/uci_packets.pdl
index edec9a7..54de313 100644
--- a/src/rust/uwb_uci_packets/uci_packets.pdl
+++ b/src/rust/uwb_uci_packets/uci_packets.pdl
@@ -49,6 +49,7 @@
CORE_GET_CONFIG = 0x05,
CORE_DEVICE_SUSPEND = 0x06,
CORE_GENERIC_ERROR_NTF = 0x07,
+ CORE_QUERY_UWBS_TIMESTAMP = 0x08,
}
enum SessionConfigOpCode : 6 {
@@ -101,7 +102,9 @@
UCI_STATUS_UNKNOWN_OID = 0x08,
UCI_STATUS_READ_ONLY = 0x09,
UCI_STATUS_COMMAND_RETRY = 0x0A,
- RFU_STATUS_CODE_RANGE_1 = 0x0B..0x10,
+ UCI_STATUS_UNKNOWN = 0x0B,
+ UCI_STATUS_NOT_APPLICABLE = 0x0C,
+ RFU_STATUS_CODE_RANGE_1 = 0x0D..0x10,
// UWB Session Specific Status Codes
UCI_STATUS_SESSION_NOT_EXIST = 0x11,
@@ -113,6 +116,7 @@
UCI_STATUS_MULTICAST_LIST_FULL = 0x17,
UCI_STATUS_ADDRESS_NOT_FOUND = 0x18,
UCI_STATUS_ADDRESS_ALREADY_PRESENT = 0x19,
+ UCI_STATUS_ERROR_UWB_INITIATION_TIME_TOO_OLD = 0x1A,
UCI_STATUS_OK_NEGATIVE_DISTANCE_REPORT = 0x1B,
RFU_STATUS_CODE_RANGE_2 = 0x1C..0x1F,
@@ -127,9 +131,8 @@
UCI_STATUS_RANGING_RX_MAC_IE_MISSING = 0x27,
UCI_STATUS_ERROR_ROUND_INDEX_NOT_ACTIVATED = 0x28,
UCI_STATUS_ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED = 0x29,
- UCI_STATUS_ERROR_ROUND_INDEX_NOT_SET_AS_INITIATOR = 0x2A,
- UCI_STATUS_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST = 0x2B,
- RFU_STATUS_CODE_RANGE_3 = 0x2C..0x2F,
+ UCI_STATUS_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST = 0x2A,
+ RFU_STATUS_CODE_RANGE_3 = 0x2B..0x2F,
// UWB Data Session Specific Status Codes
UCI_STATUS_DATA_MAX_TX_PSDU_SIZE_EXCEEDED = 0x30,
@@ -147,13 +150,6 @@
VENDOR_SPECIFIC_STATUS_CODE_2 = 0xFF,
}
-// This needs a separate type as the Status code values in an OWR for AOA
-// Measurement has different values.
-enum OwrAoaStatusCode : 8 {
- UCI_STATUS_SUCCESS = 0x00,
- UCI_STATUS_INTER_FRAME_INTERVAL_TIMEOUT = 0x01,
-}
-
// This needs a separate StatusCode as the Status code values in the DATA_RCV packet have
// different values from the generic StatusCode above.
enum DataRcvStatusCode : 8 {
@@ -178,12 +174,6 @@
UCI_DATA_TRANSFER_STATUS_ERROR_DATA_TRANSFER_IS_ONGOING = 0x06,
}
-enum FiraComponent : 8 {
- UWBS = 0x00,
- HOST = 0x01,
- SECURE_COMPONENT = 0x02,
-}
-
enum ResetConfig : 8 {
UWBS_RESET = 0x00,
}
@@ -515,21 +505,18 @@
}
packet UciDataSnd : UciDataPacket (data_packet_format = DATA_SND, message_type = DATA) {
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
dest_mac_address: 64,
- dest_fira_component: FiraComponent,
- uci_sequence_number: 8,
+ uci_sequence_number: 16,
_size_(data): 16,
data: 8[]
}
packet UciDataRcv : UciDataPacket (data_packet_format = DATA_RCV, message_type = DATA) {
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
status: DataRcvStatusCode,
- uci_sequence_number: 32,
source_mac_address: 64,
- source_fira_component: FiraComponent,
- dest_fira_component: FiraComponent,
+ uci_sequence_number: 16,
_size_(data): 16,
data: 8[]
}
@@ -722,6 +709,23 @@
"\x60\x07\x00\x01\x00\x00\x00\x01",
}
+
+packet CoreQueryTimeStampCmd : CoreCommand (opcode = 0x8) { //CORE_QUERY_UWBS_TIMESTAMP
+}
+
+test CoreQueryTimeStampCmd {
+ "\x20\x08\x00\\x00",
+}
+
+packet CoreQueryTimeStampRsp : CoreResponse (opcode = 0x8) { //CORE_QUERY_UWBS_TIMESTAMP
+ status: StatusCode,
+ timeStamp: 64,
+}
+
+test CoreQueryTimeStampRsp {
+ "\x40\x08\x00\x09\x00\x00\x00\x01\x01\x00\x01\x01\x01",
+}
+
packet SessionInitCmd : SessionConfigCommand (opcode = 0x0) { //SESSION_INIT
session_id: 32,
session_type: SessionType,
@@ -731,6 +735,17 @@
"\x21\x00\x00\x05\x00\x00\x00\x01\x02\x03\x04\x01",
}
+// FIRA version 2 introduces a new version of SESSION_INIT_RSP which
+// includes UWBS generated session handle.
+packet SessionInitRsp_V2 : SessionConfigResponse (opcode = 0x0) { //SESSION_INIT
+ status: StatusCode,
+ session_handle: 32,
+}
+
+test SessionInitRsp_V2 {
+ "\x41\x00\x00\x01\x00\x00\x00\x11\x00\x00\x00\x01",
+}
+
packet SessionInitRsp : SessionConfigResponse (opcode = 0x0) { //SESSION_INIT
status: StatusCode,
}
@@ -740,7 +755,7 @@
}
packet SessionDeinitCmd : SessionConfigCommand (opcode = 0x1) { //SESSION_DEINIT
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
}
test SessionDeinitCmd {
@@ -756,7 +771,7 @@
}
packet SessionStatusNtf : SessionConfigNotification (opcode = 0x2) { //SESSION_STATUS_NTF
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
session_state: SessionState,
// TODO(b/272775225): Switch back to the enum type ReasonCode, once PDL supports defining a
// range inside an enum (for the vendor-specific space), in b/267339120.
@@ -775,7 +790,7 @@
}
packet SessionSetAppConfigCmd : SessionConfigCommand (opcode = 0x3) { //SESSION_SET_APP_CONFIG
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
_count_(tlvs): 8,
tlvs: AppConfigTlv[]
}
@@ -800,7 +815,7 @@
}
packet SessionGetAppConfigCmd : SessionConfigCommand (opcode = 0x4) { //SESSION_GET_APP_CONFIG
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
_count_(app_cfg): 8,
app_cfg: 8[], // AppConfigTlvType (Infra does not allow array of enums)
}
@@ -836,7 +851,7 @@
}
packet SessionGetStateCmd : SessionConfigCommand (opcode = 0x6) { //SESSION_GET_STATE
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
}
test SessionGetStateCmd {
@@ -853,7 +868,7 @@
}
packet SessionUpdateDtTagRangingRoundsCmd : SessionConfigCommand (opcode = 0x9) { //SESSION_UPDATE_ACTIVE_ROUNDS_DT_TAG
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
_count_(ranging_round_indexes): 8,
ranging_round_indexes: 8[],
}
@@ -873,18 +888,18 @@
}
struct Controlee {
- short_address: 16,
+ short_address: 8[2],
subsession_id: 32,
}
struct Controlee_V2_0_16_Byte_Version {
- short_address: 16,
+ short_address: 8[2],
subsession_id: 32,
subsession_key: 8[16],
}
struct Controlee_V2_0_32_Byte_Version {
- short_address: 16,
+ short_address: 8[2],
subsession_id: 32,
subsession_key: 8[32],
}
@@ -897,7 +912,7 @@
}
packet SessionUpdateControllerMulticastListCmd : SessionConfigCommand (opcode = 0x7) { //SESSION_UPDATE_CONTROLLER_MULTICAST_LIST
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
action: UpdateMulticastListAction,
_payload_,
}
@@ -926,13 +941,13 @@
}
struct ControleeStatus {
- mac_address: 16,
+ mac_address: 8[2],
subsession_id: 32,
status: MulticastUpdateStatusCode,
}
packet SessionUpdateControllerMulticastListNtf : SessionConfigNotification (opcode = 0x7) { //SESSION_UPDATE_CONTROLLER_MULTICAST_LIST
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
remaining_multicast_list_size: 8,
_count_(controlee_status): 8,
controlee_status: ControleeStatus[],
@@ -943,7 +958,7 @@
}
packet DataCreditNtf : SessionControlNotification (opcode = 0x04) { // SESSION_DATA_CREDIT_NTF
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
credit_availability: CreditAvailability,
}
@@ -952,7 +967,7 @@
}
packet DataTransferStatusNtf : SessionControlNotification (opcode = 0x05) { // SESSION_DATA_TRANSFER_STATUS_NTF
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
uci_sequence_number: 8,
status: DataTransferNtfStatusCode,
// TODO(b/269779288): Add the tx_count field for implementing the DATA_REPETITION added in CR490.
@@ -963,7 +978,7 @@
}
packet SessionQueryMaxDataSizeCmd : SessionConfigCommand (opcode = 0xB) { //QUERY_MAX_DATA_SIZE
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
}
test SessionQueryMaxDataSizeCmd {
@@ -971,7 +986,7 @@
}
packet SessionQueryMaxDataSizeRsp : SessionConfigResponse (opcode = 0xB) { //QUER_MAX_DATA_SIZE
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
max_data_size: 16,
}
@@ -980,7 +995,7 @@
}
packet SessionStartCmd : SessionControlCommand (opcode = 0x0) { //RANGE_START
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
}
test SessionStartCmd {
@@ -1037,7 +1052,7 @@
struct ShortAddressOwrAoaRangingMeasurement {
mac_address: 16,
- status: OwrAoaStatusCode,
+ status: StatusCode,
nlos: 8,
frame_sequence_number: 8,
block_index: 16,
@@ -1049,7 +1064,7 @@
struct ExtendedAddressOwrAoaRangingMeasurement {
mac_address: 64,
- status: OwrAoaStatusCode,
+ status: StatusCode,
nlos: 8,
frame_sequence_number: 8,
block_index: 16,
@@ -1068,7 +1083,7 @@
packet SessionInfoNtf : SessionControlNotification (opcode = 0x0) { // SESSION_INFO
sequence_number: 32,
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
rcr_indicator: 8,
current_ranging_interval: 32,
ranging_measurement_type: RangingMeasurementType,
@@ -1139,7 +1154,7 @@
}
packet SessionStopCmd : SessionControlCommand (opcode = 0x1) { // SESSION_STOP
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
}
test SessionStopCmd {
@@ -1155,7 +1170,7 @@
}
packet SessionGetRangingCountCmd : SessionControlCommand (opcode = 0x3) { // SESSION_GET_RANGING_COUNT
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
}
test SessionGetRangingCountCmd {
@@ -1274,7 +1289,7 @@
}
packet AndroidRangeDiagnosticsNtf : AndroidNotification (opcode = 0x2) { //FIRA_RANGE_DIAGNOSTICS
- session_id: 32,
+ session_token: 32, // Session ID or Session Handle (based on UWBS version)
sequence_number: 32,
_count_(frame_reports): 8,
frame_reports: FrameReport[],
diff --git a/src/uci/include/uci_defs.h b/src/uci/include/uci_defs.h
deleted file mode 100755
index 8579e63..0000000
--- a/src/uci/include/uci_defs.h
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021-2022 NXP.
- *
- * 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.
- */
-
-/******************************************************************************
- *
- * This file contains the definition from UCI specification
- *
- ******************************************************************************/
-
-#ifndef UWB_UCI_DEFS_H
-#define UWB_UCI_DEFS_H
-
-#include <stdint.h>
-
-#define UCI_PAYLOAD_SUPPORT 1
-#define UCI_MAX_PAYLOAD_SIZE 4096
-
-/* Define the message header size for all UCI Commands and Notifications.
- */
-#define UCI_MSG_HDR_SIZE 0x04 /* per UCI spec */
-#define UCI_MAX_PAYLOAD_SIZE 4096 /* max control message size */
-#define UCI_MAX_PKT_SIZE 259 /* Max payload size + header size */
-#define UCI_PSDU_SIZE_4K 4096 /* PSDU Data size */
-#define UCI_VENDOR_INFO_MAX_SIZE 0xFF
-
-#define UCI_PAYLOAD_SUPPORT 1
-#define MAX_UCI_DATA_PKT_SIZE 4096
-#define UCI_LENGTH_SHIFT 8
-#define UCI_RESPONSE_STATUS_OFFSET 0x04
-#define UCI_RESPONSE_PAYLOAD_OFFSET 0x05
-#define UCI_MAX_FRAGMENT_BUFF_SIZE 4200
-
-/* UCI Command and Notification Format:
- * 4 byte message header:
- * byte 0: MT PBF GID
- * byte 1: OID
- * byte 2: RFU - To be used for extended playload length
- * byte 3: Message Length */
-
-/* MT: Message Type (byte 0) */
-#define UCI_MT_MASK 0xE0
-#define UCI_MT_SHIFT 0x05
-#define UCI_MT_DATA 0x00 /* (UCI_MT_DATA << UCI_MT_SHIFT) = 0x00 */
-#define UCI_MT_CMD 0x01 /* (UCI_MT_CMD << UCI_MT_SHIFT) = 0x20 */
-#define UCI_MT_RSP 0x02 /* (UCI_MT_RSP << UCI_MT_SHIFT) = 0x40 */
-#define UCI_MT_NTF 0x03 /* (UCI_MT_NTF << UCI_MT_SHIFT) = 0x60 */
-
-#define UCI_MTS_CMD 0x20
-#define UCI_MTS_RSP 0x40
-#define UCI_MTS_NTF 0x60
-
-#define UCI_NTF_BIT 0x80 /* the tUWB_VS_EVT is a notification */
-#define UCI_RSP_BIT 0x40 /* the tUWB_VS_EVT is a response */
-
-/* PBF: Packet Boundary Flag (byte 0) */
-#define UCI_PBF_MASK 0x10
-#define UCI_PBF_SHIFT 0x04
-#define UCI_PBF_NO_OR_LAST 0x00 /* not fragmented or last fragment */
-#define UCI_PBF_ST_CONT 0x10 /* start or continuing fragment */
-
-#define DATA_MESSAGE_SND 0x01
-
-/* GID: Group Identifier (byte 0) */
-#define UCI_GID_MASK 0x0F
-#define UCI_GID_SHIFT 0x00
-#define UCI_GID_CORE 0x00 /* 0000b UCI Core group */
-#define UCI_GID_SESSION_MANAGE 0x01 /* 0001b Session Config commands */
-#define UCI_GID_RANGE_MANAGE 0x02 /* 0010b Range Management group */
-#define UCI_GID_ANDROID 0x0C /* 1110b Android vendor group */
-#define UCI_GID_TEST 0x0D /* 1101b RF Test Gropup */
-
-/* Vendor specific group Identifier */
-#define UCI_GID_VENDOR_SPECIFIC_0x09 0x09
-#define UCI_GID_VENDOR_SPECIFIC_0x0A 0x0A
-#define UCI_GID_VENDOR_SPECIFIC_0x0B 0x0B
-#define UCI_GID_VENDOR_SPECIFIC_0x0C 0x0C
-#define UCI_GID_VENDOR_SPECIFIC_0x0E 0x0E
-#define UCI_GID_VENDOR_SPECIFIC_0x0F 0x0F
-
-/* OID: Opcode Identifier (byte 1) */
-#define UCI_OID_MASK 0x3F
-#define UCI_OID_SHIFT 0x00
-
-/* builds byte0 of UCI Command and Notification packet */
-#define UCI_MSG_BLD_HDR0(p, mt, gid) \
- *(p)++ = (uint8_t)(((mt) << UCI_MT_SHIFT) | (gid));
-
-#define UCI_MSG_PBLD_HDR0(p, mt, pbf, gid) \
- *(p)++ = (uint8_t)(((mt) << UCI_MT_SHIFT) | ((pbf) << UCI_PBF_SHIFT) | (gid));
-
-/* builds byte1 of UCI Command and Notification packet */
-#define UCI_MSG_BLD_HDR1(p, oid) *(p)++ = (uint8_t)(((oid) << UCI_OID_SHIFT));
-
-/* parse byte0 of UCI packet */
-#define UCI_MSG_PRS_HDR0(p, mt, pbf, gid) \
- mt = (*(p)&UCI_MT_MASK) >> UCI_MT_SHIFT; \
- pbf = (*(p)&UCI_PBF_MASK) >> UCI_PBF_SHIFT; \
- gid = *(p)++ & UCI_GID_MASK;
-
-/* parse MT and PBF bits of UCI packet */
-#define UCI_MSG_PRS_MT_PBF(p, mt, pbf) \
- mt = (*(p)&UCI_MT_MASK) >> UCI_MT_SHIFT; \
- pbf = (*(p)&UCI_PBF_MASK) >> UCI_PBF_SHIFT;
-
-/* parse byte1 of UCI Cmd/Ntf */
-#define UCI_MSG_PRS_HDR1(p, oid) \
- oid = (*(p)&UCI_OID_MASK); \
- (p)++;
-
-/* Allocate smallest possible buffer (for platforms with limited RAM) */
-#define UCI_GET_CMD_BUF(paramlen) \
- ((UWB_HDR*)phUwb_GKI_getbuf((uint16_t)(UWB_HDR_SIZE + UCI_MSG_HDR_SIZE + \
- UCI_MSG_OFFSET_SIZE + (paramlen))))
-
-/* UCI Data Format:
- * byte 0: MT(0) PBF DPF
- * byte 1: RFU
- * byte 2: Data Length
- * byte 3: Data Length */
-#define UCI_DATA_PBLD_HDR(p, pbf, len) \
- *(p)++ = (uint8_t)(((pbf) << UCI_PBF_SHIFT) | DATA_MESSAGE_SND); \
- *(p)++ = 0x00; \
- *(p)++ = (uint8_t)(len); \
- *(p)++ = (uint8_t)(((len) >> UCI_LENGTH_SHIFT));
-
-/**********************************************
- * UCI Core Group-0: Opcodes and size of commands
- **********************************************/
-#define UCI_MSG_CORE_DEVICE_RESET 0x00
-#define UCI_MSG_CORE_DEVICE_STATUS_NTF 0x01
-#define UCI_MSG_CORE_DEVICE_INFO 0x02
-#define UCI_MSG_CORE_GET_CAPS_INFO 0x03
-#define UCI_MSG_CORE_SET_CONFIG 0x04
-#define UCI_MSG_CORE_GET_CONFIG 0x05
-#define UCI_MSG_CORE_DEVICE_SUSPEND 0x06
-#define UCI_MSG_CORE_GENERIC_ERROR_NTF 0x07
-
-#define UCI_MSG_CORE_DEVICE_RESET_CMD_SIZE 0x01
-#define UCI_MSG_CORE_DEVICE_INFO_CMD_SIZE 0x00
-#define UCI_MSG_CORE_GET_CAPS_INFO_CMD_SIZE 0x00
-
-#define UCI_MSG_DATA_CREDIT_NTF 0x0B
-#define UCI_MSG_DATA_TRANSFER_STATUS_NTF 0x0C
-
-/*********************************************************
- * UCI session config Group-2: Opcodes and size of command
- ********************************************************/
-#define UCI_MSG_SESSION_INIT 0x00
-#define UCI_MSG_SESSION_DEINIT 0x01
-#define UCI_MSG_SESSION_STATUS_NTF 0x02
-#define UCI_MSG_SESSION_SET_APP_CONFIG 0x03
-#define UCI_MSG_SESSION_GET_APP_CONFIG 0x04
-#define UCI_MSG_SESSION_GET_COUNT 0x05
-#define UCI_MSG_SESSION_GET_STATE 0x06
-#define UCI_MSG_SESSION_UPDATE_CONTROLLER_MULTICAST_LIST 0x07
-#define UCI_MSG_SESSION_UPDATE_ACTIVE_ROUNDS_OF_DT_ANCHOR 0x08
-#define UCI_MSG_SESSION_UPDATE_ACTIVE_ROUNDS_OF_DT_TAG 0x09
-#define UCI_MSG_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_LIST 0x0A
-
-/* Pay load size for each command*/
-#define UCI_MSG_SESSION_INIT_CMD_SIZE 0x05
-#define UCI_MSG_SESSION_DEINIT_CMD_SIZE 0x04
-#define UCI_MSG_SESSION_STATUS_NTF_LEN 0x06
-#define UCI_MSG_SESSION_GET_COUNT_CMD_SIZE 0x00
-#define UCI_MSG_SESSION_GET_STATE_SIZE 0x04
-
-/*********************************************************
- * UWB Ranging Control Group-3: Opcodes and size of command
- *********************************************************/
-#define UCI_MSG_RANGE_START 0x00
-#define UCI_MSG_RANGE_STOP 0x01
-#define UCI_MSG_RANGE_GET_RANGING_COUNT 0x03
-#define UCI_MSG_RANGE_BLINK_DATA_TX 0x04
-
-#define UCI_MSG_RANGE_DATA_NTF 0x00
-#define UCI_MSG_RANGE_BLINK_DATA_TX_NTF 0x04
-
-#define UCI_MSG_RANGE_START_CMD_SIZE 0x04
-#define UCI_MSG_RANGE_STOP_CMD_SIZE 0x04
-#define UCI_MSG_RANGE_GET_COUNT_CMD_SIZE 0x04
-
-/**********************************************
- * UCI Android Vendor Group-E: Opcodes and size of commands
- **********************************************/
-#define UCI_MSG_ANDROID_GET_POWER_STATS 0x00
-#define UCI_MSG_ANDROID_SET_COUNTRY_CODE 0x01
-
-#define UCI_MSG_ANDROID_SET_COUNTRY_CODE_CMD_SIZE COUNTRY_CODE_ARRAY_LEN
-
-/**********************************************
- * UCI Parameter IDs : Device Configurations
- **********************************************/
-#define UCI_PARAM_ID_DEVICE_STATE 0x00
-#define UCI_PARAM_ID_LOW_POWER_MODE 0x01
-
-/* UCI Parameter ID Length */
-#define UCI_PARAM_LEN_DEVICE_STATE 0x01
-#define UCI_PARAM_LEN_LOW_POWER_MODE 0x01
-
-/*************************************************
- * UCI Parameter IDs : Application Configurations
- ************************************************/
-#define UCI_PARAM_ID_DEVICE_TYPE 0x00
-#define UCI_PARAM_ID_RANGING_ROUND_USAGE 0x01
-#define UCI_PARAM_ID_STS_CONFIG 0x02
-#define UCI_PARAM_ID_MULTI_NODE_MODE 0x03
-#define UCI_PARAM_ID_CHANNEL_NUMBER 0x04
-#define UCI_PARAM_ID_NO_OF_CONTROLEE 0x05
-#define UCI_PARAM_ID_DEVICE_MAC_ADDRESS 0x06
-#define UCI_PARAM_ID_DST_MAC_ADDRESS 0x07
-#define UCI_PARAM_ID_SLOT_DURATION 0x08
-#define UCI_PARAM_ID_RANGING_INTERVAL 0x09
-#define UCI_PARAM_ID_STS_INDEX 0x0A
-#define UCI_PARAM_ID_MAC_FCS_TYPE 0x0B
-#define UCI_PARAM_ID_RANGING_ROUND_CONTROL 0x0C
-#define UCI_PARAM_ID_AOA_RESULT_REQ 0x0D
-#define UCI_PARAM_ID_RNG_DATA_NTF 0x0E
-#define UCI_PARAM_ID_RNG_DATA_NTF_PROXIMITY_NEAR 0x0F
-#define UCI_PARAM_ID_RNG_DATA_NTF_PROXIMITY_FAR 0x10
-#define UCI_PARAM_ID_DEVICE_ROLE 0x11
-#define UCI_PARAM_ID_RFRAME_CONFIG 0x12
-#define UCI_PARAM_ID_PREAMBLE_CODE_INDEX 0x14
-#define UCI_PARAM_ID_SFD_ID 0x15
-#define UCI_PARAM_ID_PSDU_DATA_RATE 0x16
-#define UCI_PARAM_ID_PREAMBLE_DURATION 0x17
-#define UCI_PARAM_ID_RANGING_TIME_STRUCT 0x1A
-#define UCI_PARAM_ID_SLOTS_PER_RR 0x1B
-#define UCI_PARAM_ID_TX_ADAPTIVE_PAYLOAD_POWER 0x1C
-#define UCI_PARAM_ID_RESPONDER_SLOT_INDEX 0x1E
-#define UCI_PARAM_ID_PRF_MODE 0x1F
-#define UCI_PARAM_ID_CAP_SIZE_RANGE 0x20
-#define UCI_PARAM_ID_SCHEDULED_MODE 0x22
-#define UCI_PARAM_ID_KEY_ROTATION 0x23
-#define UCI_PARAM_ID_KEY_ROTATION_RATE 0x24
-#define UCI_PARAM_ID_SESSION_PRIORITY 0x25
-#define UCI_PARAM_ID_MAC_ADDRESS_MODE 0x26
-#define UCI_PARAM_ID_VENDOR_ID 0x27
-#define UCI_PARAM_ID_STATIC_STS_IV 0x28
-#define UCI_PARAM_ID_NUMBER_OF_STS_SEGMENTS 0x29
-#define UCI_PARAM_ID_MAX_RR_RETRY 0x2A
-#define UCI_PARAM_ID_UWB_INITIATION_TIME 0x2B
-#define UCI_PARAM_ID_HOPPING_MODE 0x2C
-#define UCI_PARAM_ID_BLOCK_STRIDE_LENGTH 0x2D
-#define UCI_PARAM_ID_RESULT_REPORT_CONFIG 0x2E
-#define UCI_PARAM_ID_IN_BAND_TERMINATION_ATTEMPT_COUNT 0x2F
-#define UCI_PARAM_ID_SUB_SESSION_ID 0x30
-#define UCI_PARAM_ID_BPRF_PHR_DATA_RATE 0x31
-#define UCI_PARAM_ID_MAX_NUMBER_OF_MEASUREMENTS 0x32
-#define UCI_PARAM_ID_UL_TDOA_TX_INTERVAL 0x33
-#define UCI_PARAM_ID_UL_TDOA_RANDOM_WINDOW 0x34
-#define UCI_PARAM_ID_UL_TDOA_DEVICE_ID 0x38
-#define UCI_PARAM_ID_UL_TDOA_TX_TIMESTAMP 0x39
-
-/* UCI Parameter ID Length */
-#define UCI_PARAM_LEN_DEVICE_ROLE 0x01
-#define UCI_PARAM_LEN_RANGING_ROUND_USAGE 0x01
-#define UCI_PARAM_LEN_STS_CONFIG 0x01
-#define UCI_PARAM_LEN_MULTI_NODE_MODE 0x01
-#define UCI_PARAM_LEN_CHANNEL_NUMBER 0x01
-#define UCI_PARAM_LEN_NO_OF_CONTROLEE 0x01
-#define UCI_PARAM_LEN_DEVICE_MAC_ADDRESS 0x02
-#define UCI_PARAM_LEN_DEST_MAC_ADDRESS 0x02
-#define UCI_PARAM_LEN_SLOT_DURATION 0x02
-#define UCI_PARAM_LEN_RANGING_INTERVAL 0x02
-#define UCI_PARAM_LEN_STS_INDEX 0x01
-#define UCI_PARAM_LEN_MAC_FCS_TYPE 0x01
-#define UCI_PARAM_LEN_RANGING_ROUND_CONTROL 0x01
-#define UCI_PARAM_LEN_AOA_RESULT_REQ 0x01
-#define UCI_PARAM_LEN_RNG_DATA_NTF 0x01
-#define UCI_PARAM_LEN_RNG_DATA_NTF_PROXIMITY_NEAR 0x02
-#define UCI_PARAM_LEN_RNG_DATA_NTF_PROXIMITY_FAR 0x02
-#define UCI_PARAM_LEN_DEVICE_TYPE 0x01
-#define UCI_PARAM_LEN_RFRAME_CONFIG 0x01
-#define UCI_PARAM_LEN_RX_MODE 0x01
-#define UCI_PARAM_LEN_PREAMBLE_CODE_INDEX 0x01
-#define UCI_PARAM_LEN_SFD_ID 0x01
-#define UCI_PARAM_LEN_PSDU_DATA_RATE 0x01
-#define UCI_PARAM_LEN_PREAMPLE_DURATION 0x01
-#define UCI_PARAM_LEN_ANTENA_PAIR_SELECTION 0x01
-#define UCI_PARAM_LEN_MAC_CFG 0x01
-#define UCI_PARAM_LEN_RANGING_TIME_STRUCT 0x01
-#define UCI_PARAM_LEN_SLOTS_PER_RR 0x01
-#define UCI_PARAM_LEN_TX_POWER_ID 0x01
-#define UCI_PARAM_LEN_TX_ADAPTIVE_PAYLOAD_POWER 0x01
-#define UCI_PARAM_LEN_VENDOR_ID 0x02
-#define UCI_PARAM_LEN_STATIC_STS_IV 0x06
-#define UCI_PARAM_LEN_NUMBER_OF_STS_SEGMENTS 0x01
-#define UCI_PARAM_LEN_MAX_RR_RETRY 0x02
-#define UCI_PARAM_LEN_UWB_INITIATION_TIME 0x04
-#define UCI_PARAM_LEN_HOPPING_MODE 0x01
-#define UCI_PARAM_LEN_RESULT_REPORT_CONFIG 0x01
-#define UCI_PARAM_LEN_IN_BAND_TERMINATION_ATTEMPT_COUNT 0x01
-#define UCI_PARAM_LEN_SUB_SESSION_ID 0x04
-#define UCI_PARAM_LEN_BLOCK_STRIDE_LENGTH 0x01
-#define UCI_PARAM_LEN_UL_TDOA_TX_INTERVAL 0x04
-#define UCI_PARAM_LEN_UL_TDOA_RANDOM_WINDOW 0x04
-#define UCI_PARAM_LEN_UL_TDOA_DEVICE_ID 0x09
-#define UCI_PARAM_LEN_UL_TDOA_TX_TIMESTAMP 0x01
-
-#define MAX_VENDOR_INFO_LENGTH 1000 // vendor specific info of rangedata max length considering 24 measures for TDOA
-
-/*************************************************
- * Status codes
- ************************************************/
-/* Generic Status Codes */
-#define UCI_STATUS_OK 0x00
-#define UCI_STATUS_REJECTED 0x01
-#define UCI_STATUS_FAILED 0x02
-#define UCI_STATUS_SYNTAX_ERROR 0x03
-#define UCI_STATUS_INVALID_PARAM 0x04
-#define UCI_STATUS_INVALID_RANGE 0x05
-#define UCI_STATUS_INVALID_MSG_SIZE 0x06
-#define UCI_STATUS_UNKNOWN_GID 0x07
-#define UCI_STATUS_UNKNOWN_OID 0x08
-#define UCI_STATUS_READ_ONLY 0x09
-#define UCI_STATUS_COMMAND_RETRY 0x0A
-
-/* UWB Session Specific Status Codes*/
-#define UCI_STATUS_SESSSION_NOT_EXIST 0x11
-#define UCI_STATUS_SESSSION_DUPLICATE 0x12
-#define UCI_STATUS_SESSSION_ACTIVE 0x13
-#define UCI_STATUS_MAX_SESSSIONS_EXCEEDED 0x14
-#define UCI_STATUS_SESSION_NOT_CONFIGURED 0x15
-
-/* UWB Ranging Session Specific Status Codes */
-#define UCI_STATUS_RANGING_TX_FAILED 0x20
-#define UCI_STATUS_RANGING_RX_TIMEOUT 0x21
-#define UCI_STATUS_RANGING_RX_PHY_DEC_FAILED 0x22
-#define UCI_STATUS_RANGING_RX_PHY_TOA_FAILED 0x23
-#define UCI_STATUS_RANGING_RX_PHY_STS_FAILED 0x24
-#define UCI_STATUS_RANGING_RX_MAC_DEC_FAILED 0x25
-#define UCI_STATUS_RANGING_RX_MAC_IE_DEC_FAILED 0x26
-#define UCI_STATUS_RANGING_RX_MAC_IE_MISSING 0x27
-#define STS_LENGTH 0x35
-#define RSSI_REPORTING 0x36
-
-/* UWB Data Session Specific Status Codes */
-#define UCI_STATUS_DATA_MAX_TX_PSDU_SIZE_EXCEEDED 0x30
-#define UCI_STATUS_DATA_RX_CRC_ERROR 0x31
-
-/*************************************************
- * Device Role config
- **************************************************/
-#define UWB_CONTROLLER 0x00
-#define UWB_CONTROLEE 0x01
-
-/*************************************************
- * Ranging Method config
- **************************************************/
-#define ONE_WAY_RANGING 0x00
-#define SS_TWR_RANGING 0x01
-#define DS_TWR_RANGING 0x02
-
-/*************************************************
- * Ranging Mesaurement type
- **************************************************/
-#define MEASUREMENT_TYPE_ULTDOA 0x00
-#define MEASUREMENT_TYPE_TWOWAY 0x01
-#define MEASUREMENT_TYPE_DLTDOA 0x02
-#define MEASUREMENT_TYPE_OWR_WITH_AOA 0x03
-
-#define EXTENDED_ADDRESS_LEN 0x08
-#define EXTENDED_PARAM_ID_MASK 0xF0
-
-/* Maximum size of UCI DATA Message the UWBS can receive */
-#define MAX_DATA_MSG_SIZE 0x00
-#define MAX_DATA_PKT_PAYLOAD_SIZE 0x01
-
-
-/* Maximum Length of RrRdmList*/
-#define MAX_RRRDM_LIST_LENGTH 0XFF
-
-/*************************************************
- * Mac Addressing Mode Indicator
- **************************************************/
-#define SHORT_MAC_ADDRESS 0x00
-#define EXTENDED_MAC_ADDRESS 0x01
-#define EXTENDED_MAC_ADDRESS_AND_HEADER 0x02
-
-#define SESSION_ID_LEN 0x04
-#define SHORT_ADDRESS_LEN 0x02
-#define EXTENDED_ADDRESS_LEN 0x08
-#define MAX_NUM_OF_TDOA_MEASURES 24
-#define MAX_NUM_OF_DLTDOA_MEASURES 10
-#define MAX_NUM_OWR_AOA_MEASURES 1
-#define UCI_MAX_DATA_SIZE 4196
-
-#define MAX_NUM_RESPONDERS \
- 12 // max number of responders for contention based raning
-#define MAX_NUM_CONTROLLEES \
- 8 // max bumber of controlees for time schedules rangng ( multicast)
-#define COUNTRY_CODE_ARRAY_LEN 2
-
-/* device status */
-typedef enum {
- UWBS_STATUS_READY = 0x01, /* UWBS is ready for performing uwb session with
- non SE use cases */
- UWBS_STATUS_ACTIVE, /* UWBS is busy running uwb session */
- UWBS_STATUS_TIMEOUT = 0xFE, /* To notify timeout to UWB service layer */
- UWBS_STATUS_ERROR = 0xFF /* error occured in UWBS*/
-} eUWBS_DEVICE_STATUS_t;
-
-/* Session status */
-typedef enum {
- UWB_SESSION_INITIALIZED,
- UWB_SESSION_DEINITIALIZED,
- UWB_SESSION_ACTIVE,
- UWB_SESSION_IDLE,
- UWB_UNKNOWN_SESSION = 0xFF
-} eSESSION_STATUS_t;
-
-/* Session status idle reason code */
-typedef enum {
- UWB_SESSION_STATE_CHANGED = 0x00,
- UWB_SESSION_MAX_RR_RETRY_COUNT_REACHED = 0x01,
- UWB_SESSION_MAX_RANGING_MEASUREMENTS_REACHED = 0x02,
- UWB_SESSION_SLOT_LENTGH_NOT_SUPPORTED = 0x20,
- UWB_SESSION_SLOTS_PER_RR_NOT_SUFFICIENT = 0x21,
- UWB_SESSION_MAC_ADDRESS_MODE_NOT_SUPPORTED = 0x22,
- UWB_SESSION_INVALID_RANGING_INTERVAL = 0x23,
- UWB_SESSION_INVALID_STS_CONFIG = 0x24,
- UWB_SESSION_INVALID_RFRAME_CONFIG = 0x25
-} eSESSION_STATUS_REASON_CODES_t;
-
-#endif /* UWB_UCI_DEFS_H */
diff --git a/src/uci/include/uci_test_defs.h b/src/uci/include/uci_test_defs.h
deleted file mode 100755
index 3b1b70d..0000000
--- a/src/uci/include/uci_test_defs.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021 NXP.
- *
- * 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.
- */
-
-/******************************************************************************
- *
- * This file contains the definition from UCI specification
- *
- ******************************************************************************/
-
-#ifndef UWB_UCI_TEST_DEFS_H
-#define UWB_UCI_TEST_DEFS_H
-
-#include <stdint.h>
-
-/* GID: Group Identifier (byte 0) */
-
-#define UCI_GID_TEST 0x0D /* 1101b UCI Test group */
-
-/**********************************************
- * UCI test group(UCI_GID_TEST)- 7: Opcodes
- **********************************************/
-#define UCI_MSG_TEST_SET_CONFIG 0
-#define UCI_MSG_TEST_GET_CONFIG 1
-#define UCI_MSG_TEST_PERIODIC_TX 2
-#define UCI_MSG_TEST_PER_RX 3
-#define UCI_MSG_TEST_TX 4
-#define UCI_MSG_TEST_RX 5
-#define UCI_MSG_TEST_LOOPBACK 6
-#define UCI_MSG_TEST_STOP_SESSION 7
-
-#define UCI_MSG_TEST_PERIODIC_TX_CMD_SIZE 0
-#define UCI_MSG_TEST_PER_RX_CMD_SIZE 0
-#define UCI_MSG_TEST_STOP_SESSION_CMD_SIZE 0
-#define UCI_MSG_TEST_RX_CMD_SIZE 0
-
-/**********************************************************
- * UCI test Parameter IDs : RF Test Configurations
- *********************************************************/
-#define UCI_TEST_PARAM_ID_NUM_PACKETS 0x00
-#define UCI_TEST_PARAM_ID_T_GAP 0x01
-#define UCI_TEST_PARAM_ID_T_START 0x02
-#define UCI_TEST_PARAM_ID_T_WIN 0x03
-#define UCI_TEST_PARAM_ID_RANDOMIZE_PSDU 0x04
-#define UCI_TEST_PARAM_ID_PHR_RANGING_BIT 0x05
-#define UCI_TEST_PARAM_ID_RMARKER_TX_START 0x06
-#define UCI_TEST_PARAM_ID_RMARKER_RX_START 0x07
-#define UCI_TEST_PARAM_ID_STS_INDEX_AUTO_INCR 0x08
-
-#endif
\ No newline at end of file
diff --git a/src/uwa/dm/uwa_dm_act.cc b/src/uwa/dm/uwa_dm_act.cc
deleted file mode 100755
index e1d13f9..0000000
--- a/src/uwa/dm/uwa_dm_act.cc
+++ /dev/null
@@ -1,1551 +0,0 @@
-
-/******************************************************************************
- *
- * Copyright (C) 1999-2014 Broadcom Corporation
- * Copyright 2018-2022 NXP
- *
- * 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.
- *
- ******************************************************************************/
-/******************************************************************************
- *
- * This file contains the action functions for device manager state
- * machine.
- *
- ******************************************************************************/
-#include <string.h>
-
-#include "uci_hmsgs.h"
-#include "uci_log.h"
-#include "uwa_api.h"
-#include "uwa_dm_int.h"
-#include "uwa_sys.h"
-#include "uwa_sys_int.h"
-#include "uwb_api.h"
-#include "uwb_osal_common.h"
-
-static void uwa_dm_set_init_uci_params(void);
-
-/*******************************************************************************
-**
-** Function uwa_dm_sys_enable
-**
-** Description This function on enable
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_dm_sys_enable(void) { uwa_dm_set_init_uci_params(); }
-
-/*******************************************************************************
-**
-** Function uwa_dm_set_init_uci_params
-**
-** Description Set initial UCI configuration parameters
-**
-** Returns void
-**
-*******************************************************************************/
-static void uwa_dm_set_init_uci_params(void) { return; }
-
-/*******************************************************************************
-**
-** Function uwa_dm_disable_event
-**
-** Description report disable event
-**
-** Returns void
-**
-*******************************************************************************/
-static void uwa_dm_disable_event(void) {
- /* Deregister DM from sys */
- uwa_sys_deregister(UWA_ID_DM);
-
- /* Notify app */
- if (uwa_dm_cb.p_dm_cback != NULL) {
- uwa_dm_cb.flags &= (uint32_t)(~UWA_DM_FLAGS_DM_IS_ACTIVE);
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_DISABLE_EVT, NULL);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_uwb_response_cback
-**
-** Description Call DM event hanlder with UWB response callback data
-**
-** Returns void
-**
-*******************************************************************************/
-static void uwa_dm_uwb_response_cback(tUWB_RESPONSE_EVT event,
- tUWB_RESPONSE* p_data) {
- tUWA_DM_CBACK_DATA dm_cback_data;
-
- UCI_TRACE_I("uwa_dm_uwb_response_cback:%s(0x%x)",
- uwa_dm_uwb_revt_2_str(event).c_str(), event);
- switch (event) {
- case UWB_ENABLE_REVT: /* 0 Enable event */
- /* UWB stack enabled. Enable uwa sub-systems */
- /* Notify app */
- uwa_dm_cb.flags &= UWA_DM_FLAGS_DM_IS_ACTIVE;
- dm_cback_data.status = p_data->enable.status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_ENABLE_EVT, &dm_cback_data);
- break;
-
- case UWB_DISABLE_REVT: /* 1 Disable event */
- uwa_dm_disable_event();
- break;
-
- case UWB_DEVICE_STATUS_REVT: /* device status notification */
- dm_cback_data.dev_status.status = p_data->sDevice_status.status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_DEVICE_STATUS_NTF_EVT, &dm_cback_data);
- break;
-
- case UWB_GET_DEVICE_INFO_REVT: {
- if (p_data->sGet_device_info.status == UWB_STATUS_OK) {
- dm_cback_data.sGet_device_info.status = UWA_STATUS_OK;
- dm_cback_data.sGet_device_info.uci_version =
- p_data->sGet_device_info.uci_version;
- dm_cback_data.sGet_device_info.mac_version =
- p_data->sGet_device_info.mac_version;
- dm_cback_data.sGet_device_info.phy_version =
- p_data->sGet_device_info.phy_version;
- dm_cback_data.sGet_device_info.uciTest_version =
- p_data->sGet_device_info.uciTest_version;
- dm_cback_data.sGet_device_info.vendor_info_len =
- p_data->sGet_device_info.vendor_info_len;
- memcpy(dm_cback_data.sGet_device_info.vendor_info,
- p_data->sGet_device_info.vendor_info,
- p_data->sGet_device_info.vendor_info_len);
- } else {
- dm_cback_data.sGet_device_info.status = UWA_STATUS_FAILED;
- }
-
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_CORE_GET_DEVICE_INFO_RSP_EVT,
- &dm_cback_data);
- } break;
-
- case UWB_SET_CORE_CONFIG_REVT: /* 2 Set Config Response */
- dm_cback_data.sCore_set_config.status = p_data->sCore_set_config.status;
- dm_cback_data.sCore_set_config.num_param_id =
- p_data->sCore_set_config.num_param_id;
- dm_cback_data.sCore_set_config.tlv_size =
- p_data->sCore_set_config.tlv_size;
- if (dm_cback_data.sCore_set_config.tlv_size > 0) {
- memcpy(dm_cback_data.sCore_set_config.param_ids,
- p_data->sCore_set_config.param_ids,
- p_data->sCore_set_config.tlv_size);
- }
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_CORE_SET_CONFIG_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_GET_CORE_CONFIG_REVT: /* 3 Get Config Response */
- dm_cback_data.sCore_get_config.status = p_data->sCore_get_config.status;
- dm_cback_data.sCore_get_config.no_of_ids =
- p_data->sCore_get_config.no_of_ids;
- dm_cback_data.sCore_get_config.tlv_size =
- p_data->sCore_get_config.tlv_size;
- if (dm_cback_data.sCore_get_config.tlv_size > 0) {
- memcpy(dm_cback_data.sCore_get_config.param_tlvs,
- p_data->sCore_get_config.p_param_tlvs,
- p_data->sCore_get_config.tlv_size);
- }
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_CORE_GET_CONFIG_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_DEVICE_RESET_REVT: /* Device Reset Response */
- if (p_data->sDevice_reset.status == UWB_STATUS_OK) {
- dm_cback_data.sDevice_reset.status = p_data->sDevice_reset.status;
- } else {
- dm_cback_data.sDevice_reset.status = UWA_STATUS_FAILED;
- }
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_DEVICE_RESET_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_CORE_GEN_ERR_STATUS_REVT: /* Generic error notification */
- {
- dm_cback_data.sCore_gen_err_status.status =
- p_data->sCore_gen_err_status.status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_CORE_GEN_ERR_STATUS_EVT, &dm_cback_data);
- } break;
-
- case UWB_SESSION_INIT_REVT: /* Session init response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E(" Session Init request is failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_INIT_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_SESSION_DEINIT_REVT: /* session de-init response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E(" Session De Init request is failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_DEINIT_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_SESSION_STATUS_NTF_REVT: /* session status notification */
- {
- tUWA_SESSION_STATUS_NTF_REVT* p_session_ntf =
- &dm_cback_data.sSessionStatus;
- p_session_ntf->session_id = p_data->sSessionStatus.session_id;
- p_session_ntf->state = p_data->sSessionStatus.state;
- p_session_ntf->reason_code = p_data->sSessionStatus.reason_code;
- if (UWB_SESSION_INITIALIZED == p_session_ntf->state) {
- // Trigger session initialization HAL API.
- tUWB_STATUS status;
- status = UWB_HalSessionInit(dm_cback_data.sSessionStatus.session_id);
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("HAL session init: success ,status=0x%X", status);
- } else {
- UCI_TRACE_E("HAL session init: status=0x%X. Deinitializing session", status);
- p_session_ntf->state = UWB_SESSION_DEINITIALIZED;
- }
- }
- }
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_STATUS_NTF_EVT, &dm_cback_data);
- break;
-
- case UWB_SESSION_GET_COUNT_REVT: /* get session count response */
- if (p_data->status == UWB_STATUS_OK) {
- tUWA_SESSION_GET_COUNT* p_sGet_session_cnt =
- &dm_cback_data.sGet_session_cnt;
- p_sGet_session_cnt->status = p_data->sGet_session_cnt.status;
- p_sGet_session_cnt->count = p_data->sGet_session_cnt.count;
-
- } else {
- UCI_TRACE_E("Get session count command failed");
- dm_cback_data.status = UWA_STATUS_FAILED;
- }
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_GET_COUNT_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_SESSION_GET_STATE_REVT: /*get session state response */
- if (p_data->sGet_session_state.status == UWB_STATUS_OK) {
- tUWA_SESSION_GET_STATE* p_sGet_session_state =
- &dm_cback_data.sGet_session_state;
- p_sGet_session_state->status = p_data->sGet_session_state.status;
- p_sGet_session_state->session_state =
- p_data->sGet_session_state.session_state;
-
- } else {
- UCI_TRACE_E("Get session state command failed");
- dm_cback_data.status = UWA_STATUS_FAILED;
- }
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_GET_STATE_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_SET_APP_CONFIG_REVT: /*set session app config response */
- dm_cback_data.sApp_set_config.status = p_data->sApp_set_config.status;
- dm_cback_data.sApp_set_config.num_param_id =
- p_data->sApp_set_config.num_param_id;
- dm_cback_data.sApp_set_config.tlv_size = p_data->sApp_set_config.tlv_size;
- if (dm_cback_data.sApp_set_config.tlv_size > 0) {
- memcpy(dm_cback_data.sApp_set_config.param_ids,
- p_data->sApp_set_config.param_ids,
- p_data->sApp_set_config.tlv_size);
- }
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_SET_CONFIG_RSP_EVT,
- &dm_cback_data);
- break;
-
- case UWB_GET_APP_CONFIG_REVT: /*get session app config response */
- dm_cback_data.sApp_get_config.status = p_data->sApp_get_config.status;
- dm_cback_data.sApp_get_config.no_of_ids =
- p_data->sApp_get_config.no_of_ids;
- dm_cback_data.sApp_get_config.tlv_size = p_data->sApp_get_config.tlv_size;
- if (dm_cback_data.sApp_get_config.tlv_size > 0) {
- memcpy(dm_cback_data.sApp_get_config.param_tlvs,
- p_data->sApp_get_config.p_param_tlvs,
- p_data->sApp_get_config.tlv_size);
- }
- /* Return result of getAppConfig to the app */
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_GET_CONFIG_RSP_EVT,
- &dm_cback_data);
- break;
-
- case UWB_START_RANGE_REVT: /* range start response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E("Range start command failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_RANGE_START_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_STOP_RANGE_REVT: /* range start response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E("Range stop command failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_RANGE_STOP_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_RANGE_DATA_REVT: /* range data notification */
- {
- tUWA_RANGE_DATA_NTF* p_sRange_data = &dm_cback_data.sRange_data;
- memset(p_sRange_data, 0, sizeof(tUWA_RANGE_DATA_NTF));
- if (p_data->sRange_data.range_data_len != 0) {
- memcpy((uint8_t*)p_sRange_data, (uint8_t*)&p_data->sRange_data,
- sizeof(tUWA_RANGE_DATA_NTF));
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_RANGE_DATA_NTF_EVT, &dm_cback_data);
- }
- } break;
-
- case UWB_GET_RANGE_COUNT_REVT: /* get ranging round count response */
- if (p_data->status == UWB_STATUS_OK) {
- tUWA_RANGE_GET_RNG_COUNT_REVT* p_sGet_range_cnt =
- &dm_cback_data.sGet_range_cnt;
- p_sGet_range_cnt->status = p_data->sGet_range_cnt.status;
- p_sGet_range_cnt->count = p_data->sGet_range_cnt.count;
- } else {
- UCI_TRACE_E("Get range count command failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_GET_RANGE_COUNT_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_CORE_GET_DEVICE_CAPABILITY_REVT: /* Core Get device capability
- Response */
- {
- dm_cback_data.sGet_device_capability.status =
- p_data->sGet_device_capability.status;
- dm_cback_data.sGet_device_capability.no_of_tlvs =
- p_data->sGet_device_capability.no_of_tlvs;
- dm_cback_data.sGet_device_capability.tlv_buffer_len =
- p_data->sGet_device_capability.tlv_buffer_len;
- if (dm_cback_data.sGet_device_capability.tlv_buffer_len > 0) {
- memcpy(dm_cback_data.sGet_device_capability.tlv_buffer,
- p_data->sGet_device_capability.tlv_buffer,
- p_data->sGet_device_capability.tlv_buffer_len);
- }
- /* Return result of core get device capability to the app */
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_GET_CORE_DEVICE_CAP_RSP_EVT,
- &dm_cback_data);
- } break;
-
- case UWB_SESSION_UPDATE_MULTICAST_LIST_REVT: /* multi-cast list update
- response*/
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E(" Session update multicast list request is failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_MC_LIST_UPDATE_RSP_EVT,
- &dm_cback_data);
- break;
-
- case UWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT: /* session update multicast
- list data notification
- */
- {
- tUWA_SESSION_UPDATE_MULTICAST_LIST_NTF* p_sMulticast_list_ntf =
- &dm_cback_data.sMulticast_list_ntf;
- memset(p_sMulticast_list_ntf, 0,
- sizeof(tUWA_SESSION_UPDATE_MULTICAST_LIST_NTF));
- memcpy((uint8_t*)p_sMulticast_list_ntf,
- (uint8_t*)&p_data->sMulticast_list_ntf,
- sizeof(tUWA_SESSION_UPDATE_MULTICAST_LIST_NTF));
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_MC_LIST_UPDATE_NTF_EVT,
- &dm_cback_data);
- } break;
-
- case UWB_SESSION_ACTIVE_ROUNDS_INDEX_UPDATE_REVT:
- {
- dm_cback_data.status = p_data->status;
- tUWA_UPDATE_RANGE_ROUND_INDEX_REVT* p_resp_data = &dm_cback_data.sRange_round_index;
- p_resp_data->status = p_data->sRange_round_index.status;
- p_resp_data->len = p_data->sRange_round_index.len;
- if(p_resp_data->len > 0){
- memcpy(p_resp_data->rng_round_index, p_data->sRange_round_index.rng_round_index, p_data->sRange_round_index.len);
- }
- }
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_ACTIVE_ROUNDS_INDEX_UPDATE_REVT, &dm_cback_data);
- break;
-
- case UWB_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT:
- {
- dm_cback_data.status = p_data->status;
- tUWA_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_REVT* p_resp_data = &dm_cback_data.sConfigure_dt_anchor_rr_rdm_list;
- p_resp_data->status = p_data->sConfigure_dt_anchor_rr_rdm_list.status;
- p_resp_data->len = p_data->sConfigure_dt_anchor_rr_rdm_list.len;
- if(p_resp_data->len > 0){
- memcpy(p_resp_data->rng_round_indexs, p_data->sConfigure_dt_anchor_rr_rdm_list.rng_round_indexs, p_data->sConfigure_dt_anchor_rr_rdm_list.len);
- }
- }
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT, &dm_cback_data);
- break;
-
- case UWB_SET_COUNTRY_CODE_REVT: /* set country code response*/
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E(" Set country code request failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SET_COUNTRY_CODE_RSP_EVT,
- &dm_cback_data);
- break;
-
- case UWB_BLINK_DATA_TX_REVT: /* blink data send response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E(" Blink data tx request is failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SEND_BLINK_DATA_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_BLINK_DATA_TX_NTF_REVT: /* blink data tx notification */
- {
- tUWA_SEND_BLINK_DATA_NTF* p_sBlink_data_ntf =
- &dm_cback_data.sBlink_data_ntf;
- p_sBlink_data_ntf->repetition_count_status =
- p_data->sSend_blink_data_ntf.repetition_count_status;
-
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SEND_BLINK_DATA_NTF_EVT, &dm_cback_data);
- } break;
-
- case UWB_SEND_DATA_STATUS_EVT:
- {
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_SEND_DATA_STATUS_EVT, &dm_cback_data);
- }
- break;
-
- case UWB_DATA_TRANSFER_STATUS_NTF_REVT:
- {
- tUWA_DATA_TRANSFER_STATUS_NTF_REVT* p_data_transmit = &dm_cback_data.sData_xfer_status;
- p_data_transmit->session_id = p_data->sData_xfer_status.session_id;
- p_data_transmit->sequence_num = p_data->sData_xfer_status.sequence_num;
- p_data_transmit->status = p_data->sData_xfer_status.status;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_DATA_TRANSFER_STATUS_NTF_EVT, &dm_cback_data);
- }
- break;
-
- case UWB_DATA_RECV_REVT:
- {
- tUWA_RX_DATA_REVT* p_rcv_data = &dm_cback_data.sRcvd_data;
- memset(p_rcv_data, 0, sizeof(tUWA_RX_DATA_REVT));
- memcpy((uint8_t*)p_rcv_data, (uint8_t*)&p_data->sRcvd_data, sizeof(tUWA_RX_DATA_REVT));
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_DATA_RECV_EVT, &dm_cback_data);
- }
- break;
-
- case UWB_CONFORMANCE_TEST_DATA: /* conformance test notification */
- {
- tUWA_CONFORMANCE_TEST_DATA* p_sConformance_data_ntf =
- &dm_cback_data.sConformance_ntf;
- p_sConformance_data_ntf->length = p_data->sConformance_test_data.length;
- memcpy((uint8_t*)p_sConformance_data_ntf->data,
- (uint8_t*)p_data->sConformance_test_data.data,
- p_data->sConformance_test_data.length);
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_CONFORMANCE_NTF_EVT, &dm_cback_data);
- } break;
- case UWB_UWBS_RESP_TIMEOUT_REVT: /* event to notify response timeout */
- {
- dm_cback_data.status = UWB_STATUS_FAILED;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_UWBS_RESP_TIMEOUT_EVT, &dm_cback_data);
- } break;
- case UWB_VENDOR_SPECIFIC_UCI_NTF_EVT:
- {
- dm_cback_data.vendor_specific_ntf.len = p_data->vendor_specific_ntf.len;
- memcpy((uint8_t*)dm_cback_data.vendor_specific_ntf.data, p_data->vendor_specific_ntf.data, p_data->vendor_specific_ntf.len);
- (*uwa_dm_cb.p_dm_cback)(UWA_VENDOR_SPECIFIC_UCI_NTF_EVT, &dm_cback_data);
- } break;
- default:
- UCI_TRACE_E("unknown event.");
- break;
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_uwb_test_response_cback
-**
-** Description callback handles all RF test responses and notifications
-**
-** Returns void
-**
-*******************************************************************************/
-static void uwa_dm_uwb_test_response_cback(tUWB_TEST_RESPONSE_EVT event,
- tUWB_TEST_RESPONSE* p_data) {
- tUWA_DM_TEST_CBACK_DATA dm_cback_data;
-
- UCI_TRACE_I("uwa_dm_uwb_test_response_cback:%s(0x%x)",
- uwa_test_dm_uwb_revt_2_str(event).c_str(), event);
- switch (event) {
- case UWB_TEST_SET_CONFIG_REVT: /* set test configs response */
- dm_cback_data.sTest_set_config.status = p_data->sTest_set_config.status;
- dm_cback_data.sTest_set_config.num_param_id =
- p_data->sTest_set_config.num_param_id;
- dm_cback_data.sTest_set_config.tlv_size =
- p_data->sTest_set_config.tlv_size;
- if (p_data->sTest_set_config.tlv_size > 0) {
- memcpy(dm_cback_data.sTest_set_config.param_ids,
- p_data->sTest_set_config.param_ids,
- p_data->sTest_set_config.tlv_size);
- }
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_SET_CONFIG_RSP_EVT,
- &dm_cback_data);
- break;
-
- case UWB_TEST_GET_CONFIG_REVT: /* get test configs response */
- dm_cback_data.sTest_get_config.status = p_data->sTest_get_config.status;
- dm_cback_data.sTest_get_config.no_of_ids =
- p_data->sTest_get_config.no_of_ids;
- dm_cback_data.sTest_get_config.tlv_size =
- p_data->sTest_get_config.tlv_size;
- if (p_data->sTest_get_config.tlv_size > 0) {
- memcpy(dm_cback_data.sTest_get_config.param_tlvs,
- p_data->sTest_get_config.p_param_tlvs,
- p_data->sTest_get_config.tlv_size);
- }
- /* Return result of getTestConfig to the app */
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_GET_CONFIG_RSP_EVT,
- &dm_cback_data);
- break;
-
- case UWB_TEST_PERIODIC_TX_REVT: /* periodic tx response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E("per tx command failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_PERIODIC_TX_RSP_EVT,
- &dm_cback_data);
- break;
-
- case UWB_TEST_PER_RX_REVT: /* per rx response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E("per rx command failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_PER_RX_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_TEST_LOOPBACK_REVT: /* rf loop back response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E("rf loop back command failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_LOOPBACK_RSP_EVT,
- &dm_cback_data);
- break;
-
- case UWB_TEST_RX_REVT: /* rx test response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E("rx test command failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_RX_RSP_EVT, &dm_cback_data);
- break;
-
- case UWB_TEST_STOP_SESSION_REVT: /* per rx response */
- if (p_data->status != UWB_STATUS_OK) {
- UCI_TRACE_E("test stop command failed");
- }
- dm_cback_data.status = p_data->status;
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_STOP_SESSION_RSP_EVT,
- &dm_cback_data);
- break;
-
- case UWB_TEST_PER_RX_DATA_REVT: /* PER test data notification */
- {
- tUWA_RF_TEST_DATA* p_per_rx_test_data = &dm_cback_data.rf_test_data;
- if (p_data->sRf_test_result.length > 0) {
- p_per_rx_test_data->length = p_data->sRf_test_result.length;
- memcpy(&p_per_rx_test_data->data[0], &p_data->sRf_test_result.data[0],
- p_per_rx_test_data->length);
- }
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_PER_RX_NTF_EVT, &dm_cback_data);
- } break;
-
- case UWB_TEST_PERIODIC_TX_DATA_REVT: /* periodic Tx test data notification
- */
- {
- tUWA_RF_TEST_DATA* p_rf_test_data = &dm_cback_data.rf_test_data;
- if (p_data->sRf_test_result.length > 0) {
- p_rf_test_data->length = p_data->sRf_test_result.length;
- memcpy(&p_rf_test_data->data[0], &p_data->sRf_test_result.data[0],
- p_rf_test_data->length);
- }
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_PERIODIC_TX_NTF_EVT,
- &dm_cback_data);
- } break;
-
- case UWB_TEST_LOOPBACK_DATA_REVT: /* loopback test data notification */
- {
- tUWA_RF_TEST_DATA* p_uwb_loopback_test_data = &dm_cback_data.rf_test_data;
- if (p_data->sRf_test_result.length > 0) {
- p_uwb_loopback_test_data->length = p_data->sRf_test_result.length;
- memcpy(&p_uwb_loopback_test_data->data[0],
- &p_data->sRf_test_result.data[0],
- p_uwb_loopback_test_data->length);
- }
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_LOOPBACK_NTF_EVT,
- &dm_cback_data);
- } break;
-
- case UWB_TEST_RX_DATA_REVT: /* Rx test data notification */
- {
- tUWA_RF_TEST_DATA* p_uwb_rx_test_data = &dm_cback_data.rf_test_data;
- if (p_data->sRf_test_result.length > 0) {
- p_uwb_rx_test_data->length = p_data->sRf_test_result.length;
- memcpy(&p_uwb_rx_test_data->data[0], &p_data->sRf_test_result.data[0],
- p_uwb_rx_test_data->length);
- }
- (*uwa_dm_cb.p_dm_test_cback)(UWA_DM_TEST_RX_NTF_EVT, &dm_cback_data);
- } break;
-
- default:
- UCI_TRACE_E("unknown event.");
- break;
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_enable
-**
-** Description Initializes the UWB device manager
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_enable(tUWA_DM_MSG* p_data) {
- tUWA_DM_CBACK_DATA dm_cback_data;
- UCI_TRACE_I("uwa_dm_enable ()");
-
- /* Check if UWA is already enabled */
- if (!(uwa_dm_cb.flags & UWA_DM_FLAGS_DM_IS_ACTIVE)) {
- uwa_dm_cb.flags |=
- (UWA_DM_FLAGS_DM_IS_ACTIVE | UWA_DM_FLAGS_ENABLE_EVT_PEND);
-
- /* Store Enable parameters */
- uwa_dm_cb.p_dm_cback = p_data->enable.p_dm_cback;
- uwa_dm_cb.p_dm_test_cback = p_data->enable.p_dm_test_cback;
- /* Enable UWB stack */
- UWB_Enable(uwa_dm_uwb_response_cback, uwa_dm_uwb_test_response_cback);
- } else {
- UCI_TRACE_E("uwa_dm_enable: ERROR ALREADY ENABLED.");
- dm_cback_data.status = UWA_STATUS_FAILED;
- (*(p_data->enable.p_dm_cback))(UWA_DM_ENABLE_EVT, &dm_cback_data);
- }
-
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_disable
-**
-** Description Disables the UWB device manager
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_disable(tUWA_DM_MSG* p_data) {
- UCI_TRACE_I("uwa_dm_disable (): graceful:%d", p_data->disable.graceful);
-
- /* Disable all subsystems other than DM (DM will be disabled after all */
- /* the other subsystem have been disabled) */
- uwa_sys_disable_subsystems(p_data->disable.graceful);
-
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_disable_complete
-**
-** Description Called when all UWA subsytems are disabled.
-**
-** UWB core stack can now be disabled.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_dm_disable_complete(void) {
- UCI_TRACE_I("uwa_dm_disable_complete ()");
- /* Disable uwb core stack */
- UWB_Disable();
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_get_device_info
-**
-** Description Function to get the UWBS device information by issuing get
-** device UCI command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_get_device_info(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_get_device_info(): p_data is NULL)");
- return false;
- } else {
- status = UWB_GetDeviceInfo();
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_get_device_info(): success ,status=0x%X", status);
- } else {
- UCI_TRACE_E("uwa_dm_act_get_device_info(): failed ,status=0x%X", status);
- }
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_set_core_config
-**
-** Description Process set core config command
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_set_core_config(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- uint8_t buff[255];
- uint8_t* p = buff;
-
- tUWA_DM_CBACK_DATA dm_cback_data;
-
- if (p_data->setconfig.length + 2 > 255) {
- /* Total length of TLV must be less than 256 (1 byte) */
- status = UWB_STATUS_FAILED;
- } else {
- UINT8_TO_STREAM(p, p_data->setconfig.param_id);
- UINT8_TO_STREAM(p, p_data->setconfig.length);
- ARRAY_TO_STREAM(p, p_data->setconfig.p_data, p_data->setconfig.length);
-
- status = UWB_SetCoreConfig((uint8_t)(p_data->setconfig.length + 2), buff);
- }
-
- if (status != UWB_STATUS_OK) {
- dm_cback_data.sCore_set_config.status = UWA_STATUS_INVALID_PARAM;
- (*uwa_dm_cb.p_dm_cback)(UWA_DM_CORE_SET_CONFIG_RSP_EVT, &dm_cback_data);
- }
-
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_get_core_config
-**
-** Description Process get config command
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_get_core_config(tUWA_DM_MSG* p_data) {
- UWB_GetCoreConfig(p_data->getconfig.num_ids, p_data->getconfig.p_pmids);
-
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_device_reset
-**
-** Description Process core device reset command
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_device_reset(tUWA_DM_MSG* pResetConfig) {
- tUWB_STATUS status;
-
- if (pResetConfig == NULL) {
- UCI_TRACE_E("uwa_dm_act_device_reset(): pResetConfig is NULL)");
- } else {
- status = UWB_DeviceResetCommand(pResetConfig->sDevice_reset.resetConfig);
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_device_reset(): success ,status=0x%X", status);
- } else {
- UCI_TRACE_E("uwa_dm_act_device_reset(): failed ,status=0x%X", status);
- }
- }
-
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_send_session_init
-**
-** Description send session init command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_send_session_init(tUWA_DM_MSG* p_data) {
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_send_session_init(): p_data is NULL)");
- return false;
- } else {
- UWB_SessionInit(p_data->sessionInit.session_id,
- p_data->sessionInit.sessionType);
- }
- return true;
-}
-/*******************************************************************************
-**
-** Function uwa_dm_act_send_session_deinit
-**
-** Description send session de init command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_send_session_deinit(tUWA_DM_MSG* p_data) {
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_send_session_deinit(): p_data is NULL)");
- return false;
- } else {
- UWB_SessionDeInit(p_data->sessionInit.session_id);
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_get_session_count
-**
-** Description send get session count to get no of active sessions
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_get_session_count(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_get_session_count(): p_data is NULL)");
- return false;
- } else {
- status = UWB_GetSessionCount();
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_get_session_count(): success ,status=0x%X",
- status);
- } else {
- UCI_TRACE_E("uwa_dm_act_get_session_count(): failed ,status=0x%X",
- status);
- }
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_app_set_config
-**
-** Description Send set configurations command to set the app configuration
-** parameters
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_app_set_config(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
-
- if (p_data->sApp_set_config.length + 2 > 255) {
- /* Total length of TLV must be less than 256 (1 byte) */
- status = UWB_STATUS_FAILED;
- } else {
- status = UWB_SetAppConfig(
- p_data->sApp_set_config.session_id, p_data->sApp_set_config.num_ids,
- p_data->sApp_set_config.length, p_data->sApp_set_config.p_data);
- }
-
- if (status != UWB_STATUS_OK) {
- UCI_TRACE_E("uwa_dm_act_app_set_config(): failed ,status=0x%X", status);
- } else {
- UCI_TRACE_I("uwa_dm_act_app_set_config(): success ,status=0x%X", status);
- }
-
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_app_get_config
-**
-** Description Send get configurations command to get the app configuration
-** parameters
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_app_get_config(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
-
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_app_get_config(): p_data is NULL)");
- } else {
- status = UWB_GetAppConfig(
- p_data->sApp_get_config.session_id, p_data->sApp_get_config.num_ids,
- p_data->sApp_get_config.length, p_data->sApp_get_config.p_pmids);
-
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_app_get_config(): success ,status=0x%X", status);
- } else {
- UCI_TRACE_E("uwa_dm_act_app_get_config(): failed ,status=0x%X", status);
- }
- }
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_start_range_session
-**
-** Description start the ranging session
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_start_range_session(tUWA_DM_MSG* p_data) {
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_start_range_session(): p_data is NULL)");
- } else {
- UWB_StartRanging(p_data->rang_start.session_id);
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_stop_range_session
-**
-** Description stop the ranging session
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_stop_range_session(tUWA_DM_MSG* p_data) {
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_stop_range_session(): p_data is NULL");
- } else {
- UWB_StopRanging(p_data->rang_stop.session_id);
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_send_raw_vs
-**
-** Description Send the raw vs command to the UCI command queue
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_send_raw_cmd(tUWA_DM_MSG* p_data) {
- UWB_HDR* p_cmd = (UWB_HDR*)p_data;
-
- p_cmd->offset = sizeof(tUWA_DM_API_SEND_RAW) - UWB_HDR_SIZE;
- p_cmd->len = p_data->send_raw.cmd_params_len;
- UWB_SendRawCommand(p_cmd, p_data->send_raw.p_cback);
-
- return false;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_send_data_frame
-**
-** Description send data frame over UWB
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_send_data_frame(tUWA_DM_MSG* p_data){
- tUWB_STATUS status;
-
- if(p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_test_stop_session(): p_data is NULL)");
- return false;
- } else {
- status = UWB_SendData(
- p_data->send_data_frame.session_id,
- p_data->send_data_frame.p_addr, p_data->send_data_frame.dest_end_point,
- p_data->send_data_frame.sequence_num, p_data->send_data_frame.data_len,
- p_data->send_data_frame.p_data);
- }
- if(status == UWB_STATUS_OK) {
- UCI_TRACE_D("uwa_dm_act_send_data_frame(): success , status=0x%X",status);
- } else {
- UCI_TRACE_E("uwa_dm_act_send_data_frame(): failed , status=0x%X",status);
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_update_active_range_round_index
-**
-** Description Update Active Ranging Index Command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_update_active_range_round_index(tUWA_DM_MSG* p_data){
- tUWB_STATUS status;
-
- if(p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_update_active_range_round_index(): p_data is NULL)");
- return false;
- } else {
- status = UWB_UpdateRangingRoundIndex(p_data->update_rng_index.dlTdoaRole, p_data->update_rng_index.session_id, p_data->update_rng_index.number_of_rng_index,
- p_data->update_rng_index.length, p_data->update_rng_index.p_rng_index);
- }
- if(status == UWB_STATUS_OK) {
- UCI_TRACE_D("uwa_dm_act_update_active_range_round_index(): success , status=0x%X",status);
- } else {
- UCI_TRACE_E("uwa_dm_act_update_active_range_round_index(): failed , status=0x%X",status);
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_get_range_count
-**
-** Description Send the get range count command to the ranging count
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_get_range_count(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
-
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_get_range_count(): p_data is NULL)");
- } else {
- status = UWB_GetRangingCount(p_data->sGet_rang_count.session_id);
-
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_get_range_count(): success ,status=0x%X", status);
- } else {
- UCI_TRACE_E("uwa_dm_act_get_range_count(): failed ,status=0x%X", status);
- }
- }
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_get_session_status
-**
-** Description Send the get session status command to get the session
-** status
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_get_session_status(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
-
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_get_session_status(): p_data is NULL)");
- } else {
- status = UWB_GetSessionStatus(p_data->sGet_session_status.session_id);
-
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_get_session_status(): success ,status=0x%X",
- status);
- } else {
- UCI_TRACE_E("uwa_dm_act_get_session_status(): failed ,status=0x%X",
- status);
- }
- }
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_get_device_capability
-**
-** Description send get capability info command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_get_device_capability(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_get_device_capability(): p_data is NULL)");
- } else {
- status = UWB_CoreGetDeviceCapability();
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_get_device_capability(): success ,status=0x%X",
- status);
- } else {
- UCI_TRACE_E("uwa_dm_act_get_device_capability(): failed ,status=0x%X",
- status);
- }
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_multicast_list_update
-**
-** Description send controlee multicast list update command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_multicast_list_update(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_multicast_list_update(): p_data is NULL)");
- } else {
- status = UWB_MulticastListUpdate(
- p_data->sMulticast_list.session_id, p_data->sMulticast_list.action,
- p_data->sMulticast_list.no_of_controlee,
- p_data->sMulticast_list.short_address_list,
- p_data->sMulticast_list.subsession_id_list);
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_multicast_list_update(): success ,status=0x%X",
- status);
- } else {
- UCI_TRACE_E("uwa_dm_act_multicast_list_update(): failed ,status=0x%X",
- status);
- }
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_configure_dt_anchor_rr_rdm
-**
-** Description Configure dt anchor rr rdm list command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_configure_dt_anchor_rr_rdm(tUWA_DM_MSG* p_data){
- tUWB_STATUS status;
- if (p_data->sConfigure_dt_anchor_rr_rdm_list.length + 2 > MAX_RRRDM_LIST_LENGTH) {
- /* Total length of mac addr list must be less than 256 (1 byte) */
- status = UWA_STATUS_FAILED;
- } else {
- status = UWB_ConfigureDTAnchorForRrRdmList(p_data->sConfigure_dt_anchor_rr_rdm_list.session_id, p_data->sConfigure_dt_anchor_rr_rdm_list.rr_rdm_count, p_data->sConfigure_dt_anchor_rr_rdm_list.length,
- p_data->sConfigure_dt_anchor_rr_rdm_list.p_data);
- if(UWB_STATUS_OK == status){
- UCI_TRACE_D("uwa_dm_act_configure_dt_anchor_rr_rdm(): success ,status=0x%X",status);
- } else {
- UCI_TRACE_E("uwa_dm_act_configure_dt_anchor_rr_rdm(): failed ,status=0x%X",status);
- }
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_set_country_code
-**
-** Description send country code set command.
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_set_country_code(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_set_country_code(): p_data is NULL)");
- } else {
- status = UWB_SetCountryCode(p_data->sCountryCode.country_code);
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_set_country_code(): success ,status=0x%X",
- status);
- } else {
- UCI_TRACE_E("uwa_dm_set_country_code(): failed ,status=0x%X", status);
- }
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_send_blink_data
-**
-** Description send blink data tx command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_send_blink_data(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_send_blink_data(): p_data is NULL)");
- } else {
- status = UWB_SendBlinkData(p_data->sSend_blink_data.session_id,
- p_data->sSend_blink_data.repetition_count,
- p_data->sSend_blink_data.app_data_len,
- p_data->sSend_blink_data.app_data);
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_send_blink_data(): success ,status=0x%X", status);
- } else {
- UCI_TRACE_E("uwa_dm_act_send_blink_data(): failed ,status=0x%X", status);
- }
- }
- return true;
-}
-/* APIs for RF Test Functionality */
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_test_set_config
-**
-** Description Send set configurations command to set the test
-** configuration parameters
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_test_set_config(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
-
- if (p_data->sTest_set_config.length + 2 > UCI_MAX_PAYLOAD_SIZE) {
- /* Total length of TLV must be less than 256 (1 byte) */
- status = UWB_STATUS_FAILED;
- } else {
- status = UWB_SetTestConfig(
- p_data->sTest_set_config.session_id, p_data->sTest_set_config.num_ids,
- p_data->sTest_set_config.length, p_data->sTest_set_config.p_data);
- }
- if (status != UWB_STATUS_OK) {
- UCI_TRACE_E("uwa_dm_act_test_set_config(): failed ,status=0x%X", status);
- } else {
- UCI_TRACE_I("uwa_dm_act_test_set_config(): success ,status=0x%X", status);
- }
-
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_test_get_config
-**
-** Description Send get configurations command to get the test
-** configuration parameters
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_test_get_config(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
-
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_test_get_config(): p_data is NULL)");
- } else {
- status = UWB_TestGetConfig(
- p_data->sTest_get_config.session_id, p_data->sTest_get_config.num_ids,
- p_data->sTest_get_config.length, p_data->sTest_get_config.p_pmids);
-
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_test_get_config(): success ,status=0x%X", status);
- } else {
- UCI_TRACE_E("uwa_dm_act_test_get_config(): failed ,status=0x%X", status);
- }
- }
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_test_periodic_tx
-**
-** Description Send periodic tx command to start periodic Tx test
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_test_periodic_tx(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_test_periodic_tx(): p_data is NULL)");
- } else {
- status = UWB_TestPeriodicTx(p_data->sPeriodic_tx.length,
- p_data->sPeriodic_tx.p_data);
-
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_test_periodic_tx(): success ,status=0x%X",
- status);
- } else {
- UCI_TRACE_E("uwa_dm_act_test_periodic_tx(): failed ,status=0x%X", status);
- }
- }
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_test_per_rx
-**
-** Description Send PER Rx command to start Packet error rate Rx test
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_test_per_rx(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_test_per_rx(): p_data is NULL)");
- } else {
- status = UWB_TestPerRx(p_data->sPer_rx.length, p_data->sPer_rx.p_data);
-
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_test_per_rx(): success ,status=0x%X", status);
- } else {
- UCI_TRACE_E("uwa_dm_act_test_per_rx(): failed ,status=0x%X", status);
- }
- }
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_test_uwb_loopback
-**
-** Description Send Rf loop back command
-**
-** Returns true (message buffer to be freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_test_uwb_loopback(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_test_uwb_loopback(): p_data is NULL)");
- } else {
- status = UWB_TestUwbLoopBack(p_data->sUwb_loopback.length,
- p_data->sUwb_loopback.p_data);
-
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_test_uwb_loopback(): success ,status=0x%X",
- status);
- } else {
- UCI_TRACE_E("uwa_dm_act_test_uwb_loopback(): failed ,status=0x%X",
- status);
- }
- }
- return (true);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_test_rx
-**
-** Description Send Test Rx Command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_test_rx(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_test_rx(): p_data is NULL)");
- return false;
- } else {
- status = UWB_TestRx();
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_test_rx(): success , status=0x%X", status);
- } else {
- UCI_TRACE_E("uwa_dm_act_test_rx(): failed , status=0x%X", status);
- }
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_act_test_stop_session
-**
-** Description send test stop session command
-**
-** Returns FALSE (message buffer is NOT freed by caller)
-**
-*******************************************************************************/
-bool uwa_dm_act_test_stop_session(tUWA_DM_MSG* p_data) {
- tUWB_STATUS status;
- if (p_data == NULL) {
- UCI_TRACE_E("uwa_dm_act_test_stop_session(): p_data is NULL)");
- return false;
- } else {
- status = UWB_TestStopSession();
- if (UWB_STATUS_OK == status) {
- UCI_TRACE_I("uwa_dm_act_test_stop_session(): success , status=0x%X",
- status);
- } else {
- UCI_TRACE_E("uwa_dm_act_test_stop_session(): failed , status=0x%X",
- status);
- }
- }
- return true;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_uwb_revt_2_str
-**
-** Description convert uwb revt to string
-**
-*******************************************************************************/
-std::string uwa_dm_uwb_revt_2_str(tUWB_RESPONSE_EVT event) {
- switch (event) {
- case UWB_ENABLE_REVT:
- return "UWB_ENABLE_REVT";
-
- case UWB_DISABLE_REVT:
- return "UWB_DISABLE_REVT";
-
- case UWB_DEVICE_STATUS_REVT:
- return "UWB_DEVICE_STATUS_REVT";
-
- case UWB_GET_DEVICE_INFO_REVT:
- return "UWB_GET_DEVICE_INFO_REVT";
-
- case UWB_SET_CORE_CONFIG_REVT:
- return "UWB_SET_CORE_CONFIG_REVT";
-
- case UWB_GET_CORE_CONFIG_REVT:
- return "UWB_GET_CORE_CONFIG_REVT";
-
- case UWB_DEVICE_RESET_REVT:
- return "UWB_DEVICE_RESET_REVT";
-
- case UWB_CORE_GEN_ERR_STATUS_REVT:
- return "UWB_CORE_GEN_ERR_STATUS_REVT";
-
- case UWB_SESSION_INIT_REVT:
- return "UWB_SESSION_INIT_REVT";
-
- case UWB_SESSION_DEINIT_REVT:
- return "UWB_SESSION_DEINIT_REVT";
-
- case UWB_SESSION_STATUS_NTF_REVT:
- return "UWB_SESSION_STATUS_NTF_REVT";
-
- case UWB_SESSION_GET_COUNT_REVT:
- return "UWB_SESSION_GET_COUNT_REVT";
-
- case UWB_SESSION_GET_STATE_REVT:
- return "UWB_SESSION_GET_STATE_REVT";
-
- case UWB_GET_APP_CONFIG_REVT:
- return "UWB_GET_APP_CONFIG_REVT";
-
- case UWB_SET_APP_CONFIG_REVT:
- return "UWB_SET_APP_CONFIG_REVT";
-
- case UWB_START_RANGE_REVT:
- return "UWB_START_RANGE_REVT";
-
- case UWB_STOP_RANGE_REVT:
- return "UWB_STOP_RANGE_REVT";
-
- case UWB_RANGE_DATA_REVT:
- return "UWB_RANGE_DATA_REVT";
-
- case UWB_GET_RANGE_COUNT_REVT:
- return "UWB_GET_RANGE_COUNT_REVT";
-
- case UWB_CORE_GET_DEVICE_CAPABILITY_REVT:
- return "UWB_CORE_GET_DEVICE_CAPABILITY_REVT";
-
- case UWB_SESSION_UPDATE_MULTICAST_LIST_REVT:
- return "UWB_SESSION_UPDATE_MULTICAST_LIST_REVT";
-
- case UWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT:
- return "UWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT";
-
- case UWB_SET_COUNTRY_CODE_REVT:
- return "UWB_SET_COUNTRY_CODE_REVT";
-
- case UWB_BLINK_DATA_TX_REVT:
- return "UWB_BLINK_DATA_TX_REVT";
-
- case UWB_BLINK_DATA_TX_NTF_REVT:
- return "UWB_BLINK_DATA_TX_NTF_REVT";
-
- case UWB_DATA_RECV_REVT:
- return "UWB_DATA_RECV_REVT";
-
- case UWB_DATA_TRANSFER_STATUS_NTF_REVT:
- return "UWB_DATA_TRANSFER_STATUS_NTF_REVT";
-
- case UWB_SEND_DATA_STATUS_EVT:
- return "UWB_SEND_DATA_STATUS_EVT";
-
- case UWB_CONFORMANCE_TEST_DATA:
- return "UWB_CONFORMANCE_TEST_DATA";
-
- case UWB_VENDOR_SPECIFIC_UCI_NTF_EVT:
- return "UWB_VENDOR_SPECIfIC_UCI_NTF_EVT";
-
- default:
- return "unknown revt";
- break;
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_test_dm_uwb_revt_2_str
-**
-** Description convert uwb revt to string for RF test events
-**
-*******************************************************************************/
-std::string uwa_test_dm_uwb_revt_2_str(tUWB_TEST_RESPONSE_EVT event) {
- switch (event) {
- case UWB_TEST_GET_CONFIG_REVT:
- return "UWB_TEST_GET_CONFIG_REVT";
-
- case UWB_TEST_SET_CONFIG_REVT:
- return "UWB_TEST_SET_CONFIG_REVT";
-
- case UWB_TEST_PERIODIC_TX_DATA_REVT:
- return "UWB_TEST_PERIODIC_TX_DATA_REVT";
-
- case UWB_TEST_PER_RX_DATA_REVT:
- return "UWB_TEST_PER_RX_DATA_REVT";
-
- case UWB_TEST_PERIODIC_TX_REVT:
- return "UWB_TEST_PERIODIC_TX_REVT";
-
- case UWB_TEST_PER_RX_REVT:
- return "UWB_TEST_PER_RX_REVT";
-
- case UWB_TEST_STOP_SESSION_REVT:
- return "UWB_TEST_STOP_SESSION_REVT";
-
- case UWB_TEST_LOOPBACK_DATA_REVT:
- return "UWB_TEST_LOOPBACK_DATA_REVT";
-
- case UWB_TEST_LOOPBACK_REVT:
- return "UWB_TEST_LOOPBACK_REVT";
-
- case UWB_TEST_RX_REVT:
- return "UWB_TEST_RX_REVT";
-
- case UWB_TEST_RX_DATA_REVT:
- return "UWB_TEST_RX_DATA_REVT";
-
- default:
- return "unknown revt";
- break;
- }
-}
diff --git a/src/uwa/dm/uwa_dm_api.cc b/src/uwa/dm/uwa_dm_api.cc
deleted file mode 100755
index b58ccba..0000000
--- a/src/uwa/dm/uwa_dm_api.cc
+++ /dev/null
@@ -1,1041 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 2010-2014 Broadcom Corporation
- * Copyright 2018-2022 NXP
- *
- * 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.
- *
- ******************************************************************************/
-
-/******************************************************************************
- *
- * UWA interface for device management
- *
- ******************************************************************************/
-#include <string.h>
-
-#include "uci_log.h"
-#include "uwa_api.h"
-#include "uwa_dm_int.h"
-#include "uwa_sys.h"
-#include "uwa_sys_int.h"
-#include "uwb_osal_common.h"
-
-tHAL_UWB_CONTEXT hal_Initcntxt;
-
-/*****************************************************************************
-** APIs
-*****************************************************************************/
-/*******************************************************************************
-**
-** Function UWA_Init
-**
-** Description This function initializes control blocks for UWA
-**
-** p_hal_entry_tbl points to a table of HAL entry points
-**
-** NOTE: the buffer that p_hal_entry_tbl points must be
-** persistent until UWA is disabled.
-**
-** Returns none
-**
-*******************************************************************************/
-void UWA_Init(tHAL_UWB_ENTRY* p_hal_entry_tbl) {
- UCI_TRACE_I(__func__);
- hal_Initcntxt.hal_entry_func = p_hal_entry_tbl;
- uwa_sys_init();
- uwa_dm_init();
- UWB_Init(&hal_Initcntxt);
-}
-
-/*******************************************************************************
-**
-** Function UWA_Enable
-**
-** Description This function enables UWBS. Prior to calling UWA_Enable,
-** the UWBC must be powered up, and ready to receive commands.
-** This function enables the tasks needed by UWB, opens the UCI
-** transport, resets the UWB Subsystem, downloads patches to
-** the UWBS (if necessary), and initializes the UWB subsystems.
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_Enable(tUWA_DM_CBACK* p_dm_cback,
- tUWA_DM_TEST_CBACK* p_dm_test_cback) {
- tUWA_DM_API_ENABLE* p_msg;
-
- UCI_TRACE_I(__func__);
-
- /* Validate parameters */
- if (!p_dm_cback) {
- UCI_TRACE_E("error null callback");
- return (UWA_STATUS_FAILED);
- }
-
- if ((p_msg = (tUWA_DM_API_ENABLE*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_ENABLE))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_ENABLE_EVT;
- p_msg->p_dm_cback = p_dm_cback;
- p_msg->p_dm_test_cback = p_dm_test_cback;
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_Disable
-**
-** Description This function is called to shutdown UWBS. The tasks for UWB
-** are terminated, and clean up routines are performed. This
-** function is typically called during platform shut-down, or
-** when UWB is disabled from a settings UI. When the UWBS
-** shutdown procedure is completed, an UWA_DM_DISABLE_EVT is
-** returned to the application using the tUWA_DM_CBACK.
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_Disable(bool graceful) {
- tUWA_DM_API_DISABLE* p_msg;
-
- UCI_TRACE_I("UWA_Disable (graceful=%i)", graceful);
-
- if ((p_msg = (tUWA_DM_API_DISABLE*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_DISABLE))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_DISABLE_EVT;
- p_msg->graceful = graceful;
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function: UWA_GetDeviceInfo
-**
-** Description: This function gets the UWB Subsystem Information
-**
-** Returns: UCI version and manufacturer specific information
-**
-*******************************************************************************/
-tUWA_STATUS UWA_GetDeviceInfo() {
- tUWA_DM_API_GET_DEVICE_INFO* p_msg;
-
- UCI_TRACE_I("UWA_GetDeviceInfo ()");
-
- p_msg = (tUWA_DM_API_GET_DEVICE_INFO*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_GET_DEVICE_INFO));
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_GET_DEVICE_INFO_EVT;
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_SetCoreConfig
-**
-** Description Set the configuration parameters to UWBS. The result is
-** reported with an UWA_DM_CORE_SET_CONFIG_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_SetCoreConfig(tUWA_PMID param_id, uint8_t length,
- uint8_t* p_data) {
- tUWA_DM_API_CORE_SET_CONFIG* p_msg;
-
- UCI_TRACE_I("param_id:0x%X", param_id);
-
- if ((p_msg = (tUWA_DM_API_CORE_SET_CONFIG*)phUwb_GKI_getbuf(
- (uint16_t)(sizeof(tUWA_DM_API_CORE_SET_CONFIG) + length))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_SET_CORE_CONFIG_EVT;
-
- p_msg->param_id = param_id;
- p_msg->length = length;
- p_msg->p_data = (uint8_t*)(p_msg + 1);
-
- /* Copy parameter data */
- memcpy(p_msg->p_data, p_data, length);
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_GetCoreConfig
-**
-** Description Get the configuration parameters from UWBS. The result is
-** reported with an UWA_DM_CORE_GET_CONFIG_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_GetCoreConfig(uint8_t num_ids, tUWA_PMID* p_param_ids) {
- tUWA_DM_API_CORE_GET_CONFIG* p_msg;
-
- UCI_TRACE_I("UWA_GetCoreConfig (): num_ids: %i", num_ids);
- if ((p_msg = (tUWA_DM_API_CORE_GET_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
- sizeof(tUWA_DM_API_CORE_GET_CONFIG) + num_ids))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_GET_CORE_CONFIG_EVT;
- p_msg->num_ids = num_ids;
- p_msg->p_pmids = (tUWA_PMID*)(p_msg + 1);
- /* Copy the param IDs */
- memcpy(p_msg->p_pmids, p_param_ids, num_ids);
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_SendDeviceReset
-**
-** Description Send Device Reset Command to UWBS. The result is
-** reported with an UWA_DM_DEVICE_RESET_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_SendDeviceReset(uint8_t resetConfig) {
- tUWA_DM_API_DEVICE_RESET* p_msg;
-
- UCI_TRACE_I("UWA_SendDeviceReset(): resetConfig:0x%X", resetConfig);
-
- if ((p_msg = (tUWA_DM_API_DEVICE_RESET*)phUwb_GKI_getbuf(
- (uint16_t)(sizeof(tUWA_DM_API_DEVICE_RESET)))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_DEVICE_RESET_EVT;
- p_msg->resetConfig = resetConfig;
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_SendSessionInit
-**
-** Description This function is called to send session init command.
-** The result is reported with an UWA_DM_SESSION_INIT_RSP_EVT
-** in the tUWA_DM_CBACK callback
-**
-** session id - value of particular session ID
-** session type - type of session to start ex: ranging,app etc
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SendSessionInit(uint32_t session_id,
- uint8_t sessionType) {
- tUWA_DM_API_SESSION_INIT* p_msg;
- p_msg = (tUWA_DM_API_SESSION_INIT*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_SESSION_INIT));
-
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_SESSION_INIT_EVT;
- p_msg->session_id = session_id;
- p_msg->sessionType = sessionType;
- uwa_sys_sendmsg(p_msg);
-
- return UWA_STATUS_OK;
- }
-
- return UWA_STATUS_FAILED;
-}
-
-/*******************************************************************************
-**
-** Function UWA_SendSessionDeInit
-**
-** Description This function is called to send session deinit command.
-** The result is reported with an UWA_DM_SESSION_DEINIT_RSP_EVT
-** in the tUWA_DM_CBACK callback
-**
-** session id - value of particular session ID
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SendSessionDeInit(uint32_t session_id) {
- tUWA_DM_API_SESSION_DEINIT* p_msg;
- p_msg = (tUWA_DM_API_SESSION_DEINIT*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_SESSION_DEINIT));
-
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_SESSION_DEINIT_EVT;
- p_msg->session_id = session_id;
- uwa_sys_sendmsg(p_msg);
-
- return UWA_STATUS_OK;
- }
-
- return UWA_STATUS_FAILED;
-}
-
-/*******************************************************************************
-**
-** Function UWA_GetSessionCount
-**
-** Description This function is called to send get session count command
-** The result is reported with an
-** UWA_DM_SESSION_GET_COUNT_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is successfully sent
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_GetSessionCount() {
- tUWA_DM_API_GET_SESSION_COUNT* p_msg;
-
- UCI_TRACE_I("UWA_GetSessionCount ()");
-
- p_msg = (tUWA_DM_API_GET_SESSION_COUNT*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_GET_SESSION_COUNT));
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_SESSION_GET_COUNT_EVT;
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_SetAppConfig
-**
-** Description Set the configuration parameters to UWBS. The result is
-** reported with an UWA_DM_SESSION_SET_CONFIG_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_SetAppConfig(uint32_t session_id, uint8_t noOfParams,
- uint8_t paramLen, uint8_t appConfigParams[]) {
- tUWA_DM_API_SET_APP_CONFIG* p_msg;
-
- if ((p_msg = (tUWA_DM_API_SET_APP_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
- sizeof(tUWA_DM_API_SET_APP_CONFIG) + paramLen))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_SET_APP_CONFIG_EVT;
-
- p_msg->session_id = session_id;
- p_msg->num_ids = noOfParams;
- p_msg->length = paramLen;
- p_msg->p_data = (uint8_t*)(p_msg + 1);
-
- /* Copy parameter data */
- memcpy(p_msg->p_data, appConfigParams, paramLen);
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_GetAppConfig
-**
-** Description Get the configuration parameters from UWBS. The result is
-** reported with an UWA_DM_SESSION_GET_CONFIG_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_GetAppConfig(uint32_t session_id, uint8_t noOfParams,
- uint8_t paramLen, tUWA_PMID* p_param_ids) {
- tUWA_DM_API_GET_APP_CONFIG* p_msg;
-
- UCI_TRACE_I("UWA_GetAppConfig (): num_ids: %i", noOfParams);
- if ((p_msg = (tUWA_DM_API_GET_APP_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
- sizeof(tUWA_DM_API_GET_APP_CONFIG) + paramLen))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_GET_APP_CONFIG_EVT;
- p_msg->session_id = session_id;
- p_msg->num_ids = noOfParams;
- p_msg->length = paramLen;
- p_msg->p_pmids = (tUWA_PMID*)(p_msg + 1);
-
- /* Copy the param IDs */
- memcpy(p_msg->p_pmids, p_param_ids, paramLen);
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-
-/*******************************************************************************
-**
-** Function UWA_UpdateRangingRoundIndex
-**
-** Description Update the Ranging Round Index for the given session for
-** TDoA Feature,The result is reported with an
-** UWA_DM_SESSION_ACTIVE_ROUNDS_INDEX_UPDATE_REVT in the tUWA_DM_CBACK
-** callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_UpdateRangingRoundIndex(uint8_t dlTdoaRole, uint32_t session_id, uint8_t number_of_active_rngIndex,
- uint8_t rng_round_index_len, uint8_t* p_rng_round_index) {
- tUWA_DM_API_UPDATE_ACTIVE_RNG_INDEX* p_msg;
-
- if ((p_msg = (tUWA_DM_API_UPDATE_ACTIVE_RNG_INDEX*)phUwb_GKI_getbuf(
- (uint16_t)(sizeof(tUWA_DM_API_UPDATE_ACTIVE_RNG_INDEX) + rng_round_index_len))) != NULL)
- {
- p_msg->hdr.event = UWA_DM_API_UPDATE_ACTIVE_RNG_INDEX_EVT;
- p_msg->session_id = session_id;
- p_msg->dlTdoaRole = dlTdoaRole;
- p_msg->number_of_rng_index = number_of_active_rngIndex;
- p_msg->length = rng_round_index_len;
- p_msg->p_rng_index = (uint8_t*)(p_msg + 1);
-
- /* Copy the param IDs */
- memcpy(p_msg->p_rng_index, p_rng_round_index, rng_round_index_len);
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_StartRangingSession
-**
-** Description start the ranging session.
-** The result is reported with an UWA_DM_RANGE_START_RSP_EVT in
-** the tUWA_DM_CBACK callback
-**
-** Returns UWA_STATUS_OK if ranging started successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_StartRangingSession(uint32_t session_id) {
- tUWA_DM_API_RANGING_START* p_msg;
-
- UCI_TRACE_I("UWA_StartRangingSession ():");
-
- p_msg = (tUWA_DM_API_RANGING_START*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_RANGING_START));
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_START_RANGE_EVT;
- p_msg->session_id = session_id;
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_StopRangingSession
-**
-** Description stop the ranging session.
-** The result is reported with an UWA_DM_RANGE_STOP_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if ranging is stopped successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_StopRangingSession(uint32_t session_id) {
- tUWA_DM_API_RANGING_STOP* p_msg;
-
- UCI_TRACE_I("UWA_StopRangingSession ()");
-
- p_msg = (tUWA_DM_API_RANGING_STOP*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_RANGING_STOP));
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_STOP_RANGE_EVT;
- p_msg->session_id = session_id;
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_GetRangingCount
-**
-** Description Get ranging count.
-** The result is reported with an
-** UWA_DM_GET_RANGE_COUNT_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns ranging count if successful
-** 0 otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_GetRangingCount(uint32_t session_id) {
- tUWA_DM_API_GET_RANGING_COUNT* p_msg;
-
- UCI_TRACE_I("UWA_GetRangeCount ()");
-
- p_msg = (tUWA_DM_API_GET_RANGING_COUNT*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_GET_RANGING_COUNT));
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_GET_RANGE_COUNT_EVT;
- p_msg->session_id = session_id;
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_GetSessionStatus
-**
-** Description Get session status.
-** The result is reported with an
-** UWA_DM_SESSION_GET_STATE_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns session status if successful
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_GetSessionStatus(uint32_t session_id) {
- tUWA_DM_API_GET_SESSION_STATUS* p_msg;
-
- UCI_TRACE_I("UWA_GetSessionStatus ()");
-
- p_msg = (tUWA_DM_API_GET_SESSION_STATUS*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_GET_SESSION_STATUS));
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_GET_SESSION_STATUS_EVT;
- p_msg->session_id = session_id;
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_GetCoreGetDeviceCapability
-**
-** Description Get core device capability info command.
-** The result is reported with an
-** UWA_DM_GET_CORE_DEVICE_CAP_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if successfully sent
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_GetCoreGetDeviceCapability() {
- tUWA_DM_API_CORE_GET_DEVICE_CAPABILITY* p_msg;
-
- UCI_TRACE_I("UWA_GetCoreGetDeviceCapability()");
-
- p_msg = (tUWA_DM_API_CORE_GET_DEVICE_CAPABILITY*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_CORE_GET_DEVICE_CAPABILITY));
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_CORE_GET_DEVICE_CAPABILITY_EVT;
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_ControllerMulticastListUpdate
-**
-** Description This function is called to send Controller Multicast List
-** Update.
-** The result is reported with an
-** UWA_DM_SESSION_MC_LIST_UPDATE_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_ControllerMulticastListUpdate(
- uint32_t session_id, uint8_t action, uint8_t noOfControlees,
- uint16_t* shortAddressList, uint32_t* subSessionIdList) {
- tUWA_DM_API_SESSION_UPDATE_MULTICAST_LIST* p_msg;
- p_msg = (tUWA_DM_API_SESSION_UPDATE_MULTICAST_LIST*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_SESSION_UPDATE_MULTICAST_LIST));
-
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_SESSION_UPDATE_MULTICAST_LIST_EVT;
- p_msg->session_id = session_id;
- p_msg->action = action;
- p_msg->no_of_controlee = noOfControlees;
- if ((noOfControlees > 0) && (shortAddressList != NULL)) {
- memcpy(p_msg->short_address_list, shortAddressList,
- (noOfControlees * SHORT_ADDRESS_LEN));
- }
- if ((noOfControlees > 0) && (subSessionIdList != NULL)) {
- memcpy(p_msg->subsession_id_list, subSessionIdList,
- (noOfControlees * SESSION_ID_LEN));
- }
- uwa_sys_sendmsg(p_msg);
-
- return UWA_STATUS_OK;
- }
- return UWA_STATUS_FAILED;
-}
-
-/*******************************************************************************
-**
-** Function UWA_ConfigureDTAnchorForRrRdmList
-**
-** Description This function is called to Configure DT Anchor RR RDM List Update.
-** The result is reported with an
-** UWA_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT in the tUWA_DM_CBACK
-** callback.
-** Returns UWA_STATUS_OK if command is successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_ConfigureDTAnchorForRrRdmList(uint32_t session_id, uint8_t noOfParams, uint8_t rrRdmConfigParamLen , uint8_t rrRdmConfigParam[]) {
- tUWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST* p_msg;
- p_msg = (tUWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST*)phUwb_GKI_getbuf(sizeof(tUWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST));
-
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_EVT;
- p_msg->session_id = session_id;
- p_msg->rr_rdm_count = noOfParams;
- p_msg->length = rrRdmConfigParamLen;
- p_msg->p_data= (uint8_t*)(p_msg + 1);
-
- memcpy(p_msg->p_data, rrRdmConfigParam, (rrRdmConfigParamLen));
-
- uwa_sys_sendmsg(p_msg);
-
- return UWA_STATUS_OK;
- }
- return UWA_STATUS_FAILED;
-}
-
-/*******************************************************************************
-**
-** Function UWA_ControllerSetCountryCode
-**
-** Description This function is called to set country code.
-** The result is reported with an
-** UWA_DM_SET_COUNTRY_CODE_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_ControllerSetCountryCode(uint8_t* countryCodeArray) {
- tUWA_DM_API_SET_COUNTRY_CODE * p_msg;
- p_msg = (tUWA_DM_API_SET_COUNTRY_CODE *)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_SET_COUNTRY_CODE));
-
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_SET_COUNTRY_CODE_EVT;
- if (countryCodeArray != NULL) {
- memcpy(p_msg->country_code, countryCodeArray, COUNTRY_CODE_ARRAY_LEN);
- }
- uwa_sys_sendmsg(p_msg);
- return UWA_STATUS_OK;
- }
- return UWA_STATUS_FAILED;
-}
-
-/*******************************************************************************
-**
-** Function UWA_SendBlinkData
-**
-** Description This function is called to send Blink Data Tx.
-** The result is reported with an
-** UWA_DM_SEND_BLINK_DATA_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SendBlinkData(uint32_t session_id,
- uint8_t repetition_count,
- uint8_t app_data_len, uint8_t* app_data) {
- tUWA_DM_API_SEND_BLINK_DATA* p_msg;
- p_msg = (tUWA_DM_API_SEND_BLINK_DATA*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_SEND_BLINK_DATA));
-
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_SEND_BLINK_DATA_EVT;
- p_msg->session_id = session_id;
- p_msg->repetition_count = repetition_count;
- p_msg->app_data_len = app_data_len;
- if ((app_data_len > 0) && (app_data != NULL)) {
- memcpy(p_msg->app_data, app_data, app_data_len);
- }
-
- uwa_sys_sendmsg(p_msg);
-
- return UWA_STATUS_OK;
- }
- return UWA_STATUS_FAILED;
-}
-
-/* UWA APIs for RF Test functionality */
-
-/*******************************************************************************
-**
-** Function UWA_TestSetConfig
-**
-** Description Set the configuration parameters to UWBS.
-** The result is reported with an
-** UWA_DM_TEST_SET_CONFIG_RSP_EVT
-** in the tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_TestSetConfig(uint32_t session_id, uint8_t noOfParams,
- uint8_t paramLen, uint8_t testConfigParams[]) {
- tUWA_DM_API_TEST_SET_CONFIG* p_msg;
-
- if ((p_msg = (tUWA_DM_API_TEST_SET_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
- sizeof(tUWA_DM_API_TEST_SET_CONFIG) + paramLen))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_TEST_SET_CONFIG_EVT;
-
- p_msg->session_id = session_id;
- p_msg->num_ids = noOfParams;
- p_msg->length = paramLen;
- p_msg->p_data = (uint8_t*)(p_msg + 1);
-
- /* Copy parameter data */
- memcpy(p_msg->p_data, testConfigParams, paramLen);
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_TestGetConfig
-**
-** Description Get the configuration parameters from UWBS.
-** The result is reported with an
-** UWA_DM_TEST_GET_CONFIG_RSP_EVT
-** in the tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_TestGetConfig(uint32_t session_id, uint8_t noOfParams,
- uint8_t paramLen, tUWA_PMID* p_param_ids) {
- tUWA_DM_API_TEST_GET_CONFIG* p_msg;
-
- UCI_TRACE_I("UWA_TestGetConfig (): num_ids: %i", noOfParams);
- if ((p_msg = (tUWA_DM_API_TEST_GET_CONFIG*)phUwb_GKI_getbuf((uint16_t)(
- sizeof(tUWA_DM_API_TEST_GET_CONFIG) + paramLen))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_TEST_GET_CONFIG_EVT;
- p_msg->session_id = session_id;
- p_msg->num_ids = noOfParams;
- p_msg->length = paramLen;
- p_msg->p_pmids = (tUWA_PMID*)(p_msg + 1);
-
- /* Copy the param IDs */
- memcpy(p_msg->p_pmids, p_param_ids, paramLen);
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_PeriodicTxTest
-**
-** Description This function is called to trigger the periodic Tx Test.
-** The result is reported with an
-** UWA_DM_TEST_PERIODIC_TX_RSP_EVT
-** in the tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_PeriodicTxTest(uint16_t psduLen, uint8_t psduData[]) {
- tUWA_DM_API_TEST_PERIODIC_TX* p_msg;
-
- if ((p_msg = (tUWA_DM_API_TEST_PERIODIC_TX*)phUwb_GKI_getbuf((uint16_t)(
- sizeof(tUWA_DM_API_TEST_PERIODIC_TX) + psduLen))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_TEST_PERIODIC_TX_EVT;
- p_msg->length = psduLen;
- p_msg->p_data = (uint8_t*)(p_msg + 1);
- if ((psduLen > 0) && (psduData != NULL)) {
- memcpy(p_msg->p_data, psduData, psduLen);
- }
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_PerRxTest
-**
-** Description This function is called to trigger the PER Rx Tx Test
-** The result is reported with an UWA_DM_TEST_PER_RX_RSP_EVT
-** in the tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_PerRxTest(uint16_t psduLen, uint8_t psduData[]) {
- tUWA_DM_API_TEST_PER_RX* p_msg;
-
- if ((p_msg = (tUWA_DM_API_TEST_PER_RX*)phUwb_GKI_getbuf(
- (uint16_t)(sizeof(tUWA_DM_API_TEST_PER_RX) + psduLen))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_TEST_PER_RX_EVT;
- p_msg->length = psduLen;
- p_msg->p_data = (uint8_t*)(p_msg + 1);
- if ((psduLen > 0) && (psduData != NULL)) {
- memcpy(p_msg->p_data, psduData, psduLen);
- }
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_UwbLoopBackTest
-**
-** Description This function is called to trigger the loop back Test.
-** The result is reported with an UWA_DM_TEST_LOOPBACK_RSP_EVT
-** in the tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_UwbLoopBackTest(uint16_t psduLen, uint8_t psduData[]) {
- tUWA_DM_API_TEST_UWB_LOOPBACK* p_msg;
-
- if ((p_msg = (tUWA_DM_API_TEST_UWB_LOOPBACK*)phUwb_GKI_getbuf((uint16_t)(
- sizeof(tUWA_DM_API_TEST_UWB_LOOPBACK) + psduLen))) != NULL) {
- p_msg->hdr.event = UWA_DM_API_TEST_UWB_LOOPBACK_EVT;
- p_msg->length = psduLen;
- p_msg->p_data = (uint8_t*)(p_msg + 1);
- if ((psduLen > 0) && (psduData != NULL)) {
- memcpy(p_msg->p_data, psduData, psduLen);
- }
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
-
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_RxTest
-**
-** Description This function is called to trigger the Rx Test.
-** The result is reported with an UWA_DM_TEST_RX_RSP_EVT in the
-** tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if Per Session stopped successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_RxTest() {
- tUWA_DM_API_TEST_RX* p_msg;
-
- UCI_TRACE_I("UWA_RxTest()");
-
- p_msg = (tUWA_DM_API_TEST_RX*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_TEST_STOP_SESSION));
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_TEST_RX_EVT;
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_TestStopSession
-**
-** Description This function is called to stop the ongoing test session.
-** The result is reported with an
-** UWA_DM_TEST_STOP_SESSION_RSP_EVT in the
-** tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if Per Session stopped successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_TestStopSession() {
- tUWA_DM_API_TEST_STOP_SESSION* p_msg;
-
- UCI_TRACE_I("UWA_TestStopSession()");
-
- p_msg = (tUWA_DM_API_TEST_STOP_SESSION*)phUwb_GKI_getbuf(
- sizeof(tUWA_DM_API_TEST_STOP_SESSION));
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_TEST_STOP_SESSION_EVT;
- uwa_sys_sendmsg(p_msg);
- return (UWA_STATUS_OK);
- }
- return (UWA_STATUS_FAILED);
-}
-
-/*******************************************************************************
-**
-** Function UWA_SendRawVsCommand
-**
-** Description This function is called to send raw Vendor Specific
-** command to UWBS.
-**
-** cmd_params_len - The command parameter len
-** p_cmd_params - The command parameter
-** p_cback - The callback function to receive the
-** command
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_SendRawCommand(uint16_t cmd_params_len, uint8_t* p_cmd_params,
- tUWA_RAW_CMD_CBACK* p_cback) {
- if (cmd_params_len == 0x00 || p_cmd_params == NULL || p_cback == NULL) {
- return UWA_STATUS_INVALID_PARAM;
- }
- uint16_t size = (uint16_t)(sizeof(tUWA_DM_API_SEND_RAW) + cmd_params_len);
- tUWA_DM_API_SEND_RAW* p_msg = (tUWA_DM_API_SEND_RAW*)phUwb_GKI_getbuf(size);
-
- if (p_msg != NULL) {
- p_msg->hdr.event = UWA_DM_API_SEND_RAW_EVT;
- p_msg->p_cback = p_cback;
- if (cmd_params_len && p_cmd_params) {
- p_msg->cmd_params_len = cmd_params_len;
- p_msg->p_cmd_params = (uint8_t*)(p_msg + 1);
- memcpy(p_msg->p_cmd_params, p_cmd_params, cmd_params_len);
- }
- uwa_sys_sendmsg(p_msg);
-
- return UWA_STATUS_OK;
- }
-
- return UWA_STATUS_FAILED;
-}
-
-/*******************************************************************************
-**
-** Function UWA_SendUwbDataFrame
-**
-** Description This function is called to send UWB data over UWB RF interafce .
-**
-** Returns UWA_STATUS_OK if data sucessfully accepeted by UWB subsystem
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-tUWA_STATUS UWA_SendUwbData(uint32_t session_id,
- uint8_t* p_addr, uint8_t dest_end_point, uint8_t sequence_num,
- uint16_t data_len,
- uint8_t* p_data) {
- tUWA_DM_API_SEND_DATA_FRAME* p_msg;
- UCI_TRACE_I("UWA_SendUwbDataFrame: data_len = %d", data_len);
- if ((data_len == 0) || (p_data == nullptr) || (p_addr == nullptr))
- return (UWA_STATUS_FAILED);
-
- p_msg = (tUWA_DM_API_SEND_DATA_FRAME*)phUwb_GKI_getbuf(sizeof(tUWA_DM_API_SEND_DATA_FRAME) + data_len);
- if (p_msg != nullptr) {
- p_msg->hdr.event = UWA_DM_API_SEND_DATA_FRAME_EVT;
- p_msg->session_id = session_id;
- memcpy(p_msg->p_addr, p_addr, EXTENDED_ADDRESS_LEN);
- p_msg->dest_end_point = dest_end_point;
- p_msg->sequence_num = sequence_num;
- p_msg->data_len = data_len;
-
- p_msg->p_data = (uint8_t*)(p_msg + 1);
- memcpy(p_msg->p_data, p_data, data_len);
-
- uwa_sys_sendmsg(p_msg);
-
- return (UWA_STATUS_OK);
- }
- return UWA_STATUS_FAILED;
-
-}
diff --git a/src/uwa/dm/uwa_dm_main.cc b/src/uwa/dm/uwa_dm_main.cc
deleted file mode 100755
index 7502e56..0000000
--- a/src/uwa/dm/uwa_dm_main.cc
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021-2022 NXP.
- *
- * 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.
- */
-
-/******************************************************************************
- *
- * This is the main implementation file for the UWA device manager.
- *
- ******************************************************************************/
-#include <string>
-
-#include "uci_log.h"
-#include "uwa_api.h"
-#include "uwa_dm_int.h"
-#include "uwb_osal_common.h"
-
-/*****************************************************************************
-** Constants and types
-*****************************************************************************/
-static const tUWA_SYS_REG uwa_dm_sys_reg = {uwa_dm_sys_enable, uwa_dm_evt_hdlr,
- uwa_dm_sys_disable};
-tUWA_DM_CB uwa_dm_cb = {};
-
-#define UWA_DM_NUM_ACTIONS (UWA_DM_MAX_EVT & 0x00ff)
-
-/* type for action functions */
-typedef bool (*tUWA_DM_ACTION)(tUWA_DM_MSG* p_data);
-
-/* action function list */
-const tUWA_DM_ACTION uwa_dm_action[] = {
- /* device manager local device API events */
- uwa_dm_enable, /* UWA_DM_API_ENABLE_EVT */
- uwa_dm_disable, /* UWA_DM_API_DISABLE_EVT */
- uwa_dm_act_get_device_info, /* UWA_DM_API_GET_DEVICE_INFO_EVT */
- uwa_dm_set_core_config, /* UWA_DM_API_SET_CORE_CONFIG_EVT */
- uwa_dm_get_core_config, /* UWA_DM_API_GET_CORE_CONFIG_EVT */
- uwa_dm_act_device_reset, /* UWA_DM_API_DEVICE_RESET_EVT */
- uwa_dm_act_send_session_init, /* UWA_DM_API_SESSION_INIT_EVT */
- uwa_dm_act_send_session_deinit, /* UWA_DM_API_SESSION_DEINIT_EVT */
- uwa_dm_act_get_session_count, /* UWA_DM_API_SESSION_GET_COUNT_EVT */
- uwa_dm_act_app_set_config, /* UWA_DM_API_SET_APP_CONFIG_EVT */
- uwa_dm_act_app_get_config, /* UWA_DM_API_GET_APP_CONFIG_EVT */
- uwa_dm_act_start_range_session, /* UWA_DM_API_START_RANGE_EVT */
- uwa_dm_act_stop_range_session, /* UWA_DM_API_STOP_RANGE_EVT */
- uwa_dm_act_send_raw_cmd, /* UWA_DM_API_SEND_RAW_EVT */
- uwa_dm_act_get_range_count, /* UWA_DM_API_GET_RANGE_COUNT_EVT */
- uwa_dm_act_get_session_status, /* UWA_DM_API_GET_SESSION_STATUS_EVT */
- uwa_dm_act_get_device_capability, /* UWA_DM_API_CORE_GET_DEVICE_CAPABILITY_EVT
- */
- uwa_dm_act_multicast_list_update, /* UWA_DM_API_SESSION_UPDATE_MULTICAST_LIST_EVT */
- uwa_dm_act_set_country_code, /* UWA_DM_API_SET_COUNTRY_CODE_EVT */
- uwa_dm_act_send_blink_data, /* UWA_DM_API_SEND_BLINK_DATA_EVT */
- /* local API events for RF test functionality */
- uwa_dm_act_test_set_config, /* UWA_DM_API_TEST_SET_CONFIG_EVT */
- uwa_dm_act_test_get_config, /* UWA_DM_API_TEST_GET_CONFIG_EVT */
- uwa_dm_act_test_periodic_tx, /* UWA_DM_API_TEST_PERIODIC_TX_EVT */
- uwa_dm_act_test_per_rx, /* UWA_DM_API_TEST_PER_RX_EVT */
- uwa_dm_act_test_uwb_loopback, /* UWA_DM_API_TEST_UWB_LOOPBACK_EVT */
- uwa_dm_act_test_rx, /* UWA_DM_API_TEST_RX_EVT */
- uwa_dm_act_test_stop_session, /* UWA_DM_API_TEST_STOP_SESSION_EVT */
- /* API events for Data tranfer handling */
- uwa_dm_act_send_data_frame, /* UWA_DM_API_SEND_DATA_FRAME_EVT */
- uwa_dm_act_configure_dt_anchor_rr_rdm, /* UWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_EVT */
- uwa_dm_act_update_active_range_round_index /* UWA_DM_API_UPDATE_ACTIVE_RNG_INDEX_EVT */
-};
-
-/*****************************************************************************
-** Local function prototypes
-*****************************************************************************/
-std::string uwa_dm_evt_2_str(uint16_t event);
-/*******************************************************************************
-**
-** Function uwa_dm_init
-**
-** Description Initialises the UWB device manager
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_dm_init(void) {
- UCI_TRACE_I(__func__);
- /* register message handler on UWA SYS */
- memset(&uwa_dm_cb, 0, sizeof(tUWA_DM_CB));
- uwa_sys_register(UWA_ID_DM, &uwa_dm_sys_reg);
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_evt_hdlr
-**
-** Description Event handling function for DM
-**
-**
-** Returns void
-**
-*******************************************************************************/
-bool uwa_dm_evt_hdlr(UWB_HDR* p_msg) {
- bool freebuf = true;
- uint16_t event = p_msg->event & 0x00ff;
-
- UCI_TRACE_I("event: %s (0x%02x)", uwa_dm_evt_2_str(event).c_str(), event);
- /* execute action functions */
- if (event < UWA_DM_NUM_ACTIONS) {
- freebuf = (*uwa_dm_action[event])((tUWA_DM_MSG*)p_msg);
- }
- return freebuf;
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_sys_disable
-**
-** Description This function is called after all subsystems have been
-** disabled.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_dm_sys_disable(void) {
- /* Disable the DM sub-system */
- uwa_dm_disable_complete();
-}
-
-/*******************************************************************************
-**
-** Function uwa_dm_uwb_revt_2_str
-**
-** Description convert uwb revt to string
-**
-*******************************************************************************/
-std::string uwa_dm_evt_2_str(uint16_t event) {
- switch (UWA_SYS_EVT_START(UWA_ID_DM) | event) {
- case UWA_DM_API_ENABLE_EVT:
- return "UWA_DM_API_ENABLE_EVT";
-
- case UWA_DM_API_DISABLE_EVT:
- return "UWA_DM_API_DISABLE_EVT";
-
- case UWA_DM_API_GET_DEVICE_INFO_EVT:
- return "UWA_DM_API_GET_DEVICE_INFO_EVT";
-
- case UWA_DM_API_SET_CORE_CONFIG_EVT:
- return "UWA_DM_API_SET_CORE_CONFIG_EVT";
-
- case UWA_DM_API_GET_CORE_CONFIG_EVT:
- return "UWA_DM_API_GET_CORE_CONFIG_EVT";
-
- case UWA_DM_API_DEVICE_RESET_EVT:
- return "UWA_DM_API_DEVICE_RESET_EVT";
-
- case UWA_DM_API_SESSION_INIT_EVT:
- return "UWA_DM_API_SESSION_INIT_EVT";
-
- case UWA_DM_API_SESSION_DEINIT_EVT:
- return "UWA_DM_API_SESSION_DEINIT_EVT";
-
- case UWA_DM_API_SESSION_GET_COUNT_EVT:
- return "UWA_DM_API_SESSION_GET_COUNT_EVT";
-
- case UWA_DM_API_SET_APP_CONFIG_EVT:
- return "UWA_DM_API_SET_APP_CONFIG_EVT";
-
- case UWA_DM_API_GET_APP_CONFIG_EVT:
- return "UWA_DM_API_GET_APP_CONFIG_EVT";
-
- case UWA_DM_API_START_RANGE_EVT:
- return "UWA_DM_API_START_RANGE_EVT";
-
- case UWA_DM_API_STOP_RANGE_EVT:
- return "UWA_DM_API_STOP_RANGE_EVT";
-
- case UWA_DM_API_SEND_RAW_EVT:
- return "UWA_DM_API_SEND_RAW_EVT";
-
- case UWA_DM_API_GET_RANGE_COUNT_EVT:
- return "UWA_DM_API_GET_RANGE_COUNT_EVT";
-
- case UWA_DM_API_GET_SESSION_STATUS_EVT:
- return "UWA_DM_API_GET_SESSION_STATUS_EVT";
-
- case UWA_DM_API_TEST_SET_CONFIG_EVT:
- return "UWA_DM_API_TEST_SET_CONFIG_EVT";
-
- case UWA_DM_API_TEST_GET_CONFIG_EVT:
- return "UWA_DM_API_TEST_GET_CONFIG_EVT";
-
- case UWA_DM_API_TEST_PERIODIC_TX_EVT:
- return "UWA_DM_API_TEST_PERIODIC_TX_EVT";
-
- case UWA_DM_API_TEST_PER_RX_EVT:
- return "UWA_DM_API_TEST_PER_RX_EVT";
-
- case UWA_DM_API_TEST_STOP_SESSION_EVT:
- return "UWA_DM_API_TEST_STOP_SESSION_EVT";
-
- case UWA_DM_API_TEST_RX_EVT:
- return "UWA_DM_API_TEST_RX_EVT";
- }
-
- return "Unknown or Vendor Specific";
-}
diff --git a/src/uwa/include/uwa_api.h b/src/uwa/include/uwa_api.h
deleted file mode 100755
index 0e14a4a..0000000
--- a/src/uwa/include/uwa_api.h
+++ /dev/null
@@ -1,969 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2022 NXP
- *
- * 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.
- *
- ******************************************************************************/
-
-/******************************************************************************
- *
- * This is the public interface file for UWA, NXP's UWB application
- * layer for mobile phones/IOT devices.
- *
- ******************************************************************************/
-#ifndef UWA_API_H
-#define UWA_API_H
-
-#include "uci_defs.h"
-#include "uwb_api.h"
-#include "uwb_gki.h"
-#include "uwb_hal_api.h"
-#include "uwb_target.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-/* UWA API return status codes */
-/* Command succeeded */
-#define UWA_STATUS_OK UCI_STATUS_OK
-/* Command is rejected. */
-#define UWA_STATUS_REJECTED UCI_STATUS_REJECTED
-/* failed */
-#define UWA_STATUS_FAILED UCI_STATUS_FAILED
-/* Syntax error */
-#define UWA_STATUS_SYNTAX_ERROR UCI_STATUS_SYNTAX_ERROR
-/* Invalid Parameter */
-#define UWA_STATUS_INVALID_PARAM UCI_STATUS_INVALID_PARAM
-/* Invalid Range */
-#define UWA_STATUS_INVALID_RANGE UCI_STATUS_INVALID_RANGE
-/*Invalid payload size in UCI packet */
-#define UWA_STATUS_INVALID_MSG_SIZE UCI_STATUS_INVALID_MSG_SIZE
-/* Unknown GID */
-#define UWA_STATUS_UNKNOWN_GID UCI_STATUS_UNKNOWN_GID
-/* Unknown OID */
-#define UWA_STATUS_UNKNOWN_OID UCI_STATUS_UNKNOWN_OID
-/* Read only */
-#define UWA_STATUS_READ_ONLY UCI_STATUS_READ_ONLY
-/* retry the command */
-#define UWA_STATUS_COMMAND_RETRY UCI_STATUS_COMMAND_RETRY
-
-/* UWA session Specific status code */
-/* session is not exist in UWBD */
-#define UWA_STATUS_SESSSION_NOT_EXIST UCI_STATUS_SESSSION_NOT_EXIST
-/* Session is already exist/duplicate */
-#define UWA_STATUS_SESSSION_DUPLICATE UCI_STATUS_SESSSION_DUPLICATE
-/* Session is in active state */
-#define UWA_STATUS_SESSSION_ACTIVE UCI_STATUS_SESSSION_ACTIVE
-/* Maximum sessions are reached */
-#define UWA_STATUS_MAX_SESSSIONS_EXCEEDED UCI_STATUS_MAX_SESSSIONS_EXCEEDED
-/*session not configured */
-#define UWA_STATUS_SESSION_NOT_CONFIGURED UCI_STATUS_SESSION_NOT_CONFIGURED
-
-/* UWA Ranging Session Specific Status Codes */
-/* Ranging tx failed */
-#define UWA_STATUS_RANGING_TX_FAILED UCI_STATUS_RANGING_TX_FAILED
-/* Ranging rx timeout */
-#define UWA_STATUS_RANGING_RX_TIMEOUT UCI_STATUS_RANGING_RX_TIMEOUT
-/* Physical layer decoding failed */
-#define UWA_STATUS_RANGING_RX_PHY_DEC_FAILED \
- UCI_STATUS_RANGING_RX_PHY_DEC_FAILED
-/* Physical layer TOA failed */
-#define UWA_STATUS_RANGING_RX_PHY_TOA_FAILED \
- UCI_STATUS_RANGING_RX_PHY_TOA_FAILED
-/* Physical layer STS failed */
-#define UWA_STATUS_RANGING_RX_PHY_STS_FAILED \
- UCI_STATUS_RANGING_RX_PHY_STS_FAILED
-/* MAC decoding failed */
-#define UWA_STATUS_RANGING_RX_MAC_DEC_FAILED \
- UCI_STATUS_RANGING_RX_MAC_DEC_FAILED
-/* MAC information decoding failed */
-#define UWA_STATUS_RANGING_RX_MAC_IE_DEC_FAILED \
- UCI_STATUS_RANGING_RX_MAC_IE_DEC_FAILED
-/* MAC information missing */
-#define UWA_STATUS_RANGING_RX_MAC_IE_MISSING \
- UCI_STATUS_RANGING_RX_MAC_IE_MISSING
-
-/* UWA Data Session Specific Status Codes */
-#define UWA_STATUS_DATA_MAX_TX_PSDU_SIZE_EXCEEDED \
- UCI_STATUS_DATA_MAX_TX_PSDU_SIZE_EXCEEDED
-#define UWA_STATUS_DATA_RX_CRC_ERROR UCI_STATUS_DATA_RX_CRC_ERROR
-
-typedef uint8_t tUWA_STATUS;
-
-/* Handle for UWA registrations and connections */
-typedef uint16_t tUWA_HANDLE;
-#define UWA_HANDLE_INVALID (0xFFFF)
-
-/* UWA_DM callback events */
-
-#define UWA_DM_EVENT 0x00
-#define UWA_TEST_DM_EVENT 0xA0
-
-enum {
- UWA_DM_ENABLE_EVT = UWA_DM_EVENT, /* Result of UWA_Enable */
- UWA_DM_DISABLE_EVT, /* Result of UWA_Disable */
- UWA_DM_REGISTER_EXT_CB_EVT, /* Result of UWA Register Ext Callback */
- UWA_DM_UWBS_RESP_TIMEOUT_EVT, /* Result of command response timeout */
- UWA_DM_UWBS_ERROR_EVT, /* Result of UWB error ntf */
- UWA_DM_CORE_GET_DEVICE_INFO_RSP_EVT, /* Result of get device info */
- UWA_DM_CORE_SET_CONFIG_RSP_EVT, /* Result of UWA_SetCoreConfig */
- UWA_DM_CORE_GET_CONFIG_RSP_EVT, /* Result of UWA_GetCoreConfig */
- UWA_DM_DEVICE_RESET_RSP_EVT, /* Result of Core Dev Reset */
- UWA_DM_DEVICE_STATUS_NTF_EVT, /* Result of device status ntf */
- UWA_DM_CORE_GEN_ERR_STATUS_EVT, /* Result of core generic error status */
- UWA_DM_SESSION_INIT_RSP_EVT, /* Result of session Init cmd */
- UWA_DM_SESSION_DEINIT_RSP_EVT, /* Result of session Deinit cmd */
- UWA_DM_SESSION_STATUS_NTF_EVT, /* Result of session NTF */
- UWA_DM_SESSION_SET_CONFIG_RSP_EVT, /* Result of setAppConfig */
- UWA_DM_SESSION_GET_CONFIG_RSP_EVT, /* Result of getAppConfig */
- UWA_DM_SESSION_GET_COUNT_RSP_EVT, /* Result of get session count */
- UWA_DM_SESSION_GET_STATE_RSP_EVT, /* Result of get session count */
- UWA_DM_RANGE_START_RSP_EVT, /* Result of range start cmd */
- UWA_DM_RANGE_STOP_RSP_EVT, /* Result of range start cmd */
- UWA_DM_RANGE_DATA_NTF_EVT, /* Result of range data ntf */
- UWA_DM_GET_RANGE_COUNT_RSP_EVT, /* Result of range get count */
- UWA_DM_GET_CORE_DEVICE_CAP_RSP_EVT, /* Results of UWA_GetCoreDeviceCapability
- */
- UWA_DM_SESSION_MC_LIST_UPDATE_RSP_EVT, /* Session Update Multicast List resp
- event*/
- UWA_DM_SESSION_MC_LIST_UPDATE_NTF_EVT, /* Session Update Multicast List ntf
- event*/
- UWA_DM_SEND_BLINK_DATA_RSP_EVT, /* Blink Data Tx event*/
- UWA_DM_SEND_BLINK_DATA_NTF_EVT, /* Blink Data Tx ntf event*/
- UWA_DM_CONFORMANCE_NTF_EVT, /* Conformance Test Ntf Event */
- UWA_DM_SET_COUNTRY_CODE_RSP_EVT, /* Country code update resp event */
- UWA_VENDOR_SPECIFIC_UCI_NTF_EVT, /* Proprietary Ntf Event */
- UWA_DM_SEND_DATA_STATUS_EVT, /* data status EVT */
- UWA_DM_SEND_DATA_PACKET_RSP_EVT, /* data reception status by UWBS */
- UWA_DM_DATA_TRANSFER_STATUS_NTF_EVT, /* data transfer status over UWB */
- UWA_DM_DATA_RECV_EVT, /* Recieved data over UWB */
- UWA_DM_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT, /* Result of Configure DT Anchor RR RDM List Cmd */
- UWA_DM_SESSION_ACTIVE_ROUNDS_INDEX_UPDATE_REVT, /* Result of Update Active Ranging Index Cmd */
-};
-
-/* UWA_DM callback events for UWB RF events */
-
-enum {
- UWA_DM_TEST_SET_CONFIG_RSP_EVT =
- UWA_TEST_DM_EVENT, /* Results of set test config event*/
- UWA_DM_TEST_GET_CONFIG_RSP_EVT, /* Results of get test config event*/
- UWA_DM_TEST_STOP_SESSION_RSP_EVT, /* Result of test session stop response */
- UWA_DM_TEST_PERIODIC_TX_RSP_EVT, /* Results of periodic tx response event*/
- UWA_DM_TEST_PERIODIC_TX_NTF_EVT, /* Results of periodic tx test NTF event*/
- UWA_DM_TEST_PER_RX_RSP_EVT, /* Results of per rx response event*/
- UWA_DM_TEST_PER_RX_NTF_EVT, /* Results of per rx test NTF event*/
- UWA_DM_TEST_LOOPBACK_RSP_EVT, /* Rf Loop Back Test resp event*/
- UWA_DM_TEST_LOOPBACK_NTF_EVT, /* Rf Loop Back Test NTF event*/
- UWA_DM_TEST_RX_RSP_EVT, /* Rf RX Test resp event*/
- UWA_DM_TEST_RX_NTF_EVT /* Rf RX Test ntf event*/
-};
-
-/* UCI Parameter IDs */
-typedef uint8_t tUWA_PMID;
-
-/* Data for UWA_DM_DEVICE_STATUS_NTF_EVT */
-typedef struct {
- uint8_t status; /* device status */
-} tUWA_DEVICE_STATUS_NTF;
-
-/* Data for UWA_DM_CORE_GEN_ERR_STATUS_EVT */
-typedef struct {
- uint8_t status; /* generic error */
-} tUWA_CORE_GEN_ERR_STATUS_NTF;
-
-/* the data type associated with UWB_GET_DEVICE_INFO_REVT */
-typedef struct {
- uint8_t status;
- uint16_t uci_version;
- uint16_t mac_version;
- uint16_t phy_version;
- uint16_t uciTest_version;
- uint8_t vendor_info_len;
- uint8_t vendor_info[UCI_MAX_FRAGMENT_BUFF_SIZE];
-} tUWA_GET_DEVICE_INFO_REVT;
-
-/* Data for UWA_DM_CORE_SET_CONFIG_RSP_EVT */
-typedef struct {
- tUWA_STATUS status; /* UWA_STATUS_OK if successful */
- uint8_t num_param_id; /* Number of rejected Param ID */
- tUWA_PMID param_ids[UWB_MAX_NUM_IDS]; /* Rejected Param ID */
- uint16_t tlv_size; /* The length of TLV */
-} tUWA_SET_CORE_CONFIG;
-
-/* Data for UWA_DM_CORE_GET_CONFIG_RSP_EVT */
-typedef struct {
- tUWA_STATUS status; /* UWA_STATUS_OK if successful */
- uint8_t no_of_ids;
- uint8_t param_tlvs[UCI_MAX_PAYLOAD_SIZE]; /* TLV (Parameter ID-Len-Value byte
- stream) */
- uint16_t tlv_size; /* The length of TLV */
-} tUWA_GET_CORE_CONFIG;
-
-/* Data for UWA_DM_DEVICE_RESET_RSP_EVT */
-typedef struct {
- tUWA_STATUS status; /* UWA_STATUS_OK if successful */
-} tUWA_DEVICE_RESET;
-
-/* Data for UWA_DM_SESSION_GET_COUNT_RSP_EVT */
-typedef struct {
- tUWA_STATUS status; /* device status */
- uint8_t count; /* active session count */
-} tUWA_SESSION_GET_COUNT;
-
-/* Data for UWA_DM_SESSION_GET_STATE_RSP_EVT */
-typedef struct {
- tUWA_STATUS status; /* device status */
- uint8_t session_state; /* current session state */
-} tUWA_SESSION_GET_STATE;
-
-/* Data for UWA_DM_SESSION_GET_CONFIG_RSP_EVT */
-typedef struct {
- tUWA_STATUS status; /* UWA_STATUS_OK if successful */
- uint8_t tlv_size; /* The length of TLV */
- uint8_t param_tlvs[UCI_MAX_PAYLOAD_SIZE]; /* TLV (Parameter ID-Len-Value byte
- stream) */
-} tUWA_GET_SESSION_APP_CONFIG;
-
-/* Data for UWA_DM_SESSION_SET_CONFIG_RSP_EVT */
-typedef struct {
- tUWA_STATUS status; /* UWA_STATUS_OK if successful */
- uint8_t num_param_id; /* Number of rejected Param ID */
- tUWA_PMID param_ids[UWB_MAX_NUM_IDS]; /* Rejected Param ID */
-} tUWA_SET_SESSION_APP_CONFIG;
-
-/* the data type associated with UWB_SESSION_STATUS_NTF_REVT */
-typedef struct {
- uint32_t session_id;
- uint8_t state;
- uint8_t reason_code;
-} tUWA_SESSION_STATUS_NTF_REVT;
-
-/* Data for UWA_DM_RANGE_DATA_NTF_EVT */
-/* the data type associated with UWB_RANGE_DATA_REVT */
-typedef struct {
- uint8_t mac_addr[8];
- uint8_t status;
- uint8_t nLos; /* non line of sight */
- uint16_t distance;
- uint16_t aoa_azimuth;
- uint8_t aoa_azimuth_FOM;
- uint16_t aoa_elevation;
- uint8_t aoa_elevation_FOM;
- uint16_t aoa_dest_azimuth;
- uint8_t aoa_dest_azimuth_FOM;
- uint16_t aoa_dest_elevation;
- uint8_t aoa_dest_elevation_FOM;
- uint8_t slot_index;
- uint8_t rssi;
- uint8_t rfu[11];
-} tUWA_TWR_RANGING_MEASR;
-
-typedef struct {
- uint8_t mac_addr[8];
- uint8_t message_control;
- uint8_t frame_type;
- uint8_t nLos; /* non line of sight */
- uint16_t aoa_azimuth;
- uint8_t aoa_azimuth_FOM;
- uint16_t aoa_elevation;
- uint8_t aoa_elevation_FOM;
- uint32_t frame_number;
- uint8_t rxTimeStamp[8];
- uint8_t ulTdoa_device_id[8];
- uint8_t txTimeStamp[8];
-} tUWA_TDoA_RANGING_MEASR;
-
-/* the data type associated with vendor notification */
-typedef struct {
- uint16_t len;
- uint8_t data[UCI_VENDOR_INFO_MAX_SIZE];
-}tUWA_VENDOR_SPECIFIC_NTF;
-
-typedef struct {
- uint8_t mac_addr[8];
- uint8_t status;
- uint8_t nLos;
- uint8_t frame_seq_num;
- uint16_t block_index;
- uint16_t aoa_azimuth;
- uint8_t aoa_azimuth_FOM;
- uint16_t aoa_elevation;
- uint8_t aoa_elevation_FOM;
-} tUWA_OWR_WITH_AOA_RANGING_MEASR;
-
-typedef struct {
- uint8_t mac_addr[8];
- uint8_t status;
- uint8_t message_type;
- uint16_t message_control;
- uint16_t block_index;
- uint8_t round_index;
- uint8_t nLos;
- uint16_t aoa_azimuth;
- uint8_t aoa_azimuth_FOM;
- uint16_t aoa_elevation;
- uint8_t aoa_elevation_FOM;
- uint8_t txTimeStamp[8];
- uint8_t rxTimeStamp[8];
- uint16_t cfo_anchor;
- uint16_t cfo;
- uint32_t initiator_reply_time;
- uint32_t responder_reply_time;
- uint16_t initiator_responder_TOF;
- uint8_t anchor_location[12];
- uint8_t active_ranging_round[15];
-} tUWA_DLTDOA_RANGING_MEASR;
-
-typedef union {
- tUWA_TWR_RANGING_MEASR twr_range_measr[MAX_NUM_RESPONDERS];
- tUWA_TDoA_RANGING_MEASR tdoa_range_measr[MAX_NUM_OF_TDOA_MEASURES];
- tUWA_DLTDOA_RANGING_MEASR dltdoa_range_measr[MAX_NUM_OF_DLTDOA_MEASURES];
- tUWA_OWR_WITH_AOA_RANGING_MEASR owr_with_aoa_range_measr;
-} tUWA_RANGING_MEASR;
-
-typedef struct {
- uint16_t ranging_data_len;
- uint32_t seq_counter;
- uint32_t session_id;
- uint8_t rcr_indication;
- uint32_t curr_range_interval;
- uint8_t ranging_measure_type;
- uint8_t rfu;
- uint8_t mac_addr_mode_indicator;
- uint8_t reserved[8];
- uint8_t no_of_measurements;
- tUWA_RANGING_MEASR ranging_measures;
- tUWA_VENDOR_SPECIFIC_NTF vendor_specific_ntf;
-} tUWA_RANGE_DATA_NTF;
-
-/* the data type associated with UWB_GET_RANGE_COUNT_REVT */
-typedef struct {
- uint8_t status;
- uint32_t count;
-} tUWA_RANGE_GET_RNG_COUNT_REVT;
-
-/* Data for UWA_DM_GET_CORE_DEVICE_CAP_RSP_EVT */
-typedef struct {
- tUWA_STATUS status; /* UWA_STATUS_OK if successful */
- uint8_t no_of_tlvs;
- uint8_t tlv_buffer[UCI_MAX_PAYLOAD_SIZE]; /* TLV (Parameter ID-Len-Value byte
- stream) */
- uint16_t tlv_buffer_len; /* The length of TLV */
-} tUWA_GET_CORE_DEVICE_CAPABILITY;
-
-/* the data type associated with UWB_SESSION_UPDATE_MULTICAST_LIST_NTF */
-typedef struct {
- uint32_t session_id;
- uint8_t remaining_list;
- uint8_t no_of_controlees;
- uint16_t controlee_mac_address_list[MAX_NUM_CONTROLLEES];
- uint32_t subsession_id_list[MAX_NUM_CONTROLLEES];
- uint8_t status_list[MAX_NUM_CONTROLLEES];
-} tUWA_SESSION_UPDATE_MULTICAST_LIST_NTF;
-
-/* the data type associated with UWB_BLINK_DATA_TX_NTF */
-typedef struct {
- uint8_t repetition_count_status; /* Status to indicate Repetition Count is
- exhausted */
-} tUWA_SEND_BLINK_DATA_NTF;
-
-/* the data type associated with UWB_DATA_TRANSFER_STATUS_NTF_REVT */
-typedef struct {
- uint32_t session_id;
- uint8_t sequence_num;
- uint8_t status;
-} tUWA_DATA_TRANSFER_STATUS_NTF_REVT;
-
-/* the data type associated with UWA_DM_DATA_RECV_REVT */
-typedef struct {
- uint32_t session_id;
- uint8_t status;
- uint32_t sequence_num;
- uint8_t address[EXTENDED_ADDRESS_LEN];
- uint8_t source_end_point;
- uint8_t dest_end_point;
- uint16_t data_len;
- uint8_t data[UCI_MAX_DATA_SIZE];
-} tUWA_RX_DATA_REVT;
-
-/* the data type associated with UWB_CONFORMANCE_TEST_DATA */
-typedef struct {
- uint16_t length;
- uint8_t data[CONFORMANCE_TEST_MAX_UCI_PKT_LENGTH];
-} tUWA_CONFORMANCE_TEST_DATA;
-
-/* the data type associated with UWB_SESSION_ACTIVE_ROUNDS_INDEX_UPDATE_REVT */
-typedef struct {
- uint8_t status;
- uint16_t len;
- uint8_t rng_round_index[255];
-}tUWA_UPDATE_RANGE_ROUND_INDEX_REVT;
-
-/* the data type associated with UWB_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT */
-typedef struct {
- uint8_t status;
- uint16_t len;
- uint8_t rng_round_indexs[255];
-}tUWA_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_REVT;
-
-/* Union of all DM callback structures */
-typedef union {
- tUWA_STATUS status; /* UWA_DM_ENABLE_EVT */
- tUWA_DEVICE_STATUS_NTF dev_status; /*UWA_DM_DEVICE_STATUS_NTF_EVT */
- tUWA_CORE_GEN_ERR_STATUS_NTF
- sCore_gen_err_status; /*UWA_DM_CORE_GEN_ERR_STATUS_EVT */
- tUWA_DEVICE_RESET sDevice_reset; /* UWA_DM_DEVICE_RESET_RSP_EVT */
- tUWA_GET_DEVICE_INFO_REVT
- sGet_device_info; /* UWA_DM_CORE_GET_DEVICE_INFO_RSP_EVT */
- tUWA_SET_CORE_CONFIG sCore_set_config; /* UWA_DM_CORE_SET_CONFIG_RSP_EVT */
- tUWA_GET_CORE_CONFIG sCore_get_config; /* UWA_DM_CORE_GET_CONFIG_RSP_EVT */
- tUWA_GET_CORE_CONFIG
- sApp_get_config; /* UWA_DM_SESSION_GET_CONFIG_RSP_EVT */
- tUWA_SET_CORE_CONFIG
- sApp_set_config; /* UWA_DM_SESSION_SET_CONFIG_RSP_EVT */
- tUWA_SESSION_STATUS_NTF_REVT
- sSessionStatus; /* UWA_DM_SESSION_STATUS_NTF_EVT */
- tUWA_SESSION_GET_COUNT
- sGet_session_cnt; /* UWA_DM_SESSION_GET_COUNT_RSP_EVT */
- tUWA_SESSION_GET_STATE
- sGet_session_state; /* UWA_DM_SESSION_GET_STATE_RSP_EVT */
- tUWA_RANGE_DATA_NTF sRange_data; /*UWA_DM_RANGE_DATA_NTF_EVT */
- tUWA_RANGE_GET_RNG_COUNT_REVT
- sGet_range_cnt; /*UWA_DM_GET_RANGE_COUNT_RSP_EVT */
- tUWA_GET_CORE_DEVICE_CAPABILITY
- sGet_device_capability; /*UWA_DM_GET_CORE_DEVICE_CAP_RSP_EVT*/
- tUWA_SESSION_UPDATE_MULTICAST_LIST_NTF
- sMulticast_list_ntf; /*UWA_DM_SESSION_MC_LIST_UPDATE_NTF_EVT*/
- tUWA_SEND_BLINK_DATA_NTF sBlink_data_ntf; /*UWA_DM_SEND_BLINK_DATA_NTF_EVT*/
- tUWA_DATA_TRANSFER_STATUS_NTF_REVT sData_xfer_status ; /*UWA_DATA_TRANSFER_STATUS_NTF_REVT*/
- tUWA_RX_DATA_REVT sRcvd_data; /*UWA_DM_DATA_RECV_REVT */
- tUWA_UPDATE_RANGE_ROUND_INDEX_REVT sRange_round_index; /*UWA_DM_UPDATE_RANGE_ROUND_INDEX_REVT */
- tUWA_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_REVT sConfigure_dt_anchor_rr_rdm_list; /*UWA_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT */
- tUWA_CONFORMANCE_TEST_DATA sConformance_ntf; /* UWA_DM_CONFORMANCE_NTF_EVT */
- tUWA_VENDOR_SPECIFIC_NTF vendor_specific_ntf; /*Vendor Specific ntf data */
- void* p_vs_evt_data; /* Vendor-specific evt data */
-} tUWA_DM_CBACK_DATA;
-
-/* Data for UWA_DM_RF_TEST_DATA_EVT */
-typedef struct {
- uint16_t length;
- uint8_t data[UCI_MAX_PAYLOAD_SIZE];
-} tUWA_RF_TEST_DATA;
-
-/* Union of all DM callback structures */
-typedef union {
- tUWA_STATUS status; /* Response status for RF Test commands */
- tUWA_GET_CORE_CONFIG sTest_get_config; /* UWA_DM_TEST_GET_CONFIG_RSP_EVT */
- tUWA_SET_CORE_CONFIG sTest_set_config; /* UWA_DM_TEST_SET_CONFIG_RSP_EVT */
- tUWA_RF_TEST_DATA rf_test_data; /*UWA_DM_RF_TEST_DATA_EVT*/
-} tUWA_DM_TEST_CBACK_DATA;
-
-/* UWA_DM callback */
-typedef void(tUWA_DM_CBACK)(uint8_t event, tUWA_DM_CBACK_DATA* p_data);
-typedef void(tUWA_DM_TEST_CBACK)(uint8_t event,
- tUWA_DM_TEST_CBACK_DATA* p_data);
-
-/* UWA_RAW_CMD callback */
-typedef void(tUWA_RAW_CMD_CBACK)(uint8_t event, uint16_t param_len,
- uint8_t* p_param);
-
-/*****************************************************************************
-** External Function Declarations
-*****************************************************************************/
-
-/*******************************************************************************
-**
-** Function UWA_Init
-**
-** Description This function initializes control blocks for UWA
-**
-** p_hal_entry_tbl points to a table of HAL entry points
-**
-** NOTE: the buffer that p_hal_entry_tbl points must be
-** persistent until UWA is disabled.
-**
-**
-** Returns none
-**
-*******************************************************************************/
-extern void UWA_Init(tHAL_UWB_ENTRY* p_hal_entry_tbl);
-
-/*******************************************************************************
-**
-** Function UWA_Enable
-**
-** Description This function enables UWB. Prior to calling UWA_Enable,
-** the UWBC must be powered up, and ready to receive commands.
-** This function enables the tasks needed by UWB, opens the UCI
-** transport, resets the UWB Subsystem, downloads patches to
-** the UWBC (if necessary), and initializes the UWB subsystems.
-**l
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_Enable(tUWA_DM_CBACK* p_dm_cback,
- tUWA_DM_TEST_CBACK* p_dm_test_cback);
-
-/*******************************************************************************
-**
-** Function UWA_Disable
-**
-** Description This function is called to shutdown UWB. The tasks for UWB
-** are terminated, and clean up routines are performed. This
-** function is typically called during platform shut-down, or
-** when UWB is disabled from a settings UI. When the UWB
-** shutdown procedure is completed, an UWA_DM_DISABLE_EVT is
-** returned to the application using the tUWA_DM_CBACK.
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_Disable(bool graceful);
-
-/*******************************************************************************
-**
-** Function: UWA_GetDeviceInfo
-**
-** Description: This function gets the UWB Subsystem Information
-**
-** Returns: UCI version and manufacturer specific information
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_GetDeviceInfo();
-
-/*******************************************************************************
-**
-** Function UWA_SetCoreConfig
-**
-** Description Set the configuration parameters to UWBS. The result is
-** reported with an UWA_DM_CORE_SET_CONFIG_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SetCoreConfig(tUWA_PMID param_id, uint8_t length,
- uint8_t* p_data);
-
-/*******************************************************************************
-**
-** Function UWA_GetCoreConfig
-**
-** Description Get the configuration parameters from UWBS. The result is
-** reported with an UWA_DM_CORE_GET_CONFIG_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_GetCoreConfig(uint8_t num_ids, tUWA_PMID* p_param_ids);
-
-/*******************************************************************************
-**
-** Function UWA_SendDeviceReset
-**
-** Description Send Device Reset Command to UWBS. The result is
-** reported with an UWA_DM_DEVICE_RESET_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SendDeviceReset(uint8_t resetConfig);
-
-/*******************************************************************************
-**
-** Function UWA_SendSessionInit
-**
-** Description This function is called to send session init command.
-** The result is reported with an UWA_DM_SESSION_INIT_RSP_EVT
-** in the tUWA_DM_CBACK callback
-**
-** session id - value of particular session ID
-** session type - type of session to start ex: ranging,app etc
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SendSessionInit(uint32_t session_id,
- uint8_t sessionType);
-
-/*******************************************************************************
-**
-** Function UWA_SendSessionDeInit
-**
-** Description This function is called to send session deinit command.
-** The result is reported with an UWA_DM_SESSION_DEINIT_RSP_EVT
-** in the tUWA_DM_CBACK callback
-**
-** session id - value of particular session ID
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SendSessionDeInit(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWA_GetSessionCount
-**
-** Description This function is called to send get session count command.
-** The result is reported with an
-** UWA_DM_SESSION_GET_COUNT_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is successfully sent
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_GetSessionCount();
-
-/*******************************************************************************
-**
-** Function UWA_SetAppConfig
-**
-** Description Set the configuration parameters to UWBS. The result is
-** reported with an UWA_DM_SESSION_SET_CONFIG_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SetAppConfig(uint32_t session_id, uint8_t noOfParams,
- uint8_t appConfigParamLen,
- uint8_t AppConfigParmas[]);
-
-/*******************************************************************************
-**
-** Function UWA_GetAppConfig
-**
-** Description Get the configuration parameters from UWBS. The result is
-** reported with an UWA_DM_SESSION_GET_CONFIG_RSP_EVT in the
-** tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_GetAppConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t paramLen, tUWA_PMID* p_param_ids);
-
-/*******************************************************************************
-**
-** Function UWA_StartRangingSession
-**
-** Description start the ranging session.
-** The result is reported with an UWA_DM_RANGE_START_RSP_EVT in
-** the tUWA_DM_CBACK callback
-**
-** Returns UWA_STATUS_OK if ranging started successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_StartRangingSession(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWA_StopRangingSession
-**
-** Description stop the ranging session.
-** The result is reported with an UWA_DM_RANGE_STOP_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if ranging is stopped successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_StopRangingSession(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWA_GetRangingCount
-**
-** Description Get ranging count.
-** The result is reported with an
-** UWA_DM_GET_RANGE_COUNT_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_GetRangingCount(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWA_GetSessionStatus
-**
-** Description Get session status.
-** The result is reported with an
-** UWA_DM_SESSION_GET_STATE_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_GetSessionStatus(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWA_GetCoreGetDeviceCapability
-**
-** Description Get core device capability info command.
-** The result is reported with an
-** UWA_DM_GET_CORE_DEVICE_CAP_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_GetCoreGetDeviceCapability(void);
-
-/*******************************************************************************
-**
-** Function UWA_ControllerMulticastListUpdate
-**
-** Description This function is called to send Controller Multicast List
-** Update.
-** The result is reported with an
-** UWA_DM_SESSION_MC_LIST_UPDATE_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_ControllerMulticastListUpdate(
- uint32_t session_id, uint8_t action, uint8_t noOfControlees,
- uint16_t* shortAddressList, uint32_t* subSessionIdList);
-
-/*******************************************************************************
-**
-** Function UWA_ControllerSetCountryCode
-**
-** Description This function is called to set country code.
-** The result is reported with an
-** UWA_DM_SET_COUNTRY_CODE_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_ControllerSetCountryCode(uint8_t* countryCodeArray);
-
-/*******************************************************************************
-**
-** Function UWA_SendBlinkData
-**
-** Description This function is called to send Blink Data Tx.
-** The result is reported with an
-** UWA_DM_SEND_BLINK_DATA_RSP_EVT
-** in the tUWA_DM_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SendBlinkData(uint32_t session_id,
- uint8_t repetition_count,
- uint8_t app_data_len, uint8_t* app_data);
-
-/* UWA APIs for RF Test functionality */
-
-/*******************************************************************************
-**
-** Function UWA_TestSetConfig
-**
-** Description Set the configuration parameters to UWBS.
-** The result is reported with an
-** UWA_DM_TEST_SET_CONFIG_RSP_EVT
-** in the tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_TestSetConfig(uint32_t session_id, uint8_t noOfParams,
- uint8_t testConfigParamLen,
- uint8_t testConfigParmas[]);
-
-/*******************************************************************************
-**
-** Function UWA_TestGetConfig
-**
-** Description Get the configuration parameters from UWBS.
-** The result is reported with an
-** UWA_DM_TEST_GET_CONFIG_RSP_EVT
-** in the tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_TestGetConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t paramLen, tUWA_PMID* p_param_ids);
-
-/*******************************************************************************
-**
-** Function UWA_PeriodicTxTest
-**
-** Description This function is called to trigger the periodic Tx Test.
-** The result is reported with an
-** UWA_DM_TEST_PERIODIC_TX_RSP_EVT
-** in the tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_PeriodicTxTest(uint16_t psduLen, uint8_t psduData[]);
-
-/*******************************************************************************
-**
-** Function UWA_PerRxTest
-**
-** Description This function is called to trigger the PER Rx Tx Test.
-** The result is reported with an UWA_DM_TEST_PER_RX_RSP_EVT
-** in the tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_PerRxTest(uint16_t psduLen, uint8_t psduData[]);
-
-/*******************************************************************************
-**
-** Function UWA_UwbLoopBackTest
-**
-** Description This function is called to trigger the loop back Test.
-** The result is reported with an UWA_DM_TEST_LOOPBACK_RSP_EVT
-*in the
-** tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if command is sent successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_UwbLoopBackTest(uint16_t psduLen, uint8_t psduData[]);
-
-/*******************************************************************************
-**
-** Function UWA_RxTest
-**
-** Description This function is called to trigger the loop back Test.
-** The result is reported with an UWA_DM_TEST_RX_EVT in the
-** tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if Per Session stopped successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_RxTest();
-
-/*******************************************************************************
-**
-** Function UWA_TestStopSession
-**
-** Description This function is called to stop the ongoing test session
-** The result is reported with an
-** UWA_DM_TEST_STOP_SESSION_RSP_EVT in the
-** tUWA_DM_TEST_CBACK callback.
-**
-** Returns UWA_STATUS_OK if Per Session stopped successfully
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_TestStopSession(void);
-
-/*******************************************************************************
-**
-** Function UWA_SendRawCommand
-**
-** Description This function is called to send raw vendor specific
-** command to Helios.
-**
-** cmd_params_len - The command parameter len
-** p_cmd_params - The command parameter
-** p_cback - The callback function to receive the
-** command
-**
-** Returns UWA_STATUS_OK if successfully initiated
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SendRawCommand(uint16_t cmd_params_len,
- uint8_t* p_cmd_params,
- tUWA_RAW_CMD_CBACK* p_cback);
-
-/*******************************************************************************
-**
-** Function UWA_SendUwbDataFrame
-**
-** Description This function is called to send UWB data over UWB RF interafce .
-**
-** data_len - The data length
-** p_data - pointer to data buffer
-**
-** Returns UWA_STATUS_OK if data sucessfully accepeted by UWB subsystem
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_SendUwbData(uint32_t session_id,
- uint8_t* p_addr, uint8_t dest_end_point, uint8_t sequence_num,
- uint16_t data_len,
- uint8_t* p_data);
-
-/*******************************************************************************
-**
-** Function UWA_ConfigureDTAnchorForRrRdmList
-**
-** Description This function is called to Configure DT anchor RR RDM List.
-**
-** Returns tUWA_STATUS
-**
-*******************************************************************************/
-extern tUWA_STATUS UWA_ConfigureDTAnchorForRrRdmList(uint32_t session_id, uint8_t rr_rdm_count,
- uint8_t rrRdmConfigParamLen, uint8_t rrRdmConfigParam[]);
-
-/*******************************************************************************
-**
-** Function UWA_UpdateRangingRoundIndex
-**
-** Description This function is called to update Ranging round index for TDoA feature.
-**
-** Returns UWA_STATUS_OK if data sucessfully accepeted by UWB subsystem
-** UWA_STATUS_FAILED otherwise
-**
-*******************************************************************************/
-
-extern tUWA_STATUS UWA_UpdateRangingRoundIndex(uint8_t dlTdoaRole, uint32_t session_id,
- uint8_t number_of_active_rngIndex, uint8_t rng_round_index_len,
- uint8_t* p_rng_round_index);
-#endif /* UWA_API_H */
diff --git a/src/uwa/include/uwa_dm_int.h b/src/uwa/include/uwa_dm_int.h
deleted file mode 100755
index 160501e..0000000
--- a/src/uwa/include/uwa_dm_int.h
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021-2022 NXP.
- *
- * 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.
- */
-
-#ifndef UWA_DM_INT_H
-#define UWA_DM_INT_H
-
-#include <string.h>
-
-#include "uwa_api.h"
-#include "uwa_sys.h"
-#include "uwb_api.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-/* UWA_DM flags */
-/* DM is enabled */
-#define UWA_DM_FLAGS_DM_IS_ACTIVE 0x00000001
-#define UWA_DM_FLAGS_ENABLE_EVT_PEND 0x00000002
-
-/* DM events */
-enum {
- /* device manager local device API events */
- UWA_DM_API_ENABLE_EVT = UWA_SYS_EVT_START(UWA_ID_DM),
- UWA_DM_API_DISABLE_EVT,
- UWA_DM_API_GET_DEVICE_INFO_EVT,
- UWA_DM_API_SET_CORE_CONFIG_EVT,
- UWA_DM_API_GET_CORE_CONFIG_EVT,
- UWA_DM_API_DEVICE_RESET_EVT,
- UWA_DM_API_SESSION_INIT_EVT,
- UWA_DM_API_SESSION_DEINIT_EVT,
- UWA_DM_API_SESSION_GET_COUNT_EVT,
- UWA_DM_API_SET_APP_CONFIG_EVT,
- UWA_DM_API_GET_APP_CONFIG_EVT,
- UWA_DM_API_START_RANGE_EVT,
- UWA_DM_API_STOP_RANGE_EVT,
- UWA_DM_API_SEND_RAW_EVT,
- UWA_DM_API_GET_RANGE_COUNT_EVT,
- UWA_DM_API_GET_SESSION_STATUS_EVT,
- UWA_DM_API_CORE_GET_DEVICE_CAPABILITY_EVT,
- UWA_DM_API_SESSION_UPDATE_MULTICAST_LIST_EVT,
- UWA_DM_API_SET_COUNTRY_CODE_EVT,
- UWA_DM_API_SEND_BLINK_DATA_EVT,
- /* UWB RF Test API events */
- UWA_DM_API_TEST_SET_CONFIG_EVT,
- UWA_DM_API_TEST_GET_CONFIG_EVT,
- UWA_DM_API_TEST_PERIODIC_TX_EVT,
- UWA_DM_API_TEST_PER_RX_EVT,
- UWA_DM_API_TEST_UWB_LOOPBACK_EVT,
- UWA_DM_API_TEST_RX_EVT,
- UWA_DM_API_TEST_STOP_SESSION_EVT,
- /* UWB Data packet events */
- UWA_DM_API_SEND_DATA_FRAME_EVT,
- UWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_EVT,
- UWA_DM_API_UPDATE_ACTIVE_RNG_INDEX_EVT,
- UWA_DM_MAX_EVT
-};
-
-/* data type for UWA_DM_API_ENABLE_EVT */
-typedef struct {
- UWB_HDR hdr;
- tUWA_DM_CBACK* p_dm_cback;
- tUWA_DM_TEST_CBACK* p_dm_test_cback;
-} tUWA_DM_API_ENABLE;
-
-/* data type for UWA_DM_API_DISABLE_EVT */
-typedef struct {
- UWB_HDR hdr;
- bool graceful;
-} tUWA_DM_API_DISABLE;
-
-/* data type for UWA_DM_API_SET_CORE_CONFIG_EVT */
-typedef struct {
- UWB_HDR hdr;
- tUWA_PMID param_id;
- uint8_t length;
- uint8_t* p_data;
-} tUWA_DM_API_CORE_SET_CONFIG;
-
-/* data type for UWA_DM_API_SET_APP_CONFIG_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
- uint8_t num_ids;
- uint8_t length;
- uint8_t* p_data;
-} tUWA_DM_API_SET_APP_CONFIG;
-
-/* data type for UWA_DM_API_GET_CORE_CONFIG_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint8_t num_ids;
- tUWA_PMID* p_pmids;
-} tUWA_DM_API_CORE_GET_CONFIG;
-
-/* data type for UWA_DM_API_GET_APP_CONFIG_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
- uint8_t num_ids;
- uint8_t length;
- uint8_t* p_pmids;
-} tUWA_DM_API_GET_APP_CONFIG;
-
-/* data type for UWA_DM_API_DEVICE_RESET_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint8_t resetConfig; /* Vendor Specific Reset Config*/
-} tUWA_DM_API_DEVICE_RESET;
-
-/* data type for UWA_DM_API_SEND_RAW_EVT */
-typedef struct {
- UWB_HDR hdr;
- tUWA_RAW_CMD_CBACK* p_cback;
- uint8_t oid;
- uint16_t cmd_params_len;
- uint8_t* p_cmd_params;
-} tUWA_DM_API_SEND_RAW;
-
-/* data type for UWA_DM_API_START_RANGE_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id; /* Session ID for which ranging shall start */
-} tUWA_DM_API_RANGING_START;
-
-/* data type for UWA_DM_API_STOP_RANGE_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id; /* Session ID for which ranging shall stop */
-} tUWA_DM_API_RANGING_STOP;
-
-/* data type for UWA_DM_API_SESSION_GET_COUNT_EVT */
-typedef struct {
- UWB_HDR hdr;
-} tUWA_DM_API_GET_SESSION_COUNT;
-
-/* data type for UWA_DM_API_SESSION_GET_COUNT_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
-} tUWA_DM_API_GET_RANGING_COUNT;
-
-/* data type for UWA_DM_API_SESSION_GET_STATUS_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
-} tUWA_DM_API_GET_SESSION_STATUS;
-
-/* data type for UWA_DM_API_SESSION_INIT_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id; /* session_id for Particular Activity */
- uint8_t sessionType; /* session type for Particular Activity */
-} tUWA_DM_API_SESSION_INIT;
-
-/* data type for UWA_DM_API_SESSION_DEINIT_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id; /* session_id for Particular activity */
-} tUWA_DM_API_SESSION_DEINIT;
-
-/* data type for UWA_DM_API_GET_DEVICE_INFO_EVT */
-typedef struct {
- UWB_HDR hdr;
-} tUWA_DM_API_GET_DEVICE_INFO;
-
-/* data type for UWA_DM_API_CORE_GET_DEVICE_CAPABILITY_EVT */
-typedef struct {
- UWB_HDR hdr;
-} tUWA_DM_API_CORE_GET_DEVICE_CAPABILITY;
-
-/* data type for UWA_DM_API_SESSION_UPDATE_MULTICAST_LIST_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
- uint8_t action;
- uint8_t no_of_controlee;
- uint16_t short_address_list[MAX_NUM_CONTROLLEES];
- uint32_t subsession_id_list[MAX_NUM_CONTROLLEES];
-} tUWA_DM_API_SESSION_UPDATE_MULTICAST_LIST;
-
-/* data type for UWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
- uint8_t rr_rdm_count;
- uint8_t length;
- uint8_t* p_data;
-} tUWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST;
-
-/* data type for UWA_DM_API_SESSION_UPDATE_MULTICAST_LIST_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint8_t country_code[COUNTRY_CODE_ARRAY_LEN];
-} tUWA_DM_API_SET_COUNTRY_CODE;
-
-/* data type for UWA_DM_API_DM_API_SEND_BLINK_DATA_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
- uint8_t repetition_count;
- uint8_t app_data_len;
- uint8_t app_data[UCI_MAX_PAYLOAD_SIZE];
-} tUWA_DM_API_SEND_BLINK_DATA;
-
-/* data type for UWA_DM_API_SEND_DATA_FRAME_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
- uint8_t p_addr[EXTENDED_ADDRESS_LEN];
- uint8_t dest_end_point;
- uint8_t sequence_num;
- uint16_t data_len;
- uint8_t* p_data;
-} tUWA_DM_API_SEND_DATA_FRAME;
-
-/* data type for UWA_DM_API_UPDATE_ACTIVE_RNG_INDEX_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint8_t dlTdoaRole;
- uint32_t session_id;
- uint8_t number_of_rng_index;
- uint8_t length;
- uint8_t* p_rng_index;
-} tUWA_DM_API_UPDATE_ACTIVE_RNG_INDEX;
-
-/* data type for UWA_DM_API_TEST_SET_CONFIG_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
- uint8_t num_ids;
- uint8_t length;
- uint8_t* p_data;
-} tUWA_DM_API_TEST_SET_CONFIG;
-
-/* data type for UWA_DM_API_TEST_GET_CONFIG_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint32_t session_id;
- uint8_t num_ids;
- uint8_t length;
- uint8_t* p_pmids;
-} tUWA_DM_API_TEST_GET_CONFIG;
-
-/* data type for UWA_DM_API_TEST_PERIODIC_TX_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint16_t length;
- uint8_t* p_data;
-} tUWA_DM_API_TEST_PERIODIC_TX;
-
-/* data type for UWA_DM_API_TEST_PER_RX_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint16_t length;
- uint8_t* p_data;
-} tUWA_DM_API_TEST_PER_RX;
-
-/* data type for UWA_DM_API_TEST_UWB_LOOPBACK_EVT */
-typedef struct {
- UWB_HDR hdr;
- uint16_t length;
- uint8_t* p_data;
-} tUWA_DM_API_TEST_UWB_LOOPBACK;
-
-/* data type for UWA_DM_API_TEST_RX_EVT */
-typedef struct {
- UWB_HDR hdr;
-} tUWA_DM_API_TEST_RX;
-
-/* data type for UWA_DM_API_TEST_STOP_SESSION_EVT */
-typedef struct {
- UWB_HDR hdr;
-} tUWA_DM_API_TEST_STOP_SESSION;
-
-/* union of all data types */
-typedef union {
- /* GKI event buffer header */
- UWB_HDR hdr;
- tUWA_DM_API_ENABLE enable; /* UWA_DM_API_ENABLE_EVT */
- tUWA_DM_API_DISABLE disable; /* UWA_DM_API_DISABLE_EVT */
- tUWA_DM_API_GET_DEVICE_INFO
- sGet_device_info; /* UWA_DM_API_GET_DEVICE_INFO */
- tUWA_DM_API_DEVICE_RESET sDevice_reset; /* UWA_DM_API_DEVICE_RESET_EVT */
- tUWA_DM_API_CORE_SET_CONFIG setconfig; /* UWA_DM_API_SET_CORE_CONFIG_EVT */
- tUWA_DM_API_CORE_GET_CONFIG getconfig; /* UWA_DM_API_GET_CORE_CONFIG_EVT */
- tUWA_DM_API_SESSION_INIT sessionInit; /* UWA_DM_API_SESSION_INIT */
- tUWA_DM_API_SESSION_DEINIT sessionDeInit; /* UWA_DM_API_SESSION_DEINIT */
- tUWA_DM_API_GET_SESSION_COUNT
- sGet_session_cnt; /* UWA_DM_API_SESSION_GET_COUNT_EVT*/
- tUWA_DM_API_GET_APP_CONFIG
- sApp_get_config; /* UWA_DM_API_GET_CORE_CONFIG_EVT */
- tUWA_DM_API_SET_APP_CONFIG
- sApp_set_config; /* UWA_DM_API_SET_CORE_CONFIG_EVT */
- tUWA_DM_API_RANGING_START rang_start; /* UWA_DM_API_START_RANGE_EVT */
- tUWA_DM_API_RANGING_STOP rang_stop; /* UWA_DM_API_STOP_RANGE_EVT */
- tUWA_DM_API_SEND_RAW send_raw; /* UWA_DM_API_SEND_RAW_EVT */
- tUWA_DM_API_GET_RANGING_COUNT
- sGet_rang_count; /* UWA_DM_API_GET_RANGE_COUNT_EVT */
- tUWA_DM_API_GET_SESSION_STATUS
- sGet_session_status; /* UWA_DM_API_GET_SESSION_STATUS_EVT */
- tUWA_DM_API_CORE_GET_DEVICE_CAPABILITY
- get_device_capability; /* UWA_DM_API_CORE_GET_DEVICE_CAPABILITY_EVT */
- tUWA_DM_API_TEST_UWB_LOOPBACK
- sUwb_loopback; /* UWA_DM_API_TEST_UWB_LOOPBACK_EVT */
- tUWA_DM_API_SESSION_UPDATE_MULTICAST_LIST
- sMulticast_list; /* UWA_DM_API_SESSION_UPDATE_MULTICAST_LIST_EVT */
- tUWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST
- sConfigure_dt_anchor_rr_rdm_list; /* UWA_DM_API_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_EVT */
- tUWA_DM_API_UPDATE_ACTIVE_RNG_INDEX
- update_rng_index; /* UWA_DM_API_UPDATE_ACTIVE_RNG_INDEX_EVT */
- tUWA_DM_API_SET_COUNTRY_CODE
- sCountryCode; /* UWA_DM_API_SET_COUNTRY_CODE_EVT */
- tUWA_DM_API_SEND_BLINK_DATA
- sSend_blink_data; /* UWA_DM_API_SEND_BLINK_DATA_EVT */
- /* data types for all UWB RF TEST events */
- tUWA_DM_API_SEND_DATA_FRAME send_data_frame; /* UWA_DM_API_SEND_DATA_FRAME_EVT */
- tUWA_DM_API_TEST_GET_CONFIG
- sTest_get_config; /* UWA_DM_API_TEST_GET_CONFIG_EVT */
- tUWA_DM_API_TEST_SET_CONFIG
- sTest_set_config; /* UWA_DM_API_TEST_SET_CONFIG_EVT */
- tUWA_DM_API_TEST_PERIODIC_TX
- sPeriodic_tx; /* UWA_DM_API_TEST_PERIODIC_TX_EVT */
- tUWA_DM_API_TEST_PER_RX sPer_rx; /* UWA_DM_API_TEST_PER_RX_EVT */
- tUWA_DM_API_TEST_RX sTest_rx; /*UWA_DM_API_TEST_RX_EVT*/
- tUWA_DM_API_TEST_STOP_SESSION
- sTest_stop_session; /* UWA_DM_API_TEST_STOP_SESSION_EVT */
-} tUWA_DM_MSG;
-
-typedef struct {
- uint32_t flags; /* UWA_DM flags (see definitions for UWA_DM_FLAGS_*) */
- tUWA_DM_CBACK* p_dm_cback; /* UWA DM callback */
- tUWA_DM_TEST_CBACK* p_dm_test_cback; /* UWA DM callback for RF test events */
- TIMER_LIST_ENT tle;
-} tUWA_DM_CB;
-
-tUWA_STATUS uwa_rw_send_raw_frame(UWB_HDR* p_data);
-void uwa_dm_disable_complete(void);
-
-/* UWA device manager control block */
-extern tUWA_DM_CB uwa_dm_cb;
-
-void uwa_dm_init(void);
-
-/* Action function prototypes */
-bool uwa_dm_enable(tUWA_DM_MSG* p_data);
-bool uwa_dm_disable(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_get_device_info(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_device_reset(tUWA_DM_MSG* p_data);
-bool uwa_dm_set_core_config(tUWA_DM_MSG* p_data);
-bool uwa_dm_get_core_config(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_send_session_init(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_send_session_deinit(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_get_session_count(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_app_set_config(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_app_get_config(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_start_range_session(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_stop_range_session(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_send_raw_cmd(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_get_range_count(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_get_session_status(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_get_device_capability(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_multicast_list_update(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_set_country_code(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_send_blink_data(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_send_data_frame(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_configure_dt_anchor_rr_rdm(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_update_active_range_round_index(tUWA_DM_MSG* p_data);
-
-/* Action function prototypes for all RF test functionality */
-bool uwa_dm_act_test_set_config(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_test_get_config(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_test_periodic_tx(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_test_per_rx(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_test_uwb_loopback(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_test_rx(tUWA_DM_MSG* p_data);
-bool uwa_dm_act_test_stop_session(tUWA_DM_MSG* p_data);
-
-/* Main function prototypes */
-bool uwa_dm_evt_hdlr(UWB_HDR* p_msg);
-void uwa_dm_sys_enable(void);
-void uwa_dm_sys_disable(void);
-
-std::string uwa_dm_uwb_revt_2_str(tUWB_RESPONSE_EVT event);
-std::string uwa_test_dm_uwb_revt_2_str(tUWB_RESPONSE_EVT event);
-
-#endif /* UWA_DM_INT_H */
diff --git a/src/uwa/include/uwa_sys.h b/src/uwa/include/uwa_sys.h
deleted file mode 100755
index 0df6634..0000000
--- a/src/uwa/include/uwa_sys.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-
-#ifndef UWA_SYS_H
-#define UWA_SYS_H
-
-#include "uwa_api.h"
-#include "uwb_gki.h"
-#include "uwb_target.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-/* SW sub-systems */
-enum {
- UWA_ID_SYS, /* system manager */
- UWA_ID_DM, /* device manager */
- UWA_ID_MAX
-};
-typedef uint8_t tUWA_SYS_ID;
-
-/* enable function type */
-typedef void(tUWA_SYS_ENABLE)(void);
-
-/* event handler function type */
-typedef bool(tUWA_SYS_EVT_HDLR)(UWB_HDR* p_msg);
-
-/* disable function type */
-typedef void(tUWA_SYS_DISABLE)(void);
-
-typedef void(tUWA_SYS_ENABLE_CBACK)(void);
-
-/* registration structure */
-typedef struct {
- tUWA_SYS_ENABLE* enable;
- tUWA_SYS_EVT_HDLR* evt_hdlr;
- tUWA_SYS_DISABLE* disable;
-} tUWA_SYS_REG;
-
-/* system manager configuration structure */
-typedef struct {
- uint16_t mbox_evt; /* GKI mailbox event */
- uint8_t mbox; /* GKI mailbox id */
- uint8_t timer; /* GKI timer id */
-} tUWA_SYS_CFG;
-
-/*****************************************************************************
-** Global data
-*****************************************************************************/
-
-/*****************************************************************************
-** Macros
-*****************************************************************************/
-
-/* Calculate start of event enumeration; id is top 8 bits of event */
-#define UWA_SYS_EVT_START(id) ((id) << 8)
-
-/*****************************************************************************
-** Function declarations
-*****************************************************************************/
-extern void uwa_sys_init(void);
-extern void uwa_sys_event(UWB_HDR* p_msg);
-extern void uwa_sys_timer_update(void);
-extern void uwa_sys_disable_timers(void);
-
-extern void uwa_sys_register(uint8_t id, const tUWA_SYS_REG* p_reg);
-extern void uwa_sys_deregister(uint8_t id);
-extern void uwa_sys_check_disabled(void);
-extern bool uwa_sys_is_register(uint8_t id);
-extern void uwa_sys_disable_subsystems(bool graceful);
-extern void uwa_sys_enable_subsystems(void);
-
-extern bool uwa_sys_is_graceful_disable(void);
-extern void uwa_sys_sendmsg(void* p_msg);
-extern void uwa_sys_start_timer(TIMER_LIST_ENT* p_tle, uint16_t type,
- uint32_t timeout);
-extern void uwa_sys_stop_timer(TIMER_LIST_ENT* p_tle);
-
-extern void uwa_sys_cback_reg_enable_complete(tUWA_SYS_ENABLE_CBACK* p_cback);
-extern void uwa_sys_cback_notify_enable_complete(uint8_t id);
-
-#endif /* UWA_SYS_H */
diff --git a/src/uwa/include/uwa_sys_int.h b/src/uwa/include/uwa_sys_int.h
deleted file mode 100755
index c26d09c..0000000
--- a/src/uwa/include/uwa_sys_int.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-#ifndef UWA_SYS_INT_H
-#define UWA_SYS_INT_H
-
-#include "uwa_sys_ptim.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-/* uwa_sys flags */
-#define UWA_SYS_FL_INITIALIZED 0x00000001 /* uwa_sys initialized */
-
-/*****************************************************************************
-** state table
-*****************************************************************************/
-
-/* system manager control block */
-typedef struct {
- uint32_t flags; /* uwa_sys flags (must be first element of structure) */
- tUWA_SYS_REG* reg[UWA_ID_MAX]; /* registration structures */
- bool is_reg[UWA_ID_MAX]; /* registration structures */
- tPTIM_CB ptim_cb; /* protocol timer list */
- tUWA_SYS_ENABLE_CBACK* p_enable_cback;
- uint16_t enable_cplt_flags;
- uint16_t enable_cplt_mask;
-
- bool graceful_disable; /* TRUE if UWA_Disable () is called with TRUE */
- bool timers_disabled; /* TRUE if sys timers disabled */
-} tUWA_SYS_CB;
-
-/*****************************************************************************
-** Global variables
-*****************************************************************************/
-
-/* system manager control block */
-extern tUWA_SYS_CB uwa_sys_cb;
-
-/* system manager configuration structure */
-extern tUWA_SYS_CFG* p_uwa_sys_cfg;
-
-#endif /* UWA_SYS_INT_H */
diff --git a/src/uwa/include/uwa_sys_ptim.h b/src/uwa/include/uwa_sys_ptim.h
deleted file mode 100755
index f96a36b..0000000
--- a/src/uwa/include/uwa_sys_ptim.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-/******************************************************************************
- *
- * Protocol timer services.
- *
- ******************************************************************************/
-#ifndef UWA_SYS_PTIM_H
-#define UWA_SYS_PTIM_H
-
-#include "uwb_gki.h"
-
-/*****************************************************************************
-** Constants and data types
-*****************************************************************************/
-
-typedef struct {
- TIMER_LIST_Q timer_queue; /* GKI timer queue */
- int32_t period; /* Timer period in milliseconds */
- uint32_t last_gki_ticks; /* GKI ticks since last time update called */
- uint8_t timer_id; /* GKI timer id */
-} tPTIM_CB;
-
-/*****************************************************************************
-** Function Declarations
-*****************************************************************************/
-
-/*******************************************************************************
-**
-** Function uwa_sys_ptim_init
-**
-** Description Initialize a protocol timer service control block.
-**
-** Returns void
-**
-*******************************************************************************/
-extern void uwa_sys_ptim_init(tPTIM_CB* p_cb, uint16_t period,
- uint8_t timer_id);
-
-/*******************************************************************************
-**
-** Function uwa_sys_ptim_timer_update
-**
-** Description Update the protocol timer list and handle expired timers.
-**
-** Returns void
-**
-*******************************************************************************/
-extern void uwa_sys_ptim_timer_update(tPTIM_CB* p_cb);
-
-/*******************************************************************************
-**
-** Function uwa_sys_ptim_start_timer
-**
-** Description Start a protocol timer for the specified amount
-** of time in milliseconds.
-**
-** Returns void
-**
-*******************************************************************************/
-extern void uwa_sys_ptim_start_timer(tPTIM_CB* p_cb, TIMER_LIST_ENT* p_tle,
- uint16_t type, uint32_t timeout);
-
-/*******************************************************************************
-**
-** Function uwa_sys_ptim_stop_timer
-**
-** Description Stop a protocol timer.
-**
-** Returns void
-**
-*******************************************************************************/
-extern void uwa_sys_ptim_stop_timer(tPTIM_CB* p_cb, TIMER_LIST_ENT* p_tle);
-
-#endif /* UWA_SYS_PTIM_H */
diff --git a/src/uwa/sys/uwa_sys_cback.cc b/src/uwa/sys/uwa_sys_cback.cc
deleted file mode 100755
index 8ff561b..0000000
--- a/src/uwa/sys/uwa_sys_cback.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-/******************************************************************************
- *
- * Registration/deregistration functions for inter-module callbacks
- *
- ******************************************************************************/
-
-#include "uci_log.h"
-#include "uwa_sys.h"
-#include "uwa_sys_int.h"
-#include "uwb_osal_common.h"
-
-/*******************************************************************************
-**
-** Function uwa_sys_cback_reg_enable_complete
-**
-** Description Called to register an initialization complete callback
-** function
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_cback_reg_enable_complete(tUWA_SYS_ENABLE_CBACK* p_cback) {
- uwa_sys_cb.p_enable_cback = p_cback;
- uwa_sys_cb.enable_cplt_flags = 0;
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_cback_notify_enable_complete
-**
-** Description Called by other UWA subsystems to notify initialization is
-** complete
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_cback_notify_enable_complete(uint8_t id) {
- uwa_sys_cb.enable_cplt_flags |= (uint16_t)(0x0001 << id);
-
- UCI_TRACE_I("enable_cplt_flags=0x%x, enable_cplt_mask=0x%x",
- uwa_sys_cb.enable_cplt_flags, uwa_sys_cb.enable_cplt_mask);
-
- if ((uwa_sys_cb.enable_cplt_flags == uwa_sys_cb.enable_cplt_mask) &&
- (uwa_sys_cb.p_enable_cback)) {
- uwa_sys_cb.p_enable_cback();
- uwa_sys_cb.p_enable_cback = NULL;
- }
-}
diff --git a/src/uwa/sys/uwa_sys_cfg.cc b/src/uwa/sys/uwa_sys_cfg.cc
deleted file mode 100755
index 64f9bf0..0000000
--- a/src/uwa/sys/uwa_sys_cfg.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-/******************************************************************************
- *
- * This file contains compile-time configurable constants for the UWA
- * system manager.
- *
- ******************************************************************************/
-
-#include "uwa_sys.h"
-#include "uwb_gki.h"
-
-const tUWA_SYS_CFG uwa_sys_cfg = {
- UWA_MBOX_EVT_MASK, /* GKI mailbox event */
- UWA_MBOX_ID, /* GKI mailbox id */
- UWA_TIMER_ID, /* GKI timer id */
-};
-
-tUWA_SYS_CFG* p_uwa_sys_cfg = (tUWA_SYS_CFG*)&uwa_sys_cfg;
diff --git a/src/uwa/sys/uwa_sys_main.cc b/src/uwa/sys/uwa_sys_main.cc
deleted file mode 100755
index 9241771..0000000
--- a/src/uwa/sys/uwa_sys_main.cc
+++ /dev/null
@@ -1,301 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-/******************************************************************************
- *
- * This is the main implementation file for the UWA system manager.
- *
- ******************************************************************************/
-#include <string.h>
-
-#include "uci_log.h"
-#include "uwa_api.h"
-#include "uwa_dm_int.h"
-#include "uwa_sys.h"
-#include "uwa_sys_int.h"
-#include "uwb_osal_common.h"
-
-/* protocol timer update period, in milliseconds */
-#ifndef UWA_SYS_TIMER_PERIOD
-#define UWA_SYS_TIMER_PERIOD 10
-#endif
-
-/* system manager control block definition */
-tUWA_SYS_CB uwa_sys_cb =
- {}; /* uwa_sys control block. statically initialize 'flags' field to 0 */
-
-/*******************************************************************************
-**
-** Function uwa_sys_init
-**
-** Description UWA initialization; called from task initialization.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_init(void) {
- memset(&uwa_sys_cb, 0, sizeof(tUWA_SYS_CB));
- uwa_sys_cb.flags |= UWA_SYS_FL_INITIALIZED;
- uwa_sys_ptim_init(&uwa_sys_cb.ptim_cb, UWA_SYS_TIMER_PERIOD,
- p_uwa_sys_cfg->timer);
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_event
-**
-** Description BTA event handler; called from task event handler.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_event(UWB_HDR* p_msg) {
- uint8_t id;
- bool freebuf = true;
-
- UCI_TRACE_I("UWA got event 0x%04X", p_msg->event);
-
- /* get subsystem id from event */
- id = (uint8_t)(p_msg->event >> 8);
-
- /* verify id and call subsystem event handler */
- if ((id < UWA_ID_MAX) && (uwa_sys_cb.is_reg[id])) {
- freebuf = (*uwa_sys_cb.reg[id]->evt_hdlr)(p_msg);
- } else {
- UCI_TRACE_W("UWA got unregistered event id %d", id);
- }
-
- if (freebuf) {
- phUwb_GKI_freebuf(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_timer_update
-**
-** Description Update the BTA timer list and handle expired timers.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_timer_update(void) {
- if (!uwa_sys_cb.timers_disabled) {
- uwa_sys_ptim_timer_update(&uwa_sys_cb.ptim_cb);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_register
-**
-** Description Called by other BTA subsystems to register their event
-** handler.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_register(uint8_t id, const tUWA_SYS_REG* p_reg) {
- uwa_sys_cb.reg[id] = (tUWA_SYS_REG*)p_reg;
- uwa_sys_cb.is_reg[id] = true;
-
- if ((id != UWA_ID_DM) && (id != UWA_ID_SYS))
- uwa_sys_cb.enable_cplt_mask |= (uint16_t)(0x0001 << id);
-
- UCI_TRACE_I("id=%i, enable_cplt_mask=0x%x", id, uwa_sys_cb.enable_cplt_mask);
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_check_disabled
-**
-** Description If all subsystems above DM have been disabled, then
-** disable DM. Called during UWA shutdown
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_check_disabled(void) {
- /* Disable DM */
- if (uwa_sys_cb.is_reg[UWA_ID_DM]) {
- (*uwa_sys_cb.reg[UWA_ID_DM]->disable)();
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_deregister
-**
-** Description Called by other BTA subsystems to de-register
-** handler.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_deregister(uint8_t id) {
- UCI_TRACE_I("uwa_sys: deregistering subsystem %i", id);
-
- uwa_sys_cb.is_reg[id] = false;
-
- /* If not deregistering DM, then check if any other subsystems above DM are
- * still */
- /* registered. */
- if (id != UWA_ID_DM) {
- /* If all subsystems above UWA_DM have been disabled, then okay to disable
- * DM */
- uwa_sys_check_disabled();
- } else {
- /* DM (the final sub-system) is deregistering. Clear pending timer events in
- * uwa_sys. */
- uwa_sys_ptim_init(&uwa_sys_cb.ptim_cb, UWA_SYS_TIMER_PERIOD,
- p_uwa_sys_cfg->timer);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_is_register
-**
-** Description Called by other BTA subsystems to get registeration
-** status.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-bool uwa_sys_is_register(uint8_t id) { return uwa_sys_cb.is_reg[id]; }
-
-/*******************************************************************************
-**
-** Function uwa_sys_is_graceful_disable
-**
-** Description Called by other BTA subsystems to get disable
-** parameter.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-bool uwa_sys_is_graceful_disable(void) { return uwa_sys_cb.graceful_disable; }
-
-/*******************************************************************************
-**
-** Function uwa_sys_enable_subsystems
-**
-** Description Call on UWA Start up
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_enable_subsystems(void) {
- uint8_t id;
-
- UCI_TRACE_I("uwa_sys: enabling subsystems");
-
- /* Enable all subsystems except SYS */
- for (id = UWA_ID_DM; id < UWA_ID_MAX; id++) {
- if (uwa_sys_cb.is_reg[id]) {
- if (uwa_sys_cb.reg[id]->enable != NULL) {
- /* Subsytem has a Disable fuuciton. Call it now */
- (*uwa_sys_cb.reg[id]->enable)();
- } else {
- /* Subsytem does not have a Enable function. Report Enable on behalf of
- * subsystem */
- uwa_sys_cback_notify_enable_complete(id);
- }
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_disable_subsystems
-**
-** Description Call on UWA shutdown. Disable all subsystems above UWA_DM
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_disable_subsystems(bool graceful) {
- UCI_TRACE_I("uwa_sys: disabling subsystems:%d", graceful);
- uwa_sys_cb.graceful_disable = graceful;
-
- /* Disable DM */
- if (uwa_sys_cb.is_reg[UWA_ID_DM]) {
- (*uwa_sys_cb.reg[UWA_ID_DM]->disable)();
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_sendmsg
-**
-** Description Send a GKI message to BTA. This function is designed to
-** optimize sending of messages to BTA. It is called by BTA
-** API functions and call-in functions.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_sendmsg(void* p_msg) {
- phUwb_GKI_send_msg(UWB_TASK, p_uwa_sys_cfg->mbox, p_msg);
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_start_timer
-**
-** Description Start a protocol timer for the specified amount
-** of time in milliseconds.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_start_timer(TIMER_LIST_ENT* p_tle, uint16_t type,
- uint32_t timeout) {
- uwa_sys_ptim_start_timer(&uwa_sys_cb.ptim_cb, p_tle, type, timeout);
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_stop_timer
-**
-** Description Stop a BTA timer.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_stop_timer(TIMER_LIST_ENT* p_tle) {
- uwa_sys_ptim_stop_timer(&uwa_sys_cb.ptim_cb, p_tle);
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_disable_timers
-**
-** Description Disable sys timer event handling
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_disable_timers(void) { uwa_sys_cb.timers_disabled = true; }
diff --git a/src/uwa/sys/uwa_sys_ptim.cc b/src/uwa/sys/uwa_sys_ptim.cc
deleted file mode 100755
index 628e39f..0000000
--- a/src/uwa/sys/uwa_sys_ptim.cc
+++ /dev/null
@@ -1,163 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 1999-2012 Broadcom Corporation
- * Copyright 2018-2019 NXP
- *
- * 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.
- *
- ******************************************************************************/
-/******************************************************************************
- *
- * Protocol timer services (taken from bta ptim)
- *
- ******************************************************************************/
-#include "uwa_sys_ptim.h"
-
-#include "uci_log.h"
-#include "uwa_sys.h"
-#include "uwa_sys_int.h"
-#include "uwb_gki.h"
-#include "uwb_osal_common.h"
-#include "uwb_target.h"
-
-/*******************************************************************************
-**
-** Function uwa_sys_ptim_init
-**
-** Description Initialize a protocol timer control block. Parameter
-** period is the GKI timer period in milliseconds. Parameter
-** timer_id is the GKI timer id.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_ptim_init(tPTIM_CB* p_cb, uint16_t period, uint8_t timer_id) {
- phUwb_GKI_init_timer_list(&p_cb->timer_queue);
- p_cb->period = period;
- p_cb->timer_id = timer_id;
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_ptim_timer_update
-**
-** Description Update the protocol timer list and handle expired timers.
-** This function is called from the task running the protocol
-** timers when the periodic GKI timer expires.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_ptim_timer_update(tPTIM_CB* p_cb) {
- TIMER_LIST_ENT* p_tle;
- UWB_HDR* p_msg;
- uint32_t new_ticks_count;
- uint32_t period_in_ticks;
-
- /* To handle the case when the function is called less frequently than the
- period
- we must convert determine the number of ticks since the last update, then
- convert back to milliseconds before updating timer list */
- new_ticks_count = phUwb_GKI_get_tick_count();
-
- /* Check for wrapped condition */
- if (new_ticks_count >= p_cb->last_gki_ticks) {
- period_in_ticks = (uint32_t)(new_ticks_count - p_cb->last_gki_ticks);
- } else {
- period_in_ticks = (uint32_t)(((uint32_t)0xffffffff - p_cb->last_gki_ticks) +
- new_ticks_count + 1);
- }
-
- /* update timer list */
- phUwb_GKI_update_timer_list(&p_cb->timer_queue,
- GKI_TICKS_TO_MS(period_in_ticks));
-
- p_cb->last_gki_ticks = new_ticks_count;
-
- /* while there are expired timers */
- while ((p_cb->timer_queue.p_first) &&
- (p_cb->timer_queue.p_first->ticks <= 0)) {
- /* removed expired timer from list */
- p_tle = p_cb->timer_queue.p_first;
- UCI_TRACE_I("uwa_sys_ptim_timer_update expired: %p", p_tle);
- phUwb_GKI_remove_from_timer_list(&p_cb->timer_queue, p_tle);
-
- /* call timer callback */
- if (p_tle->p_cback) {
- (*p_tle->p_cback)(p_tle);
- } else if (p_tle->event) {
- p_msg = (UWB_HDR*)phUwb_GKI_getbuf(sizeof(UWB_HDR));
- if (p_msg != NULL) {
- p_msg->event = p_tle->event;
- p_msg->layer_specific = 0;
- uwa_sys_sendmsg(p_msg);
- }
- }
- }
-
- /* if timer list is empty stop periodic GKI timer */
- if (p_cb->timer_queue.p_first == NULL) {
- UCI_TRACE_I("ptim timer stop");
- phUwb_GKI_stop_timer(p_cb->timer_id, 0);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_ptim_start_timer
-**
-** Description Start a protocol timer for the specified amount
-** of time in seconds.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_ptim_start_timer(tPTIM_CB* p_cb, TIMER_LIST_ENT* p_tle,
- uint16_t type, uint32_t timeout) {
- UCI_TRACE_I("uwa_sys_ptim_start_timer %p", p_tle);
-
- /* if timer list is currently empty, start periodic GKI timer */
- if (p_cb->timer_queue.p_first == NULL) {
- UCI_TRACE_I("ptim timer start");
- p_cb->last_gki_ticks = phUwb_GKI_get_tick_count();
- phUwb_GKI_start_timer(p_cb->timer_id, GKI_MS_TO_TICKS(p_cb->period), true);
- }
-
- phUwb_GKI_remove_from_timer_list(&p_cb->timer_queue, p_tle);
-
- p_tle->event = type;
- p_tle->ticks = timeout;
-
- phUwb_GKI_add_to_timer_list(&p_cb->timer_queue, p_tle);
-}
-
-/*******************************************************************************
-**
-** Function uwa_sys_ptim_stop_timer
-**
-** Description Stop a protocol timer.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwa_sys_ptim_stop_timer(tPTIM_CB* p_cb, TIMER_LIST_ENT* p_tle) {
- UCI_TRACE_I("uwa_sys_ptim_stop_timer %p", p_tle);
-
- phUwb_GKI_remove_from_timer_list(&p_cb->timer_queue, p_tle);
-
- /* if timer list is empty stop periodic GKI timer */
- if (p_cb->timer_queue.p_first == NULL) {
- UCI_TRACE_I("ptim timer stop");
- phUwb_GKI_stop_timer(p_cb->timer_id, 0);
- }
-}
diff --git a/src/uwb/include/uci_hmsgs.h b/src/uwb/include/uci_hmsgs.h
deleted file mode 100755
index 2ecbe04..0000000
--- a/src/uwb/include/uci_hmsgs.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021-2022 NXP.
- *
- * 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.
- */
-
-/******************************************************************************
- *
- * defines UCI interface messages (for DH)
- *
- ******************************************************************************/
-#ifndef UWB_UCI_HMSGS_H
-#define UWB_UCI_HMSGS_H
-
-#include <stdbool.h>
-
-#include "uci_defs.h"
-#include "uwb_types.h"
-
-uint8_t uci_snd_get_device_info_cmd(void);
-uint8_t uci_snd_device_reset_cmd(uint8_t resetConfig);
-uint8_t uci_snd_core_set_config_cmd(uint8_t* p_param_tlvs, uint8_t tlv_size);
-uint8_t uci_snd_core_get_config_cmd(uint8_t* param_ids, uint8_t num_ids);
-uint8_t uci_snd_core_get_device_capability(void);
-uint8_t uci_snd_session_init_cmd(uint32_t session_id, uint8_t session_type);
-uint8_t uci_snd_session_deinit_cmd(uint32_t session_id);
-uint8_t uci_snd_get_session_count_cmd(void);
-uint8_t uci_snd_get_range_count_cmd(uint32_t session_id);
-uint8_t uci_snd_get_session_status_cmd(uint32_t session_id);
-uint8_t uci_snd_multicast_list_update_cmd(uint32_t session_id, uint8_t action,
- uint8_t noOfControlees,
- uint16_t* shortAddressList,
- uint32_t* subSessionIdList);
-uint8_t uci_snd_set_country_code_cmd(uint8_t* country_code);
-uint8_t uci_snd_app_get_config_cmd(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* param_ids);
-uint8_t uci_snd_app_set_config_cmd(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* data);
-uint8_t uci_snd_range_start_cmd(uint32_t session_id);
-uint8_t uci_snd_range_stop_cmd(uint32_t session_id);
-uint8_t uci_snd_blink_data_cmd(uint32_t session_id, uint8_t repetition_count,
- uint8_t app_data_len, uint8_t* app_data);
-uint8_t uci_send_data_frame(uint32_t session_id,
- uint8_t* p_addr, uint8_t dest_end_point, uint8_t sequence_num,
- uint16_t data_len,
- uint8_t* p_data);
-uint8_t uci_send_range_round_index_update_cmd(uint8_t dlTdoaRole,
- uint32_t session_id, uint8_t number_of_active_rngIndex,
- uint8_t rng_round_index_len, uint8_t* p_rng_round_index);
-uint8_t uci_snd_configure_dt_anchor_for_rr_rdm_list_cmd(uint32_t session_id,
- uint8_t rr_rdm_count, uint8_t length, uint8_t* data);
-
-/* APIs for UWB RF test functionality */
-uint8_t uci_snd_test_get_config_cmd(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* param_ids);
-uint8_t uci_snd_test_set_config_cmd(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* data);
-uint8_t uci_snd_test_periodic_tx_cmd(uint16_t length, uint8_t* data);
-uint8_t uci_snd_test_per_rx_cmd(uint16_t length, uint8_t* data);
-uint8_t uci_snd_test_uwb_loopback_cmd(uint16_t length, uint8_t* data);
-uint8_t uci_snd_test_stop_session_cmd(void);
-uint8_t uci_snd_test_rx_cmd(void);
-
-extern void uci_proc_session_management_rsp(uint8_t op_code, uint8_t* p_buf,
- uint16_t len);
-extern void uci_proc_session_management_ntf(uint8_t op_code, uint8_t* p_buf,
- uint16_t len);
-extern void uci_proc_device_management_ntf(uint8_t op_code, uint8_t* p_buf,
- uint16_t len);
-extern void uci_proc_core_management_ntf(uint8_t op_code, uint8_t* p_buf,
- uint16_t len);
-extern void uci_proc_rang_management_rsp(uint8_t op_code, uint8_t* p_buf,
- uint16_t len);
-extern void uci_proc_rang_management_ntf(uint8_t op_code, uint8_t* p_buf,
- uint16_t len);
-extern void uci_proc_android_rsp(uint8_t op_code, uint8_t* p_buf, uint16_t len);
-extern void uci_proc_test_management_ntf(uint8_t op_code, uint8_t* p_buf,
- uint16_t len);
-extern void uci_proc_test_management_rsp(uint8_t op_code, uint8_t* p_buf,
- uint16_t len);
-extern void uci_proc_raw_cmd_rsp(uint8_t* p_buf, uint16_t len);
-
-extern void uci_proc_data_control_ntf(uint8_t op_code, uint8_t* p_buf, uint16_t len);
-
-extern void uci_proc_app_data_management_ntf(uint8_t op_code, uint8_t* p_buf, uint16_t len);
-
-extern void uci_proc_vendor_specific_ntf(uint8_t gid, uint8_t* p_buf, uint16_t len);
-#endif /* UWB_UCI_MSGS_H */
diff --git a/src/uwb/include/uwb_api.h b/src/uwb/include/uwb_api.h
deleted file mode 100755
index e75e924..0000000
--- a/src/uwb/include/uwb_api.h
+++ /dev/null
@@ -1,1120 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021 NXP.
- *
- * 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.
- */
-
-/******************************************************************************
- *
- * This file contains the Near Field Communication (UWB) API function
- * external definitions.
- *
- ******************************************************************************/
-
-#ifndef UWB_API_H
-#define UWB_API_H
-
-#include "uci_defs.h"
-#include "uwb_gki.h"
-#include "uwb_hal_api.h"
-#include "uwb_target.h"
-#include "uwb_types.h"
-
-typedef uint8_t tUWB_STATUS;
-
-/* UWB application return status codes */
-/* Command succeeded */
-#define UWB_STATUS_OK UCI_STATUS_OK
-/* Command is rejected. */
-#define UWB_STATUS_REJECTED UCI_STATUS_REJECTED
-/* failed */
-#define UWB_STATUS_FAILED UCI_STATUS_FAILED
-/* Syntax error */
-#define UWB_STATUS_SYNTAX_ERROR UCI_STATUS_SYNTAX_ERROR
-/* Invalid Parameter */
-#define UWB_STATUS_INVALID_PARAM UCI_STATUS_INVALID_PARAM
-/* Invalid Range */
-#define UWB_STATUS_INVALID_RANGE UCI_STATUS_INVALID_RANGE
-/* Unknown UCI Group ID */
-#define UWB_STATUS_UNKNOWN_GID UCI_STATUS_UNKNOWN_GID
-/* Unknown UCI Opcode */
-#define UWB_STATUS_UNKNOWN_OID UCI_STATUS_UNKNOWN_OID
-/* Read Only */
-#define UWB_STATUS_READ_ONLY UCI_STATUS_READ_ONLY
-/* retry the command */
-#define UWB_STATUS_COMMAND_RETRY UCI_STATUS_COMMAND_RETRY
-
-/* UWB session Specific status code */
-/* session is not exist in UWBD */
-#define UWB_STATUS_SESSSION_NOT_EXIST UCI_STATUS_SESSSION_NOT_EXIST
-/* Session is already exist/duplicate */
-#define UWB_STATUS_SESSSION_DUPLICATE UCI_STATUS_SESSSION_DUPLICATE
-/* Session is in active state */
-#define UWB_STATUS_SESSSION_ACTIVE UCI_STATUS_SESSSION_ACTIVE
-/* Maximum sessions are reached */
-#define UWB_STATUS_MAX_SESSSIONS_EXCEEDED UCI_STATUS_MAX_SESSSIONS_EXCEEDED
-/*session not configured */
-#define UWB_STATUS_SESSION_NOT_CONFIGURED UCI_STATUS_SESSION_NOT_CONFIGURED
-
-/* Ranging specific error code */
-/* Ranging tx failed */
-#define UWB_STATUS_RANGING_TX_FAILED UCI_STATUS_RANGING_TX_FAILED
-/* Ranging rx timeout */
-#define UWB_STATUS_RANGING_RX_TIMEOUT UCI_STATUS_RANGING_RX_TIMEOUT
-/* Physical layer decoding failed */
-#define UWB_STATUS_RANGING_RX_PHY_DEC_FAILED \
- UCI_STATUS_RANGING_RX_PHY_DEC_FAILED
-/* Physical layer TOA failed */
-#define UWB_STATUS_RANGING_RX_PHY_TOA_FAILED \
- UCI_STATUS_RANGING_RX_PHY_TOA_FAILED
-/* Physical layer STS failed */
-#define UWB_STATUS_RANGING_RX_PHY_STS_FAILED \
- UCI_STATUS_RANGING_RX_PHY_STS_FAILED
-/* MAC decoding failed */
-#define UWB_STATUS_RANGING_RX_MAC_DEC_FAILED \
- UCI_STATUS_RANGING_RX_MAC_DEC_FAILED
-/* MAC information decoding failed */
-#define UWB_STATUS_RANGING_RX_MAC_IE_DEC_FAILED \
- UCI_STATUS_RANGING_RX_MAC_IE_DEC_FAILED
-/* MAC information missing */
-#define UWB_STATUS_RANGING_RX_MAC_IE_MISSING \
- UCI_STATUS_RANGING_RX_MAC_IE_MISSING
-
-/* all UWB Manager Callback functions have prototype like void (cback) (uint8_t
- * event, void *p_data)
- * tUWB_RESPONSE_CBACK uses tNFC_RESPONSE_EVT; range 0x4000 ~
- * tUWB_TEST_RESPONSE_CBACK uses tNFC_RESPONSE_EVT; range 0x5000 ~
- */
-
-#define UWB_FIRST_REVT 0x4000
-#define UWB_FIRST_TEVT 0x5000
-
-// RFU size for tdoa Ranging
-
-#define TDOA_RANGE_MEASR_RFU 12
-#define TWR_RANGE_MEASR_RFU 11
-
-#define CONFORMANCE_TEST_MAX_UCI_PKT_LENGTH 260
-
-/* the events reported on tUWB_RESPONSE_CBACK */
-enum {
- UWB_ENABLE_REVT = UWB_FIRST_REVT, /* 0 Enable event */
- UWB_DISABLE_REVT, /* 1 Disable event */
- UWB_REGISTER_EXT_CB_REVT, /* 2 Register Ext Callback */
- UWB_DEVICE_STATUS_REVT, /* 3 device status notification */
- UWB_SET_CORE_CONFIG_REVT, /* 4 Set Config Response */
- UWB_GET_CORE_CONFIG_REVT, /* 5 Get Config Response */
- UWB_GET_DEVICE_INFO_REVT, /* 6 Get Device Info response */
- UWB_DEVICE_RESET_REVT, /* 7 device Reset response */
- UWB_CORE_GEN_ERR_STATUS_REVT, /* 8 Generic Error Notification */
- UWB_SESSION_INIT_REVT, /* 9 session Init request */
- UWB_SESSION_STATUS_NTF_REVT, /* 10 SESSION STATUS NTF response */
- UWB_SESSION_DEINIT_REVT, /* 11 session DeInit request */
- UWB_SESSION_GET_COUNT_REVT, /* 12 get session count response */
- UWB_GET_APP_CONFIG_REVT, /* 13 Get App Config response */
- UWB_SET_APP_CONFIG_REVT, /* 14 Get App Config response */
- UWB_START_RANGE_REVT, /* 15 range start response */
- UWB_STOP_RANGE_REVT, /* 16 range stop response */
- UWB_RANGE_DATA_REVT, /* 17 range data notofication */
- UWB_GET_RANGE_COUNT_REVT, /* 23 get Range Count response */
- UWB_SESSION_GET_STATE_REVT, /* 24 get session status response */
- UWB_UWBS_TRANSPORT_ERR_REVT, /* 25 UCI Transport error */
- UWB_UWBS_RESP_TIMEOUT_REVT, /* 26 UWB device is not responding */
- UWB_CORE_GET_DEVICE_CAPABILITY_REVT, /* 27 Get Device Capability */
- UWB_SESSION_UPDATE_MULTICAST_LIST_REVT, /* 28 Session Update Multicast List
- resp */
- UWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT, /* 29 Session Update Multicast
- List ntf */
- UWB_BLINK_DATA_TX_REVT, /* 30 Blink Data Tx resp */
- UWB_BLINK_DATA_TX_NTF_REVT, /* 31 Blink Data Tx ntf */
- UWB_CONFORMANCE_TEST_DATA, /* 32 Conformance test data ntf */
- UWB_SET_COUNTRY_CODE_REVT, /* 33 Set country code resp */
- UWB_VENDOR_SPECIFIC_UCI_NTF_EVT, /* 34 Proprietary ntf */
- UWB_SEND_DATA_STATUS_EVT, /* 35 UWB data reception status by UWBS */
- UWB_DATA_TRANSFER_STATUS_NTF_REVT, /* 36 UWB data transfer status over UWB */
- UWB_DATA_RECV_REVT, /* 37 received data over UWB */
- UWB_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT, /* 38 DL TDoA Configure DT Anchor
- RR RDM List Response */
- UWB_SESSION_ACTIVE_ROUNDS_INDEX_UPDATE_REVT /* 39 DL-TDoA Update Ranging Index
- status Response */
-};
-typedef uint16_t tUWB_RESPONSE_EVT;
-
-/* the events reported on tUWB_TEST_RESPONSE_CBACK */
-enum {
- UWB_TEST_GET_CONFIG_REVT =
- UWB_FIRST_TEVT, /* 0 Get test Config response......*/
- UWB_TEST_SET_CONFIG_REVT, /* 1 Set test Config response */
- UWB_TEST_PERIODIC_TX_DATA_REVT, /* 2 PERIODIC TX ntf results response */
- UWB_TEST_PER_RX_DATA_REVT, /* 3 PER RX ntf results response */
- UWB_TEST_PERIODIC_TX_REVT, /* 4 PERIODIC tx test results response */
- UWB_TEST_PER_RX_REVT, /* 5 PER rx test results response */
- UWB_TEST_STOP_SESSION_REVT, /* 6 Stop PER test Session */
- UWB_TEST_LOOPBACK_DATA_REVT, /* 7 Test Rf loop back ntf */
- UWB_TEST_LOOPBACK_REVT, /* 8 Test Rf loop back resp */
- UWB_TEST_RX_REVT, /* 9 RX Test resp */
- UWB_TEST_RX_DATA_REVT /* 10 RX Test ntf */
-};
-typedef uint16_t tUWB_TEST_RESPONSE_EVT;
-
-typedef uint8_t tUWB_RAW_EVT; /* proprietary events */
-typedef uint8_t tUWB_STATUS;
-
-typedef struct {
- tUWB_STATUS status; /* The event status. */
-} tUWB_ENABLE_REVT;
-
-#define UWB_MAX_NUM_IDS 125
-/* the data type associated with UWB_SET_CORE_CONFIG_REVT */
-typedef struct {
- tUWB_STATUS status; /* The event status. */
- uint8_t num_param_id; /* Number of rejected UCI Param ID */
- uint8_t param_ids[UWB_MAX_NUM_IDS]; /* UCI Param ID */
- uint16_t tlv_size; /* The length of TLV */
-} tUWB_SET_CORE_CONFIG_REVT;
-
-typedef struct {
- tUWB_STATUS status; /* The event status. */
- uint8_t num_param_id; /* Number of rejected UCI Param ID */
- uint8_t param_ids[UWB_MAX_NUM_IDS]; /* UCI Param ID */
- uint16_t tlv_size; /* The length of TLV */
-} tUWB_SET_APP_CONFIG_REVT;
-
-/* the data type associated with UWB_GET_CORE_CONFIG_REVT */
-typedef struct {
- tUWB_STATUS status; /* The event status. */
- uint8_t no_of_ids;
- uint8_t p_param_tlvs[UCI_MAX_PAYLOAD_SIZE]; /* TLV */
- uint16_t tlv_size; /* The length of TLV */
-} tUWB_GET_CORE_CONFIG_REVT;
-
-/* the data type associated with UWB_GET_APP_CONFIG_REVT */
-typedef struct {
- tUWB_STATUS status; /* The event status. */
- uint8_t no_of_ids;
- uint8_t p_param_tlvs[UCI_MAX_PAYLOAD_SIZE]; /* TLV */
- uint16_t tlv_size; /* The length of TLV */
-} tUWB_GET_APP_CONFIG_REVT;
-/* the data type associated with UWB_DEVICE_RESET_REVT */
-typedef struct {
- tUWB_STATUS status; /* The event status. */
- uint8_t resetConfig; /* Vendor Specific Reset Config */
-} tUWB_DEVICE_RESET_REVT;
-
-/* the data type associated with UWB_DEVICE_STATUS_REVT */
-typedef struct {
- uint8_t status;
-} tUWB_DEVICE_STATUS_REVT;
-
-/* the data type associated with UWB_CORE_GEN_ERR_STATUS_REVT */
-typedef struct {
- uint8_t status;
-} tUWB_CORE_GEN_ERR_STATUS_REVT;
-
-/* the data type associated with UWB_SESSION_GET_COUNT_REVT */
-typedef struct {
- uint8_t status; /* device status */
- uint8_t count; /* active session count */
-} tUWB_SESSION_GET_COUNT_REVT;
-
-/* the data type associated with UWB_SESSION_GET_STATE_REVT */
-typedef struct {
- uint8_t status; /* device status */
- uint8_t session_state; /* current session state */
-} tUWB_SESSION_GET_STATE_REVT;
-
-/* the data type associated with UWB_SESSION_NTF_REVT */
-typedef struct {
- uint32_t session_id;
- uint8_t state;
- uint8_t reason_code;
-} tUWB_SESSION_NTF_REVT;
-
-/* the data type associated with tUWB_GET_DEVICE_INFO_REVT */
-typedef struct {
- tUWB_STATUS status; /* The event status. */
- uint16_t uci_version; /* UCI version */
- uint16_t mac_version; /* MAC version */
- uint16_t phy_version; /* PHY version */
- uint16_t uciTest_version; /* UCI Test specification version */
- uint8_t vendor_info_len; /* Device Information length */
- uint8_t vendor_info[UCI_VENDOR_INFO_MAX_SIZE]; /* Manufacturer specific
- information */
-} tUWB_GET_DEVICE_INFO_REVT;
-
-typedef struct {
- uint8_t mac_addr[8];
- uint8_t status;
- uint8_t nLos; /* non line of sight */
- uint16_t distance;
- uint16_t aoa_azimuth;
- uint8_t aoa_azimuth_FOM;
- uint16_t aoa_elevation;
- uint8_t aoa_elevation_FOM;
- uint16_t aoa_dest_azimuth;
- uint8_t aoa_dest_azimuth_FOM;
- uint16_t aoa_dest_elevation;
- uint8_t aoa_dest_elevation_FOM;
- uint8_t slot_index;
- uint8_t rssi;
- uint8_t rfu[TWR_RANGE_MEASR_RFU];
-} tUWB_TWR_RANGING_MEASR;
-
-typedef struct {
- uint8_t mac_addr[8];
- uint8_t message_control;
- uint8_t frame_type;
- uint8_t nLos; /* non line of sight */
- uint16_t aoa_azimuth;
- uint8_t aoa_azimuth_FOM;
- uint16_t aoa_elevation;
- uint8_t aoa_elevation_FOM;
- uint32_t frame_number; /* Number received in the payload of the Blink UTM */
- uint8_t rxTimeStamp[8]; /* Local RX timestamp of the received UWB RFRAME */
- uint8_t ulTdoa_device_id[8]; /* Device ID of the sender of the received UTM */
- uint8_t txTimeStamp[8]; /* TX timestamp of the UWB RFRAME */
-} tUWB_TDoA_RANGING_MEASR;
-
-
-/* the data type associated with vendor notification */
-typedef struct {
- uint16_t len;
- uint8_t data[UCI_VENDOR_INFO_MAX_SIZE];
-}tUWB_VENDOR_SPECIFIC_NTF;
-
-typedef struct {
- uint8_t mac_addr[8];
- uint8_t status;
- uint8_t message_type;
- uint16_t message_control;
- uint16_t block_index;
- uint8_t round_index;
- uint8_t nLos;
- uint16_t aoa_azimuth;
- uint8_t aoa_azimuth_FOM;
- uint16_t aoa_elevation;
- uint8_t aoa_elevation_FOM;
- uint8_t rssi;
- uint64_t txTimeStamp;
- uint64_t rxTimeStamp;
- uint16_t cfo_anchor;
- uint16_t cfo;
- uint32_t initiator_reply_time;
- uint32_t responder_reply_time;
- uint16_t initiator_responder_TOF;
- uint8_t anchor_location[12];
- uint8_t active_ranging_round[15];
-} tUWB_DLTDOA_RANGING_MEASR;
-
-typedef struct {
- uint8_t mac_addr[8];
- uint8_t status;
- uint8_t nLos;
- uint8_t frame_seq_num;
- uint16_t block_index;
- uint16_t aoa_azimuth;
- uint8_t aoa_azimuth_FOM;
- uint16_t aoa_elevation;
- uint8_t aoa_elevation_FOM;
-} tUWB_OWR_WITH_AOA_RANGING_MEASR;
-
-typedef union {
- tUWB_TWR_RANGING_MEASR twr_range_measr[MAX_NUM_RESPONDERS];
- tUWB_TDoA_RANGING_MEASR tdoa_range_measr[MAX_NUM_OF_TDOA_MEASURES];
- tUWB_DLTDOA_RANGING_MEASR dltdoa_range_measr[MAX_NUM_OF_DLTDOA_MEASURES];
- tUWB_OWR_WITH_AOA_RANGING_MEASR owr_with_aoa_range_measr;
-} tUWB_RANGING_MEASR;
-
-/* the data type associated with vendor notification */
-typedef struct {
- uint16_t len;
- uint8_t data[UCI_VENDOR_INFO_MAX_SIZE];
-}tUWB_VENDOR_SPECIFIC_NTF;
-
-/* the data type associated with UWB_RANGE_DATA_REVT */
-typedef struct {
- uint16_t range_data_len;
- uint32_t seq_counter;
- uint32_t session_id;
- uint8_t rcr_indication;
- uint32_t curr_range_interval;
- uint8_t ranging_measure_type;
- uint8_t rfu;
- uint8_t mac_addr_mode_indicator;
- uint8_t reserved[8];
- uint8_t no_of_measurements;
- tUWB_RANGING_MEASR ranging_measures;
- tUWB_VENDOR_SPECIFIC_NTF vendor_specific_ntf;
-} tUWB_RANGE_DATA_REVT;
-
-/* the data type associated with UWB_CONFORMANCE_TEST_DATA */
-typedef struct {
- uint16_t length;
- uint8_t data[CONFORMANCE_TEST_MAX_UCI_PKT_LENGTH];
-} tUWB_CONFORMANCE_TEST_DATA;
-
-/* the data type associated with vendor notification */
-typedef struct {
- uint16_t len;
- uint8_t data[UCI_VENDOR_INFO_MAX_SIZE];
-} tUWB_VENDOR_SPECIFIC_REVT;
-
-/* the data type associated with UWB_RANGING_GET_COUNT_REVT */
-typedef struct {
- uint8_t status; /* response status */
- uint32_t count; /* ranging count in particular session duration */
-} tUWB_GET_RANGE_COUNT_REVT;
-
-/* the data type associated with UWB_CORE_GET_DEVICE_CAPABILITY_REVT */
-typedef struct {
- tUWB_STATUS status; /* The event status. */
- uint8_t no_of_tlvs;
- uint8_t tlv_buffer[UCI_MAX_PAYLOAD_SIZE]; /* TLV */
- uint16_t tlv_buffer_len; /* The length of TLV */
-} tUWB_CORE_GET_DEVICE_CAPABILITY_REVT;
-
-/* the data type associated with UWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT */
-typedef struct {
- uint32_t session_id;
- uint8_t remaining_list;
- uint8_t no_of_controlees;
- uint16_t controlee_mac_address_list[MAX_NUM_CONTROLLEES];
- uint32_t subsession_id_list[MAX_NUM_CONTROLLEES];
- uint8_t status_list[MAX_NUM_CONTROLLEES];
-} tUWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT;
-
-/* the data type associated with UWB_BLINK_DATA_TX_NTF_REVT */
-typedef struct {
- uint8_t repetition_count_status; /* repetition count status */
-} tUWB_SEND_BLINK_DATA_NTF_REVT;
-
-/* the data type associated with UWB_DATA_TRANSFER_STATUS_NTF_REVT */
-typedef struct {
- uint32_t session_id;
- uint32_t sequence_num;
- uint8_t status;
-}tUWB_DATA_TRANSFER_STATUS_NTF_REVT;
-
-/* the data type associated with UWB_DATA_RECV_REVT */
-typedef struct {
- uint32_t session_id;
- uint8_t status;
- uint32_t sequence_num;
- uint8_t address[EXTENDED_ADDRESS_LEN];
- uint8_t source_end_point;
- uint8_t dest_end_point;
- uint16_t data_len;
- uint8_t data[UCI_MAX_DATA_SIZE];
-}tUWB_RX_DATA_REVT;
-
-
-/* the data type associated with UWB_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT */
-typedef struct {
- uint8_t status;
- uint16_t len;
- uint8_t rng_round_indexs[255];
-}tUWB_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_REVT;
-
-/* the data type associated with UWB_DATA_RECV_REVT */
-typedef struct {
- uint8_t status;
- uint16_t len;
- uint8_t rng_round_index[255];
-}tUWB_UPDATE_RANGE_ROUND_INDEX_REVT;
-
-typedef struct {
- tUWB_STATUS status; /* The event status. */
-} tUWB_SET_COUNTRY_CODE_REVT;
-
-typedef union {
- tUWB_STATUS status; /* The event status. */
- tUWB_ENABLE_REVT enable;
- tUWB_GET_DEVICE_INFO_REVT sGet_device_info;
- tUWB_DEVICE_STATUS_REVT sDevice_status;
- tUWB_CORE_GEN_ERR_STATUS_REVT sCore_gen_err_status;
- tUWB_DEVICE_RESET_REVT sDevice_reset;
- tUWB_SET_CORE_CONFIG_REVT sCore_set_config;
- tUWB_GET_CORE_CONFIG_REVT sCore_get_config;
- tUWB_SESSION_NTF_REVT sSessionStatus;
- tUWB_GET_APP_CONFIG_REVT sApp_get_config;
- tUWB_SET_APP_CONFIG_REVT sApp_set_config;
- tUWB_SESSION_GET_COUNT_REVT sGet_session_cnt;
- tUWB_SESSION_GET_STATE_REVT sGet_session_state;
- tUWB_RANGE_DATA_REVT sRange_data;
- tUWB_GET_RANGE_COUNT_REVT sGet_range_cnt;
- tUWB_CORE_GET_DEVICE_CAPABILITY_REVT sGet_device_capability;
- tUWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT sMulticast_list_ntf;
- tUWB_SET_COUNTRY_CODE_REVT sSet_country_code_status;
- tUWB_SEND_BLINK_DATA_NTF_REVT sSend_blink_data_ntf;
- tUWB_CONFORMANCE_TEST_DATA sConformance_test_data;
- tUWB_VENDOR_SPECIFIC_REVT vendor_specific_ntf;
- tUWB_DATA_TRANSFER_STATUS_NTF_REVT sData_xfer_status;
- tUWB_RX_DATA_REVT sRcvd_data;
- tUWB_UPDATE_RANGE_ROUND_INDEX_REVT sRange_round_index;
- tUWB_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_REVT sConfigure_dt_anchor_rr_rdm_list;
-} tUWB_RESPONSE;
-
-/* Data types associated with all RF test Events */
-
-/* the data type associated with UWB_GET_TEST_CONFIG_REVT */
-typedef struct {
- tUWB_STATUS status; /* The event status. */
- uint8_t no_of_ids;
- uint8_t p_param_tlvs[UCI_MAX_PAYLOAD_SIZE]; /* TLV */
- uint16_t tlv_size; /* The length of TLV */
-} tUWB_TEST_GET_CONFIG_REVT;
-
-typedef struct {
- tUWB_STATUS status; /* The event status. */
- uint8_t num_param_id; /* Number of rejected UCI Param ID */
- uint8_t param_ids[UWB_MAX_NUM_IDS]; /* UCI Param ID */
- uint16_t tlv_size; /* The length of TLV */
-} tUWB_TEST_SET_CONFIG_REVT;
-
-/* The data type associated with UWB_RF_TEST_DATA_REVT*/
-typedef struct {
- uint16_t length;
- uint8_t data[255];
-} tUWB_RF_TEST_DATA;
-
-typedef union {
- tUWB_STATUS status; /* The event status. */
- tUWB_TEST_GET_CONFIG_REVT sTest_get_config;
- tUWB_TEST_SET_CONFIG_REVT sTest_set_config;
- tUWB_RF_TEST_DATA sRf_test_result;
-} tUWB_TEST_RESPONSE;
-
-/*************************************
-** RESPONSE Callback Functions
-**************************************/
-typedef void(tUWB_RESPONSE_CBACK)(tUWB_RESPONSE_EVT event,
- tUWB_RESPONSE* p_data);
-typedef void(tUWB_TEST_RESPONSE_CBACK)(tUWB_TEST_RESPONSE_EVT event,
- tUWB_TEST_RESPONSE* p_data);
-typedef void(tUWB_RAW_CBACK)(tUWB_RAW_EVT event, uint16_t data_len,
- uint8_t* p_data);
-
-/*******************************************************************************
-**
-** Function UWB_Enable
-**
-** Description This function enables UWBS. Prior to calling UWB_Enable:
-** - the UWBS must be powered up, and ready to receive
-** commands.
-** - GKI must be enabled
-** - UWB_TASK must be started
-** - UCIT_TASK must be started (if using dedicated UCI
-** transport)
-**
-** This function opens the UCI transport (if applicable),
-** resets the UWB controller, and initializes the UWB
-** subsystem.
-**
-** When the UWB startup procedure is completed, an
-** UWB_ENABLE_REVT is returned to the application using the
-** tUWB_RESPONSE_CBACK.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_Enable(tUWB_RESPONSE_CBACK* p_cback,
- tUWB_TEST_RESPONSE_CBACK* p_test_cback);
-
-/*******************************************************************************
-**
-** Function UWB_Disable
-**
-** Description This function performs clean up routines for shutting down
-** UWB subsystem and closes the UCI transport (if using
-** dedicated UCI transport).
-**
-** When the UWB shutdown procedure is completed, an
-** UWB_DISABLED_REVT is returned to the application using the
-** tUWB_RESPONSE_CBACK.
-**
-** Returns nothing
-**
-*******************************************************************************/
-extern void UWB_Disable(void);
-
-/*******************************************************************************
-**
-** Function UWB_Init
-**
-** Description This function initializes control blocks for UWB
-**
-** Returns nothing
-**
-*******************************************************************************/
-
-extern void UWB_Init(tHAL_UWB_CONTEXT* p_hal_entry_cntxt);
-
-/*******************************************************************************
-**
-** Function UWB_GetDeviceInfo
-**
-** Description This function is called to get Device Info
-** The response from UWBS is reported with an
-** UWB_GET_DEVICE_INFO_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters None
-**
-** Returns none
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_GetDeviceInfo();
-
-/*******************************************************************************
-**
-** Function UWB_DeviceResetCommand
-**
-** Description This function is called to send Device Reset Command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_DEVICE_RESET_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters resetConfig - Vendor Specific Reset Config to be sent
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_DeviceResetCommand(uint8_t resetConfig);
-
-/*******************************************************************************
-**
-** Function UWB_SetCoreConfig
-**
-** Description This function is called to send the configuration
-** parameters.
-** The response from UWBS is reported with an
-** UWB_SET_CORE_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters tlv_size - the length of p_param_tlvs.
-** p_param_tlvs - the parameter ID/Len/Value list
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_SetCoreConfig(uint8_t tlv_size, uint8_t* p_param_tlvs);
-
-/*******************************************************************************
-**
-** Function UWB_GetCoreConfig
-**
-** Description This function is called to retrieve the configuration
-** parameters from UWBS.
-** The response from UWBS is reported with an
-** UWB_GET_CORE_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters num_ids - the number of parameter IDs
-** p_param_ids - the parameter ID list.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_GetCoreConfig(uint8_t num_ids, uint8_t* p_param_ids);
-
-/*******************************************************************************
-**
-** Function UWB_SessionInit
-**
-** Description This function is called to send session init command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_SESSION_INIT_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_SessionInit(uint32_t session_id, uint8_t sessionType);
-
-/*******************************************************************************
-**
-** Function UWB_HalSessionInit
-**
-** Description This function is called to send session init command to
-** HAL.
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_HalSessionInit(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWB_SessionDeInit
-**
-** Description This function is called to send session DeInit command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_SESSION_DEINIT_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_SessionDeInit(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWB_GetSessionCount
-**
-** Description This function is called to send get session count command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_SESSION_GET_COUNT_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_GetSessionCount();
-
-/*******************************************************************************
-**
-** Function UWB_GetAppConfig
-**
-** Description This function is called to retrieve the parameter TLV from
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_GET_APP_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - All APP configurations belonging to this
-** Session ID
-** num_ids - the number of parameter IDs
-** length - Length of app parameter ID
-** p_param_ids - the parameter ID list.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_GetAppConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* p_param_ids);
-
-/*******************************************************************************
-**
-** Function UWB_SetAppConfig
-**
-** Description This function is called to set the parameter TLV to UWBS.
-** The response from UWBS is reported with an
-** UWB_SET_APP_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - All APP configurations belonging to this SessionID
-** num_ids - the number of parameter IDs
-** length - Length of app parameter data
-** p_data - SetAppConfig TLV data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_SetAppConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* p_data);
-
-/*******************************************************************************
-**
-** Function UWB_StartRanging
-**
-** Description This function is called to send the range start command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_START_RANGE_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID for which ranging shall start
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_StartRanging(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWB_StopRanging
-**
-** Description This function is called to send the range stop command to
-** UWBS.
-** The response from UWBS is reported with an UWB_STOP_RANGE_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID for which ranging shall stop
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_StopRanging(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWB_GetRangingCount
-**
-** Description This function is called to send get ranging count command.
-** The response from UWBS is reported with an
-** UWB_GET_RANGE_COUNT_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID for which ranging round count is
-** required
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_GetRangingCount(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWB_GetSessionStatus
-**
-** Description This function is called to send get session status command.
-** The response from UWBS is reported with an
-** UWB_SESSION_GET_STATE_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID for which session state is required
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_GetSessionStatus(uint32_t session_id);
-
-/*******************************************************************************
-**
-** Function UWB_CoreGetDeviceCapability
-**
-** Description This function is called to send the Core Get Capability
-** The response from UWBS is reported with an
-** UWB_CORE_GET_DEVICE_CAPABILITY_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters None
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_CoreGetDeviceCapability(void);
-
-/*******************************************************************************
-**
-** Function UWB_MulticastListUpdate
-**
-** Description This function is called to send the Multicast list update
-** command
-** The response from UWBS is reported with an
-** UWB_SESSION_UPDATE_MULTICAST_LIST_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID
-** action - action
-** noOfControlees - No Of Controlees
-** shortAddress - array of short address
-** subSessionId - array of sub session ID
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_MulticastListUpdate(uint32_t session_id, uint8_t action,
- uint8_t noOfControlees,
- uint16_t* shortAddressList,
- uint32_t* subSessionIdList);
-
-/*******************************************************************************
-**
-** Function UWB_SetCountryCode
-**
-** Description This function is called to send the country code set
-** command.
-** The response from UWBS is reported with an
-** UWB_SESSION_SET_COUNTRY_CODE_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters country_code - ISO Country code
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SetCountryCode(uint8_t* countryCode);
-
-/*******************************************************************************
-**
-** Function UWB_SendBlinkData
-**
-** Description This function is called to send blink data tx command
-** The response from UWBS is reported with an
-** UWB_BLINK_DATA_TX_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID
-** repetition_count - repetition count
-** app_data_len - size of application data
-** app_data - application data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_SendBlinkData(uint32_t session_id,
- uint8_t repetition_count,
- uint8_t app_data_len, uint8_t* app_data);
-
-/*******************************************************************************
-**
-** Function UWB_SendRawCommand
-**
-** Description This function is called to send the given raw command to
-** UWBS. The response from UWBC is reported to the given
-** tUWB_RAW_CBACK.
-**
-** Parameters p_data - The command buffer
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_SendRawCommand(UWB_HDR* p_data, tUWB_RAW_CBACK* p_cback);
-
-/*******************************************************************************
-**
-** Function UWB_SendData
-**
-** Description This function is called to send the data packet over UWB.
-**
-** Parameters p_data - The data buffer
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SendData(uint32_t session_id, uint8_t* p_addr,
- uint8_t dest_end_point, uint8_t sequence_num,
- uint16_t data_len, uint8_t* p_data);
-/*******************************************************************************
-**
-** Function UWB_ConfigureDTAnchorForRrRdmList
-**
-** Description This function is called to Configure DT anchor RR RDM List.
-**
-** Parameter session_id - Session id To which Rangng index need to update
-** rr_rdm_count - Number Of rr_rdm
-** length - length of data buffer
-** p_data - The data buffer
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_ConfigureDTAnchorForRrRdmList(uint32_t session_id, uint8_t rr_rdm_count,
- uint8_t length, uint8_t* p_data);
-
-/*******************************************************************************
-**
-** Function UWB_UpdateRangingRoundIndex
-**
-** Description This function is called to Update Active Ranging Index.
-**
-** Parameter dlTdoaRole - 0x00(Anchor) or 0x01(Tag)
-** session_id - Session id To which Rangng index need to update
-** number_of_active_rngIndex - NUmber Of Ranging index to be updated
-** rng_round_index_len - Range Round Index Len
-** p_rng_round_index - pointer to Ranging Index buffer
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_UpdateRangingRoundIndex(uint8_t dlTdoaRole, uint32_t session_id, uint8_t number_of_rng_index,
- uint8_t rng_round_index_len, uint8_t* p_rng_round_index);
-
-/*******************************************************************************
-**
-** Function UWB_EnableConformanceTest
-**
-** Description This function is called to set MCTT/PCTT mode.
-** In this mode application is sending raw UCI packets.
-**
-** Parameters p_data - The data buffer
-**
-** Returns None
-**
-*******************************************************************************/
-void UWB_EnableConformanceTest(uint8_t enable);
-
-/*******************************************************************************
-**
-** Function UWB_SetDataXferCapMaxMsgSize
-**
-** Description This function is called to set max msg size supported for data Tranfer
-**
-** Parameters maxMsgSize - max msg size value
-**
-** Returns None
-**
-*******************************************************************************/
-void UWB_SetDataXferCapMaxMsgSize(uint16_t maxMsgSize);
-
-/*******************************************************************************
-**
-** Function UWB_SetDataXferCapMaxDataPktPayloadSize
-**
-** Description This function is called to set max data packet size at one time supported for data Tranfer
-**
-** Parameters maxDataPktPayloadSize - max data packet size value
-**
-** Returns None
-**
-*******************************************************************************/
-void UWB_SetDataXferCapMaxDataPktPayloadSize(uint16_t maxDataPktPayloadSize);
-
-/*******************************************************************************
-**
-** Function UWB_GetStatusName
-**
-** Description This function returns the status name.
-**
-** NOTE conditionally compiled to save memory.
-**
-** Returns pointer to the name
-**
-*******************************************************************************/
-extern const uint8_t* UWB_GetStatusName(tUWB_STATUS status);
-
-/****************** RF TEST
- * FUNCTIONS********************************************/
-
-/*******************************************************************************
-**
-** Function UWB_TestGetConfig
-**
-** Description This function is called to retrieve the test configuration
-** parameter from UWBS.
-** The response from UWBS is reported with an
-** UWB_TEST_GET_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - All TEST configurations belonging to this SessionId
-** num_ids - the number of parameter IDs
-** length - Length of test parameter ID
-** p_param_ids - the parameter ID list.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_TestGetConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* p_param_ids);
-
-/*******************************************************************************
-**
-** Function UWB_SetTestConfig
-**
-** Description This function is called to set the test configuration
-** parameters.
-** The response from UWBS is reported with an
-** UWB_TEST_SET_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - All TEST configurations belonging to this SessionId
-** num_ids - the number of parameter IDs
-** length - Length of test parameter data
-** p_data - SetAppConfig TLV data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_SetTestConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* p_data);
-
-/*******************************************************************************
-**
-** Function UWB_TestPeriodicTx
-**
-** Description This function is called send periodic Tx test command
-** The response from UWBS is reported with an
-** UWB_TEST_PERIODIC_TX_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters length - Length of psdu data.
-** p_data - psdu data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_TestPeriodicTx(uint16_t length, uint8_t* p_data);
-
-/*******************************************************************************
-**
-** Function UWB_TestPerRx
-**
-** Description This function is called send Packet Error Rate(PER) Rx test
-** command.
-** The response from UWBS is reported with an
-** UWB_TEST_PER_RX_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters length - Length of psdu data.
-** p_data - psdu data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_TestPerRx(uint16_t length, uint8_t* p_data);
-
-/*******************************************************************************
-**
-** Function UWB_TestUwbLoopBack
-**
-** Description This function is called send Loop Back test command.
-** The response from UWBS is reported with an
-** UWB_TEST_LOOPBACK_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters length - Length of psdu data.
-** p_data - psdu data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_TestUwbLoopBack(uint16_t length, uint8_t* p_data);
-
-/********************************************************************************
-**
-** Function UWB_TestRx
-**
-** Description This function is called send Rx Test command
-** The response from UWBS is reported with an UWB_TEST_RX_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters None
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_TestRx(void);
-
-/*******************************************************************************
-**
-** Function UWB_TestStopSession
-**
-** Description This function is called to send test session stop command.
-** The response from UWBS is reported with an
-** UWB_TEST_STOP_SESSION_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters None
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-extern tUWB_STATUS UWB_TestStopSession(void);
-
-#endif /* UWB_API_H */
diff --git a/src/uwb/include/uwb_int.h b/src/uwb/include/uwb_int.h
deleted file mode 100755
index da2952e..0000000
--- a/src/uwb/include/uwb_int.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021 NXP.
- *
- * 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.
- */
-
-#ifndef UWB_INT_H_
-#define UWB_INT_H_
-
-#include "uci_defs.h"
-#include "uwb_api.h"
-#include "uwb_gki.h"
-#include "uwb_target.h"
-
-/****************************************************************************
-** UWB_TASK definitions
-****************************************************************************/
-
-/* UWB_TASK event masks */
-#define UWB_TASK_EVT_TRANSPORT_READY EVENT_MASK(APPL_EVT_0)
-
-/* UWB Timer events */
-#define UWB_TTYPE_UCI_WAIT_RSP 0x00
-#define UWB_WAIT_RSP_RAW_CMD 0x01
-#define UWB_TTYPE_UCI_WAIT_DATA_NTF 0x02
-
-#define UWB_SAVED_HDR_SIZE 2
-
-/* UWB Task event messages */
-enum {
- UWB_STATE_NONE, /* not start up yet */
- UWB_STATE_W4_HAL_OPEN, /* waiting for HAL_UWB_OPEN_CPLT_EVT */
- UWB_STATE_IDLE, /* normal operation( device is in idle state) */
- UWB_STATE_ACTIVE, /* UWB device is in active */
- UWB_STATE_W4_HAL_CLOSE, /* waiting for HAL_UWB_CLOSE_CPLT_EVT */
- UWB_STATE_CLOSING
-};
-typedef uint8_t tUWB_STATE;
-
-/* This data type is for UWB task to send a UCI VS command to UCIT task */
-typedef struct {
- UWB_HDR bt_hdr; /* the UCI command */
- tUWB_RAW_CBACK* p_cback; /* the callback function to receive RSP */
-} tUWB_UCI_RAW_MSG;
-
-/* This data type is for HAL event */
-typedef struct {
- UWB_HDR hdr;
- uint8_t hal_evt; /* HAL event code */
- uint8_t status; /* tHAL_UWB_STATUS */
-} tUWB_HAL_EVT_MSG;
-
-/* callback function pointer(8; use 8 to be safe + UWB_SAVED_CMD_SIZE(2) */
-#define UWB_RECEIVE_MSGS_OFFSET (10)
-
-/* UWB control blocks */
-typedef struct {
- tUWB_RESPONSE_CBACK* p_resp_cback;
- tUWB_TEST_RESPONSE_CBACK* p_test_resp_cback;
-
- /* UWB_TASK timer management */
- TIMER_LIST_Q timer_queue; /* 1-sec timer event queue */
- TIMER_LIST_Q quick_timer_queue;
-
- tUWB_STATE uwb_state;
-
- uint8_t trace_level;
- uint8_t last_hdr[UWB_SAVED_HDR_SIZE]; /* part of last UCI command header */
- uint8_t last_cmd[UWB_SAVED_HDR_SIZE]; /* part of last UCI command payload */
-
- void* p_raw_cmd_cback; /* the callback function for last raw command */
- BUFFER_Q uci_cmd_xmit_q; /* UCI command queue */
-
- TIMER_LIST_ENT
- uci_wait_rsp_timer; /* Timer for waiting for uci command response */
- uint16_t uci_wait_rsp_tout; /* UCI command timeout (in ms) */
- uint16_t retry_rsp_timeout; /* UCI command timeout during retry */
-
- uint8_t uci_cmd_window; /* Number of commands the controller can accecpt
- without waiting for response */
- bool is_resp_pending; /* response is pending from UWBS */
- bool is_recovery_in_progress; /* recovery in progresss */
-
- tHAL_UWB_ENTRY* p_hal;
- uint8_t rawCmdCbflag;
- uint8_t device_state;
-
- uint16_t cmd_retry_count;
- uint8_t invalid_len_cmd_retry_cnt;
- UWB_HDR* pLast_cmd_buf;
-
- UWB_HDR* pLast_data_buf;
- uint8_t data_pkt_retry_count;
- bool is_credit_ntf_pending;
-
- bool IsConformaceTestEnabled; /* MCTT mode indicator */
-
- uint8_t data_credits; /* number of buffer credits */
- TIMER_LIST_ENT
- uci_wait_credit_ntf_timer; /* Timer for waiting for uci credit ntf */
- uint16_t uci_credit_ntf_timeout; /* UCI credit timeout (in ms) */
- bool is_first_frgmnt_done; /*flag indicates recieved pbf=1 uci pkt before*/
-} tUWB_CB;
-
-typedef struct {
- DATA_BUFFER_Q tx_data_pkt[5];
- uint8_t no_of_sessions;
- uint32_t curr_session_id;
- uint8_t curr_session_idx;
- uint16_t max_data_pkt_payload_size;
- uint16_t max_msg_size;
-}tDATA_TX_CB;
-
-struct chained_uci_packet {
- uint8_t buffer[UCI_MAX_FRAGMENT_BUFF_SIZE];
- uint8_t oid;
- uint8_t gid;
- uint16_t offset;
-};
-
-typedef struct chained_uci_packet chained_uci_packet;
-extern chained_uci_packet chained_packet;
-
-/*****************************************************************************
- ** EXTERNAL FUNCTION DECLARATIONS
- *****************************************************************************/
-
-/* Global UWB data */
-extern tUWB_CB uwb_cb;
-extern tDATA_TX_CB data_tx_cb;
-
-/****************************************************************************
- ** Internal uwb functions
- ****************************************************************************/
-
-extern void uwb_init(void);
-
-extern bool uwb_ucif_process_event(UWB_HDR* p_msg);
-extern void uwb_ucif_check_cmd_queue(UWB_HDR* p_buf);
-extern void uwb_ucif_retransmit_cmd(UWB_HDR* p_buf);
-extern void uwb_ucif_send_cmd(UWB_HDR* p_buf);
-extern void uwb_ucif_update_cmd_window(void);
-extern void uwb_ucif_cmd_timeout(void);
-extern void uwb_ucif_event_status(tUWB_RESPONSE_EVT event, uint8_t status);
-extern void uwb_ucif_error_status(uint8_t conn_id, uint8_t status);
-extern void uwb_ucif_uwb_recovery(void);
-
-extern bool uwb_proc_core_rsp(uint8_t op_code, uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_get_device_info_rsp(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_get_device_capability_rsp(uint8_t* p_buf,
- uint16_t len);
-extern void uwb_ucif_proc_core_set_config_status(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_core_get_config_rsp(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_core_device_reset_rsp_status(uint8_t* p_buf,
- uint16_t len);
-extern void uwb_ucif_proc_core_device_status(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_core_generic_error_ntf(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_conformance_ntf(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_app_get_config_status(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_app_set_config_status(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_ranging_data(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_send_blink_data_ntf(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_range_management_status(tUWB_RESPONSE_EVT event,
- uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_get_range_count_status(tUWB_RESPONSE_EVT event,
- uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_session_management_status(tUWB_RESPONSE_EVT event,
- uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_session_status(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_multicast_list_update_ntf(uint8_t* p_buf,
- uint16_t len);
-void uwb_ucif_proc_android_set_country_code_status(uint8_t* p_buf,
- uint16_t len);
-
-/* APIs for handling UWB RF test command responses and notifications */
-extern void uwb_ucif_test_management_status(tUWB_RESPONSE_EVT event,
- uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_test_get_config_status(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_test_set_config_status(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_rf_test_data(tUWB_RESPONSE_EVT event, uint8_t* p_buf,
- uint16_t len);
-
-/* APIs for handling data transfer */
-extern void uwb_ucif_send_data_frame(uint32_t session_id, uint8_t* p_addr,
- uint16_t data_len, uint8_t* p_data);
-extern void uwb_ucif_proc_data_credit_ntf(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_proc_data_transfer_status_ntf(uint8_t* p_buf, uint16_t len);
-extern void uci_ucif_proc_data_packet(uint8_t* p_buf, uint16_t len);
-extern void uwb_ucif_credit_ntf_timeout(void);
-extern void uwb_ucif_send_data_frame(UWB_HDR* p_data);
-
-/* From uwb_task.c */
-extern uint32_t uwb_task(uint32_t param);
-void uwb_task_shutdown_uwbc(void);
-
-/* From uwb_main.c */
-void uwb_enabled(tUWB_STATUS uwb_status, UWB_HDR* p_init_rsp_msg);
-void uwb_set_state(tUWB_STATE uwb_state);
-void uwb_main_flush_cmd_queue(void);
-void uwb_main_flush_data_queue(void);
-void uwb_main_handle_hal_evt(tUWB_HAL_EVT_MSG* p_msg);
-void uwb_gen_cleanup(void);
-
-/* Timer functions */
-void uwb_start_timer(TIMER_LIST_ENT* p_tle, uint16_t type, uint32_t timeout);
-uint32_t uwb_remaining_time(TIMER_LIST_ENT* p_tle);
-void uwb_stop_timer(TIMER_LIST_ENT* p_tle);
-
-void uwb_start_quick_timer(TIMER_LIST_ENT* p_tle, uint16_t type,
- uint32_t timeout);
-void uwb_stop_quick_timer(TIMER_LIST_ENT* p_tle);
-void uwb_process_quick_timer_evt(void);
-
-#endif /* UWB_INT_H_ */
diff --git a/src/uwb/uci/uci_hmsgs.cc b/src/uwb/uci/uci_hmsgs.cc
deleted file mode 100755
index 8e57954..0000000
--- a/src/uwb/uci/uci_hmsgs.cc
+++ /dev/null
@@ -1,1032 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021 NXP.
- *
- * 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.
- */
-
-/******************************************************************************
- *
- * This file contains function of the UCI unit to format and send UCI
- * commands(for DH).
- *
- ******************************************************************************/
-#include "uci_hmsgs.h"
-
-#include "uci_defs.h"
-#include "uci_log.h"
-#include "uci_test_defs.h"
-#include "uwb_api.h"
-#include "uwb_int.h"
-#include "uwb_osal_common.h"
-#include "uwb_target.h"
-
-/*******************************************************************************
-**
-** Function uci_snd_get_device_info_cmd
-**
-** Description compose and send CORE_GET_DEVICE_INFO_CMD command to command
-** queue
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_get_device_info_cmd(void) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_CORE_DEVICE_INFO_CMD_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_CORE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_CORE_DEVICE_INFO);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_CORE_DEVICE_INFO_CMD_SIZE);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_device_reset_cmd
-**
-** Description compose and send CORE_DEVICE_RESET_CMD command to command
-** queue
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_device_reset_cmd(uint8_t resetConfig) {
- UWB_HDR* p;
- uint8_t* pp;
- p = UCI_GET_CMD_BUF(UCI_MSG_CORE_DEVICE_RESET_CMD_SIZE);
- if (p == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE + UCI_MSG_CORE_DEVICE_RESET_CMD_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_CORE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_CORE_DEVICE_RESET);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_CORE_DEVICE_RESET_CMD_SIZE);
- UINT8_TO_STREAM(pp, resetConfig);
- uwb_ucif_send_cmd(p);
-
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_core_set_config_cmd
-**
-** Description compose and send CORE CORE_SET_CONFIG_CMD command to command
-** queue
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_core_set_config_cmd(uint8_t* p_param_tlvs, uint8_t tlv_size) {
- UWB_HDR* p;
- uint8_t* pp;
- uint8_t num = 0, ulen, len, *pt;
-
- p = UCI_GET_CMD_BUF(tlv_size + 1);
- if (p == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + tlv_size + 1);
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_CORE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_CORE_SET_CONFIG);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, (uint8_t)(tlv_size + 1));
- len = tlv_size;
- pt = p_param_tlvs;
- while (len > 1) {
- len = (uint8_t)(len - 2);
- pt++;
- num++;
- ulen = *pt++;
- pt += ulen;
- if (len >= ulen) {
- len = (uint8_t)(len - ulen);
- } else {
- phUwb_GKI_freebuf(p);
- return UCI_STATUS_FAILED;
- }
- }
-
- UINT8_TO_STREAM(pp, num);
- ARRAY_TO_STREAM(pp, p_param_tlvs, tlv_size);
- uwb_ucif_send_cmd(p);
-
- return (UCI_STATUS_OK);
-}
-/*******************************************************************************
-**
-** Function uci_snd_core_get_config_cmd
-**
-** Description compose and send CORE_GET_CONFIG_CMD command to command
-** queue
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_core_get_config_cmd(uint8_t* param_ids, uint8_t num_ids) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(num_ids)) == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
-
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + num_ids + 1);
-
- p->offset = UCI_MSG_OFFSET_SIZE;
- p->layer_specific = 0;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_CORE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_CORE_GET_CONFIG);
- UINT8_TO_STREAM(pp, 0x00);
-
- UINT8_TO_STREAM(pp, (uint8_t)(num_ids + 1));
- UINT8_TO_STREAM(pp, num_ids);
- ARRAY_TO_STREAM(pp, param_ids, num_ids);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_session_init_cmd
-**
-** Description compose and send SESSION_INIT_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_session_init_cmd(uint32_t session_id, uint8_t sessionType) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_SESSION_INIT_CMD_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE + UCI_MSG_SESSION_INIT_CMD_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_SESSION_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_SESSION_INIT);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_SESSION_INIT_CMD_SIZE);
- UINT32_TO_STREAM(pp, session_id);
- UINT8_TO_STREAM(pp, sessionType);
-
- data_tx_cb.tx_data_pkt[data_tx_cb.no_of_sessions].session_id = session_id;
- data_tx_cb.tx_data_pkt[data_tx_cb.no_of_sessions].credit_available = 1;
- phUwb_GKI_init_q(&data_tx_cb.tx_data_pkt[data_tx_cb.no_of_sessions].tx_data_pkt_q);
- data_tx_cb.no_of_sessions++;
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_session_deinit_cmd
-**
-** Description compose and send SESSION_DEINIT_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_session_deinit_cmd(uint32_t session_id) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_SESSION_DEINIT_CMD_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE + UCI_MSG_SESSION_DEINIT_CMD_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_SESSION_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_SESSION_DEINIT);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_SESSION_DEINIT_CMD_SIZE);
- UINT32_TO_STREAM(pp, session_id);
-
- for(int i=0; i < data_tx_cb.no_of_sessions; i++) {
- if(data_tx_cb.tx_data_pkt[i].session_id == session_id)
- data_tx_cb.tx_data_pkt[i].session_id = 0;
- }
- if (data_tx_cb.no_of_sessions > 0) {
- data_tx_cb.no_of_sessions--;
- }
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_app_set_config_cmd
-**
-** Description compose and send SESSION_SET_APP_CONFIG_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_app_set_config_cmd(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* data) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(num_ids)) == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
-
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + sizeof(session_id) + sizeof(num_ids) +
- length);
-
- p->offset = UCI_MSG_OFFSET_SIZE;
- p->layer_specific = 0;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_SESSION_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_SESSION_SET_APP_CONFIG);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, sizeof(session_id) + sizeof(num_ids) + length);
-
- UINT32_TO_STREAM(pp, session_id);
- UINT8_TO_STREAM(pp, num_ids);
- ARRAY_TO_STREAM(pp, data, length);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_app_get_config_cmd
-**
-** Description compose and send SESSION_GET_APP_CONFIG_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_app_get_config_cmd(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* param_ids) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(length)) == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
-
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + sizeof(session_id) + sizeof(num_ids) +
- length);
-
- p->offset = UCI_MSG_OFFSET_SIZE;
- p->layer_specific = 0;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_SESSION_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_SESSION_GET_APP_CONFIG);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, sizeof(session_id) + sizeof(num_ids) + length);
-
- UINT32_TO_STREAM(pp, session_id);
- UINT8_TO_STREAM(pp, num_ids);
- ARRAY_TO_STREAM(pp, param_ids, length);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_get_session_count_cmd
-**
-** Description compose and send SESSION_GET_COUNT_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_get_session_count_cmd(void) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_SESSION_GET_COUNT_CMD_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_SESSION_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_SESSION_GET_COUNT);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_SESSION_GET_COUNT_CMD_SIZE);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_get_session_status_cmd
-**
-** Description compose and send SESSION_GET_STATE_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_get_session_status_cmd(uint32_t session_id) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_SESSION_GET_STATE_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE + UCI_MSG_SESSION_GET_STATE_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_SESSION_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_SESSION_GET_STATE);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_SESSION_GET_STATE_SIZE);
- UINT32_TO_STREAM(pp, session_id);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_get_range_count_cmd
-**
-** Description compose and send RANGE_GET_RANGING_COUNT_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_get_range_count_cmd(uint32_t session_id) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_RANGE_GET_COUNT_CMD_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE + UCI_MSG_RANGE_GET_COUNT_CMD_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_RANGE_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_RANGE_GET_RANGING_COUNT);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_RANGE_GET_COUNT_CMD_SIZE);
- UINT32_TO_STREAM(pp, session_id);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-/*******************************************************************************
-**
-** Function uci_snd_range_start_cmd
-**
-** Description compose and send RANGE_START_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_range_start_cmd(uint32_t session_id) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_RANGE_START_CMD_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE + UCI_MSG_RANGE_START_CMD_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_RANGE_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_RANGE_START);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_RANGE_START_CMD_SIZE);
- UINT32_TO_STREAM(pp, session_id);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_range_stop_cmd
-**
-** Description compose and send RANGE_STOP_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_range_stop_cmd(uint32_t session_id) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_RANGE_STOP_CMD_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE + UCI_MSG_RANGE_STOP_CMD_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_RANGE_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_RANGE_STOP);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_RANGE_STOP_CMD_SIZE);
- UINT32_TO_STREAM(pp, session_id);
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_core_get_device_capability
-**
-** Description compose and send CORE_GET_CAPS_INFO_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_core_get_device_capability(void) {
- UWB_HDR* p;
- uint8_t* pp;
- p = UCI_GET_CMD_BUF(UCI_MSG_CORE_GET_CAPS_INFO_CMD_SIZE);
- if (p == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE + UCI_MSG_CORE_GET_CAPS_INFO_CMD_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_CORE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_CORE_GET_CAPS_INFO);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_CORE_GET_CAPS_INFO_CMD_SIZE);
- uwb_ucif_send_cmd(p);
-
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_multicast_list_update_cmd
-**
-** Description compose and send SESSION_UPDATE_CONTROLLER
-** _MULTICAST_LIST_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_multicast_list_update_cmd(uint32_t session_id, uint8_t action,
- uint8_t noOfControlees,
- uint16_t* shortAddressList,
- uint32_t* subSessionIdList) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(noOfControlees)) == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
-
- p->len =
- (uint16_t)(UCI_MSG_HDR_SIZE + sizeof(session_id) + sizeof(action) +
- sizeof(noOfControlees) + (noOfControlees * SHORT_ADDRESS_LEN) +
- (noOfControlees * SESSION_ID_LEN));
-
- p->offset = UCI_MSG_OFFSET_SIZE;
- p->layer_specific = 0;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_SESSION_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_SESSION_UPDATE_CONTROLLER_MULTICAST_LIST);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, sizeof(session_id) + sizeof(action) +
- sizeof(noOfControlees) +
- (noOfControlees * SHORT_ADDRESS_LEN) +
- (noOfControlees * SESSION_ID_LEN));
-
- UINT32_TO_STREAM(pp, session_id);
- UINT8_TO_STREAM(pp, action);
- UINT8_TO_STREAM(pp, noOfControlees);
- for (uint8_t i = 0; i < noOfControlees; i++) {
- UINT16_TO_STREAM(pp, shortAddressList[i]);
- UINT32_TO_STREAM(pp, subSessionIdList[i]);
- }
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_configure_dt_anchor_for_rr_rdm_list_cmd
-**
-** Description compose and send SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_LIST_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_configure_dt_anchor_for_rr_rdm_list_cmd(uint32_t session_id, uint8_t rr_rdm_count, uint8_t length, uint8_t* data) {
- UWB_HDR* p;
- uint8_t* pp;
- uint16_t total_size = 0;
-
- total_size = sizeof(session_id) + sizeof(rr_rdm_count) + length;
- if ((p = UCI_GET_CMD_BUF(total_size)) == NULL) return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = (uint16_t) (UCI_MSG_HDR_SIZE + total_size);
-
- p->offset = UCI_MSG_OFFSET_SIZE;
- p->layer_specific = 0;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_SESSION_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_LIST);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, total_size);
- UINT32_TO_STREAM(pp, session_id);
- UINT8_TO_STREAM(pp, rr_rdm_count);
- ARRAY_TO_STREAM(pp, data, length);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_set_country_code_cmd
-**
-** Description compose and send SET_COUNTRY_CODE_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_set_country_code_cmd(uint8_t *country_code) {
- UWB_HDR* p;
- uint8_t* pp;
- p = UCI_GET_CMD_BUF(UCI_MSG_ANDROID_SET_COUNTRY_CODE_CMD_SIZE);
- if (p == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE + UCI_MSG_ANDROID_SET_COUNTRY_CODE_CMD_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_ANDROID);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_ANDROID_SET_COUNTRY_CODE);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_ANDROID_SET_COUNTRY_CODE_CMD_SIZE);
- ARRAY8_TO_STREAM(pp, country_code, UCI_MSG_ANDROID_SET_COUNTRY_CODE_CMD_SIZE);
- uwb_ucif_send_cmd(p);
-
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_blink_data_cmd
-**
-** Description compose and send BLINK_DATA_TX_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_blink_data_cmd(uint32_t session_id, uint8_t repetition_count,
- uint8_t app_data_len, uint8_t* app_data) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(sizeof(session_id) + sizeof(repetition_count) +
- sizeof(app_data_len) + app_data_len)) == NULL)
- return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
-
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + sizeof(session_id) +
- sizeof(repetition_count) + sizeof(app_data_len) +
- app_data_len);
-
- p->offset = UCI_MSG_OFFSET_SIZE;
- p->layer_specific = 0;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_RANGE_MANAGE);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_RANGE_BLINK_DATA_TX);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, sizeof(session_id) + sizeof(repetition_count) +
- sizeof(app_data_len) + app_data_len);
-
- UINT32_TO_STREAM(pp, session_id);
- UINT8_TO_STREAM(pp, repetition_count);
- UINT8_TO_STREAM(pp, app_data_len);
- if ((app_data_len > 0) && (app_data != NULL)) {
- ARRAY_TO_STREAM(pp, app_data, app_data_len);
- }
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/* APIs for UWB RF test functionality */
-
-/*******************************************************************************
-**
-** Function uci_snd_test_set_config_cmd
-**
-** Description compose and send TEST_CONFIG_SET_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_test_set_config_cmd(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* data) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(num_ids)) == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
-
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + sizeof(session_id) + sizeof(num_ids) +
- length);
-
- p->offset = UCI_MSG_OFFSET_SIZE;
- p->layer_specific = 0;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_TEST);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_TEST_SET_CONFIG);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, sizeof(session_id) + sizeof(num_ids) + length);
-
- UINT32_TO_STREAM(pp, session_id);
- UINT8_TO_STREAM(pp, num_ids);
- ARRAY_TO_STREAM(pp, data, length);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_test_get_config_cmd
-**
-** Description compose and send TEST_CONFIG_GET_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_test_get_config_cmd(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* param_ids) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(length)) == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
-
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + sizeof(session_id) + sizeof(num_ids) +
- length);
-
- p->offset = UCI_MSG_OFFSET_SIZE;
- p->layer_specific = 0;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_TEST);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_TEST_GET_CONFIG);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, sizeof(session_id) + sizeof(num_ids) + length);
-
- UINT32_TO_STREAM(pp, session_id);
- UINT8_TO_STREAM(pp, num_ids);
- ARRAY_TO_STREAM(pp, param_ids, length);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_test_periodic_tx_cmd
-**
-** Description compose and send TEST_PERIODIC_TX_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_test_periodic_tx_cmd(uint16_t psduLen, uint8_t* psduData) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(psduLen)) == NULL) return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + psduLen);
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_TEST);
- if (psduLen <= UCI_MAX_PAYLOAD_SIZE) {
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_TEST_PERIODIC_TX);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, psduLen);
- } else { /* extended len apdu */
- UCI_MSG_BLD_HDR1(pp, (1 << 7) | UCI_MSG_TEST_PERIODIC_TX);
- UINT8_TO_STREAM(pp, psduLen & 0x00FF);
- UINT8_TO_STREAM(pp, (psduLen & 0xFF00) >> 8);
- }
- if ((psduLen > 0) && (psduData != NULL)) {
- ARRAY_TO_STREAM(pp, psduData, psduLen);
- }
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_test_per_rx_cmd
-**
-** Description compose and send TEST_PER_RX_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_test_per_rx_cmd(uint16_t psduLen, uint8_t* psduData) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(psduLen)) == NULL) return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + psduLen);
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_TEST);
- if (psduLen <= UCI_MAX_PAYLOAD_SIZE) {
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_TEST_PER_RX);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, psduLen);
- } else { /* extended len apdu */
- UCI_MSG_BLD_HDR1(pp, (1 << 7) | UCI_MSG_TEST_PER_RX);
- UINT8_TO_STREAM(pp, psduLen & 0x00FF);
- UINT8_TO_STREAM(pp, (psduLen & 0xFF00) >> 8);
- }
- if ((psduLen > 0) && (psduData != NULL)) {
- ARRAY_TO_STREAM(pp, psduData, psduLen);
- }
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_test_uwb_loopback_cmd
-**
-** Description compose and send TEST_LOOPBACK_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_test_uwb_loopback_cmd(uint16_t psduLen, uint8_t* psduData) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(psduLen)) == NULL) return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = (uint16_t)(UCI_MSG_HDR_SIZE + psduLen);
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_TEST);
- if (psduLen <= UCI_MAX_PAYLOAD_SIZE) {
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_TEST_LOOPBACK);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, psduLen);
- } else { /* extended len apdu */
- UCI_MSG_BLD_HDR1(pp, (1 << 7) | UCI_MSG_TEST_LOOPBACK);
- UINT8_TO_STREAM(pp, psduLen & 0x00FF);
- UINT8_TO_STREAM(pp, (psduLen & 0xFF00) >> 8);
- }
- if ((psduLen > 0) && (psduData != NULL)) {
- ARRAY_TO_STREAM(pp, psduData, psduLen);
- }
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_test_rx_cmd
-**
-** Description compose and send TEST_RX_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_test_rx_cmd(void) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_TEST_RX_CMD_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_TEST);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_TEST_RX);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_TEST_RX_CMD_SIZE);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_snd_test_stop_session_cmd
-**
-** Description compose and send TEST_STOP_SESSION_CMD command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_snd_test_stop_session_cmd(void) {
- UWB_HDR* p;
- uint8_t* pp;
-
- if ((p = UCI_GET_CMD_BUF(UCI_MSG_TEST_STOP_SESSION_CMD_SIZE)) == NULL)
- return (UCI_STATUS_FAILED);
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = UCI_MSG_HDR_SIZE;
- p->offset = UCI_MSG_OFFSET_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_TEST);
- UCI_MSG_BLD_HDR1(pp, UCI_MSG_TEST_STOP_SESSION);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, UCI_MSG_TEST_STOP_SESSION_CMD_SIZE);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_send_data_frame
-**
-** Description compose and send data packets
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_send_data_frame(uint32_t session_id, uint8_t* p_addr, uint8_t dest_end_point, uint8_t sequence_num,
- uint16_t data_len, uint8_t* p_data) {
- UCI_TRACE_I("uci_send_data_frame()");
- UWB_HDR* p;
- uint8_t* pp;
- uint16_t uci_pkt_len;
- uint8_t pbf = 1;
- tUWB_RESPONSE evt_data;
- uint16_t max_supported_uci_payload;
- uint16_t starIndex = 0;
- bool isFirstSegment = true;
-
- int16_t total_size = sizeof(session_id) + EXTENDED_ADDRESS_LEN + data_len +
- sizeof(dest_end_point) + sizeof(uint8_t) +
- sizeof(data_len);
- data_tx_cb.curr_session_id = session_id;
-
- for (int i = 0; i < data_tx_cb.no_of_sessions; i++) {
- if (data_tx_cb.curr_session_id == data_tx_cb.tx_data_pkt[i].session_id) {
- data_tx_cb.curr_session_idx = i;
- }
- }
-
-
- if((p_data == nullptr) || (p_addr == nullptr)){
- evt_data.status = UCI_STATUS_FAILED;
- (*uwb_cb.p_resp_cback)(UWB_SEND_DATA_STATUS_EVT, &evt_data);
- return (UCI_STATUS_FAILED);
- }
-
- max_supported_uci_payload = data_tx_cb.max_data_pkt_payload_size;
- while (data_len > 0) {
- if (total_size <= max_supported_uci_payload) {
- pbf = 0; /* last fragment */
- uci_pkt_len = total_size;
- } else { /* Handling PBF as per generic specification*/
- pbf = 1;
- uci_pkt_len = max_supported_uci_payload;
- }
- if ((p = UCI_GET_CMD_BUF(uci_pkt_len)) == NULL) {
- evt_data.status = UCI_STATUS_FAILED;
- (*uwb_cb.p_resp_cback)(UWB_SEND_DATA_STATUS_EVT, &evt_data);
- }
-
- p->event = BT_EVT_TO_UWB_UCI;
- p->len = uci_pkt_len + UCI_MSG_HDR_SIZE;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- UCI_DATA_PBLD_HDR(pp, pbf, uci_pkt_len);
-
- if (isFirstSegment) {
- UINT32_TO_STREAM(pp, session_id);
- ARRAY_TO_STREAM(pp, p_addr, EXTENDED_ADDRESS_LEN);
- UINT8_TO_STREAM(pp, dest_end_point);
- UINT8_TO_STREAM(pp, sequence_num);
- uci_pkt_len -= (sizeof(session_id) + EXTENDED_ADDRESS_LEN + sizeof(dest_end_point) +
- sizeof(data_len) + sizeof(uint8_t));
- }
- if(!isFirstSegment){
- uci_pkt_len -= sizeof(data_len);
- }
- UINT16_TO_STREAM(pp, uci_pkt_len);
-
- ARRAY_TO_STREAM(pp, (p_data + starIndex), uci_pkt_len);
- starIndex += uci_pkt_len;
- data_len -= uci_pkt_len;
- total_size = sizeof(data_len) + data_len;
-
- uwb_ucif_send_data_frame(p);
- isFirstSegment = false;
- }
- evt_data.status = UCI_STATUS_OK;
- (*uwb_cb.p_resp_cback)(UWB_SEND_DATA_STATUS_EVT, &evt_data);
- return (UCI_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function uci_send_range_round_index_update_cmd
-**
-** Description compose and send range round index update command
-**
-** Returns status
-**
-*******************************************************************************/
-uint8_t uci_send_range_round_index_update_cmd(uint8_t dlTdoaRole, uint32_t session_id, uint8_t number_of_active_rngIndex,
- uint8_t rng_round_index_len, uint8_t* p_rng_round_index) {
- UWB_HDR* p;
- uint8_t* pp;
- uint16_t total_size;
- uint8_t oid;
-
- total_size = sizeof(session_id) + sizeof(number_of_active_rngIndex) + rng_round_index_len;
-
- if ((p = UCI_GET_CMD_BUF(total_size)) == NULL) return (UCI_STATUS_FAILED);
-
- p->event = BT_EVT_TO_UWB_UCI;
-
- p->len = (uint16_t) (UCI_MSG_HDR_SIZE + total_size);
-
- p->offset = UCI_MSG_OFFSET_SIZE;
- p->layer_specific = 0;
- pp = (uint8_t*)(p + 1) + p->offset;
-
- if(dlTdoaRole == 0x00) {
- oid = UCI_MSG_SESSION_UPDATE_ACTIVE_ROUNDS_OF_DT_ANCHOR;
- } else {
- oid = UCI_MSG_SESSION_UPDATE_ACTIVE_ROUNDS_OF_DT_TAG;
- }
-
- UCI_MSG_BLD_HDR0(pp, UCI_MT_CMD, UCI_GID_SESSION_MANAGE);
- UCI_MSG_BLD_HDR1(pp, oid);
- UINT8_TO_STREAM(pp, 0x00);
- UINT8_TO_STREAM(pp, total_size);
-
- UINT32_TO_STREAM(pp, session_id);
- UINT8_TO_STREAM(pp, number_of_active_rngIndex);
- ARRAY_TO_STREAM(pp, p_rng_round_index, rng_round_index_len);
-
- uwb_ucif_send_cmd(p);
- return (UCI_STATUS_OK);
-}
diff --git a/src/uwb/uci/uci_hrcv.cc b/src/uwb/uci/uci_hrcv.cc
deleted file mode 100755
index 69c5591..0000000
--- a/src/uwb/uci/uci_hrcv.cc
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021-2022 NXP.
- *
- * 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.
- */
-
-/******************************************************************************
- *
- * This file contains function of the UWB unit to receive/process UCI
- * commands.
- *
- ******************************************************************************/
-
-#include "uci_defs.h"
-#include "uci_hmsgs.h"
-#include "uci_log.h"
-#include "uci_test_defs.h"
-#include "uwa_sys.h"
-#include "uwb_api.h"
-#include "uwb_gki.h"
-#include "uwb_hal_int.h"
-#include "uwb_int.h"
-#include "uwb_osal_common.h"
-#include "uwb_target.h"
-
-/*******************************************************************************
- **
- ** Function uwb_proc_core_rsp
- **
- ** Description Process UCI responses in the CORE group
- **
- ** Returns true-caller of this function to free the GKI buffer p_msg
- **
- *******************************************************************************/
-bool uwb_proc_core_rsp(uint8_t op_code, uint8_t* p_buf, uint16_t len) {
- bool free = true;
-
- /* process the message based on the opcode and message type */
- switch (op_code) {
- case UCI_MSG_CORE_DEVICE_RESET:
- uwb_ucif_proc_core_device_reset_rsp_status(p_buf, len);
- break;
- case UCI_MSG_CORE_DEVICE_INFO:
- uwb_ucif_proc_get_device_info_rsp(p_buf, len);
- break;
- case UCI_MSG_CORE_GET_CAPS_INFO:
- uwb_ucif_proc_get_device_capability_rsp(p_buf, len);
- break;
- case UCI_MSG_CORE_GET_CONFIG:
- uwb_ucif_proc_core_get_config_rsp(p_buf, len);
- break;
- case UCI_MSG_CORE_SET_CONFIG:
- uwb_ucif_proc_core_set_config_status(p_buf, len);
- break;
- default:
- UCI_TRACE_E("%s: unknown opcode:0x%x", __func__, op_code);
- break;
- }
-
- return free;
-}
-/*******************************************************************************
- **
- ** Function uci_proc_core_management_ntf
- **
- ** Description Process UCI notifications in the core Management group
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_core_management_ntf(uint8_t op_code, uint8_t* p_buf,
- uint16_t len) {
- switch (op_code) {
- case UCI_MSG_CORE_GENERIC_ERROR_NTF:
- uwb_ucif_proc_core_generic_error_ntf(p_buf, len);
- break;
- case UCI_MSG_CORE_DEVICE_STATUS_NTF:
- uwb_ucif_proc_core_device_status(p_buf, len);
- break;
- default:
- UCI_TRACE_E("%s: unknown opcode:0x%x", __func__, op_code);
- break;
- }
-}
-
-/*******************************************************************************
- **
- ** Function uci_proc_session_management_rsp
- **
- ** Description Process UCI responses in the Session Management group
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_session_management_rsp(uint8_t op_code, uint8_t* p_buf,
- uint16_t len) {
- switch (op_code) {
- case UCI_MSG_SESSION_INIT:
- uwb_ucif_session_management_status(UWB_SESSION_INIT_REVT, p_buf, len);
- break;
- case UCI_MSG_SESSION_DEINIT:
- uwb_ucif_session_management_status(UWB_SESSION_DEINIT_REVT, p_buf, len);
- break;
- case UCI_MSG_SESSION_GET_APP_CONFIG:
- uwb_ucif_proc_app_get_config_status(p_buf, len);
- break;
- case UCI_MSG_SESSION_SET_APP_CONFIG:
- uwb_ucif_proc_app_set_config_status(p_buf, len);
- break;
- case UCI_MSG_SESSION_GET_COUNT:
- uwb_ucif_session_management_status(UWB_SESSION_GET_COUNT_REVT, p_buf,
- len);
- break;
- case UCI_MSG_SESSION_GET_STATE:
- uwb_ucif_session_management_status(UWB_SESSION_GET_STATE_REVT, p_buf,
- len);
- break;
- case UCI_MSG_SESSION_UPDATE_CONTROLLER_MULTICAST_LIST:
- uwb_ucif_session_management_status(UWB_SESSION_UPDATE_MULTICAST_LIST_REVT,
- p_buf, len);
- break;
- case UCI_MSG_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_LIST:
- uwb_ucif_session_management_status(UWB_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT, p_buf, len);
- break;
- case UCI_MSG_SESSION_UPDATE_ACTIVE_ROUNDS_OF_DT_ANCHOR:
- case UCI_MSG_SESSION_UPDATE_ACTIVE_ROUNDS_OF_DT_TAG:
- uwb_ucif_session_management_status(UWB_SESSION_ACTIVE_ROUNDS_INDEX_UPDATE_REVT, p_buf,
- len);
- break;
- default:
- UCI_TRACE_E("%s: unknown opcode:0x%x", __func__, op_code);
- break;
- }
-}
-
-/*******************************************************************************
- **
- ** Function uci_proc_test_management_rsp
- **
- ** Description Process UCI responses in the Test Management group
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_test_management_rsp(uint8_t op_code, uint8_t* p_buf,
- uint16_t len) {
- switch (op_code) {
- case UCI_MSG_TEST_GET_CONFIG:
- uwb_ucif_proc_test_get_config_status(p_buf, len);
- break;
- case UCI_MSG_TEST_SET_CONFIG:
- uwb_ucif_proc_test_set_config_status(p_buf, len);
- break;
- case UCI_MSG_TEST_PERIODIC_TX:
- uwb_ucif_test_management_status(UWB_TEST_PERIODIC_TX_REVT, p_buf, len);
- break;
- case UCI_MSG_TEST_PER_RX:
- uwb_ucif_test_management_status(UWB_TEST_PER_RX_REVT, p_buf, len);
- break;
- case UCI_MSG_TEST_LOOPBACK:
- uwb_ucif_test_management_status(UWB_TEST_LOOPBACK_REVT, p_buf, len);
- break;
- case UCI_MSG_TEST_RX:
- uwb_ucif_test_management_status(UWB_TEST_RX_REVT, p_buf, len);
- break;
- case UCI_MSG_TEST_STOP_SESSION:
- uwb_ucif_test_management_status(UWB_TEST_STOP_SESSION_REVT, p_buf, len);
- break;
- default:
- UCI_TRACE_E("%s: unknown opcode:0x%x", __func__, op_code);
- break;
- }
-}
-
-/*******************************************************************************
- **
- ** Function uci_proc_session_management_ntf
- **
- ** Description Process UCI notifications in the Session Management group
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_session_management_ntf(uint8_t op_code, uint8_t* p_buf,
- uint16_t len) {
- switch (op_code) {
- case UCI_MSG_SESSION_STATUS_NTF:
- uwb_ucif_proc_session_status(p_buf, len);
- break;
- case UCI_MSG_SESSION_UPDATE_CONTROLLER_MULTICAST_LIST:
- uwb_ucif_proc_multicast_list_update_ntf(p_buf, len);
- break;
- case UCI_MSG_DATA_CREDIT_NTF:
- uwb_ucif_proc_data_credit_ntf(p_buf, len);
- break;
- case UCI_MSG_DATA_TRANSFER_STATUS_NTF:
- uwb_ucif_proc_data_transfer_status_ntf(p_buf, len);
- break;
- default:
- UCI_TRACE_E("%s: unknown opcode:0x%x", __func__, op_code);
- break;
- }
-}
-
-/*******************************************************************************
- **
- ** Function uci_proc_rang_management_rsp
- **
- ** Description Process UCI responses in the Ranging Management group
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_rang_management_rsp(uint8_t op_code, uint8_t* p_buf,
- uint16_t len) {
- switch (op_code) {
- case UCI_MSG_RANGE_START:
- uwb_ucif_range_management_status(UWB_START_RANGE_REVT, p_buf, len);
- break;
- case UCI_MSG_RANGE_STOP:
- uwb_ucif_range_management_status(UWB_STOP_RANGE_REVT, p_buf, len);
- break;
- case UCI_MSG_RANGE_GET_RANGING_COUNT:
- uwb_ucif_get_range_count_status(UWB_GET_RANGE_COUNT_REVT, p_buf, len);
- break;
- case UCI_MSG_RANGE_BLINK_DATA_TX:
- uwb_ucif_range_management_status(UWB_BLINK_DATA_TX_REVT, p_buf, len);
- break;
- default:
- UCI_TRACE_E("%s: unknown opcode:0x%x", __func__, op_code);
- break;
- }
-}
-
-/*******************************************************************************
- **
- ** Function uci_proc_rang_management_ntf
- **
- ** Description Process UCI notifications in the Ranging Management group
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_rang_management_ntf(uint8_t op_code, uint8_t* p_buf,
- uint16_t len) {
- switch (op_code) {
- case UCI_MSG_RANGE_DATA_NTF:
- uwb_ucif_proc_ranging_data(p_buf, len);
- break;
- case UCI_MSG_RANGE_BLINK_DATA_TX_NTF:
- uwb_ucif_proc_send_blink_data_ntf(p_buf, len);
- break;
- default:
- UCI_TRACE_E("%s: unknown opcode:0x%x", __func__, op_code);
- break;
- }
-}
-
-/*******************************************************************************
- **
- ** Function uci_proc_android_rsp
- **
- ** Description Process UCI responses in the vendor Android group
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_android_rsp(uint8_t op_code, uint8_t* p_buf, uint16_t len) {
- switch (op_code) {
- case UCI_MSG_ANDROID_GET_POWER_STATS:
- break;
- case UCI_MSG_ANDROID_SET_COUNTRY_CODE:
- uwb_ucif_proc_android_set_country_code_status(p_buf, len);
- break;
- default:
- UCI_TRACE_E("%s: unknown opcode:0x%x", __func__, op_code);
- break;
- }
-}
-
-/*******************************************************************************
- **
- ** Function uci_proc_proprietary_ntf
- **
- ** Description Process UCI notifications in the proprietary Management group
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_vendor_specific_ntf(uint8_t gid, uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE evt_data;
- UNUSED(gid);
- if (len > 0) {
-
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("ext response callback is null");
- } else {
- evt_data.vendor_specific_ntf.len = len;
- if (evt_data.vendor_specific_ntf.len > 0) {
- STREAM_TO_ARRAY(evt_data.vendor_specific_ntf.data, p_buf,
- len);
- }
- (*uwb_cb.p_resp_cback)(UWB_VENDOR_SPECIFIC_UCI_NTF_EVT, &evt_data);
- }
- } else {
- UCI_TRACE_E("%s: len is zero", __func__);
- }
-}
-
-/*******************************************************************************
- **
- ** Function uci_proc_raw_cmd_rsp
- **
- ** Description Process RAW CMD responses
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_raw_cmd_rsp(uint8_t* p_buf, uint16_t len) {
- tUWB_RAW_CBACK* p_cback = (tUWB_RAW_CBACK*)uwb_cb.p_raw_cmd_cback;
-
- UCI_TRACE_I(" uci_proc_raw_cmd_rsp:"); // for debug
-
- /* If there's a pending/stored command, restore the associated address of the
- * callback function */
- if (p_cback == NULL) {
- UCI_TRACE_E("p_raw_cmd_cback is null");
- } else {
- (*p_cback)(0 /*unused in this case*/, len, p_buf);
- uwb_cb.p_raw_cmd_cback = NULL;
- }
- uwb_cb.rawCmdCbflag = false;
- uwb_ucif_update_cmd_window();
-}
-
-/*******************************************************************************
- **
- ** Function uci_proc_test_management_ntf
- **
- ** Description Process UCI notifications in the Test Management group
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_proc_test_management_ntf(uint8_t op_code, uint8_t* p_buf,
- uint16_t len) {
- switch (op_code) {
- case UCI_MSG_TEST_PERIODIC_TX:
- uwb_ucif_proc_rf_test_data(UWB_TEST_PERIODIC_TX_DATA_REVT, p_buf, len);
- break;
- case UCI_MSG_TEST_PER_RX:
- uwb_ucif_proc_rf_test_data(UWB_TEST_PER_RX_DATA_REVT, p_buf, len);
- break;
- case UCI_MSG_TEST_LOOPBACK:
- uwb_ucif_proc_rf_test_data(UWB_TEST_LOOPBACK_DATA_REVT, p_buf, len);
- break;
- case UCI_MSG_TEST_RX:
- uwb_ucif_proc_rf_test_data(UWB_TEST_RX_DATA_REVT, p_buf, len);
- break;
- default:
- UCI_TRACE_E("%s: unknown opcode:0x%x", __func__, op_code);
- break;
- }
-}
diff --git a/src/uwb/uwb/uwb_main.cc b/src/uwb/uwb/uwb_main.cc
deleted file mode 100755
index b79de22..0000000
--- a/src/uwb/uwb/uwb_main.cc
+++ /dev/null
@@ -1,1172 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021-2022 NXP.
- *
- * 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.
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "uci_hmsgs.h"
-#include "uci_log.h"
-#include "uwa_dm_int.h"
-#include "uwa_sys.h"
-#include "uwb_api.h"
-#include "uwb_gki.h"
-#include "uwb_hal_api.h"
-#include "uwb_hal_int.h"
-#include "uwb_int.h"
-#include "uwb_osal_common.h"
-#include "uwb_target.h"
-
-/****************************************************************************
-** Declarations
-****************************************************************************/
-tUWB_CB uwb_cb;
-tDATA_TX_CB data_tx_cb;
-
-/*******************************************************************************
-**
-** Function uwb_state_name
-**
-** Description This function returns the state name.
-**
-** NOTE conditionally compiled to save memory.
-**
-** Returns pointer to the name
-**
-*******************************************************************************/
-std::string uwb_state_name(uint8_t state) {
- switch (state) {
- case UWB_STATE_NONE:
- return "NONE";
- case UWB_STATE_W4_HAL_OPEN:
- return "W4_HAL_OPEN";
- case UWB_STATE_IDLE:
- return "IDLE";
- case UWB_STATE_ACTIVE:
- return "ACTIVE";
- case UWB_STATE_CLOSING:
- return "CLOSING";
- case UWB_STATE_W4_HAL_CLOSE:
- return "W4_HAL_CLOSE";
- default:
- return "???? UNKNOWN STATE";
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_hal_event_name
-**
-** Description This function returns the HAL event name.
-**
-** NOTE conditionally compiled to save memory.
-**
-** Returns pointer to the name
-**
-*******************************************************************************/
-
-std::string uwb_hal_event_name(uint8_t event) {
- switch (event) {
- case HAL_UWB_OPEN_CPLT_EVT:
- return "HAL_UWB_OPEN_CPLT_EVT";
-
- case HAL_UWB_CLOSE_CPLT_EVT:
- return "HAL_UWB_CLOSE_CPLT_EVT";
-
- case HAL_UWB_ERROR_EVT:
- return "HAL_UWB_ERROR_EVT";
-
- default:
- return "???? UNKNOWN EVENT";
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_main_notify_enable_status
-**
-** Description Notify status of Enable/PowerOffSleep/PowerCycle
-**
-*******************************************************************************/
-static void uwb_main_notify_enable_status(tUWB_STATUS uwb_status) {
- tUWB_RESPONSE evt_data;
-
- evt_data.status = uwb_status;
-
- if (uwb_cb.p_resp_cback) {
- (*uwb_cb.p_resp_cback)(UWB_ENABLE_REVT, &evt_data);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_enabled
-**
-** Description UWBC enabled, proceed with stack start up.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_enabled(tUWB_STATUS uwb_status,
- __attribute__((unused)) UWB_HDR* p_init_rsp_msg) {
- tUWB_RESPONSE evt_data;
-
- memset(&evt_data, 0, sizeof(tUWB_RESPONSE));
-
- if (uwb_status == UCI_STATUS_OK) {
- uwb_set_state(UWB_STATE_IDLE);
- }
- uwb_main_notify_enable_status(uwb_status);
-}
-
-/*******************************************************************************
-**
-** Function uwb_set_state
-**
-** Description Set the state of UWB stack
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_set_state(tUWB_STATE uwb_state) {
- UCI_TRACE_I("uwb_set_state %d (%s)->%d (%s)", uwb_cb.uwb_state,
- uwb_state_name(uwb_cb.uwb_state).c_str(), uwb_state,
- uwb_state_name(uwb_state).c_str());
- uwb_cb.uwb_state = uwb_state;
-}
-
-/*******************************************************************************
-**
-** Function uwb_gen_cleanup
-**
-** Description Clean up for both going into low power mode and disabling
-** UWB
-**
-*******************************************************************************/
-void uwb_gen_cleanup(void) {
- /* clear any pending CMD/RSP */
- uwb_main_flush_cmd_queue();
- uwb_main_flush_data_queue();
-}
-
-/*******************************************************************************
-**
-** Function uwb_main_handle_hal_evt
-**
-** Description Handle BT_EVT_TO_UWB_MSGS
-**
-*******************************************************************************/
-void uwb_main_handle_hal_evt(tUWB_HAL_EVT_MSG* p_msg) {
- // uint8_t* ps;
-
- UCI_TRACE_I("HAL event=0x%x", p_msg->hal_evt);
-
- switch (p_msg->hal_evt) {
- case HAL_UWB_OPEN_CPLT_EVT: /* only for failure case */
- uwb_enabled(UWB_STATUS_FAILED, NULL);
- break;
-
- case HAL_UWB_CLOSE_CPLT_EVT:
- if (uwb_cb.p_resp_cback) {
- if (uwb_cb.uwb_state == UWB_STATE_W4_HAL_CLOSE) {
- uwb_set_state(UWB_STATE_NONE);
- (*uwb_cb.p_resp_cback)(UWB_DISABLE_REVT, NULL);
- uwb_cb.p_resp_cback = NULL;
- } else {
- /* found error during initialization */
- uwb_set_state(UWB_STATE_NONE);
- uwb_main_notify_enable_status(UWB_STATUS_FAILED);
- }
- }
- break;
-
- case HAL_UWB_INIT_CPLT_EVT: /* only for failure case */
- uwb_set_state(UWB_STATE_NONE);
- break;
-
- case HAL_UWB_ERROR_EVT:
- switch (p_msg->status) {
- case HAL_UWB_STATUS_ERR_TRANSPORT:
- /* Notify app of transport error */
- if (uwb_cb.p_resp_cback) {
- (*uwb_cb.p_resp_cback)(UWB_UWBS_TRANSPORT_ERR_REVT, NULL);
-
- /* if enabling UWB, notify upper layer of failure after closing HAL
- */
- if (uwb_cb.uwb_state < UWB_STATE_IDLE) {
- uwb_enabled(UWB_STATUS_FAILED, NULL);
- }
- }
- break;
- default:
- break;
- }
- break;
- default:
- UCI_TRACE_E("unhandled event (0x%x).", p_msg->hal_evt);
- break;
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_main_flush_cmd_queue
-**
-** Description This function is called when setting power off sleep state.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_main_flush_cmd_queue(void) {
- UWB_HDR* p_msg;
-
- UCI_TRACE_I(__func__);
-
- /* initialize command window */
- uwb_cb.uci_cmd_window = UCI_MAX_CMD_WINDOW;
-
- /* Stop command-pending timer */
- uwb_stop_quick_timer(&uwb_cb.uci_wait_rsp_timer);
- uwb_cb.is_resp_pending = false;
- uwb_cb.cmd_retry_count = 0;
-
- /* dequeue and free buffer */
- while ((p_msg = (UWB_HDR*)phUwb_GKI_dequeue(&uwb_cb.uci_cmd_xmit_q)) !=
- NULL) {
- phUwb_GKI_freebuf(p_msg);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_main_flush_data_queue
-**
-** Description This function is called when setting power off sleep state.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_main_flush_data_queue(void) {
- UWB_HDR* p_msg;
-
- UCI_TRACE_I(__func__);
-
- /* Stop command-pending timer */
- uwb_stop_quick_timer(&uwb_cb.uci_wait_credit_ntf_timer);
- uwb_cb.is_credit_ntf_pending = false;
- uwb_cb.data_pkt_retry_count = 0;
-
- /* dequeue and free buffer */
- for (int i = 0; i < data_tx_cb.no_of_sessions; i++) {
- while ((p_msg = (UWB_HDR*)phUwb_GKI_dequeue(&data_tx_cb.tx_data_pkt[i].tx_data_pkt_q)) !=
- NULL) {
- phUwb_GKI_freebuf(p_msg);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_main_post_hal_evt
-**
-** Description This function posts HAL event to UWB_TASK
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_main_post_hal_evt(uint8_t hal_evt, tUWB_STATUS status) {
- tUWB_HAL_EVT_MSG* p_msg;
-
- p_msg = (tUWB_HAL_EVT_MSG*)phUwb_GKI_getbuf(sizeof(tUWB_HAL_EVT_MSG));
- if (p_msg != NULL) {
- /* Initialize UWB_HDR */
- p_msg->hdr.len = 0;
- p_msg->hdr.event = BT_EVT_TO_UWB_MSGS;
- p_msg->hdr.offset = 0;
- p_msg->hdr.layer_specific = 0;
- p_msg->hal_evt = hal_evt;
- p_msg->status = status;
- phUwb_GKI_send_msg(UWB_TASK, UWB_MBOX_ID, p_msg);
- } else {
- UCI_TRACE_E("No buffer");
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_main_hal_cback
-**
-** Description HAL event handler
-**
-** Returns void
-**
-*******************************************************************************/
-static void uwb_main_hal_cback(uint8_t event, tUWB_STATUS status) {
- UCI_TRACE_I("uwb_main_hal_cback event: %s(0x%x), status=%d",
- uwb_hal_event_name(event).c_str(), event, status);
- switch (event) {
- case HAL_UWB_OPEN_CPLT_EVT:
- /*
- ** if UWB_Disable() is called before receiving HAL_UWB_OPEN_CPLT_EVT,
- ** then wait for HAL_UWB_CLOSE_CPLT_EVT.
- */
- if (uwb_cb.uwb_state == UWB_STATE_W4_HAL_OPEN) {
- if (status == HAL_UWB_STATUS_OK) {
- /* Notify UWB_TASK that UCI transport is initialized */
- phUwb_GKI_send_event(UWB_TASK, UWB_TASK_EVT_TRANSPORT_READY);
- } else {
- uwb_main_post_hal_evt(event, status);
- }
- }
- break;
-
- case HAL_UWB_INIT_CPLT_EVT:
- UCI_TRACE_D("uwb_main_hal_cback HAL Init complete %x", event);
- break;
-
- case HAL_UWB_CLOSE_CPLT_EVT:
- case HAL_UWB_ERROR_EVT:
- uwb_main_post_hal_evt(event, status);
- break;
-
- default:
- UCI_TRACE_E("uwb_main_hal_cback unhandled event %x", event);
- break;
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_main_hal_data_cback
-**
-** Description HAL data event handler
-**
-** Returns void
-**
-*******************************************************************************/
-static void uwb_main_hal_data_cback(uint16_t data_len, uint8_t* p_data) {
- UWB_HDR* p_msg;
-
- /* ignore all data while shutting down Helio */
- if (uwb_cb.uwb_state == UWB_STATE_W4_HAL_CLOSE ||
- uwb_cb.uwb_state == UWB_STATE_W4_HAL_OPEN) {
- return;
- }
- if (p_data) {
- p_msg = (UWB_HDR*)phUwb_GKI_getpoolbuf(UWB_UCI_POOL_ID);
- if (p_msg != NULL) {
- /* Initialize UWB_HDR */
- p_msg->len = data_len;
- p_msg->event = BT_EVT_TO_UWB_UCI;
- p_msg->offset = UWB_RECEIVE_MSGS_OFFSET;
- /* no need to check length, it always less than pool size */
- memcpy((uint8_t*)(p_msg + 1) + p_msg->offset, p_data, p_msg->len);
-
- phUwb_GKI_send_msg(UWB_TASK, UWB_MBOX_ID, p_msg);
- } else {
- UCI_TRACE_E("No buffer");
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function UWB_Enable
-**
-** Description This function enables UWBS. Prior to calling UWB_Enable:
-** - the UWBS must be powered up, and ready to receive
-** commands.
-** - GKI must be enabled
-** - UWB_TASK must be started
-** - UCIT_TASK must be started (if using dedicated UCI
-** transport)
-**
-** This function opens the UCI transport (if applicable),
-** resets the UWB Subsystem, and initializes the UWB
-** subsystems.
-**
-** When the UWB startup procedure is completed, an
-** UWB_ENABLE_REVT is returned to the application using the
-** tUWB_RESPONSE_CBACK.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_Enable(tUWB_RESPONSE_CBACK* p_cback,
- tUWB_TEST_RESPONSE_CBACK* p_test_cback) {
- UCI_TRACE_I(__func__);
- /* Validate callback */
- if (!p_cback) {
- return (UWB_STATUS_INVALID_PARAM);
- }
- uwb_set_state(UWB_STATE_W4_HAL_OPEN);
- uwb_cb.p_resp_cback = p_cback;
- uwb_cb.p_test_resp_cback = p_test_cback;
- uwb_cb.p_hal->open(uwb_main_hal_cback, uwb_main_hal_data_cback);
- return (UWB_STATUS_OK);
-}
-
-/*******************************************************************************
-**
-** Function UWB_Disable
-**
-** Description This function performs clean up routines for shutting down
-** UWB and closes the UCI transport (if using dedicated UCI
-** transport).
-**
-** When the UWB shutdown procedure is completed, an
-** UWB_DISABLED_REVT is returned to the application using the
-** tUWB_RESPONSE_CBACK.
-**
-** Returns nothing
-**
-*******************************************************************************/
-void UWB_Disable(void) {
- UCI_TRACE_I("uwb_state = %d", uwb_cb.uwb_state);
-
- if (uwb_cb.uwb_state == UWB_STATE_NONE) {
- uwb_set_state(UWB_STATE_NONE);
- if (uwb_cb.p_resp_cback) {
- (*uwb_cb.p_resp_cback)(UWB_DISABLE_REVT, NULL);
- uwb_cb.p_resp_cback = NULL;
- uwb_cb.p_test_resp_cback = NULL;
- }
- return;
- }
-
- /* Close transport and clean up */
- uwb_task_shutdown_uwbc();
-}
-
-/*******************************************************************************
-**
-** Function UWB_Init
-**
-** Description This function initializes control block for UWB
-**
-** Returns nothing
-**
-*******************************************************************************/
-void UWB_Init(tHAL_UWB_CONTEXT* p_hal_entry_cntxt) {
- /* Clear uwb control block */
- memset(&uwb_cb, 0, sizeof(tUWB_CB));
- uwb_cb.p_hal = p_hal_entry_cntxt->hal_entry_func;
- uwb_cb.uwb_state = UWB_STATE_NONE;
- uwb_cb.uci_cmd_window = UCI_MAX_CMD_WINDOW;
- uwb_cb.retry_rsp_timeout =
- ((UWB_CMD_RETRY_TIMEOUT * QUICK_TIMER_TICKS_PER_SEC) / 1000);
- uwb_cb.uci_wait_rsp_tout =
- ((UWB_CMD_CMPL_TIMEOUT * QUICK_TIMER_TICKS_PER_SEC) / 1000);
- uwb_cb.pLast_cmd_buf = NULL;
- uwb_cb.is_resp_pending = false;
- uwb_cb.is_credit_ntf_pending = false;
- data_tx_cb.max_data_pkt_payload_size = 255;
- data_tx_cb.max_msg_size = 255;
- data_tx_cb.no_of_sessions = 0;
- uwb_cb.cmd_retry_count = 0;
- uwb_cb.is_recovery_in_progress = false;
- uwb_cb.IsConformaceTestEnabled = false;
- uwb_cb.uci_credit_ntf_timeout = ((UWB_CMD_CMPL_TIMEOUT * QUICK_TIMER_TICKS_PER_SEC) / 1000); // currently used same timeout value as cmd timeout
- uwb_cb.data_credits = 1;
- /* initialize the segment handling context */
- chained_packet.offset = 0;
- uwb_cb.is_first_frgmnt_done = false;
- chained_packet.oid = 0xFF;
- chained_packet.gid = 0xFF;
-}
-
-/*******************************************************************************
-**
-** Function UWB_GetDeviceInfo
-**
-** Description This function is called to get Device Info
-** The response from UWBS is reported with an
-** UWB_GET_DEVICE_INFO_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters None
-**
-** Returns none
-**
-*******************************************************************************/
-tUWB_STATUS UWB_GetDeviceInfo() { return uci_snd_get_device_info_cmd(); }
-
-/*******************************************************************************
-**
-** Function UWB_DeviceResetCommand
-**
-** Description This function is called to send Device Reset Command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_DEVICE_RESET_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters resetConfig - Vendor Specific Reset Config to be sent
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-
-tUWB_STATUS UWB_DeviceResetCommand(uint8_t resetConfig) {
- return uci_snd_device_reset_cmd(resetConfig);
-}
-
-/*******************************************************************************
-**
-** Function UWB_SetCoreConfig
-**
-** Description This function is called to send the configuration
-** parameters.
-** The response from UWBS is reported with an
-** UWB_SET_CORE_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters tlv_size - the length of p_param_tlvs.
-** p_param_tlvs - the parameter ID/Len/Value list
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SetCoreConfig(uint8_t tlv_size, uint8_t* p_param_tlvs) {
- return uci_snd_core_set_config_cmd(p_param_tlvs, tlv_size);
-}
-
-/*******************************************************************************
-**
-** Function UWB_GetCoreConfig
-**
-** Description This function is called to retrieve the configuration
-** parameters from UWBS.
-** The response from UWBS is reported with an
-** UWB_GET_CORE_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters num_ids - the number of parameter IDs
-** p_param_ids - the parameter ID list.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_GetCoreConfig(uint8_t num_ids, uint8_t* p_param_ids) {
- return uci_snd_core_get_config_cmd(p_param_ids, num_ids);
-}
-
-/*******************************************************************************
-**
-** Function UWB_SessionInit
-**
-** Description This function is called to send session init command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_SESSION_INIT_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SessionInit(uint32_t session_id, uint8_t session_type) {
- return uci_snd_session_init_cmd(session_id, session_type);
-}
-
-/*******************************************************************************
-**
-** Function UWB_HalSessionInit
-**
-** Description This function is called to send session init command to
-** HAL.
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_HalSessionInit(uint32_t session_id) {
- return uwb_cb.p_hal->SessionInitialization(session_id);
-}
-
-/*******************************************************************************
-**
-** Function UWB_SessionDeInit
-**
-** Description This function is called to send session DeInit command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_SESSION_DEINIT_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SessionDeInit(uint32_t session_id) {
- return uci_snd_session_deinit_cmd(session_id);
-}
-
-/*******************************************************************************
-**
-** Function UWB_GetAppConfig
-**
-** Description This function is called to retrieve the parameter TLV from
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_GET_APP_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - All APP configurations belonging to this
-** Session ID
-** num_ids - the number of parameter IDs
-** length - Length of app parameter ID
-** p_param_ids - the parameter ID list.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_GetAppConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* p_param_ids) {
- return uci_snd_app_get_config_cmd(session_id, num_ids, length, p_param_ids);
-}
-
-/*******************************************************************************
-**
-** Function UWB_SetAppConfig
-**
-** Description This function is called to set the parameter TLV to UWBS.
-** The response from UWBS is reported with an
-** UWB_SET_APP_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - All APP configurations belonging to this SessionId
-** num_ids - the number of parameter IDs
-** length - Length of app parameter data
-** p_data - SetAppConfig TLV data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SetAppConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* p_data) {
- return uci_snd_app_set_config_cmd(session_id, num_ids, length, p_data);
-}
-
-/*******************************************************************************
-**
-** Function UWB_GetSessionCount
-**
-** Description This function is called to send get session count command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_SESSION_GET_COUNT_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_GetSessionCount() { return uci_snd_get_session_count_cmd(); }
-
-/*******************************************************************************
-**
-** Function UWB_StartRanging
-**
-** Description This function is called to send the range start command to
-** UWBS.
-** The response from UWBS is reported with an
-** UWB_START_RANGE_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID for which ranging shall start
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_StartRanging(uint32_t session_id) {
- return uci_snd_range_start_cmd(session_id);
-}
-
-/*******************************************************************************
-**
-** Function UWB_StopRanging
-**
-** Description This function is called to send the range stop command to
-** UWBS.
-** The response from UWBS is reported with an UWB_STOP_RANGE_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID for which ranging shall stop
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_StopRanging(uint32_t session_id) {
- return uci_snd_range_stop_cmd(session_id);
-}
-
-/*******************************************************************************
-**
-** Function UWB_GetRangingCount
-**
-** Description This function is called to send get ranging count command.
-** The response from UWBS is reported with an
-** UWB_GET_RANGE_COUNT_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID for which ranging round count is
-** required
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_GetRangingCount(uint32_t session_id) {
- return uci_snd_get_range_count_cmd(session_id);
-}
-
-/*******************************************************************************
-**
-** Function UWB_GetSessionStatus
-**
-** Description This function is called to send get session status command.
-** The response from UWBS is reported with an
-** UWB_SESSION_GET_STATE_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID for which session state is required
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_GetSessionStatus(uint32_t session_id) {
- return uci_snd_get_session_status_cmd(session_id);
-}
-
-/*******************************************************************************
-**
-** Function UWB_MulticastListUpdate
-**
-** Description This function is called to send the Multicast list update
-** command.
-** The response from UWBS is reported with an
-** UWB_SESSION_UPDATE_MULTICAST_LIST_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID
-** action - action
-** noOfControlees - No Of Controlees
-** shortAddress - array of short address
-** subSessionId - array of sub session ID
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_MulticastListUpdate(uint32_t session_id, uint8_t action,
- uint8_t noOfControlees,
- uint16_t* shortAddressList,
- uint32_t* subSessionIdList) {
- return uci_snd_multicast_list_update_cmd(session_id, action, noOfControlees,
- shortAddressList, subSessionIdList);
-}
-
-/*******************************************************************************
-**
-** Function UWB_SetCountryCode
-**
-** Description This function is called to send the country code set
-** command.
-** The response from UWBS is reported with an
-** UWB_SESSION_SET_COUNTRY_CODE_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters country_code - ISO Country code
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SetCountryCode(uint8_t* countryCode) {
- return uci_snd_set_country_code_cmd(countryCode);
-}
-
-/*******************************************************************************
-**
-** Function UWB_CoreGetDeviceCapability
-**
-** Description This function is called to send the Core Get Capability.
-** The response from UWBS is reported with an
-** UWB_CORE_GET_DEVICE_CAPABILITY_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters None
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_CoreGetDeviceCapability(void) {
- return uci_snd_core_get_device_capability();
-}
-
-/*******************************************************************************
-**
-** Function UWB_SendBlinkData
-**
-** Description This function is called to send blink data tx command.
-** The response from UWBS is reported with an
-** UWB_BLINK_DATA_TX_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - Session ID
-** repetition_count - repetition count
-** app_data_len - size of application data
-** app_data - application data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SendBlinkData(uint32_t session_id, uint8_t repetition_count,
- uint8_t app_data_len, uint8_t* app_data) {
- return uci_snd_blink_data_cmd(session_id, repetition_count, app_data_len,
- app_data);
-}
-
-/* APIs for UWB RF test functionality */
-
-/*******************************************************************************
-**
-** Function UWB_TestGetConfig
-**
-** Description This function is called to retrieve the test configuration
-** parameter from UWBS.
-** The response from UWBS is reported with an
-** UWB_TEST_GET_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - All TEST configurations belonging to this SessionId
-** num_ids - the number of parameter IDs
-** length - Length of test parameter ID
-** p_param_ids - the parameter ID list.
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_TestGetConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* p_param_ids) {
- return uci_snd_test_get_config_cmd(session_id, num_ids, length, p_param_ids);
-}
-
-/*******************************************************************************
-**
-** Function UWB_SetTestConfig
-**
-** Description This function is called to set the test configuration
-** parameters.
-** The response from UWBS is reported with an
-** UWB_TEST_SET_CONFIG_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters session_id - All TEST configurations belonging to this SessionId
-** num_ids - the number of parameter IDs
-** length - Length of test parameter data
-** p_data - SetAppConfig TLV data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SetTestConfig(uint32_t session_id, uint8_t num_ids,
- uint8_t length, uint8_t* p_data) {
- return uci_snd_test_set_config_cmd(session_id, num_ids, length, p_data);
-}
-
-/*******************************************************************************
-**
-** Function UWB_TestPeriodicTx
-**
-** Description This function is called send periodic Tx test command.
-** The response from UWBS is reported with an
-** UWB_TEST_PERIODIC_TX_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters length - Length of psdu data.
-** p_data - psdu data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_TestPeriodicTx(uint16_t length, uint8_t* p_data) {
- return uci_snd_test_periodic_tx_cmd(length, p_data);
-}
-
-/*******************************************************************************
-**
-** Function UWB_TestPerRx
-**
-** Description This function is called send Packet Error Rate(PER) Rx test
-** command.
-** The response from UWBS is reported with an
-** UWB_TEST_PER_RX_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters length - Length of psdu data.
-** p_data - psdu data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_TestPerRx(uint16_t length, uint8_t* p_data) {
- return uci_snd_test_per_rx_cmd(length, p_data);
-}
-
-/*******************************************************************************
-**
-** Function UWB_TestUwbLoopBack
-**
-** Description This function is called send Loop Back test command.
-** The response from UWBS is reported with an
-** UWB_TEST_LOOPBACK_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters length - Length of psdu data.
-** p_data - psdu data
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_TestUwbLoopBack(uint16_t length, uint8_t* p_data) {
- return uci_snd_test_uwb_loopback_cmd(length, p_data);
-}
-
-/********************************************************************************
-**
-** Function UWB_TestStopSession
-**
-** Description This function is called to send test session stop command.
-** The response from UWBS is reported with an
-** UWB_TEST_STOP_SESSION_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters None
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_TestStopSession(void) {
- return uci_snd_test_stop_session_cmd();
-}
-
-/********************************************************************************
-**
-** Function UWB_TestRx
-**
-** Description This function is called send Rx Test command.
-** The response from UWBS is reported with an UWB_TEST_RX_REVT
-** in the tUWB_RESPONSE_CBACK callback.
-**
-** Parameters None
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_TestRx(void) { return uci_snd_test_rx_cmd(); }
-
-/*******************************************************************************
-**
-** Function UWB_SendRawCommand
-**
-** Description This function is called to send the given raw command to
-** UWBS. The response from UWBC is reported to the given
-** tUWB_RAW_CBACK.
-**
-** Parameters p_data - The command buffer
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SendRawCommand(UWB_HDR* p_data, tUWB_RAW_CBACK* p_cback) {
- /* Validate parameters */
- if (p_data == NULL) {
- return UWB_STATUS_INVALID_PARAM;
- }
-
- p_data->event = BT_EVT_TO_UWB_UCI;
- p_data->layer_specific = UWB_WAIT_RSP_RAW_CMD;
- /* save the callback function in the BT_HDR, to receive the response */
- ((tUWB_UCI_RAW_MSG*)p_data)->p_cback = p_cback;
-
- uwb_ucif_check_cmd_queue(p_data);
- return UWB_STATUS_OK;
-}
-
-/*******************************************************************************
-**
-** Function UWB_SendData
-**
-** Description This function is called to send the data packet over UWB.
-**
-** Parameters p_data - The data buffer
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_SendData(uint32_t session_id, uint8_t* p_addr,
- uint8_t dest_end_point, uint8_t sequence_num,
- uint16_t data_len, uint8_t* p_data) {
- return uci_send_data_frame(session_id, p_addr, dest_end_point, sequence_num, data_len, p_data);
-}
-
-/*******************************************************************************
-**
-** Function UWB_UpdateRangingRoundIndex
-**
-** Description This function is called to Update Active Ranging Index.
-**
-** Parameter dlTdoaRole - 0x00(Anchor) or 0x01(Tag)
-** session_id - Session id To which Rangng index need to update
-** number_of_active_rngIndex - NUmber Of Ranging index to be updated
-** rng_round_index_len - Range Round Index Len
-** p_rng_round_index - pointer to Ranging Index buffer
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_UpdateRangingRoundIndex(uint8_t dlTdoaRole, uint32_t session_id, uint8_t number_of_rng_index,
- uint8_t rng_round_index_len, uint8_t* p_rng_round_index) {
- return uci_send_range_round_index_update_cmd(dlTdoaRole, session_id, number_of_rng_index, rng_round_index_len, p_rng_round_index);
-}
-
-/*******************************************************************************
-**
-** Function UWB_ConfigureDTAnchorForRrRdmList
-**
-** Description This function is called to Configure DT anchor RR RDM List.
-**
-** Parameter session_id - Session id To which Rangng index need to update
-** rr_rdm_count - Number Of rr_rdm
-** length - length of data buffer
-** p_data - The data buffer
-**
-** Returns tUWB_STATUS
-**
-*******************************************************************************/
-tUWB_STATUS UWB_ConfigureDTAnchorForRrRdmList(uint32_t session_id, uint8_t rr_rdm_count, uint8_t length, uint8_t* p_data) {
- return uci_snd_configure_dt_anchor_for_rr_rdm_list_cmd(session_id, rr_rdm_count, length, p_data);
-}
-
-/*******************************************************************************
-**
-** Function UWB_EnableConformanceTest
-**
-** Description This function is called to set MCTT/PCTT mode.
-** In this mode application is sending raw UCI packets.
-**
-** Parameters p_data - The data buffer
-**
-** Returns None
-**
-*******************************************************************************/
-void UWB_EnableConformanceTest(uint8_t enable) {
- uwb_cb.IsConformaceTestEnabled = enable;
-}
-
-/*******************************************************************************
-**
-** Function UWB_SetDataXferCapMaxMsgSize
-**
-** Description This function is called to set max msg size supported for data Tranfer
-**
-** Parameters maxMsgSize - max msg size value
-**
-** Returns None
-**
-*******************************************************************************/
-void UWB_SetDataXferCapMaxMsgSize(uint16_t maxMsgSize){
- data_tx_cb.max_msg_size = maxMsgSize;
- UCI_TRACE_D(
- "UWB_SetDataXferCapMaxMsgSize %d ",data_tx_cb.max_msg_size);
-}
-
-/*******************************************************************************
-**
-** Function UWB_SetDataXferCapMaxDataPktPayloadSize
-**
-** Description This function is called to set max data packet size at one time supported for data Tranfer
-**
-** Parameters maxDataPktPayloadSize - max data packet size value
-**
-** Returns None
-**
-*******************************************************************************/
-void UWB_SetDataXferCapMaxDataPktPayloadSize(uint16_t maxDataPktPayloadSize)
-{
- data_tx_cb.max_data_pkt_payload_size = maxDataPktPayloadSize;
- UCI_TRACE_D(
- "UWB_SetDataXferCapMaxDataPktPayloadSize %d ",data_tx_cb.max_data_pkt_payload_size);
-}
-
-/*******************************************************************************
-**
-** Function UWB_GetStatusName
-**
-** Description This function returns the status name.
-**
-** NOTE conditionally compiled to save memory.
-**
-** Returns pointer to the name
-**
-*******************************************************************************/
-const uint8_t* UWB_GetStatusName(tUWB_STATUS status) {
- switch (status) {
- case UWB_STATUS_OK:
- return (uint8_t*)"OK";
- case UWB_STATUS_REJECTED:
- return (uint8_t*)"REJECTED";
- case UWB_STATUS_FAILED:
- return (uint8_t*)"FAILED";
- case UWB_STATUS_SYNTAX_ERROR:
- return (uint8_t*)"SYNTAX_ERROR";
- case UWB_STATUS_UNKNOWN_GID:
- return (uint8_t*)"UNKNOWN_GID";
- case UWB_STATUS_UNKNOWN_OID:
- return (uint8_t*)"UNKNOWN_OID";
- case UWB_STATUS_INVALID_PARAM:
- return (uint8_t*)"INVALID_PARAM";
- case UWB_STATUS_INVALID_RANGE:
- return (uint8_t*)"INVALID_RANGE";
- case UWB_STATUS_READ_ONLY:
- return (uint8_t*)"READ_ONLY";
- case UWB_STATUS_COMMAND_RETRY:
- return (uint8_t*)"COMMAND_RETRY";
- case UWB_STATUS_SESSSION_NOT_EXIST:
- return (uint8_t*)"SESSION_NOT_EXIST";
- case UWB_STATUS_SESSSION_DUPLICATE:
- return (uint8_t*)"SESSION_DUPLICATE";
- case UWB_STATUS_SESSSION_ACTIVE:
- return (uint8_t*)"SESSION_IN_ACTIVE";
- case UWB_STATUS_MAX_SESSSIONS_EXCEEDED:
- return (uint8_t*)"MAX_SESSION_REACHED";
- case UWB_STATUS_SESSION_NOT_CONFIGURED:
- return (uint8_t*)"SESSION_NOT_CONFIGURED";
- case UWB_STATUS_RANGING_TX_FAILED:
- return (uint8_t*)"RANGING TX FAILED";
- case UWB_STATUS_RANGING_RX_TIMEOUT:
- return (uint8_t*)"RANGING RX TIMEOUT";
- case UWB_STATUS_RANGING_RX_PHY_DEC_FAILED:
- return (uint8_t*)"PHYSICAL DECODING FAILED";
- case UWB_STATUS_RANGING_RX_PHY_TOA_FAILED:
- return (uint8_t*)"PHYSICAL TOA FAILED";
- case UWB_STATUS_RANGING_RX_PHY_STS_FAILED:
- return (uint8_t*)"PHYSICAL STS FAILED";
- case UWB_STATUS_RANGING_RX_MAC_DEC_FAILED:
- return (uint8_t*)"MAC DECODING FAILED";
- case UWB_STATUS_RANGING_RX_MAC_IE_DEC_FAILED:
- return (uint8_t*)"MAC INFORMATION DECODING FAILED";
- case UWB_STATUS_RANGING_RX_MAC_IE_MISSING:
- return (uint8_t*)"MAC INFORMATION MISSING";
- default:
- return (uint8_t*)"UNKNOWN";
- }
-}
diff --git a/src/uwb/uwb/uwb_task.cc b/src/uwb/uwb/uwb_task.cc
deleted file mode 100755
index ff462ad..0000000
--- a/src/uwb/uwb/uwb_task.cc
+++ /dev/null
@@ -1,366 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 2010-2014 Broadcom Corporation
- *..Copyright 2018-2020 NXP
- *
- * 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.
- *
- ******************************************************************************/
-
-/******************************************************************************
- *
- * Entry point for UWB_TASK
- *
- ******************************************************************************/
-#include <string.h>
-
-#include "uci_hmsgs.h"
-#include "uci_log.h"
-#include "uwa_dm_int.h"
-#include "uwa_sys.h"
-#include "uwb_api.h"
-#include "uwb_gki.h"
-#include "uwb_hal_api.h"
-#include "uwb_int.h"
-#include "uwb_osal_common.h"
-#include "uwb_target.h"
-
-/*******************************************************************************
-**
-** Function uwb_start_timer
-**
-** Description Start a timer for the specified amount of time.
-** NOTE: The timeout resolution is in SECONDS! (Even
-** though the timer structure field is ticks)
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_start_timer(TIMER_LIST_ENT* p_tle, uint16_t type, uint32_t timeout) {
- UWB_HDR* p_msg;
-
- /* if timer list is currently empty, start periodic GKI timer */
- if (uwb_cb.timer_queue.p_first == NULL) {
- /* if timer starts on other than UWB task (scritp wrapper) */
- if (phUwb_GKI_get_taskid() != UWB_TASK) {
- /* post event to start timer in UWB task */
- p_msg = (UWB_HDR*)phUwb_GKI_getbuf(UWB_HDR_SIZE);
- if (p_msg != NULL) {
- p_msg->event = BT_EVT_TO_START_TIMER;
- phUwb_GKI_send_msg(UWB_TASK, UWB_MBOX_ID, p_msg);
- }
- } else {
- /* Start uwb_task 1-sec resolution timer */
- phUwb_GKI_start_timer(UWB_TIMER_ID, GKI_SECS_TO_TICKS(1), true);
- }
- }
-
- phUwb_GKI_remove_from_timer_list(&uwb_cb.timer_queue, p_tle);
-
- p_tle->event = type;
- p_tle->ticks = timeout; /* Save the number of seconds for the timer */
-
- phUwb_GKI_add_to_timer_list(&uwb_cb.timer_queue, p_tle);
-}
-
-/*******************************************************************************
-**
-** Function uwb_remaining_time
-**
-** Description Return amount of time to expire
-**
-** Returns time in second
-**
-*******************************************************************************/
-uint32_t uwb_remaining_time(TIMER_LIST_ENT* p_tle) {
- return (phUwb_GKI_get_remaining_ticks(&uwb_cb.timer_queue, p_tle));
-}
-
-/*******************************************************************************
-**
-** Function uwb_process_timer_evt
-**
-** Description Process uwb GKI timer event
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_process_timer_evt(void) {
- TIMER_LIST_ENT* p_tle;
-
- phUwb_GKI_update_timer_list(&uwb_cb.timer_queue, 1);
-
- while ((uwb_cb.timer_queue.p_first) && (!uwb_cb.timer_queue.p_first->ticks)) {
- p_tle = uwb_cb.timer_queue.p_first;
- phUwb_GKI_remove_from_timer_list(&uwb_cb.timer_queue, p_tle);
-
- if (uwb_cb.uwb_state == UWB_STATE_W4_HAL_CLOSE ||
- uwb_cb.uwb_state == UWB_STATE_NONE) {
- return;
- }
- switch (p_tle->event) {
- default:
- UCI_TRACE_I("uwb_process_timer_evt: timer:0x%p event (0x%04x)", p_tle,
- p_tle->event);
- UCI_TRACE_W("uwb_process_timer_evt: unhandled timer event (0x%04x)",
- p_tle->event);
- }
- }
-
- /* if timer list is empty stop periodic GKI timer */
- if (uwb_cb.timer_queue.p_first == NULL) {
- phUwb_GKI_stop_timer(UWB_TIMER_ID, 0);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_stop_timer
-**
-** Description Stop a timer.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_stop_timer(TIMER_LIST_ENT* p_tle) {
- phUwb_GKI_remove_from_timer_list(&uwb_cb.timer_queue, p_tle);
-
- /* if timer list is empty stop periodic GKI timer */
- if (uwb_cb.timer_queue.p_first == NULL) {
- phUwb_GKI_stop_timer(UWB_TIMER_ID, 0);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_start_quick_timer
-**
-** Description Start a timer for the specified amount of time.
-** NOTE: The timeout resolution depends on including modules.
-** QUICK_TIMER_TICKS_PER_SEC should be used to convert from
-** time to ticks.
-**
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_start_quick_timer(TIMER_LIST_ENT* p_tle, uint16_t type,
- uint32_t timeout) {
- UCI_TRACE_I("uwb_start_quick_timer enter: timeout: %d", timeout);
- UWB_HDR* p_msg;
-
- /* if timer list is currently empty, start periodic GKI timer */
- if (uwb_cb.quick_timer_queue.p_first == NULL) {
- /* if timer starts on other than UWB task (scritp wrapper) */
- if (phUwb_GKI_get_taskid() != UWB_TASK) {
- /* post event to start timer in UWB task */
- p_msg = (UWB_HDR*)phUwb_GKI_getbuf(UWB_HDR_SIZE);
- if (p_msg != NULL) {
- p_msg->event = BT_EVT_TO_START_QUICK_TIMER;
- phUwb_GKI_send_msg(UWB_TASK, UWB_MBOX_ID, p_msg);
- }
- } else {
- /* Quick-timer is required for LLCP */
- phUwb_GKI_start_timer(
- UWB_QUICK_TIMER_ID,
- ((GKI_SECS_TO_TICKS(1) / QUICK_TIMER_TICKS_PER_SEC)), true);
- }
- }
-
- phUwb_GKI_remove_from_timer_list(&uwb_cb.quick_timer_queue, p_tle);
-
- p_tle->event = type;
- p_tle->ticks = timeout; /* Save the number of ticks for the timer */
-
- phUwb_GKI_add_to_timer_list(&uwb_cb.quick_timer_queue, p_tle);
-}
-
-/*******************************************************************************
-**
-** Function uwb_stop_quick_timer
-**
-** Description Stop a timer.
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_stop_quick_timer(TIMER_LIST_ENT* p_tle) {
- UCI_TRACE_I("uwb_stop_quick_timer: enter");
- phUwb_GKI_remove_from_timer_list(&uwb_cb.quick_timer_queue, p_tle);
-
- /* if timer list is empty stop periodic GKI timer */
- if (uwb_cb.quick_timer_queue.p_first == NULL) {
- phUwb_GKI_stop_timer(UWB_QUICK_TIMER_ID, 0);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_process_quick_timer_evt
-**
-** Description Process quick timer event
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_process_quick_timer_evt(void) {
- TIMER_LIST_ENT* p_tle;
-
- if (uwb_cb.uwb_state == UWB_STATE_W4_HAL_CLOSE ||
- uwb_cb.uwb_state == UWB_STATE_NONE) {
- return;
- }
-
- phUwb_GKI_update_timer_list(&uwb_cb.quick_timer_queue, 1);
-
- while ((uwb_cb.quick_timer_queue.p_first) &&
- (!uwb_cb.quick_timer_queue.p_first->ticks)) {
- p_tle = uwb_cb.quick_timer_queue.p_first;
- phUwb_GKI_remove_from_timer_list(&uwb_cb.quick_timer_queue, p_tle);
-
- switch (p_tle->event) {
- case UWB_TTYPE_UCI_WAIT_RSP:
- uwb_ucif_cmd_timeout();
- break;
- default:
- UCI_TRACE_I(
- "uwb_process_quick_timer_evt: unhandled timer event (0x%04x)",
- p_tle->event);
- break;
- }
- }
-
- /* if timer list is empty stop periodic GKI timer */
- if (uwb_cb.quick_timer_queue.p_first == NULL) {
- phUwb_GKI_stop_timer(UWB_QUICK_TIMER_ID, 0);
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_task_shutdown_uwbc
-**
-** Description Handle UWB shutdown
-**
-** Returns nothing
-**
-*******************************************************************************/
-void uwb_task_shutdown_uwbc(void) {
- UWB_HDR* p_msg;
-
- /* Free any messages still in the mbox */
- while ((p_msg = (UWB_HDR*)phUwb_GKI_read_mbox(UWB_MBOX_ID)) != NULL) {
- phUwb_GKI_freebuf(p_msg);
- }
- uwb_gen_cleanup();
-
- uwb_set_state(UWB_STATE_W4_HAL_CLOSE);
- uwb_cb.p_hal->close();
-
- /* Stop the timers */
- phUwb_GKI_stop_timer(UWB_TIMER_ID, 0);
- phUwb_GKI_stop_timer(UWB_QUICK_TIMER_ID, 0);
- phUwb_GKI_stop_timer(UWA_TIMER_ID, 0);
-}
-
-#define UWB_TASK_ARGS __attribute__((unused)) uint32_t arg
-
-uint32_t uwb_task(__attribute__((unused)) uint32_t arg) {
- uint16_t event;
- UWB_HDR* p_msg;
- bool free_buf;
- /* Initialize the uwb control block */
- memset(&uwb_cb, 0, sizeof(tUWB_CB));
-
- UCI_TRACE_I("UWB_TASK started.");
-
- /* main loop */
- while (true) {
- event = phUwb_GKI_wait(0xFFFF, 0);
- if (event == EVENT_MASK(GKI_SHUTDOWN_EVT)) {
- break;
- }
- /* Handle UWB_TASK_EVT_TRANSPORT_READY from UWB HAL */
- if (event & UWB_TASK_EVT_TRANSPORT_READY) {
- UCI_TRACE_I("UWB_TASK got UWB_TASK_EVT_TRANSPORT_READY.");
-
- /* Reset the UWB controller. */
- uwb_set_state(UWB_STATE_IDLE);
- uwb_enabled(UWB_STATUS_OK, NULL);
- }
-
- if (event & UWB_MBOX_EVT_MASK) {
- /* Process all incoming UCI messages */
- while ((p_msg = (UWB_HDR*)phUwb_GKI_read_mbox(UWB_MBOX_ID)) != NULL) {
- free_buf = true;
-
- /* Determine the input message type. */
- switch (p_msg->event & UWB_EVT_MASK) {
- case BT_EVT_TO_UWB_UCI:
- free_buf = uwb_ucif_process_event(p_msg);
- break;
-
- case BT_EVT_TO_START_TIMER:
- /* Start uwb_task 1-sec resolution timer */
- phUwb_GKI_start_timer(UWB_TIMER_ID, GKI_SECS_TO_TICKS(1), true);
- break;
-
- case BT_EVT_TO_START_QUICK_TIMER:
- /* Quick-timer is required for LLCP */
- phUwb_GKI_start_timer(
- UWB_QUICK_TIMER_ID,
- ((GKI_SECS_TO_TICKS(1) / QUICK_TIMER_TICKS_PER_SEC)), true);
- break;
-
- case BT_EVT_TO_UWB_MSGS:
- uwb_main_handle_hal_evt((tUWB_HAL_EVT_MSG*)p_msg);
- break;
-
- default:
- UCI_TRACE_E("uwb_task: unhandle mbox message, event=%04x",
- p_msg->event);
- break;
- }
-
- if (free_buf) {
- phUwb_GKI_freebuf(p_msg);
- }
- }
- }
-
- /* Process gki timer tick */
- if (event & UWB_TIMER_EVT_MASK) {
- uwb_process_timer_evt();
- }
-
- /* Process quick timer tick */
- if (event & UWB_QUICK_TIMER_EVT_MASK) {
- uwb_process_quick_timer_evt();
- }
-
- if (event & UWA_MBOX_EVT_MASK) {
- while ((p_msg = (UWB_HDR*)phUwb_GKI_read_mbox(UWA_MBOX_ID)) != NULL) {
- uwa_sys_event(p_msg);
- }
- }
-
- if (event & UWA_TIMER_EVT_MASK) {
- uwa_sys_timer_update();
- }
- }
-
- UCI_TRACE_I("uwb_task terminated");
-
- phUwb_GKI_exit_task(phUwb_GKI_get_taskid());
- return 0;
-}
diff --git a/src/uwb/uwb/uwb_ucif.cc b/src/uwb/uwb/uwb_ucif.cc
deleted file mode 100755
index 04cbd77..0000000
--- a/src/uwb/uwb/uwb_ucif.cc
+++ /dev/null
@@ -1,1896 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Copyright 2021-2022 NXP.
- *
- * 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.
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "uci_defs.h"
-#include "uci_hmsgs.h"
-#include "uci_log.h"
-#include "uci_test_defs.h"
-#include "uwa_dm_int.h"
-#include "uwa_sys.h"
-#include "uwb_api.h"
-#include "uwb_config.h"
-#include "uwb_hal_api.h"
-#include "uwb_hal_int.h"
-#include "uwb_int.h"
-#include "uwb_osal_common.h"
-#include "uwb_target.h"
-
-#define NORMAL_MODE_LENGTH_OFFSET 0x03
-#define DATA_PACKET_LEN_SHIFT 0x08
-#define TDOA_TX_TIMESTAMP_OFFSET 0x00FF
-#define TDOA_TX_TIMESTAMP_OFFSET_MASK 0x06
-#define TDOA_RX_TIMESTAMP_OFFSET 0x00FF
-#define TDOA_RX_TIMESTAMP_OFFSET_MASK 0x18
-#define ULTDOA_RX_TIMESTAMP_OFFSET 0xF0
-#define ULTDOA_RX_TIMESTAMP_OFFSET_MASK 0x30
-#define ULTDOA_DEVICE_ID_OFFSET 0x0F
-#define ULTDOA_DEVICE_ID_OFFSET_MASK 0X03
-#define ULTDOA_TX_TIMESTAMP_OFFSET 0x0F
-#define ULTDOA_TX_TIMESTAMP_OFFSET_MASK 0x0C
-#define TDOA_ANCHOR_LOC_OFFSET 0x00FF
-#define TDOA_ANCHOR_LOC_OFFSET_MASK 0x60
-#define TDOA_ACTIVE_RR_OFFSET 0x0FF0
-#define TDOA_ACTIVE_RR_OFFSET_MASK 0x0780
-
-#define MAC_SHORT_ADD_LEN 2
-#define MAC_EXT_ADD_LEN 8
-#define PDOA_LEN 4
-#define AOA_LEN 4
-#define AOA_DEST_LEN 4
-#define CONFIG_TLV_OFFSET 2
-#define TWO_WAY_MEASUREMENT_LENGTH 31
-#define ULTDOA_MEASUREMENT_LENGTH 45
-#define ONE_WAY_MEASUREMENT_LENGTH 36
-#define RANGING_DATA_LENGTH 25
-
-#define VENDOR_SPEC_INFO_LEN 2
-#define OWR_WITH_AOA_MEASUREMENT_LENGTH 11
-#define TDOA_TIMESTAMP_LEN_40BITS 5
-#define TDOA_TIMESTAMP_LEN_64BITS 8
-#define TDOA_ANCHOR_LOC_LEN_10BYTES 10
-#define TDOA_ANCHOR_LOC_LEN_12BYTES 12
-#define TDOA_TX_TIMESTAMP_40BITS 0
-#define TDOA_TX_TIMESTAMP_64BITS 2
-#define TDOA_RX_TIMESTAMP_40BITS 0
-#define TDOA_RX_TIMESTAMP_64BITS 8
-#define ULTDOA_TIMESTAMP_LEN 0
-#define ULTDOA_TIMESTAMP_LEN_40BITS 5
-#define ULTDOA_TIMESTAMP_LEN_64BITS 8
-#define ULTDOA_DEVICE_ID_LEN 0
-#define ULTDOA_DEVICE_ID_LEN_16BITS 2
-#define ULTDOA_DEVICE_ID_LEN_32BITS 4
-#define ULTDOA_DEVICE_ID_LEN_64BITS 8
-#define ULTDOA_RX_TIMESTAMP_40BITS 0
-#define ULTDOA_RX_TIMESTAMP_64BITS 20
-#define ULTDOA_DEVICE_ID_PRESCENCE 0
-#define ULTDOA_DEVICE_ID_16BITS 1
-#define ULTDOA_DEVICE_ID_32BITS 2
-#define ULTDOA_DEVICE_ID_64BITS 3
-#define ULTDOA_TX_TIMESTAMP_PRESENCE 0
-#define ULTDOA_TX_TIMESTAMP_40BITS 8
-#define ULTDOA_TX_TIMESTAMP_64BITS 4
-#define TDOA_ANCHOR_LOC_NOT_INCLUDED 0
-#define TDOA_ANCHOR_LOC_NOT_INCLUDED 0
-#define TDOA_ANCHOR_LOC_IN_RELATIVE_SYSTEM 0x40
-#define TDOA_ANCHOR_LOC_IN_WGS84_SYSTEM 0x20
-#define TDOA_ACTIVE_RR_INDEX_POSITION 7
-
-uint8_t last_cmd_buff[UCI_MAX_PAYLOAD_SIZE];
-uint8_t last_data_buff[4096];
-static uint8_t range_data_ntf_buffer[2048];
-static uint8_t range_data_ntf_len =0;
-
-chained_uci_packet chained_packet;
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_update_cmd_window
- **
- ** Description Update tx cmd window to indicate that UWBC can received
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_update_cmd_window(void) {
- /* Sanity check - see if we were expecting a update_window */
- if (uwb_cb.uci_cmd_window == UCI_MAX_CMD_WINDOW) {
- if (uwb_cb.uwb_state != UWB_STATE_W4_HAL_CLOSE) {
- UCI_TRACE_E("uwb_ucif_update_window: Unexpected call");
- }
- return;
- }
- /* Stop command-pending timer */
- uwb_stop_quick_timer(&uwb_cb.uci_wait_rsp_timer);
-
- uwb_cb.p_raw_cmd_cback = NULL;
- uwb_cb.uci_cmd_window++;
- uwb_cb.is_resp_pending = false;
- uwb_cb.cmd_retry_count = 0; /* reset the retry count as response is received*/
-
- uwb_ucif_check_cmd_queue(NULL);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_cmd_timeout
- **
- ** Description Handle a command timeout
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_cmd_timeout(void) {
- UCI_TRACE_I("uwb_ucif_cmd_timeout");
- /* if enabling UWB, notify upper layer of failure */
- if (uwb_cb.is_resp_pending &&
- (uwb_cb.cmd_retry_count < UCI_CMD_MAX_RETRY_COUNT)) {
- uwb_stop_quick_timer(
- &uwb_cb.uci_wait_rsp_timer); /*stop the pending timer */
- uwb_ucif_retransmit_cmd(uwb_cb.pLast_cmd_buf);
- uwb_cb.cmd_retry_count++;
- } else {
- uwb_ucif_event_status(UWB_UWBS_RESP_TIMEOUT_REVT, UWB_STATUS_FAILED);
- }
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_retransmit_cmd
- **
- ** Description Retransmission of last packet
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_retransmit_cmd(UWB_HDR* p_buf) {
- UCI_TRACE_I("uwb_ucif_retransmit_cmd");
- if (p_buf == NULL) {
- UCI_TRACE_E("uwb_ucif_retransmit_cmd: p_data is NULL");
- return;
- }
- HAL_RE_WRITE(p_buf);
- /* start UWB command-timeout timer */
- uwb_start_quick_timer(&uwb_cb.uci_wait_rsp_timer,
- (uint16_t)(UWB_TTYPE_UCI_WAIT_RSP),
- uwb_cb.retry_rsp_timeout);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_retransmit_data
- **
- ** Description Retransmission of last data packet
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_retransmit_data(UWB_HDR* p_buf) {
- UCI_TRACE_I("uwb_ucif_retransmit_data");
- if (p_buf == NULL) {
- UCI_TRACE_E("uwb_ucif_retransmit_data: p_data is NULL");
- return;
- }
- HAL_RE_WRITE(p_buf);
-
- /* start the credit timeout timer */
- uwb_start_quick_timer(&uwb_cb.uci_wait_credit_ntf_timer,
- (uint16_t)(UWB_TTYPE_UCI_WAIT_DATA_NTF),uwb_cb.uci_credit_ntf_timeout);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_check_cmd_queue
- **
- ** Description Send UCI command to the transport
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_check_cmd_queue(UWB_HDR* p_buf) {
- uint8_t* ps;
- uint8_t* pTemp;
- // tUWB_CONN_CB* p_cb = NULL;
- UCI_TRACE_I("uwb_ucif_check_cmd_queue()");
-
- if (uwb_cb.uwb_state == UWB_STATE_W4_HAL_CLOSE ||
- uwb_cb.uwb_state == UWB_STATE_NONE) {
- UCI_TRACE_E("%s: HAL is not initialized", __func__);
- phUwb_GKI_freebuf(p_buf);
- return;
- }
-
- /* If there are commands waiting in the xmit queue, or if the UWBS
- * cannot accept any more commands, */
- /* then enqueue this command */
- if (p_buf) {
- if ((uwb_cb.uci_cmd_xmit_q.count) || (uwb_cb.uci_cmd_window == 0)) {
- phUwb_GKI_enqueue(&uwb_cb.uci_cmd_xmit_q, p_buf);
- if (p_buf != NULL) {
- UCI_TRACE_E("uwb_ucif_check_cmd_queue : making p_buf NULL.");
- p_buf = NULL;
- }
- }
- }
-
- /* If Helios can accept another command, then send the next command */
- if (uwb_cb.uci_cmd_window > 0) {
- /* If no command was provided, or if older commands were in the queue, then
- * get cmd from the queue */
- if (!p_buf) p_buf = (UWB_HDR*)phUwb_GKI_dequeue(&uwb_cb.uci_cmd_xmit_q);
-
- if (p_buf) {
- /* save the message header to double check the response */
- ps = (uint8_t*)(p_buf + 1) + p_buf->offset;
- uint8_t pbf = (*(ps)&UCI_PBF_MASK) >> UCI_PBF_SHIFT;
- memcpy(uwb_cb.last_hdr, ps, UWB_SAVED_HDR_SIZE);
- memcpy(uwb_cb.last_cmd, ps + UCI_MSG_HDR_SIZE, UWB_SAVED_HDR_SIZE);
- /* copying command to temp buff for retransmission */
- uwb_cb.pLast_cmd_buf = (UWB_HDR*)last_cmd_buff;
- uwb_cb.pLast_cmd_buf->offset = p_buf->offset;
- pTemp =
- (uint8_t*)(uwb_cb.pLast_cmd_buf + 1) + uwb_cb.pLast_cmd_buf->offset;
- uwb_cb.pLast_cmd_buf->len = p_buf->len;
- memcpy(pTemp, ps, p_buf->len);
- if (p_buf->layer_specific == UWB_WAIT_RSP_RAW_CMD) {
- /* save the callback for RAW VS */
- uwb_cb.p_raw_cmd_cback = (void*)((tUWB_UCI_RAW_MSG*)p_buf)->p_cback;
- uwb_cb.rawCmdCbflag = true;
- }
-
- /* Indicate command is pending */
- uwb_cb.uci_cmd_window--;
- uwb_cb.is_resp_pending = true;
- uwb_cb.cmd_retry_count = 0;
-
- /* send to HAL */
- HAL_WRITE(p_buf);
- if (!(pbf && uwb_cb.IsConformaceTestEnabled)) { // if pbf bit is set for
- // conformance test skip
- // timer start.
- /* start UWB command-timeout timer */
- uwb_start_quick_timer(&uwb_cb.uci_wait_rsp_timer,
- (uint16_t)(UWB_TTYPE_UCI_WAIT_RSP),
- uwb_cb.uci_wait_rsp_tout);
- }
- }
- }
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_send_cmd
- **
- ** Description Send UCI command to the UCIT task
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_send_cmd(UWB_HDR* p_buf) {
- UCI_TRACE_I("uwb_ucif_send_cmd.");
- if (p_buf == NULL) {
- UCI_TRACE_E("p_buf is NULL.");
- return;
- }
- /* post the p_buf to UCIT task */
- p_buf->event = BT_EVT_TO_UWB_UCI;
- p_buf->layer_specific = 0;
- uwb_ucif_check_cmd_queue(p_buf);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_credit_ntf_timeout
- **
- ** Description Handle a credit ntf timeout
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_credit_ntf_timeout(void){
- UCI_TRACE_I("uwb_ucif_credit_ntf_timeout");
-/* if enabling UWB, notify upper layer of failure */
- if (uwb_cb.is_credit_ntf_pending && (uwb_cb.data_pkt_retry_count < UCI_CMD_MAX_RETRY_COUNT)) {
- uwb_stop_quick_timer(&uwb_cb.uci_wait_credit_ntf_timer); /*stop the pending timer */
- uwb_ucif_retransmit_data(uwb_cb.pLast_data_buf);
- uwb_cb.data_pkt_retry_count++;
- } else {
- uwb_cb.is_credit_ntf_pending = false;
- uwb_cb.data_pkt_retry_count = 0;
- uwb_ucif_event_status(UWB_UWBS_RESP_TIMEOUT_REVT, UWB_STATUS_FAILED);
- uwb_ucif_uwb_recovery();
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_ucif_send_data_frame
-**
-** Description This function is called to send UCI data packet to UWB subsystem as credits are available
-**
-** Returns void
-**
-*******************************************************************************/
-
-void uwb_ucif_send_data_frame(UWB_HDR* p_data){
- UCI_TRACE_I("uwb_ucif_send_data_frame()");
- uint8_t* ps;
- uint8_t* pTemp;
-
- if (uwb_cb.uwb_state == UWB_STATE_W4_HAL_CLOSE ||
- uwb_cb.uwb_state == UWB_STATE_NONE) {
- UCI_TRACE_E("%s: HAL is not initialized", __func__);
- return;
- }
-
- /* If no credit available */
- /* then enqueue this command */
- if (p_data) {
- if ((data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx].credit_available ==
- 0) ||
- (data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx]
- .tx_data_pkt_q.count) ||
- (uwb_cb.uci_cmd_window == 0)) {
- UCI_TRACE_D(
- "Enqueuing p_Data");
- phUwb_GKI_enqueue(
- &data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx].tx_data_pkt_q,
- p_data);
- if (p_data != NULL) {
- UCI_TRACE_D(
- "uwb_ucif_send_data_frame : making p_data NULL.");
- p_data = NULL;
- }
- }
- }
-
- if ((data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx].credit_available) && (uwb_cb.uci_cmd_window > 0)) {
- if (!p_data) {
- UCI_TRACE_D(
- "Dequeueing p_Data");
- p_data = (UWB_HDR*)phUwb_GKI_dequeue(
- &data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx].tx_data_pkt_q);
- }
-
- if (p_data) {
- /* save the message header to double check the response */
- ps = (uint8_t*)(p_data + 1) + p_data->offset;
- /* copying command to temp buff for retransmission */
- uwb_cb.pLast_data_buf = (UWB_HDR*)last_data_buff;
- uwb_cb.pLast_data_buf->offset = p_data->offset;
- pTemp =
- (uint8_t*)(uwb_cb.pLast_data_buf + 1) + uwb_cb.pLast_data_buf->offset;
- uwb_cb.pLast_data_buf->len = p_data->len;
- memcpy(pTemp, ps, p_data->len);
- /* decrease the credits */
- data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx].credit_available = 0;
- uwb_cb.is_credit_ntf_pending = true;
- uwb_cb.uci_cmd_window--;
- /* send to HAL */
- HAL_WRITE(p_data);
- /* start the credit timeout timer */
- uwb_start_quick_timer(&uwb_cb.uci_wait_credit_ntf_timer,
- (uint16_t)(UWB_TTYPE_UCI_WAIT_DATA_NTF),
- uwb_cb.uci_credit_ntf_timeout);
- }
- }
-}
-
-
-/*******************************************************************************
-**
-** Function uwb_ucif_proc_data_credit_ntf
-**
-** Description This function is called to process credits ntf
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_ucif_proc_data_credit_ntf(uint8_t* p_buf, uint16_t len) {
- uint32_t session_id;
-
- /* Stop pending credit ntf timer */
- if (uwb_cb.is_credit_ntf_pending) {
- uwb_stop_quick_timer(&uwb_cb.uci_wait_credit_ntf_timer);
- uwb_cb.is_credit_ntf_pending = false;
- uwb_cb.data_pkt_retry_count = 0;
- uwb_cb.invalid_len_cmd_retry_cnt = 0;
- uwb_cb.uci_cmd_window++;
- }
-
- if (len != 0) {
- STREAM_TO_UINT32(session_id, p_buf);
- STREAM_TO_UINT8(uwb_cb.data_credits, p_buf);
- for (int i = 0; i < data_tx_cb.no_of_sessions; i++) {
- if (session_id == data_tx_cb.tx_data_pkt[i].session_id) {
- data_tx_cb.curr_session_idx = i;
- }
- }
- data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx].credit_available =
- uwb_cb.data_credits;
- if ((data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx]
- .credit_available) &&
- (data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx]
- .tx_data_pkt_q.count)) {
- uwb_ucif_send_data_frame(NULL);
- } else {
- for (int i = 0; i < data_tx_cb.no_of_sessions; i++) {
- if ((data_tx_cb.tx_data_pkt[i].credit_available) &&
- (data_tx_cb.tx_data_pkt[i].tx_data_pkt_q.count)) {
- data_tx_cb.curr_session_idx = i;
- break;
- }
- }
- uwb_ucif_send_data_frame(NULL);
- }
- }
-}
-
-/*******************************************************************************
-**
-** Function uwb_ucif_proc_data_transfer_status_ntf
-**
-** Description This function is called to process data transfer status over UWB
-**
-** Returns void
-**
-*******************************************************************************/
-void uwb_ucif_proc_data_transfer_status_ntf(uint8_t* p_buf, uint16_t len){
- tUWB_DATA_TRANSFER_STATUS_NTF_REVT dataXferStatus;
- tUWB_RESPONSE uwb_response;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.is_credit_ntf_pending == true) {
- uwb_stop_quick_timer(&uwb_cb.uci_wait_credit_ntf_timer);
- uwb_cb.is_credit_ntf_pending = false;
- uwb_cb.data_pkt_retry_count = 0;
- uwb_cb.uci_cmd_window++;
- }
-
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- memset(&dataXferStatus, 0, sizeof(tUWB_DATA_TRANSFER_STATUS_NTF_REVT ));
- STREAM_TO_UINT32(dataXferStatus.session_id, p_buf);
- STREAM_TO_UINT8(dataXferStatus.sequence_num, p_buf);
- STREAM_TO_UINT8(dataXferStatus.status, p_buf);
-
- uwb_response.sData_xfer_status = dataXferStatus;
-
- for (int i = 0; i < data_tx_cb.no_of_sessions; i++) {
- if (dataXferStatus.session_id == data_tx_cb.tx_data_pkt[i].session_id) {
- data_tx_cb.tx_data_pkt[i].credit_available = 1;
- data_tx_cb.curr_session_idx = i;
- break;
- }
- }
-
- (*uwb_cb.p_resp_cback)(UWB_DATA_TRANSFER_STATUS_NTF_REVT, &uwb_response);
-
- if ((data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx].credit_available) &&
- (data_tx_cb.tx_data_pkt[data_tx_cb.curr_session_idx]
- .tx_data_pkt_q.count)) {
- uwb_ucif_send_data_frame(NULL);
- }
-}
-
-/*******************************************************************************
- **
- ** Function uci_ucif_proc_data_packet()
- **
- ** Description This function is called to report received data
- **
- ** Returns void
- **
- *******************************************************************************/
-void uci_ucif_proc_data_packet(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE evt_data;
-
- UCI_TRACE_D("%s: len = %d", __func__, len);
-
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- STREAM_TO_UINT32(evt_data.sRcvd_data.session_id, p_buf);
- STREAM_TO_UINT8(evt_data.sRcvd_data.status, p_buf);
- STREAM_TO_UINT32(evt_data.sRcvd_data.sequence_num, p_buf);
- STREAM_TO_ARRAY(evt_data.sRcvd_data.address, p_buf, EXTENDED_ADDRESS_LEN);
- STREAM_TO_UINT8(evt_data.sRcvd_data.source_end_point, p_buf);
- STREAM_TO_UINT8(evt_data.sRcvd_data.dest_end_point, p_buf);
- STREAM_TO_UINT16(evt_data.sRcvd_data.data_len, p_buf);
- STREAM_TO_ARRAY(evt_data.sRcvd_data.data, p_buf, evt_data.sRcvd_data.data_len);
-
- (*uwb_cb.p_resp_cback)(UWB_DATA_RECV_REVT, &evt_data);
-}
-
-void chain_data_packet(UWB_HDR* p_msg) {
- uint16_t payload_length = 0;
- uint8_t mt, pbf, dpf, *p, *pp;
- p = (uint8_t*)(p_msg + 1) + p_msg->offset;
- pp = p;
- if ((p != NULL) & (pp != NULL)) {
- UCI_MSG_PRS_HDR0(pp, mt, pbf, dpf);
- pp = pp + 3;
- payload_length = p[NORMAL_MODE_LENGTH_OFFSET];
- payload_length = (uint16_t)((payload_length << DATA_PACKET_LEN_SHIFT) |
- p[NORMAL_MODE_LENGTH_OFFSET - 1]);
- if (!uwb_cb.IsConformaceTestEnabled) {
- if (pbf) {
- if (!uwb_cb.is_first_frgmnt_done) {
- chained_packet.gid = dpf;
- memcpy(&chained_packet.buffer[chained_packet.offset], p, p_msg->len);
- chained_packet.offset = p_msg->len;
- uwb_cb.is_first_frgmnt_done = true;
- } else {
- memcpy(&chained_packet.buffer[chained_packet.offset], pp,
- payload_length);
- chained_packet.offset =
- (uint16_t)(chained_packet.offset + payload_length);
- }
- } else {
- if (uwb_cb.is_first_frgmnt_done) {
- memcpy(&chained_packet.buffer[chained_packet.offset], pp,
- payload_length); // Append only payload to chained packet
- chained_packet.offset =
- (uint16_t)(chained_packet.offset + payload_length);
-
- // Update P & PP
- p = &chained_packet
- .buffer[0]; // p -> points to complete UCI packet
- pp = p + 2; // Skip oid & gid bytes
- payload_length =
- (uint16_t)(chained_packet.offset - UCI_MSG_HDR_SIZE);
- UINT16_TO_STREAM(pp,
- payload_length); // Update overall payload length
- // into the chained packet
- }
- // Clear flags
- chained_packet.offset = 0;
- uwb_cb.is_first_frgmnt_done = false;
- chained_packet.oid = 0xFF;
- chained_packet.gid = 0xFF;
- }
- }
- uci_ucif_proc_data_packet(pp, payload_length);
- }
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_process_event
- **
- ** Description This function is called to process the
- ** data/response/notification from UWBC
- **
- ** Returns true if need to free buffer
- **
- *******************************************************************************/
-bool uwb_ucif_process_event(UWB_HDR* p_msg) {
- uint8_t mt, pbf, gid, oid, *p, *pp;
- bool free = true;
- uint16_t payload_length =0;
- uint8_t *p_old, old_gid, old_oid, old_mt;
- uint8_t is_extended_length = 0;
-
- p = (uint8_t*)(p_msg + 1) + p_msg->offset;
- pp = p;
-
- if ((p != NULL) & (pp != NULL)) {
- UCI_MSG_PRS_HDR0(pp, mt, pbf, gid);
- if (mt == UCI_MT_DATA) {
- chain_data_packet(p_msg);
- } else {
- UCI_MSG_PRS_HDR1(pp, oid);
- pp = pp + 2; // Skip payload fields
- UCI_TRACE_I("uwb_ucif_process_event enter gid:0x%x status:0x%x", p[0],
- pp[0]);
- payload_length = p[NORMAL_MODE_LENGTH_OFFSET];
- if (!uwb_cb.IsConformaceTestEnabled) {
- if (pbf) {
- if (!uwb_cb.is_first_frgmnt_done) {
- chained_packet.oid = oid;
- chained_packet.gid = gid;
- memcpy(&chained_packet.buffer[chained_packet.offset], p,
- p_msg->len); // Copy first fragment(uci packet with header)(p)
- chained_packet.offset = p_msg->len;
- uwb_cb.is_first_frgmnt_done = true;
- } else {
- // if first fragment is copied, then copy only uci payload(pp) for
- // subsequent fragments
- if ((chained_packet.oid == oid) && (chained_packet.gid == gid)) {
- memcpy(&chained_packet.buffer[chained_packet.offset], pp,
- payload_length);
- chained_packet.offset =
- (uint16_t)(chained_packet.offset + payload_length);
- } else {
- UCI_TRACE_D(
- "uwb_ucif_process_event: unexpected chain packet: "
- "chained_packed_gid: 0x%x, chained_packet_oid=0x%x, received "
- "packet gid:0x%x, recived packet oid:0x%x",
- chained_packet.gid, chained_packet.oid, gid, oid);
- }
- }
- return (free);
- } else {
- if (uwb_cb.is_first_frgmnt_done) {
- if ((chained_packet.oid == oid) && (chained_packet.gid == gid)) {
- memcpy(&chained_packet.buffer[chained_packet.offset], pp,
- payload_length); // Append only payload to chained packet
- chained_packet.offset =
- (uint16_t)(chained_packet.offset + payload_length);
-
- // Update P & PP
- p = &chained_packet
- .buffer[0]; // p -> points to complete UCI packet
- pp = p + 2; // Skip oid & gid bytes
- payload_length =
- (uint16_t)(chained_packet.offset - UCI_MSG_HDR_SIZE);
- UCI_TRACE_I("%s: payloadLength is %d", __func__, payload_length);
- UINT16_TO_STREAM(pp,
- payload_length); // Update overall payload length
- // into the chained packet
- }
- }
- // Clear flags
- chained_packet.offset = 0;
- chained_packet.oid = 0xFF;
- chained_packet.gid = 0xFF;
- uwb_cb.is_first_frgmnt_done = false;
- }
- }
- }
-
- if ((uwb_cb.rawCmdCbflag == true) && (mt != UCI_MT_NTF)) {
- uci_proc_raw_cmd_rsp(p, p_msg->len);
- uwb_cb.rawCmdCbflag = false;
- return (free);
- }
-
- switch (mt) {
- case UCI_MT_RSP:
- UCI_TRACE_I("uwb_ucif_process_event: UWB received rsp gid:%d", gid);
- p_old = uwb_cb.last_hdr;
- UCI_MSG_PRS_HDR0(p_old, old_mt, pbf, old_gid);
- UCI_MSG_PRS_HDR1(p_old, old_oid);
- (void)old_mt; // Dummy conversion to fix the warning
- /* make sure this is the RSP we are waiting for before updating the
- * command window */
- if ((old_gid != gid) || (old_oid != oid)) {
- UCI_TRACE_E(
- "uwb_ucif_process_event unexpected rsp: gid:0x%x, oid:0x%x", gid,
- oid);
- return true;
- }
-
- switch (gid) {
- case UCI_GID_CORE: /* 0000b UCI Core group */
- free = uwb_proc_core_rsp(oid, pp, payload_length);
- break;
- case UCI_GID_SESSION_MANAGE: /* 0001b UCI Session Config group */
- uci_proc_session_management_rsp(oid, pp, payload_length);
- break;
- case UCI_GID_RANGE_MANAGE: /* 0010b UCI Range group */
- uci_proc_rang_management_rsp(oid, pp, payload_length);
- break;
- case UCI_GID_ANDROID: /* 1110b UCI vendor Android group */
- uci_proc_android_rsp(oid, pp, payload_length);
- break;
- case UCI_GID_TEST: /* 1101b test group */
- uci_proc_test_management_rsp(oid, pp, payload_length);
- break;
- default:
- UCI_TRACE_E("uwb_ucif_process_event: Unknown gid:%d", gid);
- break;
- }
-
- uwb_ucif_update_cmd_window();
- break;
-
- case UCI_MT_NTF:
- UCI_TRACE_I("uwb_ucif_process_event: UWB received ntf gid:%d", gid);
- if ((!(gid == UCI_GID_CORE && oid == UCI_MSG_CORE_GENERIC_ERROR_NTF &&
- pp[0] == UCI_STATUS_COMMAND_RETRY)) &&
- uwb_cb.IsConformaceTestEnabled) {
- // handling of ntf for conformance test
- uwb_ucif_proc_conformance_ntf(p, payload_length + 4);
- return (free);
- }
-
- switch (gid) {
- case UCI_GID_CORE:
- uci_proc_core_management_ntf(oid, pp, payload_length);
- break;
- case UCI_GID_SESSION_MANAGE: /* 0001b UCI management group */
- uci_proc_session_management_ntf(oid, pp, payload_length);
- break;
- case UCI_GID_RANGE_MANAGE: /* 0011b UCI Range management group */
- range_data_ntf_len = p_msg->len;
- for (int i=0; i<p_msg->len;i++) {
- range_data_ntf_buffer[i] = p[i];
- }
- uci_proc_rang_management_ntf(oid, pp, payload_length);
- break;
- case UCI_GID_TEST: /* 1101b test group */
- //uci_proc_test_management_ntf(oid, pp, payload_length);
- //send vendor specific ntf as it is handled by vendor extension
- uci_proc_vendor_specific_ntf(gid, p, (payload_length + UCI_MSG_HDR_SIZE));
- break;
- case UCI_GID_VENDOR_SPECIFIC_0x09:
- case UCI_GID_VENDOR_SPECIFIC_0x0A:
- case UCI_GID_VENDOR_SPECIFIC_0x0B:
- case UCI_GID_VENDOR_SPECIFIC_0x0C:
- case UCI_GID_VENDOR_SPECIFIC_0x0E:
- case UCI_GID_VENDOR_SPECIFIC_0x0F:
- uci_proc_vendor_specific_ntf(gid, p, (payload_length + UCI_MSG_HDR_SIZE));
- break;
- default:
- UCI_TRACE_E("uwb_ucif_process_event: UWB Unknown gid:%d", gid);
- break;
- }
- break;
- default:
- UCI_TRACE_E(
- "uwb_ucif_process_event: UWB received unknown mt:0x%x, gid:%d", mt,
- gid);
- }
- } else {
- UCI_TRACE_E("uwb_ucif_process_event: NULL pointer");
- }
- return (free);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_core_device_reset_rsp_status
- **
- ** Description This function is called to report UWB_DEVICE_RESET_REVT
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_core_device_reset_rsp_status(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE evt_data;
- tUWB_STATUS status;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- status = (tUWB_STATUS)*p_buf;
- UCI_TRACE_I("StatusName:%s and StatusValue:%d", UWB_GetStatusName(status),
- status);
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- evt_data.sDevice_reset.status = status;
- if (status == UWA_STATUS_OK) {
- UCI_TRACE_I("%s: Device Reset Successful", __func__);
- } else {
- UCI_TRACE_E("%s: Device Reset Failed", __func__);
- }
- (*uwb_cb.p_resp_cback)(UWB_DEVICE_RESET_REVT, &evt_data);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_core_set_config_status
- **
- ** Description This function is called to report UWB_SET_CORE_CONFIG_REVT
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_core_set_config_status(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE evt_data;
- tUWB_STATUS status;
- uint8_t* p = p_buf;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- status = (tUWB_STATUS)*p++;
- UCI_TRACE_I("StatusName:%s and StatusValue:%d", UWB_GetStatusName(status),
- status);
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- evt_data.sCore_set_config.status = status;
- evt_data.sCore_set_config.num_param_id = *p++;
- evt_data.sCore_set_config.tlv_size = (uint16_t)(len - CONFIG_TLV_OFFSET);
- if (evt_data.sCore_set_config.tlv_size > 0) {
- STREAM_TO_ARRAY(evt_data.sCore_set_config.param_ids, p,
- evt_data.sCore_set_config.tlv_size);
- }
- (*uwb_cb.p_resp_cback)(UWB_SET_CORE_CONFIG_REVT, &evt_data);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_core_get_config_rsp
- **
- ** Description This function is called to process get config response
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_core_get_config_rsp(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE evt_data;
- tUWB_STATUS status;
- uint8_t* p = p_buf;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- status = *p++;
- UCI_TRACE_I("StatusName:%s and StatusValue:%d", UWB_GetStatusName(status),
- status);
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- evt_data.sCore_get_config.status = status;
- evt_data.sCore_get_config.no_of_ids = *p++;
- evt_data.sCore_get_config.tlv_size = (uint16_t)(len - CONFIG_TLV_OFFSET);
- if (evt_data.sCore_get_config.tlv_size > 0) {
- memcpy(evt_data.sCore_get_config.p_param_tlvs, p,
- evt_data.sCore_get_config.tlv_size);
- }
-
- (*uwb_cb.p_resp_cback)(UWB_GET_CORE_CONFIG_REVT, &evt_data);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_session_management_status
- **
- ** Description This function is called to process session command
- *responses
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_session_management_status(tUWB_RESPONSE_EVT event, uint8_t* p_buf,
- uint16_t len) {
- tUWB_RESPONSE evt_data;
- tUWB_RESPONSE_EVT evt = 0;
- tUWB_STATUS status;
- uint8_t* p = p_buf;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- status = *p++;
- UCI_TRACE_I("StatusName:%s and StatusValue:%d", UWB_GetStatusName(status),
- status);
- switch (event) {
- case UWB_SESSION_INIT_REVT:
- evt = UWB_SESSION_INIT_REVT;
- evt_data.status = status;
- break;
- case UWB_SESSION_DEINIT_REVT:
- evt = UWB_SESSION_DEINIT_REVT;
- evt_data.status = status;
- break;
- case UWB_SESSION_GET_COUNT_REVT:
- evt = UWB_SESSION_GET_COUNT_REVT;
- evt_data.sGet_session_cnt.status = status;
- evt_data.sGet_session_cnt.count = *p;
- break;
- case UWB_SESSION_GET_STATE_REVT:
- evt = UWB_SESSION_GET_STATE_REVT;
- evt_data.sGet_session_state.status = status;
- evt_data.sGet_session_state.session_state = *p;
- break;
- case UWB_SESSION_UPDATE_MULTICAST_LIST_REVT:
- evt = UWB_SESSION_UPDATE_MULTICAST_LIST_REVT;
- evt_data.status = status;
- break;
- case UWB_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT:
- evt_data.status = status;
- evt = UWB_SESSION_CONFIGURE_DT_ANCHOR_RR_RDM_REVT;
- evt_data.sConfigure_dt_anchor_rr_rdm_list.status = status;
- evt_data.sConfigure_dt_anchor_rr_rdm_list.len = len;
- if(len > 0){
- STREAM_TO_ARRAY(evt_data.sConfigure_dt_anchor_rr_rdm_list.rng_round_indexs, p_buf, len);
- }
- break;
- case UWB_SESSION_ACTIVE_ROUNDS_INDEX_UPDATE_REVT:
- evt_data.status = status;
- evt = UWB_SESSION_ACTIVE_ROUNDS_INDEX_UPDATE_REVT;
- evt_data.sRange_round_index.status = status;
- evt_data.sRange_round_index.len = len;
- if(len > 0){
- STREAM_TO_ARRAY(evt_data.sRange_round_index.rng_round_index, p_buf, len);
- }
- break;
- default:
- UCI_TRACE_E("unknown response event %x", event);
- }
- if (evt) {
- (*uwb_cb.p_resp_cback)(evt, &evt_data);
- }
-}
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_app_get_config_status
- **
- ** Description This function is called to process get config response
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_app_get_config_status(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE evt_data;
- tUWB_STATUS status;
- uint8_t* p = p_buf;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- status = *p++;
- UCI_TRACE_I("StatusName:%s and StatusValue:%d", UWB_GetStatusName(status),
- status);
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- evt_data.sApp_get_config.status = status;
- evt_data.sApp_get_config.no_of_ids = *p++;
- evt_data.sApp_get_config.tlv_size = (uint16_t)(len - CONFIG_TLV_OFFSET);
- if (evt_data.sApp_get_config.tlv_size > 0) {
- memcpy(evt_data.sApp_get_config.p_param_tlvs, p,
- evt_data.sApp_get_config.tlv_size);
- }
- (*uwb_cb.p_resp_cback)(UWB_GET_APP_CONFIG_REVT, &evt_data);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_app_set_config_status
- **
- ** Description This function is called to report UWB_SET_APP_CONFIG_REVT
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_app_set_config_status(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE evt_data;
- tUWB_STATUS status;
- uint8_t* p = p_buf;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- status = *p++;
- UCI_TRACE_I("StatusName:%s and StatusValue:%d", UWB_GetStatusName(status),
- status);
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- evt_data.sApp_set_config.status = status;
- evt_data.sApp_set_config.num_param_id = *p++;
- evt_data.sApp_set_config.tlv_size = (uint16_t)(len - CONFIG_TLV_OFFSET);
- if (evt_data.sApp_set_config.tlv_size > 0) {
- STREAM_TO_ARRAY(evt_data.sApp_set_config.param_ids, p,
- evt_data.sApp_set_config.tlv_size);
- }
-
- (*uwb_cb.p_resp_cback)(UWB_SET_APP_CONFIG_REVT, &evt_data);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_range_management_status
- **
- ** Description This function is called to process raning start/stop
- *command responses
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_range_management_status(tUWB_RESPONSE_EVT event, uint8_t* p_buf,
- uint16_t len) {
- tUWB_RESPONSE evt_data;
- tUWB_RESPONSE_EVT evt = 0;
- uint8_t status = *p_buf;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- UCI_TRACE_I("StatusName:%s and StatusValue:%d", UWB_GetStatusName(status),
- status);
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- switch (event) {
- case UWB_START_RANGE_REVT:
- evt = UWB_START_RANGE_REVT;
- break;
- case UWB_STOP_RANGE_REVT:
- evt = UWB_STOP_RANGE_REVT;
- break;
- case UWB_BLINK_DATA_TX_REVT:
- evt = UWB_BLINK_DATA_TX_REVT;
- break;
- default:
- UCI_TRACE_E("unknown response event %x", event);
- }
- if (evt) {
- evt_data.status = status;
- (*uwb_cb.p_resp_cback)(evt, &evt_data);
- }
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_get_range_count_status
- **
- ** Description This function is called to process get range command
- ** responses
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_get_range_count_status(tUWB_RESPONSE_EVT event, uint8_t* p_buf,
- uint16_t len) {
- tUWB_RESPONSE evt_data;
- tUWB_RESPONSE_EVT evt = 0;
- tUWB_GET_RANGE_COUNT_REVT get_count;
- get_count.count = 0x00;
- uint8_t* p = p_buf;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- switch (event) {
- case UWB_GET_RANGE_COUNT_REVT:
- STREAM_TO_UINT8(get_count.status, p);
- STREAM_TO_UINT32(get_count.count, p);
- UCI_TRACE_I("get_count status = %d", get_count.status);
- evt_data.sGet_range_cnt = get_count;
- evt = UWB_GET_RANGE_COUNT_REVT;
- break;
- default:
- UCI_TRACE_E("unknown response event %x", event);
- }
- if (evt) {
- evt_data.status = get_count.status;
- (*uwb_cb.p_resp_cback)(evt, &evt_data);
- }
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_core_device_status
- **
- ** Description This function is called to device status notification
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_core_device_status(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE uwb_response;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- uint8_t status = *p_buf;
-
- UCI_TRACE_I("uwb_ucif_proc_core_device_status dev_status = %x", status);
- uwb_response.sDevice_status.status = status;
- uwb_cb.device_state = status;
-
- (*uwb_cb.p_resp_cback)(UWB_DEVICE_STATUS_REVT, &uwb_response);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_core_generic_error_ntf
- **
- ** Description This function is called to process core generic error
- ** notification
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_core_generic_error_ntf(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE uwb_response;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- uint8_t status = *p_buf;
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- UCI_TRACE_I("uwb_ucif_proc_core_generic_error_ntf: status = %x", status);
- uwb_response.sCore_gen_err_status.status = status;
- if ((status == UCI_STATUS_COMMAND_RETRY) && uwb_cb.is_resp_pending) {
- uwb_stop_quick_timer(
- &uwb_cb.uci_wait_rsp_timer); /*stop the pending timer */
- uwb_ucif_retransmit_cmd(uwb_cb.pLast_cmd_buf);
- uwb_cb.cmd_retry_count++;
- } else {
- (*uwb_cb.p_resp_cback)(UWB_CORE_GEN_ERR_STATUS_REVT, &uwb_response);
- }
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_ranging_data
- **
- ** Description This function is called to process ranging data
- ** notifications
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_ranging_data(uint8_t* p, uint16_t len) {
- tUWB_RANGE_DATA_REVT sRange_data;
- tUWB_RESPONSE uwb_response;
- int16_t ranging_measures_length = 0;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- memset(&sRange_data, 0, sizeof(tUWB_RANGE_DATA_REVT));
- sRange_data.range_data_len = len;
- STREAM_TO_UINT32(sRange_data.seq_counter, p);
- STREAM_TO_UINT32(sRange_data.session_id, p);
- STREAM_TO_UINT8(sRange_data.rcr_indication, p);
- STREAM_TO_UINT32(sRange_data.curr_range_interval, p);
- STREAM_TO_UINT8(sRange_data.ranging_measure_type, p);
- STREAM_TO_UINT8(sRange_data.rfu, p);
- STREAM_TO_UINT8(sRange_data.mac_addr_mode_indicator, p);
- STREAM_TO_ARRAY(&sRange_data.reserved[0], p, 8);
- STREAM_TO_UINT8(sRange_data.no_of_measurements, p);
- ranging_measures_length = len - RANGING_DATA_LENGTH;
- if (sRange_data.ranging_measure_type == MEASUREMENT_TYPE_TWOWAY &&
- sRange_data.no_of_measurements > MAX_NUM_RESPONDERS) {
- UCI_TRACE_E(
- "%s: MEASUREMENT_TYPE_TWOWAY Wrong number of measurements received:%d",
- __func__, sRange_data.no_of_measurements);
- return;
- } else if (sRange_data.ranging_measure_type == MEASUREMENT_TYPE_ULTDOA &&
- sRange_data.no_of_measurements > MAX_NUM_OF_TDOA_MEASURES) {
- UCI_TRACE_E(
- "%s: MEASUREMENT_TYPE_ULTDOA Wrong number of measurements received:%d",
- __func__, sRange_data.no_of_measurements);
- return;
- } else if (sRange_data.ranging_measure_type == MEASUREMENT_TYPE_DLTDOA &&
- sRange_data.no_of_measurements > MAX_NUM_OF_DLTDOA_MEASURES) {
- UCI_TRACE_E(
- "%s: MEASUREMENT_TYPE_DLTDOA Wrong number of measurements received:%d",
- __func__, sRange_data.no_of_measurements);
- return;
- } else if (sRange_data.ranging_measure_type == MEASUREMENT_TYPE_OWR_WITH_AOA &&
- sRange_data.no_of_measurements > MAX_NUM_OWR_AOA_MEASURES) {
- UCI_TRACE_E("%s: MEASUREMENT_TYPE_OWR_WITH_AOA Wrong number of measurements received:%d",
- __func__, sRange_data.no_of_measurements);
- return;
- }
- if (sRange_data.ranging_measure_type == MEASUREMENT_TYPE_TWOWAY) {
- for (uint8_t i = 0; i < sRange_data.no_of_measurements; i++) {
- tUWA_TWR_RANGING_MEASR* twr_range_measr =
- (tUWA_TWR_RANGING_MEASR*)&sRange_data.ranging_measures
- .twr_range_measr[i];
- if (ranging_measures_length < TWO_WAY_MEASUREMENT_LENGTH) {
- UCI_TRACE_E("%s: Invalid ranging_measures_length = %x", __func__,
- ranging_measures_length);
- return;
- }
- ranging_measures_length -= TWO_WAY_MEASUREMENT_LENGTH;
- if (sRange_data.mac_addr_mode_indicator == SHORT_MAC_ADDRESS) {
- STREAM_TO_ARRAY(&twr_range_measr->mac_addr[0], p, MAC_SHORT_ADD_LEN);
- } else if (sRange_data.mac_addr_mode_indicator == EXTENDED_MAC_ADDRESS) {
- STREAM_TO_ARRAY(&twr_range_measr->mac_addr[0], p, MAC_EXT_ADD_LEN);
- } else {
- UCI_TRACE_E("%s: Invalid mac addressing indicator", __func__);
- return;
- }
- STREAM_TO_UINT8(twr_range_measr->status, p);
- STREAM_TO_UINT8(twr_range_measr->nLos, p);
- STREAM_TO_UINT16(twr_range_measr->distance, p);
- STREAM_TO_UINT16(twr_range_measr->aoa_azimuth, p);
- STREAM_TO_UINT8(twr_range_measr->aoa_azimuth_FOM, p);
- STREAM_TO_UINT16(twr_range_measr->aoa_elevation, p);
- STREAM_TO_UINT8(twr_range_measr->aoa_elevation_FOM, p);
- STREAM_TO_UINT16(twr_range_measr->aoa_dest_azimuth, p);
- STREAM_TO_UINT8(twr_range_measr->aoa_dest_azimuth_FOM, p);
- STREAM_TO_UINT16(twr_range_measr->aoa_dest_elevation, p);
- STREAM_TO_UINT8(twr_range_measr->aoa_dest_elevation_FOM, p);
- STREAM_TO_UINT8(twr_range_measr->slot_index, p);
- STREAM_TO_UINT8(twr_range_measr->rssi, p);
- /* Read & Ignore RFU bytes
- if mac address format is short, then 11 bytes
- if mac address format is extended, then read 5 bytes */
- if (sRange_data.mac_addr_mode_indicator == SHORT_MAC_ADDRESS) {
- STREAM_TO_ARRAY(&twr_range_measr->rfu[0], p, 11);
- } else {
- STREAM_TO_ARRAY(&twr_range_measr->rfu[0], p, 5);
- }
- }
- } else if (sRange_data.ranging_measure_type == MEASUREMENT_TYPE_DLTDOA) {
- for (uint8_t i = 0; i < sRange_data.no_of_measurements; i++) {
- tUWB_DLTDOA_RANGING_MEASR *dltdoa_range_measr = (tUWB_DLTDOA_RANGING_MEASR*)&sRange_data.ranging_measures.dltdoa_range_measr[i];
- uint16_t txTimeStampValue = 0;
- uint16_t rxTimeStampValue = 0;
- uint16_t anchorLocationValue = 0;
- uint16_t activeRangingRoundValue = 0;
-
- if(sRange_data.mac_addr_mode_indicator == SHORT_MAC_ADDRESS) {
- STREAM_TO_ARRAY(&dltdoa_range_measr->mac_addr[0], p, MAC_SHORT_ADD_LEN);
- } else if(sRange_data.mac_addr_mode_indicator == EXTENDED_MAC_ADDRESS) {
- STREAM_TO_ARRAY(&dltdoa_range_measr->mac_addr[0], p, MAC_EXT_ADD_LEN);
- } else {
- UCI_TRACE_E("%s: Invalid mac addressing indicator", __func__);
- return;
- }
- STREAM_TO_UINT8(dltdoa_range_measr->status, p);
- STREAM_TO_UINT8(dltdoa_range_measr->message_type, p);
- STREAM_TO_UINT16(dltdoa_range_measr->message_control, p);
- STREAM_TO_UINT16(dltdoa_range_measr->block_index, p);
- STREAM_TO_UINT8(dltdoa_range_measr->round_index, p);
- STREAM_TO_UINT8(dltdoa_range_measr->nLos, p);
- STREAM_TO_UINT16(dltdoa_range_measr->aoa_azimuth, p);
- STREAM_TO_UINT8(dltdoa_range_measr->aoa_azimuth_FOM, p);
- STREAM_TO_UINT16(dltdoa_range_measr->aoa_elevation, p);
- STREAM_TO_UINT8(dltdoa_range_measr->aoa_elevation_FOM, p);
- STREAM_TO_UINT8(dltdoa_range_measr->rssi, p);
- txTimeStampValue = ((dltdoa_range_measr->message_control & TDOA_TX_TIMESTAMP_OFFSET ) & (TDOA_TX_TIMESTAMP_OFFSET_MASK));
- if(txTimeStampValue == TDOA_TX_TIMESTAMP_40BITS) {
- STREAM_TO_UINT40(dltdoa_range_measr->txTimeStamp, p);
- } else if(txTimeStampValue == TDOA_TX_TIMESTAMP_64BITS) {
- STREAM_TO_UINT64(dltdoa_range_measr->txTimeStamp, p);
- } else {
- UCI_TRACE_E("%s: Invalid txTimeStamp value", __func__);
- return;
- }
- rxTimeStampValue = ((dltdoa_range_measr->message_control & TDOA_RX_TIMESTAMP_OFFSET ) & (TDOA_RX_TIMESTAMP_OFFSET_MASK));
- if(rxTimeStampValue == TDOA_RX_TIMESTAMP_40BITS) {
- STREAM_TO_UINT40(dltdoa_range_measr->rxTimeStamp, p);
- } else if(rxTimeStampValue == TDOA_RX_TIMESTAMP_64BITS) {
- STREAM_TO_UINT64(dltdoa_range_measr->rxTimeStamp, p);
- } else {
- UCI_TRACE_E("%s: Invalid rxTimeStamp value", __func__);
- return;
- }
- STREAM_TO_UINT16(dltdoa_range_measr->cfo_anchor, p);
- STREAM_TO_UINT16(dltdoa_range_measr->cfo, p);
- STREAM_TO_UINT32(dltdoa_range_measr->initiator_reply_time, p);
- STREAM_TO_UINT32(dltdoa_range_measr->responder_reply_time, p);
- STREAM_TO_UINT16(dltdoa_range_measr->initiator_responder_TOF, p);
- anchorLocationValue = ((dltdoa_range_measr->message_control & TDOA_ANCHOR_LOC_OFFSET ) & (TDOA_ANCHOR_LOC_OFFSET_MASK));
- if(anchorLocationValue == TDOA_ANCHOR_LOC_NOT_INCLUDED) {
- UCI_TRACE_D("%s: anchorLocation not included", __func__);
- } else if(anchorLocationValue == TDOA_ANCHOR_LOC_IN_RELATIVE_SYSTEM) {
- STREAM_TO_ARRAY(&dltdoa_range_measr->anchor_location[0], p, TDOA_ANCHOR_LOC_LEN_10BYTES);
- } else if(anchorLocationValue == TDOA_ANCHOR_LOC_IN_WGS84_SYSTEM) {
- STREAM_TO_ARRAY(&dltdoa_range_measr->anchor_location[0], p, TDOA_ANCHOR_LOC_LEN_12BYTES);
- } else {
- UCI_TRACE_E("%s: Invalid anchorLocationvalue value", __func__);
- return;
- }
- activeRangingRoundValue = ((dltdoa_range_measr->message_control & TDOA_ACTIVE_RR_OFFSET)
- & (TDOA_ACTIVE_RR_OFFSET_MASK)) >> TDOA_ACTIVE_RR_INDEX_POSITION;
- if(activeRangingRoundValue != 0) {
- STREAM_TO_ARRAY(&dltdoa_range_measr->active_ranging_round[0], p, activeRangingRoundValue);
- } else {
- UCI_TRACE_D("%s: activeRangingRound not included", __func__);
- }
- }
- } else if (sRange_data.ranging_measure_type == MEASUREMENT_TYPE_ULTDOA) {
- for (uint8_t i = 0; i < sRange_data.no_of_measurements; i++) {
- tUWA_TDoA_RANGING_MEASR* tdoa_range_measr =
- (tUWA_TDoA_RANGING_MEASR*)&sRange_data.ranging_measures
- .tdoa_range_measr[i];
- if (ranging_measures_length < ULTDOA_MEASUREMENT_LENGTH) {
- UCI_TRACE_E("%s: Invalid ranging_measures_length = %x", __func__,
- ranging_measures_length);
- return;
- }
- uint16_t txTimeStampValue = 0;
- uint16_t ultdoaDeviceIdValue = 0;
- uint16_t rxTimeStampValue = 0;
- ranging_measures_length -= ULTDOA_MEASUREMENT_LENGTH;
- if (sRange_data.mac_addr_mode_indicator == SHORT_MAC_ADDRESS) {
- STREAM_TO_ARRAY(&tdoa_range_measr->mac_addr[0], p, MAC_SHORT_ADD_LEN);
- } else if (sRange_data.mac_addr_mode_indicator == EXTENDED_MAC_ADDRESS) {
- STREAM_TO_ARRAY(&tdoa_range_measr->mac_addr[0], p, MAC_EXT_ADD_LEN);
- } else {
- UCI_TRACE_E("%s: Invalid mac addressing indicator", __func__);
- return;
- }
- STREAM_TO_UINT8(tdoa_range_measr->message_control, p);
- STREAM_TO_UINT8(tdoa_range_measr->frame_type, p);
- STREAM_TO_UINT8(tdoa_range_measr->nLos, p);
- STREAM_TO_UINT16(tdoa_range_measr->aoa_azimuth, p);
- STREAM_TO_UINT8(tdoa_range_measr->aoa_azimuth_FOM, p);
- STREAM_TO_UINT16(tdoa_range_measr->aoa_elevation, p);
- STREAM_TO_UINT8(tdoa_range_measr->aoa_elevation_FOM, p);
- STREAM_TO_UINT32(tdoa_range_measr->frame_number, p);
- rxTimeStampValue = ((tdoa_range_measr->message_control & ULTDOA_RX_TIMESTAMP_OFFSET ) & (ULTDOA_RX_TIMESTAMP_OFFSET_MASK));
- if(rxTimeStampValue == ULTDOA_RX_TIMESTAMP_40BITS) {
- STREAM_TO_ARRAY(&tdoa_range_measr->rxTimeStamp[0], p, ULTDOA_TIMESTAMP_LEN_40BITS);
- } else if(rxTimeStampValue == ULTDOA_RX_TIMESTAMP_64BITS) {
- STREAM_TO_ARRAY(&tdoa_range_measr->rxTimeStamp[0], p, ULTDOA_TIMESTAMP_LEN_64BITS);
- } else {
- UCI_TRACE_E("%s: Invalid rxTimeStamp value", __func__);
- return;
- }
- ultdoaDeviceIdValue = ((tdoa_range_measr->message_control & ULTDOA_DEVICE_ID_OFFSET ) & (ULTDOA_DEVICE_ID_OFFSET_MASK));
- if(ultdoaDeviceIdValue > 0) {
- if(ultdoaDeviceIdValue == ULTDOA_DEVICE_ID_16BITS) {
- STREAM_TO_ARRAY(&tdoa_range_measr->ulTdoa_device_id[0], p, ULTDOA_DEVICE_ID_LEN_16BITS);
- } else if(ultdoaDeviceIdValue == ULTDOA_DEVICE_ID_32BITS) {
- STREAM_TO_ARRAY(&tdoa_range_measr->ulTdoa_device_id[0], p, ULTDOA_DEVICE_ID_LEN_32BITS);
- } else if(ultdoaDeviceIdValue == ULTDOA_DEVICE_ID_64BITS) {
- STREAM_TO_ARRAY(&tdoa_range_measr->ulTdoa_device_id[0], p, ULTDOA_DEVICE_ID_LEN_64BITS);
- } else {
- UCI_TRACE_E("%s: Invalid Device Id value", __func__);
- return;
- }
- }
- txTimeStampValue = ((tdoa_range_measr->message_control & ULTDOA_TX_TIMESTAMP_OFFSET ) & (ULTDOA_TX_TIMESTAMP_OFFSET_MASK));
- if(txTimeStampValue > 0) {
- if(txTimeStampValue == ULTDOA_TX_TIMESTAMP_40BITS) {
- STREAM_TO_ARRAY(&tdoa_range_measr->txTimeStamp[0], p, ULTDOA_TIMESTAMP_LEN_40BITS);
- } else if(txTimeStampValue == ULTDOA_TX_TIMESTAMP_64BITS){
- STREAM_TO_ARRAY(&tdoa_range_measr->txTimeStamp[0], p, ULTDOA_TIMESTAMP_LEN_64BITS);
- } else {
- UCI_TRACE_E("%s: Invalid txTimeStamp value", __func__);
- return;
- }
- }
- }
- } else if (sRange_data.ranging_measure_type == MEASUREMENT_TYPE_OWR_WITH_AOA) {
- tUWA_OWR_WITH_AOA_RANGING_MEASR* owr_aoa_range_measr =
- (tUWA_OWR_WITH_AOA_RANGING_MEASR*)&sRange_data.ranging_measures
- .owr_with_aoa_range_measr;
- if (ranging_measures_length < OWR_WITH_AOA_MEASUREMENT_LENGTH) {
- UCI_TRACE_E("%s: Invalid one way ranging_measures_length = %x", __func__,
- ranging_measures_length);
- return;
- }
- ranging_measures_length -= OWR_WITH_AOA_MEASUREMENT_LENGTH;
- if (sRange_data.mac_addr_mode_indicator == SHORT_MAC_ADDRESS) {
- STREAM_TO_ARRAY(&owr_aoa_range_measr->mac_addr[0], p, MAC_SHORT_ADD_LEN);
- ranging_measures_length -= MAC_SHORT_ADD_LEN;
- } else if (sRange_data.mac_addr_mode_indicator == EXTENDED_MAC_ADDRESS) {
- STREAM_TO_ARRAY(&owr_aoa_range_measr->mac_addr[0], p, MAC_EXT_ADD_LEN);
- ranging_measures_length -= MAC_EXT_ADD_LEN;
- } else {
- UCI_TRACE_E("%s: Invalid mac addressing indicator", __func__);
- return;
- }
- STREAM_TO_UINT8(owr_aoa_range_measr->status, p);
- STREAM_TO_UINT8(owr_aoa_range_measr->nLos, p);
- STREAM_TO_UINT8(owr_aoa_range_measr->frame_seq_num, p);
- STREAM_TO_UINT16(owr_aoa_range_measr->block_index, p);
- STREAM_TO_UINT16(owr_aoa_range_measr->aoa_azimuth, p);
- STREAM_TO_UINT8(owr_aoa_range_measr->aoa_azimuth_FOM, p);
- STREAM_TO_UINT16(owr_aoa_range_measr->aoa_elevation, p);
- STREAM_TO_UINT8(owr_aoa_range_measr->aoa_elevation_FOM, p);
- } else {
- UCI_TRACE_E("%s: Measurement type(%d) not matched", __func__, sRange_data.ranging_measure_type);
- }
-
- UCI_TRACE_I("%s: ranging_measures_length = %d range_data_ntf_len = %d", __func__,ranging_measures_length,range_data_ntf_len);
- if (ranging_measures_length >= VENDOR_SPEC_INFO_LEN) {
- uint16_t vendor_specific_length =0;
- STREAM_TO_UINT16(vendor_specific_length, p);
- if (vendor_specific_length > 0) {
- if (vendor_specific_length > MAX_VENDOR_INFO_LENGTH) {
- UCI_TRACE_E("%s: Invalid Range_data vendor_specific_length = %x",
- __func__, vendor_specific_length);
- }
-
- STREAM_TO_ARRAY(sRange_data.vendor_specific_ntf.data, p, vendor_specific_length);
- sRange_data.vendor_specific_ntf.len = vendor_specific_length;
- }
- }
-
- uwb_response.sRange_data = sRange_data;
-
- (*uwb_cb.p_resp_cback)(UWB_RANGE_DATA_REVT, &uwb_response);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_send_blink_data_ntf
- **
- ** Description This function is called to process blink data tx
- ** notification
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_send_blink_data_ntf(uint8_t* p_buf, uint16_t len) {
- tUWB_SEND_BLINK_DATA_NTF_REVT blink_data_tx_ntf;
- tUWB_RESPONSE uwb_response;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- memset(&blink_data_tx_ntf, 0, sizeof(tUWB_SEND_BLINK_DATA_NTF_REVT));
- if (len != 0) {
- STREAM_TO_UINT8(blink_data_tx_ntf.repetition_count_status, p_buf);
- } else {
- UCI_TRACE_E("blink_data_tx ntf error");
- }
- uwb_response.sSend_blink_data_ntf = blink_data_tx_ntf;
-
- (*uwb_cb.p_resp_cback)(UWB_BLINK_DATA_TX_NTF_REVT, &uwb_response);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_android_set_country_code_status
- **
- ** Description This function is called to set country code status
- ** notification
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_android_set_country_code_status(uint8_t* p_buf,
- uint16_t len) {
- tUWB_RESPONSE uwb_response;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- uint8_t status = *p_buf;
-
- UCI_TRACE_I("uwb_ucif_proc_android_set_country_code_status country code status = %x", status);
- uwb_response.sSet_country_code_status.status = status;
- uwb_cb.device_state = status;
-
- (*uwb_cb.p_resp_cback)(UWB_SET_COUNTRY_CODE_REVT, &uwb_response);
- if (status == UWBS_STATUS_ERROR) {
- uwb_stop_quick_timer(&uwb_cb.uci_wait_rsp_timer);
- uwb_ucif_uwb_recovery();
- }
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_conformance_ntf
- **
- ** Description This function is called to process conformance test ntf
- **
- ** Returns void
- **
- *******************************************************************************/
-
-void uwb_ucif_proc_conformance_ntf(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE uwb_response;
- tUWB_CONFORMANCE_TEST_DATA conformance_data_ntf;
-
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- memset(&conformance_data_ntf, 0, sizeof(tUWB_CONFORMANCE_TEST_DATA));
- if (len < CONFORMANCE_TEST_MAX_UCI_PKT_LENGTH) {
- conformance_data_ntf.length = len;
- STREAM_TO_ARRAY(&conformance_data_ntf.data[0], p_buf, len);
- } else {
- conformance_data_ntf.length = CONFORMANCE_TEST_MAX_UCI_PKT_LENGTH;
- STREAM_TO_ARRAY(&conformance_data_ntf.data[0], p_buf,
- CONFORMANCE_TEST_MAX_UCI_PKT_LENGTH);
- }
- uwb_response.sConformance_test_data = conformance_data_ntf;
- (*uwb_cb.p_resp_cback)(UWB_CONFORMANCE_TEST_DATA, &uwb_response);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_session_status
- **
- ** Description This function is called to process session related
- ** notification
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_session_status(uint8_t* p_buf, uint16_t len) {
- tUWB_SESSION_NTF_REVT sessionNtf;
- tUWB_RESPONSE uwb_response;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- memset(&sessionNtf, 0, sizeof(tUWB_SESSION_NTF_REVT));
- if (len != 0) {
- STREAM_TO_UINT32(sessionNtf.session_id, p_buf);
- STREAM_TO_UINT8(sessionNtf.state, p_buf);
- STREAM_TO_UINT8(sessionNtf.reason_code, p_buf);
- } else {
- UCI_TRACE_E("session ntf error");
- }
- uwb_response.sSessionStatus = sessionNtf;
-
- (*uwb_cb.p_resp_cback)(UWB_SESSION_STATUS_NTF_REVT, &uwb_response);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_multicast_list_update_ntf
- **
- ** Description This function is called to process multicast list update
- ** notification
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_multicast_list_update_ntf(uint8_t* p_buf, uint16_t len) {
- tUWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT sMulticast_list_ntf;
- tUWB_RESPONSE uwb_response;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- memset(&sMulticast_list_ntf, 0,
- sizeof(tUWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT));
- if (len != 0) {
- STREAM_TO_UINT32(sMulticast_list_ntf.session_id, p_buf);
- STREAM_TO_UINT8(sMulticast_list_ntf.remaining_list, p_buf);
- STREAM_TO_UINT8(sMulticast_list_ntf.no_of_controlees, p_buf);
- if (sMulticast_list_ntf.no_of_controlees > MAX_NUM_CONTROLLEES) {
- UCI_TRACE_E("%s: wrong number of controless : %d", __func__,
- sMulticast_list_ntf.no_of_controlees);
- return;
- }
- for (uint8_t i = 0; i < sMulticast_list_ntf.no_of_controlees; i++) {
- REVERSE_STREAM_TO_ARRAY(
- &sMulticast_list_ntf.controlee_mac_address_list[i], p_buf,
- SHORT_ADDRESS_LEN);
- STREAM_TO_UINT32(sMulticast_list_ntf.subsession_id_list[i], p_buf);
- STREAM_TO_UINT8(sMulticast_list_ntf.status_list[i], p_buf);
- }
- } else {
- UCI_TRACE_E("multicast list update ntf error");
- }
- uwb_response.sMulticast_list_ntf = sMulticast_list_ntf;
-
- (*uwb_cb.p_resp_cback)(UWB_SESSION_UPDATE_MULTICAST_LIST_NTF_REVT,
- &uwb_response);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_get_device_info_rsp
- **
- ** Description This function is called to process get device info response
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_get_device_info_rsp(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE evt_data;
- uint8_t* p = p_buf;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- memset(&evt_data.sGet_device_info, 0, sizeof(tUWB_GET_DEVICE_INFO_REVT));
- evt_data.sGet_device_info.status = *p++;
- STREAM_TO_UINT16(evt_data.sGet_device_info.uci_version, p);
- STREAM_TO_UINT16(evt_data.sGet_device_info.mac_version, p);
- STREAM_TO_UINT16(evt_data.sGet_device_info.phy_version, p);
- STREAM_TO_UINT16(evt_data.sGet_device_info.uciTest_version, p);
- STREAM_TO_UINT8(evt_data.sGet_device_info.vendor_info_len, p);
- STREAM_TO_ARRAY(evt_data.sGet_device_info.vendor_info, p,
- evt_data.sGet_device_info.vendor_info_len);
-
- (*uwb_cb.p_resp_cback)(UWB_GET_DEVICE_INFO_REVT, &evt_data);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_get_device_capability_rsp
- **
- ** Description This function is called to process get device capability
- ** response.
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_get_device_capability_rsp(uint8_t* p_buf, uint16_t len) {
- tUWB_RESPONSE evt_data;
- tUWB_STATUS status;
- uint8_t* p = p_buf;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- status = *p++;
- UCI_TRACE_I("StatusName:%s and StatusValue:%d", UWB_GetStatusName(status),
- status);
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- evt_data.sGet_device_capability.status = status;
- evt_data.sGet_device_capability.no_of_tlvs = *p++;
- evt_data.sGet_device_capability.tlv_buffer_len =
- (uint16_t)(len - CONFIG_TLV_OFFSET);
- if (evt_data.sGet_device_capability.tlv_buffer_len > 0) {
- memcpy(evt_data.sGet_device_capability.tlv_buffer, p,
- evt_data.sGet_device_capability.tlv_buffer_len);
- }
-
- (*uwb_cb.p_resp_cback)(UWB_CORE_GET_DEVICE_CAPABILITY_REVT, &evt_data);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_test_get_config_status
- **
- ** Description This function is called to process get test config response
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_test_get_config_status(uint8_t* p_buf, uint16_t len) {
- tUWB_TEST_RESPONSE evt_data;
- tUWB_STATUS status;
- uint8_t* p = p_buf;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- status = *p++;
- UCI_TRACE_I("Status:%s", UWB_GetStatusName(status));
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- evt_data.sTest_get_config.status = status;
- evt_data.sTest_get_config.no_of_ids = *p++;
- evt_data.sTest_get_config.tlv_size = (uint16_t)(len - CONFIG_TLV_OFFSET);
- if (evt_data.sTest_get_config.tlv_size > 0) {
- memcpy(evt_data.sTest_get_config.p_param_tlvs, p,
- evt_data.sTest_get_config.tlv_size);
- }
- (*uwb_cb.p_test_resp_cback)(UWB_TEST_GET_CONFIG_REVT, &evt_data);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_test_set_config_status
- **
- ** Description This function is called to report UWB_SET_TEST_CONFIG_REVT
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_test_set_config_status(uint8_t* p_buf, uint16_t len) {
- tUWB_TEST_RESPONSE evt_data;
- tUWB_STATUS status;
- uint8_t* p = p_buf;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- status = *p++;
- UCI_TRACE_I("Status:%s", UWB_GetStatusName(status));
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- evt_data.sTest_set_config.status = status;
- evt_data.sTest_set_config.num_param_id = *p++;
- evt_data.sTest_set_config.tlv_size = (uint16_t)(len - CONFIG_TLV_OFFSET);
- if (evt_data.sTest_set_config.tlv_size > 0) {
- STREAM_TO_ARRAY(evt_data.sTest_set_config.param_ids, p,
- evt_data.sTest_set_config.tlv_size);
- }
- (*uwb_cb.p_test_resp_cback)(UWB_TEST_SET_CONFIG_REVT, &evt_data);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_test_management_status
- **
- ** Description This function is called to process test command responses
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_test_management_status(tUWB_TEST_RESPONSE_EVT event,
- uint8_t* p_buf, uint16_t len) {
- tUWB_TEST_RESPONSE evt_data;
- tUWB_TEST_RESPONSE_EVT evt = 0;
- tUWB_STATUS status;
- uint8_t* p = p_buf;
-
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- status = *p++;
- UCI_TRACE_I("Status:%s", UWB_GetStatusName(status));
- switch (event) {
- case UWB_TEST_PERIODIC_TX_REVT:
- evt = UWB_TEST_PERIODIC_TX_REVT;
- evt_data.status = status;
- break;
- case UWB_TEST_PER_RX_REVT:
- evt = UWB_TEST_PER_RX_REVT;
- evt_data.status = status;
- break;
- case UWB_TEST_STOP_SESSION_REVT:
- evt = UWB_TEST_STOP_SESSION_REVT;
- evt_data.status = status;
- break;
- case UWB_TEST_LOOPBACK_REVT:
- evt = UWB_TEST_LOOPBACK_REVT;
- evt_data.status = status;
- break;
- case UWB_TEST_RX_REVT:
- evt = UWB_TEST_RX_REVT;
- evt_data.status = status;
- break;
- default:
- UCI_TRACE_E("unknown response event %x", event);
- }
- if (evt) {
- (*uwb_cb.p_test_resp_cback)(evt, &evt_data);
- }
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_proc_rf_test_data
- **
- ** Description This function is called to report the RF test notifications
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_proc_rf_test_data(tUWB_TEST_RESPONSE_EVT event, uint8_t* p_buf,
- uint16_t len) {
- tUWB_RF_TEST_DATA rf_test_data;
- tUWB_TEST_RESPONSE uwb_response;
- if (len == 0) {
- UCI_TRACE_E("%s: len is zero", __func__);
- return;
- }
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- memset(&rf_test_data, 0, sizeof(tUWB_RF_TEST_DATA));
- rf_test_data.length = len;
- memcpy(&rf_test_data.data[0], p_buf, len);
- uwb_response.sRf_test_result = rf_test_data;
-
- (*uwb_cb.p_test_resp_cback)(event, &uwb_response);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_event_status
- **
- ** Description This function is called to report the event
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_event_status(tUWB_RESPONSE_EVT event, uint8_t status) {
- tUWB_RESPONSE uwb_response;
-
- UCI_TRACE_E("Timeout error ");
- if (uwb_cb.p_resp_cback == NULL) {
- UCI_TRACE_E("%s: response callback is null", __func__);
- return;
- }
- uwb_response.status = status;
- (*uwb_cb.p_resp_cback)(event, &uwb_response);
-}
-
-/*******************************************************************************
- **
- ** Function uwb_ucif_uwb_recovery
- **
- ** Description uwb recovery
- ** 1) spi reset
- ** 2) FW download
- **
- ** Returns void
- **
- *******************************************************************************/
-void uwb_ucif_uwb_recovery(void) {
- uint8_t stat;
- UCI_TRACE_I("uwb_ucif_uwb_recovery");
- if (uwb_cb.is_recovery_in_progress) {
- UCI_TRACE_I("uwb_ucif_uwb_recovery: recovery is already in progreess");
- return;
- }
- uwb_cb.cmd_retry_count = 0;
- uwb_cb.is_resp_pending = false;
- uwb_cb.is_recovery_in_progress = true;
-
- if (uwb_cb.uwb_state == UWB_STATE_W4_HAL_CLOSE ||
- uwb_cb.uwb_state == UWB_STATE_NONE) {
- UCI_TRACE_E("%s: HAL is not initialized", __func__);
- uwb_cb.is_recovery_in_progress = false;
- return;
- }
- stat = uwb_cb.p_hal->CoreInitialization();
- if (stat == UWA_STATUS_OK) {
- UCI_TRACE_I("%s: uwb fw download successfull", __func__);
- } else {
- UCI_TRACE_E("%s: uwb fw download Failed", __func__);
- }
- uwb_main_flush_cmd_queue();
- uwb_cb.is_recovery_in_progress = false;
-}