From 2482c4a0252a0f4c5e34a87a5e055020d5654495 Mon Sep 17 00:00:00 2001 From: liuning Date: Thu, 26 Oct 2023 20:46:32 +0800 Subject: [PATCH] feat(coex): apply struct for coex version --- components/bt/controller/esp32/bt.c | 23 +++++-------------- .../include/private/esp_coexist_adapter.h | 8 ++++++- .../include/private/esp_coexist_internal.h | 8 +++++++ components/esp_coex/lib | 2 +- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/components/bt/controller/esp32/bt.c b/components/bt/controller/esp32/bt.c index 2a8c553b9e..7b2b391a8c 100644 --- a/components/bt/controller/esp32/bt.c +++ b/components/bt/controller/esp32/bt.c @@ -1197,23 +1197,12 @@ static int coex_register_wifi_channel_change_callback_wrapper(void *cb) static int coex_version_get_wrapper(unsigned int *major, unsigned int *minor, unsigned int *patch) { #if CONFIG_SW_COEXIST_ENABLE - const char *ver_str = esp_coex_version_get(); - if (ver_str != NULL) { - unsigned int _major = 0, _minor = 0, _patch = 0; - if (sscanf(ver_str, "%u.%u.%u", &_major, &_minor, &_patch) != 3) { - return -1; - } - if (major != NULL) { - *major = _major; - } - if (minor != NULL) { - *minor = _minor; - } - if (patch != NULL) { - *patch = _patch; - } - return 0; - } + coex_version_t version; + ESP_ERROR_CHECK(coex_version_get_value(&version)); + *major = (unsigned int)version.major; + *minor = (unsigned int)version.minor; + *patch = (unsigned int)version.patch; + return 0; #endif return -1; } diff --git a/components/esp_coex/include/private/esp_coexist_adapter.h b/components/esp_coex/include/private/esp_coexist_adapter.h index fde83d1111..539fd3ec63 100644 --- a/components/esp_coex/include/private/esp_coexist_adapter.h +++ b/components/esp_coex/include/private/esp_coexist_adapter.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -51,6 +51,12 @@ typedef struct { extern coex_adapter_funcs_t g_coex_adapter_funcs; +typedef struct { + uint8_t major; + uint8_t minor; + uint8_t patch; +} coex_version_t; + #ifdef __cplusplus } #endif diff --git a/components/esp_coex/include/private/esp_coexist_internal.h b/components/esp_coex/include/private/esp_coexist_internal.h index 15fe35cc1b..7aee0c0533 100644 --- a/components/esp_coex/include/private/esp_coexist_internal.h +++ b/components/esp_coex/include/private/esp_coexist_internal.h @@ -75,6 +75,14 @@ void coex_disable(void); */ const char *coex_version_get(void); +/** + * @brief Get software coexist version value + * extern function for internal use. + * @param ptr_version : points to version structure + * @return : ESP_OK - success, other - failed + */ +esp_err_t coex_version_get_value(coex_version_t* ptr_version); + /** * @brief Coexist performance preference set from libbt.a * extern function for internal use. diff --git a/components/esp_coex/lib b/components/esp_coex/lib index 68cbbdb45c..cc027a4382 160000 --- a/components/esp_coex/lib +++ b/components/esp_coex/lib @@ -1 +1 @@ -Subproject commit 68cbbdb45cdc8c88ffbfc2587a4e7af020695e56 +Subproject commit cc027a43829f91e0ff5fe0b84713edf61e52cfc6