Merge branch 'release/v3.3' of https://github.com/espressif/esp-idf.git into release/v3.3

# Conflicts:
#	components/bt/include/esp_bt.h
This commit is contained in:
Michael Balzer 2020-07-15 12:08:17 +02:00
commit 0137aef471
975 changed files with 132096 additions and 6715 deletions

File diff suppressed because it is too large Load Diff

4
.gitmodules vendored
View File

@ -69,3 +69,7 @@
[submodule "examples/build_system/cmake/import_lib/main/lib/tinyxml2"]
path = examples/build_system/cmake/import_lib/main/lib/tinyxml2
url = https://github.com/leethomason/tinyxml2
[submodule "components/nimble/nimble"]
path = components/nimble/nimble
url = https://github.com/espressif/esp-nimble.git

View File

@ -7,7 +7,6 @@ version: 2
# Optionally build your docs in additional formats such as PDF and ePub
formats:
- htmlzip
- pdf
# Optionally set the version of Python and requirements required to build your docs
@ -16,7 +15,7 @@ python:
install:
- requirements: docs/requirements.txt
# We need to list all the submodules included in documenation build by Doxygen
# We need to list all the submodules included in documentation build by Doxygen
submodules:
include:
- components/mqtt/esp-mqtt

View File

@ -1,108 +1,6 @@
cmake_minimum_required(VERSION 3.5)
project(esp-idf C CXX ASM)
if(NOT IDF_PATH)
set(IDF_PATH ${CMAKE_CURRENT_LIST_DIR})
endif()
include(tools/cmake/idf_functions.cmake)
#
# Set variables that control the build configuration and the build itself
#
idf_set_variables()
kconfig_set_variables()
#
# Generate a component dependencies file, enumerating components to be included in the build
# as well as their dependencies.
#
execute_process(COMMAND "${CMAKE_COMMAND}"
-D "COMPONENTS=${IDF_COMPONENTS}"
-D "COMPONENT_REQUIRES_COMMON=${IDF_COMPONENT_REQUIRES_COMMON}"
-D "EXCLUDE_COMPONENTS=${IDF_EXCLUDE_COMPONENTS}"
-D "TEST_COMPONENTS=${IDF_TEST_COMPONENTS}"
-D "TEST_EXCLUDE_COMPONENTS=${IDF_TEST_EXCLUDE_COMPONENTS}"
-D "BUILD_TESTS=${IDF_BUILD_TESTS}"
-D "DEPENDENCIES_FILE=${CMAKE_BINARY_DIR}/component_depends.cmake"
-D "COMPONENT_DIRS=${IDF_COMPONENT_DIRS}"
-D "BOOTLOADER_BUILD=${BOOTLOADER_BUILD}"
-D "IDF_TARGET=${IDF_TARGET}"
-D "IDF_PATH=${IDF_PATH}"
-D "DEBUG=${DEBUG}"
-P "${IDF_PATH}/tools/cmake/scripts/expand_requirements.cmake"
WORKING_DIRECTORY "${PROJECT_PATH}"
RESULT_VARIABLE expand_requirements_result)
if(expand_requirements_result)
message(FATAL_ERROR "Failed to expand component requirements")
endif()
include("${CMAKE_BINARY_DIR}/component_depends.cmake")
#
# We now have the following component-related variables:
#
# IDF_COMPONENTS is the list of initial components set by the user
# (or empty to include all components in the build).
# BUILD_COMPONENTS is the list of components to include in the build.
# BUILD_COMPONENT_PATHS is the paths to all of these components, obtained from the component dependencies file.
#
# Print the list of found components and test components
#
string(REPLACE ";" " " BUILD_COMPONENTS_SPACES "${BUILD_COMPONENTS}")
message(STATUS "Component names: ${BUILD_COMPONENTS_SPACES}")
unset(BUILD_COMPONENTS_SPACES)
message(STATUS "Component paths: ${BUILD_COMPONENT_PATHS}")
# Print list of test components
if(TESTS_ALL EQUAL 1 OR TEST_COMPONENTS)
string(REPLACE ";" " " BUILD_TEST_COMPONENTS_SPACES "${BUILD_TEST_COMPONENTS}")
message(STATUS "Test component names: ${BUILD_TEST_COMPONENTS_SPACES}")
unset(BUILD_TEST_COMPONENTS_SPACES)
message(STATUS "Test component paths: ${BUILD_TEST_COMPONENT_PATHS}")
endif()
# Generate project configuration
kconfig_process_config()
# Include sdkconfig.cmake so rest of the build knows the configuration
include(${SDKCONFIG_CMAKE})
# Verify the environment is configured correctly
idf_verify_environment()
# Check git revision (may trigger reruns of cmake)
## sets IDF_VER to IDF git revision
idf_get_git_revision()
# Check that the targets set in cache, sdkconfig, and in environment all match
idf_check_config_target()
## get PROJECT_VER
if(NOT BOOTLOADER_BUILD)
app_get_revision("${CMAKE_SOURCE_DIR}")
endif()
# Add some idf-wide definitions
idf_set_global_compile_options()
# generate compile_commands.json (needs to come after project)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
#
# Setup variables for linker script generation
#
ldgen_set_variables()
# Include any top-level project_include.cmake files from components
foreach(component ${BUILD_COMPONENT_PATHS})
set(COMPONENT_PATH "${component}")
include_if_exists("${component}/project_include.cmake")
unset(COMPONENT_PATH)
endforeach()
#
# Add each component to the build as a library
#
@ -144,18 +42,4 @@ foreach(component ${BUILD_COMPONENTS})
add_component_dependencies(${component_target} ${dep_target} PRIVATE)
endforeach()
endif()
endforeach()
if(IDF_BUILD_ARTIFACTS)
# Write project description JSON file
make_json_list("${BUILD_COMPONENTS}" build_components_json)
make_json_list("${BUILD_COMPONENT_PATHS}" build_component_paths_json)
configure_file("${IDF_PATH}/tools/cmake/project_description.json.in"
"${IDF_BUILD_ARTIFACTS_DIR}/project_description.json")
unset(build_components_json)
unset(build_component_paths_json)
endif()
set(BUILD_COMPONENTS ${BUILD_COMPONENTS} PARENT_SCOPE)
ldgen_add_dependencies()
endforeach()

View File

@ -23,6 +23,10 @@ mainmenu "Espressif IoT Development Framework Configuration"
default "IDF_TARGET_NOT_SET" if IDF_TARGET_ENV=""
default IDF_TARGET_ENV
config IDF_FIRMWARE_CHIP_ID
hex
default 0x0000 if IDF_TARGET="esp32"
default 0xFFFF
menu "SDK tool configuration"
config TOOLPREFIX

66
SUPPORT_POLICY.md Normal file
View File

@ -0,0 +1,66 @@
The latest support policy for ESP-IDF can be found at [https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md](https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md)
Support Period Policy
=====================
Each ESP-IDF major and minor release (V4.0, V4.1, etc) is supported for
18 months after the initial stable release date.
Supported means that the ESP-IDF team will continue to apply bug fixes,
security fixes, etc to the release branch on GitHub, and periodically
make new bugfix releases as needed.
Users are encouraged to upgrade to a newer ESP-IDF release before the
support period finishes and the release becomes End of Life (EOL). It is
our policy to not continue fixing bugs in End of Life releases.
Pre-release versions (betas, previews, `-rc` and `-dev` versions, etc)
are not covered by any support period. Sometimes a particular feature is
marked as \"Preview\" in a release, which means it is also not covered
by the support period.
The ESP-IDF Programming Guide has information about the
[different versions of ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/versions.html)
(major, minor, bugfix, etc).
Long Term Support releases
--------------------------
Some releases (starting with ESP-IDF V3.3) are designated Long Term
Support (LTS). LTS releases are supported for 30 months (2.5 years)
after the initial stable release date.
A new LTS release will be made at least every 18 months. This means
there will always be a period of at least 12 months to upgrade from the
previous LTS release to the following LTS release.
Example
-------
ESP-IDF V3.3 was released in September 2019 and is a Long Term Support
(LTS) release, meaning it will be supported for 30 months until February
2022.
- The first V3.3 release was `v3.3` in September 2019.
- The ESP-IDF team continues to backport bug fixes, security fixes,
etc to the release branch `release/v3.3`.
- Periodically stable bugfix releases are created from the release
branch. For example `v3.3.1`, `v3.3.2`, etc. Users are encouraged to
always update to the latest bugfix release.
- V3.3 bugfix releases continue until February 2022, when all V3.3.x
releases become End of Life.
Existing Releases
-----------------
ESP-IDF release V3.3 and all newer releases will follow this support
period policy. The support period for each release will be announced
when the release is made.
For releases made before the support period policy was announced,
the following support periods apply:
- ESP-IDF V3.1.x and V3.2.x will both be supported until October 2020.
- ESP-IDF V3.0.9 (planned for October 2019) will be the last V3.0
bugfix release. ESP-IDF V3.0.x is End of Life from October 2019.
- ESP-IDF versions before V3.0 are already End of Life.

View File

@ -22,4 +22,14 @@ menu "Application manager"
The PROJECT_NAME variable from the build system will not affect the firmware image.
This value will not be contained in the esp_app_desc structure.
config APP_RETRIEVE_LEN_ELF_SHA
int "The length of APP ELF SHA is stored in RAM(chars)"
default 16
range 8 64
help
At startup, the app will read this many hex characters from the embedded APP ELF SHA-256 hash value
and store it in static RAM. This ensures the app ELF SHA-256 value is always available
if it needs to be printed by the panic handler code.
Changing this value will change the size of a static buffer, in bytes.
endmenu # "Application manager"

View File

@ -72,13 +72,35 @@ static inline char IRAM_ATTR to_hex_digit(unsigned val)
return (val < 10) ? ('0' + val) : ('a' + val - 10);
}
__attribute__((constructor)) void esp_ota_init_app_elf_sha256(void)
{
esp_ota_get_app_elf_sha256(NULL, 0);
}
/* The esp_app_desc.app_elf_sha256 should be possible to print in panic handler during cache is disabled.
* But because the cache is disabled the reading esp_app_desc.app_elf_sha256 is not right and
* can lead to a complete lock-up of the CPU.
* For this reason we do a reading of esp_app_desc.app_elf_sha256 while start up in esp_ota_init_app_elf_sha256()
* and keep it in the static s_app_elf_sha256 value.
*/
int IRAM_ATTR esp_ota_get_app_elf_sha256(char* dst, size_t size)
{
size_t n = MIN((size - 1) / 2, sizeof(esp_app_desc.app_elf_sha256));
const uint8_t* src = esp_app_desc.app_elf_sha256;
static char s_app_elf_sha256[CONFIG_APP_RETRIEVE_LEN_ELF_SHA / 2];
static bool first_call = true;
if (first_call) {
first_call = false;
const uint8_t* src = esp_app_desc.app_elf_sha256;
for (size_t i = 0; i < sizeof(s_app_elf_sha256); ++i) {
s_app_elf_sha256[i] = src[i];
}
}
if (dst == NULL || size == 0) {
return 0;
}
size_t n = MIN((size - 1) / 2, sizeof(s_app_elf_sha256));
for (size_t i = 0; i < n; ++i) {
dst[2*i] = to_hex_digit(src[i] >> 4);
dst[2*i + 1] = to_hex_digit(src[i] & 0xf);
dst[2*i] = to_hex_digit(s_app_elf_sha256[i] >> 4);
dst[2*i + 1] = to_hex_digit(s_app_elf_sha256[i] & 0xf);
}
dst[2*n] = 0;
return 2*n + 1;

View File

@ -43,7 +43,7 @@
#include "esp_efuse.h"
#define SUB_TYPE_ID(i) (i & 0x0F)
#define SUB_TYPE_ID(i) (i & 0x0F)
typedef struct ota_ops_entry_ {
uint32_t handle;
@ -165,7 +165,8 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
if ((image_size == 0) || (image_size == OTA_SIZE_UNKNOWN)) {
ret = esp_partition_erase_range(partition, 0, partition->size);
} else {
ret = esp_partition_erase_range(partition, 0, (image_size / SPI_FLASH_SEC_SIZE + 1) * SPI_FLASH_SEC_SIZE);
const int aligned_erase_size = (image_size + SPI_FLASH_SEC_SIZE - 1) & ~(SPI_FLASH_SEC_SIZE - 1);
ret = esp_partition_erase_range(partition, 0, aligned_erase_size);
}
if (ret != ESP_OK) {
@ -208,7 +209,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
// must erase the partition before writing to it
assert(it->erased_size > 0 && "must erase the partition before writing to it");
if (it->wrote_size == 0 && it->partial_bytes == 0 && size > 0 && data_bytes[0] != ESP_IMAGE_HEADER_MAGIC) {
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x", data_bytes[0]);
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x)", data_bytes[0]);
return ESP_ERR_OTA_VALIDATE_FAILED;
}

View File

@ -4,7 +4,7 @@
TEST_CASE("esp_ota_get_app_elf_sha256 test", "[esp_app_desc]")
{
const int sha256_hex_len = 64;
const int sha256_hex_len = CONFIG_APP_RETRIEVE_LEN_ELF_SHA;
char dst[sha256_hex_len + 2];
const char fill = 0xcc;
int res;

View File

@ -295,7 +295,7 @@ static void test_flow1(void)
// 3 Stage: run OTA0 -> check it -> copy OTA0 to OTA1 -> reboot --//--
// 4 Stage: run OTA1 -> check it -> copy OTA1 to OTA0 -> reboot --//--
// 5 Stage: run OTA0 -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, OTA1, OTA0", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow1, test_flow1, test_flow1, test_flow1);
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, OTA1, OTA0", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow1, test_flow1, test_flow1, test_flow1);
static void test_flow2(void)
{
@ -332,7 +332,7 @@ static void test_flow2(void)
// 2 Stage: run factory -> check it -> copy factory to OTA0 -> reboot --//--
// 3 Stage: run OTA0 -> check it -> corrupt ota data -> reboot --//--
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, corrupt ota_sec1, factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow2, test_flow2, test_flow2);
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, corrupt ota_sec1, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow2, test_flow2, test_flow2);
static void test_flow3(void)
{
@ -376,7 +376,7 @@ static void test_flow3(void)
// 3 Stage: run OTA0 -> check it -> copy OTA0 to OTA1 -> reboot --//--
// 3 Stage: run OTA1 -> check it -> corrupt ota sector2 -> reboot --//--
// 4 Stage: run OTA0 -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, OTA1, currupt ota_sec2, OTA0", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow3, test_flow3, test_flow3, test_flow3);
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, OTA1, currupt ota_sec2, OTA0", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow3, test_flow3, test_flow3, test_flow3);
#ifdef CONFIG_BOOTLOADER_FACTORY_RESET
#define STORAGE_NAMESPACE "update_ota"
@ -443,7 +443,7 @@ static void test_flow4(void)
// 2 Stage: run factory -> check it -> copy factory to OTA0 -> reboot --//--
// 3 Stage: run OTA0 -> check it -> set_pin_factory_reset -> reboot --//--
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
#endif
#ifdef CONFIG_BOOTLOADER_APP_TEST
@ -486,7 +486,7 @@ static void test_flow5(void)
// 2 Stage: run factory -> check it -> copy factory to Test and set pin_test_app -> reboot --//--
// 3 Stage: run test -> check it -> reset pin_test_app -> reboot --//--
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
#endif
static const esp_partition_t* app_update(void)
@ -580,7 +580,7 @@ static void test_rollback1_1(void)
// 3 Stage: run OTA0 -> check it -> esp_ota_mark_app_valid_cancel_rollback() -> reboot --//--
// 4 Stage: run OTA0 -> check it -> esp_ota_mark_app_invalid_rollback_and_reboot() -> reboot
// 5 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Test rollback. factory, OTA0, OTA0, rollback -> factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback1, test_rollback1, test_rollback1, test_rollback1_1);
TEST_CASE_MULTIPLE_STAGES("Test rollback. factory, OTA0, OTA0, rollback -> factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback1, test_rollback1, test_rollback1, test_rollback1_1);
static void test_rollback2(void)
{
@ -678,7 +678,7 @@ static void test_rollback2_1(void)
// 3 Stage: run OTA0 -> check it -> esp_ota_mark_app_valid_cancel_rollback(), copy to next app slot -> reboot --//--
// 4 Stage: run OTA1 -> check it -> PENDING_VERIFY/esp_ota_mark_app_invalid_rollback_and_reboot() -> reboot
// 5 Stage: run OTA0(rollback) -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Test rollback. factory, OTA0, OTA1, rollback -> OTA0", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback2, test_rollback2, test_rollback2, test_rollback2_1);
TEST_CASE_MULTIPLE_STAGES("Test rollback. factory, OTA0, OTA1, rollback -> OTA0", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback2, test_rollback2, test_rollback2, test_rollback2_1);
static void test_erase_last_app_flow(void)
{
@ -729,4 +729,4 @@ static void test_erase_last_app_rollback(void)
// 3 Stage: run OTA0 -> check it -> copy factory to OTA1 -> reboot --//--
// 4 Stage: run OTA1 -> check it -> erase OTA0 and rollback -> reboot
// 5 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Test erase_last_boot_app_partition. factory, OTA1, OTA0, factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_erase_last_app_flow, test_erase_last_app_flow, test_erase_last_app_flow, test_erase_last_app_rollback);
TEST_CASE_MULTIPLE_STAGES("Test erase_last_boot_app_partition. factory, OTA1, OTA0, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_erase_last_app_flow, test_erase_last_app_flow, test_erase_last_app_flow, test_erase_last_app_rollback);

View File

@ -223,6 +223,7 @@ endmenu # Bootloader
menu "Security features"
visible if !IDF_CMAKE
# These three are the actual options to check in code,
# selected by the displayed options
@ -505,4 +506,22 @@ menu "Security features"
Only set this option in testing environments.
endmenu # Potentially Insecure
config FLASH_ENCRYPTION_DISABLE_PLAINTEXT
bool "Disable serial reflashing of plaintext firmware"
depends on FLASH_ENCRYPTION_ENABLED
default y if SECURE_BOOT_ENABLED
default n if !SECURE_BOOT_ENABLED
help
If this option is enabled, flash encryption is permanently enabled after first boot by write-protecting
the FLASH_CRYPT_CNT efuse. This is the recommended configuration for a secure production system.
If this option is disabled, FLASH_CRYPT_CNT is left writeable and up to 4 plaintext re-flashes are allowed.
An attacker with physical access will be able to read out encrypted flash contents until all plaintext
re-flashes have been used up.
If this option is disabled and hardware Secure Boot is enabled, Secure Boot must be configured in
Reflashable mode so that a new Secure Boot digest can be flashed at the same time as plaintext firmware.
This combination is not secure and should not be used for a production system.
endmenu # Security features

View File

@ -24,6 +24,7 @@
#include "bootloader_common.h"
#include "sdkconfig.h"
#include "esp_image_format.h"
#include "rom/rtc.h"
static const char* TAG = "boot";
@ -74,7 +75,8 @@ static int selected_boot_partition(const bootloader_state_t *bs)
int boot_index = bootloader_utility_get_selected_boot_partition(bs);
if (boot_index == INVALID_INDEX) {
return boot_index; // Unrecoverable failure (not due to corrupt ota data or bad partition contents)
} else {
}
if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET) {
// Factory firmware.
#ifdef CONFIG_BOOTLOADER_FACTORY_RESET
if (bootloader_common_check_long_hold_gpio(CONFIG_BOOTLOADER_NUM_PIN_FACTORY_RESET, CONFIG_BOOTLOADER_HOLD_TIME_GPIO) == 1) {

View File

@ -1,6 +1,7 @@
set(COMPONENT_SRCS "src/bootloader_clock.c"
"src/bootloader_common.c"
"src/bootloader_flash.c"
"src/bootloader_flash_config.c"
"src/bootloader_random.c"
"src/bootloader_sha.c"
"src/bootloader_utility.c"

View File

@ -15,6 +15,7 @@
#pragma once
#include "esp_flash_data_types.h"
#include "esp_image_format.h"
#include "esp_image_format.h"
/// Type of hold a GPIO in low state
typedef enum {
@ -23,6 +24,11 @@ typedef enum {
GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
} esp_comm_gpio_hold_t;
typedef enum {
ESP_IMAGE_BOOTLOADER,
ESP_IMAGE_APPLICATION
} esp_image_type;
/**
* @brief Calculate crc for the OTA data select.
*
@ -125,7 +131,7 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
/**
* @brief Returns esp_app_desc structure for app partition. This structure includes app version.
*
*
* Returns a description for the requested app partition.
* @param[in] partition App partition description.
* @param[out] app_desc Structure of info about app.
@ -137,6 +143,24 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
*/
esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t *partition, esp_app_desc_t *app_desc);
/**
* @brief Get chip revision
*
* @return Chip revision number
*/
uint8_t bootloader_common_get_chip_revision(void);
/**
* @brief Check if the image (bootloader and application) has valid chip ID and revision
*
* @param[in] img_hdr: image header
* @param[in] type: image type, bootloader or application
* @return
* - ESP_OK: image and chip are matched well
* - ESP_FAIL: image doesn't match to the chip
*/
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type);
/**
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
*/

View File

@ -0,0 +1,71 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// 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 "esp_image_format.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Update the flash id in g_rom_flashchip(global esp_rom_spiflash_chip_t structure).
*
* @return None
*/
void bootloader_flash_update_id();
/**
* @brief Set the flash CS setup and hold time.
*
* @note CS setup time is recomemded to be 1.5T, and CS hold time is recommended to be 2.5T.
* cs_setup = 1, cs_setup_time = 0; cs_hold = 1, cs_hold_time = 1.
*
* @return None
*/
void bootloader_flash_cs_timing_config();
/**
* @brief Configure SPI flash clock.
*
* @note This function only set clock frequency for SPI0.
*
* @param pfhdr Pointer to App image header, from where to fetch flash settings.
*
* @return None
*/
void bootloader_flash_clock_config(const esp_image_header_t* pfhdr);
/**
* @brief Configure SPI flash gpio, include the IO matrix and drive strength configuration.
*
* @param pfhdr Pointer to App image header, from where to fetch flash settings.
*
* @return None
*/
void bootloader_flash_gpio_config(const esp_image_header_t* pfhdr);
/**
* @brief Configure SPI flash read dummy based on different mode and frequency.
*
* @param pfhdr Pointer to App image header, from where to fetch flash settings.
*
* @return None
*/
void bootloader_flash_dummy_config(const esp_image_header_t* pfhdr);
#ifdef __cplusplus
}
#endif

View File

@ -55,6 +55,19 @@ typedef enum {
#define ESP_IMAGE_HEADER_MAGIC 0xE9
/**
* @brief ESP chip ID
*
*/
typedef enum {
ESP_CHIP_ID_ESP32 = 0x0000, /*!< chip ID: ESP32 */
ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */
} __attribute__((packed)) esp_chip_id_t;
/** @cond */
_Static_assert(sizeof(esp_chip_id_t) == 2, "esp_chip_id_t should be 16 bit");
/** @endcond */
/* Main header of binary image */
typedef struct {
uint8_t magic;
@ -71,8 +84,9 @@ typedef struct {
uint8_t wp_pin;
/* Drive settings for the SPI flash pins (read by ROM bootloader) */
uint8_t spi_pin_drv[3];
/* Reserved bytes in ESP32 additional header space, currently unused */
uint8_t reserved[11];
esp_chip_id_t chip_id; /*!< Chip identification number */
uint8_t min_chip_rev; /*!< Minimum chip revision supported by image */
uint8_t reserved[8]; /*!< Reserved bytes in additional header space, currently unused */
/* If 1, a SHA256 digest "simple hash" (of the entire image) is appended after the checksum. Included in image length. This digest
* is separate to secure boot and only used for detecting corruption. For secure boot signed images, the signature
* is appended after this (and the simple hash is included in the signed data). */

View File

@ -30,6 +30,13 @@
bootloader_support components only.
*/
/**
* @brief Get number of free pages
*
* @return Number of free pages
*/
uint32_t bootloader_mmap_get_free_pages();
/**
* @brief Map a region of flash to data memory
*

View File

@ -59,3 +59,12 @@ void bootloader_clock_configure()
}
#endif
}
#ifdef BOOTLOADER_BUILD
int esp_clk_apb_freq(void)
{
return rtc_clk_apb_freq_get();
}
#endif // BOOTLOADER_BUILD

View File

@ -29,6 +29,9 @@
#include "soc/gpio_periph.h"
#include "soc/efuse_reg.h"
#include "soc/rtc.h"
#include "soc/spi_reg.h"
#include "soc/efuse_reg.h"
#include "soc/apb_ctrl_reg.h"
#include "esp_image_format.h"
#include "bootloader_sha.h"
#include "sys/param.h"
@ -274,3 +277,51 @@ void bootloader_common_vddsdio_configure()
}
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
}
#ifdef CONFIG_IDF_TARGET_ESP32
uint8_t bootloader_common_get_chip_revision(void)
{
uint8_t eco_bit0, eco_bit1, eco_bit2;
eco_bit0 = (REG_READ(EFUSE_BLK0_RDATA3_REG) & 0xF000) >> 15;
eco_bit1 = (REG_READ(EFUSE_BLK0_RDATA5_REG) & 0x100000) >> 20;
eco_bit2 = (REG_READ(APB_CTRL_DATE_REG) & 0x80000000) >> 31;
uint32_t combine_value = (eco_bit2 << 2) | (eco_bit1 << 1) | eco_bit0;
uint8_t chip_ver = 0;
switch (combine_value) {
case 0:
chip_ver = 0;
break;
case 1:
chip_ver = 1;
break;
case 3:
chip_ver = 2;
break;
case 7:
chip_ver = 3;
break;
default:
chip_ver = 0;
break;
}
return chip_ver;
}
#endif
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type)
{
esp_err_t err = ESP_OK;
esp_chip_id_t chip_id = CONFIG_IDF_FIRMWARE_CHIP_ID;
if (chip_id != img_hdr->chip_id) {
ESP_LOGE(TAG, "mismatch chip ID, expected %d, found %d", chip_id, img_hdr->chip_id);
err = ESP_FAIL;
}
uint8_t revision = bootloader_common_get_chip_revision();
if (revision < img_hdr->min_chip_rev) {
ESP_LOGE(TAG, "can't run on lower chip revision, expected %d, found %d", revision, img_hdr->min_chip_rev);
err = ESP_FAIL;
} else if (revision != img_hdr->min_chip_rev) {
ESP_LOGI(TAG, "chip revision: %d, min. %s chip revision: %d", revision, type == ESP_IMAGE_BOOTLOADER ? "bootloader" : "application", img_hdr->min_chip_rev);
}
return err;
}

View File

@ -25,6 +25,11 @@ static const char *TAG = "bootloader_mmap";
static spi_flash_mmap_handle_t map;
uint32_t bootloader_mmap_get_free_pages()
{
return spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA);
}
const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
{
if (map) {
@ -91,12 +96,22 @@ static const char *TAG = "bootloader_flash";
*/
#define MMU_BLOCK0_VADDR 0x3f400000
#define MMU_BLOCK50_VADDR 0x3f720000
#define MMU_FREE_PAGES ((MMU_BLOCK50_VADDR - MMU_BLOCK0_VADDR) / FLASH_BLOCK_SIZE)
static bool mapped;
// Current bootloader mapping (ab)used for bootloader_read()
static uint32_t current_read_mapping = UINT32_MAX;
uint32_t bootloader_mmap_get_free_pages()
{
/**
* Allow mapping up to 50 of the 51 available MMU blocks (last one used for reads)
* Since, bootloader_mmap function below assumes it to be 0x320000 (50 pages), we can safely do this.
*/
return MMU_FREE_PAGES;
}
const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
{
if (mapped) {

View File

@ -0,0 +1,166 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// 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 <stdbool.h>
#include <assert.h>
#include "string.h"
#include "sdkconfig.h"
#include "esp_err.h"
#include "esp_log.h"
#include "rom/gpio.h"
#include "rom/spi_flash.h"
#include "rom/efuse.h"
#include "soc/gpio_periph.h"
#include "soc/efuse_reg.h"
#include "soc/spi_reg.h"
#include "soc/spi_pins.h"
#include "flash_qio_mode.h"
#include "bootloader_flash_config.h"
void bootloader_flash_update_id()
{
g_rom_flashchip.device_id = bootloader_read_flash_id();
}
void IRAM_ATTR bootloader_flash_cs_timing_config()
{
SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_SETUP_TIME_V, 0, SPI_SETUP_TIME_S);
SET_PERI_REG_MASK(SPI_USER_REG(1), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_SETUP_TIME_V, 0, SPI_SETUP_TIME_S);
}
void IRAM_ATTR bootloader_flash_clock_config(const esp_image_header_t* pfhdr)
{
uint32_t spi_clk_div = 0;
switch (pfhdr->spi_speed) {
case ESP_IMAGE_SPI_SPEED_80M:
spi_clk_div = 1;
break;
case ESP_IMAGE_SPI_SPEED_40M:
spi_clk_div = 2;
break;
case ESP_IMAGE_SPI_SPEED_26M:
spi_clk_div = 3;
break;
case ESP_IMAGE_SPI_SPEED_20M:
spi_clk_div = 4;
break;
default:
break;
}
esp_rom_spiflash_config_clk(spi_clk_div, 0);
esp_rom_spiflash_config_clk(spi_clk_div, 1);
}
void IRAM_ATTR bootloader_flash_gpio_config(const esp_image_header_t* pfhdr)
{
uint32_t drv = 2;
if (pfhdr->spi_speed == ESP_IMAGE_SPI_SPEED_80M) {
drv = 3;
}
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
uint32_t pkg_ver = chip_ver & 0x7;
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
// For ESP32D2WD the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
// For ESP32PICOD2 the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
// For ESP32PICOD4 the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else {
const uint32_t spiconfig = ets_efuse_get_spiconfig();
if (spiconfig == EFUSE_SPICONFIG_SPI_DEFAULTS) {
gpio_matrix_out(SPI_IOMUX_PIN_NUM_CS, SPICS0_OUT_IDX, 0, 0);
gpio_matrix_out(SPI_IOMUX_PIN_NUM_MISO, SPIQ_OUT_IDX, 0, 0);
gpio_matrix_in(SPI_IOMUX_PIN_NUM_MISO, SPIQ_IN_IDX, 0);
gpio_matrix_out(SPI_IOMUX_PIN_NUM_MOSI, SPID_OUT_IDX, 0, 0);
gpio_matrix_in(SPI_IOMUX_PIN_NUM_MOSI, SPID_IN_IDX, 0);
gpio_matrix_out(SPI_IOMUX_PIN_NUM_WP, SPIWP_OUT_IDX, 0, 0);
gpio_matrix_in(SPI_IOMUX_PIN_NUM_WP, SPIWP_IN_IDX, 0);
gpio_matrix_out(SPI_IOMUX_PIN_NUM_HD, SPIHD_OUT_IDX, 0, 0);
gpio_matrix_in(SPI_IOMUX_PIN_NUM_HD, SPIHD_IN_IDX, 0);
//select pin function gpio
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA0_U, PIN_FUNC_GPIO);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA1_U, PIN_FUNC_GPIO);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, PIN_FUNC_GPIO);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, PIN_FUNC_GPIO);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CMD_U, PIN_FUNC_GPIO);
// flash clock signal should come from IO MUX.
// set drive ability for clock
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
uint32_t flash_id = g_rom_flashchip.device_id;
if (flash_id == FLASH_ID_GD25LQ32C) {
// Set drive ability for 1.8v flash in 80Mhz.
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA0_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA1_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA2_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA3_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CMD_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, 3, FUN_DRV_S);
}
}
}
}
void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t* pfhdr)
{
int spi_cache_dummy = 0;
uint32_t modebit = READ_PERI_REG(SPI_CTRL_REG(0));
if (modebit & SPI_FASTRD_MODE) {
if (modebit & SPI_FREAD_QIO) { //SPI mode is QIO
spi_cache_dummy = SPI0_R_QIO_DUMMY_CYCLELEN;
} else if (modebit & SPI_FREAD_DIO) { //SPI mode is DIO
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN;
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_ADDR_BITLEN_V, SPI0_R_DIO_ADDR_BITSLEN, SPI_USR_ADDR_BITLEN_S);
} else if(modebit & (SPI_FREAD_QUAD | SPI_FREAD_DUAL)) { //SPI mode is QOUT or DIO
spi_cache_dummy = SPI0_R_FAST_DUMMY_CYCLELEN;
}
}
extern uint8_t g_rom_spiflash_dummy_len_plus[];
switch (pfhdr->spi_speed) {
case ESP_IMAGE_SPI_SPEED_80M:
g_rom_spiflash_dummy_len_plus[0] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_80M;
g_rom_spiflash_dummy_len_plus[1] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_80M;
break;
case ESP_IMAGE_SPI_SPEED_40M:
g_rom_spiflash_dummy_len_plus[0] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_40M;
g_rom_spiflash_dummy_len_plus[1] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_40M;
break;
case ESP_IMAGE_SPI_SPEED_26M:
case ESP_IMAGE_SPI_SPEED_20M:
g_rom_spiflash_dummy_len_plus[0] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_20M;
g_rom_spiflash_dummy_len_plus[1] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_20M;
break;
default:
break;
}
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + g_rom_spiflash_dummy_len_plus[0],
SPI_USR_DUMMY_CYCLELEN_S);
}

View File

@ -49,6 +49,7 @@
#include "bootloader_config.h"
#include "bootloader_clock.h"
#include "bootloader_common.h"
#include "bootloader_flash_config.h"
#include "flash_qio_mode.h"
@ -62,7 +63,7 @@ static const char* TAG = "boot";
static esp_err_t bootloader_main();
static void print_flash_info(const esp_image_header_t* pfhdr);
static void update_flash_config(const esp_image_header_t* pfhdr);
static void flash_gpio_configure(const esp_image_header_t* pfhdr);
static void bootloader_init_flash_configure(const esp_image_header_t* pfhdr);
static void uart_console_configure(void);
static void wdt_reset_check(void);
@ -125,7 +126,15 @@ static esp_err_t bootloader_main()
ESP_LOGE(TAG, "failed to load bootloader header!");
return ESP_FAIL;
}
flash_gpio_configure(&fhdr);
/* Check chip ID and minimum chip revision that supported by this image */
uint8_t revision = bootloader_common_get_chip_revision();
ESP_LOGI(TAG, "Chip Revision: %d", revision);
if (bootloader_common_check_chip_validity(&fhdr, ESP_IMAGE_BOOTLOADER) != ESP_OK) {
return ESP_FAIL;
}
bootloader_init_flash_configure(&fhdr);
#if (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240)
//Check if ESP32 is rated for a CPU frequency of 160MHz only
if (REG_GET_BIT(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_CPU_FREQ_RATED) &&
@ -285,118 +294,15 @@ static void print_flash_info(const esp_image_header_t* phdr)
#endif
}
#define FLASH_CLK_IO 6
#define FLASH_CS_IO 11
#define FLASH_SPIQ_IO 7
#define FLASH_SPID_IO 8
#define FLASH_SPIWP_IO 10
#define FLASH_SPIHD_IO 9
#define FLASH_IO_MATRIX_DUMMY_40M 1
#define FLASH_IO_MATRIX_DUMMY_80M 2
#define FLASH_IO_DRIVE_GD_WITH_1V8PSRAM 3
/*
* Bootloader reads SPI configuration from bin header, so that
* the burning configuration can be different with compiling configuration.
*/
static void IRAM_ATTR flash_gpio_configure(const esp_image_header_t* pfhdr)
static void IRAM_ATTR bootloader_init_flash_configure(const esp_image_header_t* pfhdr)
{
int spi_cache_dummy = 0;
int drv = 2;
switch (pfhdr->spi_mode) {
case ESP_IMAGE_SPI_MODE_QIO:
spi_cache_dummy = SPI0_R_QIO_DUMMY_CYCLELEN;
break;
case ESP_IMAGE_SPI_MODE_DIO:
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN;
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_ADDR_BITLEN_V, SPI0_R_DIO_ADDR_BITSLEN, SPI_USR_ADDR_BITLEN_S);
break;
case ESP_IMAGE_SPI_MODE_QOUT:
case ESP_IMAGE_SPI_MODE_DOUT:
default:
spi_cache_dummy = SPI0_R_FAST_DUMMY_CYCLELEN;
break;
}
/* dummy_len_plus values defined in ROM for SPI flash configuration */
extern uint8_t g_rom_spiflash_dummy_len_plus[];
switch (pfhdr->spi_speed) {
case ESP_IMAGE_SPI_SPEED_80M:
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_80M;
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_80M;
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_80M,
SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
drv = 3;
break;
case ESP_IMAGE_SPI_SPEED_40M:
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_40M;
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_40M;
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_40M,
SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
break;
case ESP_IMAGE_SPI_SPEED_26M:
case ESP_IMAGE_SPI_SPEED_20M:
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy, SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
break;
default:
break;
}
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
uint32_t pkg_ver = chip_ver & 0x7;
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
// For ESP32D2WD the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
// For ESP32PICOD2 the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
// For ESP32PICOD4 the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else {
const uint32_t spiconfig = ets_efuse_get_spiconfig();
if (spiconfig == EFUSE_SPICONFIG_SPI_DEFAULTS) {
gpio_matrix_out(FLASH_CS_IO, SPICS0_OUT_IDX, 0, 0);
gpio_matrix_out(FLASH_SPIQ_IO, SPIQ_OUT_IDX, 0, 0);
gpio_matrix_in(FLASH_SPIQ_IO, SPIQ_IN_IDX, 0);
gpio_matrix_out(FLASH_SPID_IO, SPID_OUT_IDX, 0, 0);
gpio_matrix_in(FLASH_SPID_IO, SPID_IN_IDX, 0);
gpio_matrix_out(FLASH_SPIWP_IO, SPIWP_OUT_IDX, 0, 0);
gpio_matrix_in(FLASH_SPIWP_IO, SPIWP_IN_IDX, 0);
gpio_matrix_out(FLASH_SPIHD_IO, SPIHD_OUT_IDX, 0, 0);
gpio_matrix_in(FLASH_SPIHD_IO, SPIHD_IN_IDX, 0);
//select pin function gpio
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA0_U, PIN_FUNC_GPIO);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA1_U, PIN_FUNC_GPIO);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, PIN_FUNC_GPIO);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, PIN_FUNC_GPIO);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CMD_U, PIN_FUNC_GPIO);
// flash clock signal should come from IO MUX.
// set drive ability for clock
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
#if CONFIG_SPIRAM_TYPE_ESPPSRAM32
uint32_t flash_id = g_rom_flashchip.device_id;
if (flash_id == FLASH_ID_GD25LQ32C) {
// Set drive ability for 1.8v flash in 80Mhz.
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA0_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA1_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA2_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA3_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CMD_U, FUN_DRV, 3, FUN_DRV_S);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, 3, FUN_DRV_S);
}
#endif
}
}
bootloader_flash_gpio_config(pfhdr);
bootloader_flash_dummy_config(pfhdr);
bootloader_flash_cs_timing_config();
}
static void uart_console_configure(void)

View File

@ -114,17 +114,18 @@ void bootloader_random_enable(void)
void bootloader_random_disable(void)
{
/* Disable i2s clock */
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
/* Reset some i2s configuration (possibly redundant as we reset entire
I2S peripheral further down). */
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
SET_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_CAMERA_EN);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_LCD_EN);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE_TEST_EN);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE);
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
/* Disable i2s clock */
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
/* Restore SYSCON mode registers */
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);

View File

@ -24,6 +24,7 @@
#include <bootloader_random.h>
#include <bootloader_sha.h>
#include "bootloader_util.h"
#include "bootloader_common.h"
/* Checking signatures as part of verifying images is necessary:
- Always if secure boot is enabled
@ -280,6 +281,9 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t
}
err = ESP_ERR_IMAGE_INVALID;
}
if (bootloader_common_check_chip_validity(image, ESP_IMAGE_APPLICATION) != ESP_OK) {
err = ESP_ERR_IMAGE_INVALID;
}
if (!silent) {
if (image->spi_mode > ESP_IMAGE_SPI_MODE_SLOW_READ) {
ESP_LOGW(TAG, "image at 0x%x has invalid SPI mode %d", src_addr, image->spi_mode);
@ -368,24 +372,22 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
}
#endif // BOOTLOADER_BUILD
#ifndef BOOTLOADER_BUILD
uint32_t free_page_count = spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA);
ESP_LOGD(TAG, "free data page_count 0x%08x",free_page_count);
uint32_t offset_page = 0;
while (data_len >= free_page_count * SPI_FLASH_MMU_PAGE_SIZE) {
offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0)?1:0;
err = process_segment_data(load_addr, data_addr, (free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE, do_load, sha_handle, checksum);
uint32_t free_page_count = bootloader_mmap_get_free_pages();
ESP_LOGD(TAG, "free data page_count 0x%08x", free_page_count);
int32_t data_len_remain = data_len;
while (data_len_remain > 0) {
uint32_t offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0) ? 1 : 0;
/* Data we could map in case we are not aligned to PAGE boundary is one page size lesser. */
data_len = MIN(data_len_remain, ((free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE));
err = process_segment_data(load_addr, data_addr, data_len, do_load, sha_handle, checksum);
if (err != ESP_OK) {
return err;
}
data_addr += (free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE;
data_len -= (free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE;
}
#endif
err = process_segment_data(load_addr, data_addr, data_len, do_load, sha_handle, checksum);
if (err != ESP_OK) {
return err;
data_addr += data_len;
data_len_remain -= data_len;
}
return ESP_OK;
err:

View File

@ -205,6 +205,14 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
uint32_t new_flash_crypt_cnt = flash_crypt_cnt + (1 << (ffs_inv - 1));
ESP_LOGD(TAG, "FLASH_CRYPT_CNT 0x%x -> 0x%x", flash_crypt_cnt, new_flash_crypt_cnt);
REG_SET_FIELD(EFUSE_BLK0_WDATA0_REG, EFUSE_FLASH_CRYPT_CNT, new_flash_crypt_cnt);
#ifdef CONFIG_FLASH_ENCRYPTION_DISABLE_PLAINTEXT
ESP_LOGI(TAG, "Write protecting FLASH_CRYPT_CNT efuse...");
REG_SET_BIT(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_FLASH_CRYPT_CNT);
#else
ESP_LOGW(TAG, "Not disabling FLASH_CRYPT_CNT - plaintext flashing is still possible");
#endif
esp_efuse_burn_new_values();
ESP_LOGI(TAG, "Flash encryption completed");

View File

@ -21,12 +21,7 @@
#include "uECC.h"
#ifdef BOOTLOADER_BUILD
#include "rom/sha.h"
typedef SHA_CTX sha_context;
#else
#include "mbedtls/sha256.h"
#endif
#include <sys/param.h>
static const char* TAG = "secure_boot";
@ -37,6 +32,9 @@ extern const uint8_t signature_verification_key_end[] asm("_binary_signature_ver
#define DIGEST_LEN 32
/* Mmap source address mask */
#define MMAP_ALIGNED_MASK 0x0000FFFF
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
{
uint8_t digest[DIGEST_LEN];
@ -45,26 +43,44 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
ESP_LOGD(TAG, "verifying signature src_addr 0x%x length 0x%x", src_addr, length);
data = bootloader_mmap(src_addr, length + sizeof(esp_secure_boot_sig_block_t));
if(data == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", src_addr, length+sizeof(esp_secure_boot_sig_block_t));
return ESP_FAIL;
bootloader_sha256_handle_t handle = bootloader_sha256_start();
uint32_t free_page_count = bootloader_mmap_get_free_pages();
ESP_LOGD(TAG, "free data page_count 0x%08x", free_page_count);
int32_t data_len_remain = length;
uint32_t data_addr = src_addr;
while (data_len_remain > 0) {
uint32_t offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0) ? 1 : 0;
/* Data we could map in case we are not aligned to PAGE boundary is one page size lesser. */
uint32_t data_len = MIN(data_len_remain, ((free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE));
data = (const uint8_t *) bootloader_mmap(data_addr, data_len);
if(!data) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", data_addr, data_len);
bootloader_sha256_finish(handle, NULL);
return ESP_FAIL;
}
bootloader_sha256_data(handle, data, data_len);
bootloader_munmap(data);
data_addr += data_len;
data_len_remain -= data_len;
}
// Calculate digest of main image
#ifdef BOOTLOADER_BUILD
bootloader_sha256_handle_t handle = bootloader_sha256_start();
bootloader_sha256_data(handle, data, length);
/* Done! Get the digest */
bootloader_sha256_finish(handle, digest);
#else
/* Use thread-safe mbedTLS version */
mbedtls_sha256_ret(data, length, digest, 0);
#endif
// Map the signature block and verify the signature
sigblock = (const esp_secure_boot_sig_block_t *)(data + length);
// Map the signature block
sigblock = (const esp_secure_boot_sig_block_t *) bootloader_mmap(src_addr + length, sizeof(esp_secure_boot_sig_block_t));
if(!sigblock) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", src_addr + length, sizeof(esp_secure_boot_sig_block_t));
return ESP_FAIL;
}
// Verify the signature
esp_err_t err = esp_secure_boot_verify_signature_block(sigblock, digest);
bootloader_munmap(data);
// Unmap
bootloader_munmap(sigblock);
return err;
}

View File

@ -6,6 +6,8 @@ if(CONFIG_BT_ENABLED)
if(CONFIG_BLUEDROID_ENABLED)
list(APPEND COMPONENT_PRIV_INCLUDEDIRS
common/btc/include
common/include
bluedroid/bta/include
bluedroid/bta/ar/include
bluedroid/bta/av/include
@ -18,7 +20,6 @@ if(CONFIG_BT_ENABLED)
bluedroid/bta/sys/include
bluedroid/device/include
bluedroid/hci/include
bluedroid/osi/include
bluedroid/external/sbc/decoder/include
bluedroid/external/sbc/encoder/include
bluedroid/btc/profile/esp/blufi/include
@ -38,11 +39,29 @@ if(CONFIG_BT_ENABLED)
bluedroid/stack/a2dp/include
bluedroid/stack/rfcomm/include
bluedroid/stack/include
bluedroid/common/include)
bluedroid/common/include
common/btc/include
common/include)
list(APPEND COMPONENT_ADD_INCLUDEDIRS bluedroid/api/include/api)
list(APPEND COMPONENT_ADD_INCLUDEDIRS bluedroid/api/include/api
common/osi/include)
list(APPEND COMPONENT_SRCS "bluedroid/api/esp_a2dp_api.c"
list(APPEND COMPONENT_SRCS "common/btc/core/btc_alarm.c"
"common/btc/core/btc_manage.c"
"common/btc/core/btc_task.c"
"common/osi/alarm.c"
"common/osi/allocator.c"
"common/osi/buffer.c"
"common/osi/config.c"
"common/osi/fixed_queue.c"
"common/osi/future.c"
"common/osi/hash_functions.c"
"common/osi/hash_map.c"
"common/osi/list.c"
"common/osi/mutex.c"
"common/osi/osi.c"
"common/osi/semaphore.c"
"bluedroid/api/esp_a2dp_api.c"
"bluedroid/api/esp_avrc_api.c"
"bluedroid/api/esp_blufi_api.c"
"bluedroid/api/esp_bt_device.c"
@ -109,18 +128,15 @@ if(CONFIG_BT_ENABLED)
"bluedroid/bta/sys/bta_sys_conn.c"
"bluedroid/bta/sys/bta_sys_main.c"
"bluedroid/bta/sys/utl.c"
"bluedroid/btc/core/btc_alarm.c"
"bluedroid/btc/core/btc_ble_storage.c"
"bluedroid/btc/core/btc_config.c"
"bluedroid/btc/core/btc_dev.c"
"bluedroid/btc/core/btc_dm.c"
"bluedroid/btc/core/btc_main.c"
"bluedroid/btc/core/btc_manage.c"
"bluedroid/btc/core/btc_profile_queue.c"
"bluedroid/btc/core/btc_sec.c"
"bluedroid/btc/core/btc_sm.c"
"bluedroid/btc/core/btc_storage.c"
"bluedroid/btc/core/btc_task.c"
"bluedroid/btc/core/btc_util.c"
"bluedroid/btc/profile/esp/blufi/blufi_prf.c"
"bluedroid/btc/profile/esp/blufi/blufi_protocol.c"
@ -173,18 +189,6 @@ if(CONFIG_BT_ENABLED)
"bluedroid/hci/packet_fragmenter.c"
"bluedroid/main/bte_init.c"
"bluedroid/main/bte_main.c"
"bluedroid/osi/alarm.c"
"bluedroid/osi/allocator.c"
"bluedroid/osi/buffer.c"
"bluedroid/osi/config.c"
"bluedroid/osi/fixed_queue.c"
"bluedroid/osi/future.c"
"bluedroid/osi/hash_functions.c"
"bluedroid/osi/hash_map.c"
"bluedroid/osi/list.c"
"bluedroid/osi/mutex.c"
"bluedroid/osi/osi.c"
"bluedroid/osi/semaphore.c"
"bluedroid/stack/a2dp/a2d_api.c"
"bluedroid/stack/a2dp/a2d_sbc.c"
"bluedroid/stack/avct/avct_api.c"
@ -279,11 +283,125 @@ if(CONFIG_BT_ENABLED)
"bluedroid/stack/smp/smp_l2c.c"
"bluedroid/stack/smp/smp_main.c"
"bluedroid/stack/smp/smp_utils.c")
if(CONFIG_BLE_MESH)
list(APPEND COMPONENT_SRCS "esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c")
endif()
endif()
if(CONFIG_BLE_MESH)
list(APPEND COMPONENT_ADD_INCLUDEDIRS
"esp_ble_mesh/mesh_common/include"
"esp_ble_mesh/mesh_core"
"esp_ble_mesh/mesh_core/include"
"esp_ble_mesh/mesh_core/storage"
"esp_ble_mesh/btc/include"
"esp_ble_mesh/mesh_models/common/include"
"esp_ble_mesh/mesh_models/client/include"
"esp_ble_mesh/mesh_models/server/include"
"esp_ble_mesh/api/core/include"
"esp_ble_mesh/api/models/include"
"esp_ble_mesh/api")
list(APPEND COMPONENT_SRCS
"esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_common_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_local_data_operation_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_low_power_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c"
"esp_ble_mesh/api/models/esp_ble_mesh_config_model_api.c"
"esp_ble_mesh/api/models/esp_ble_mesh_generic_model_api.c"
"esp_ble_mesh/api/models/esp_ble_mesh_health_model_api.c"
"esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c"
"esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c"
"esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c"
"esp_ble_mesh/btc/btc_ble_mesh_config_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_generic_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_health_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
"esp_ble_mesh/mesh_common/mesh_aes_encrypt.c"
"esp_ble_mesh/mesh_common/mesh_atomic.c"
"esp_ble_mesh/mesh_common/mesh_buf.c"
"esp_ble_mesh/mesh_common/mesh_common.c"
"esp_ble_mesh/mesh_common/mesh_kernel.c"
"esp_ble_mesh/mesh_common/mesh_mutex.c"
"esp_ble_mesh/mesh_common/mesh_timer.c"
"esp_ble_mesh/mesh_common/mesh_util.c"
"esp_ble_mesh/mesh_core/storage/settings_nvs.c"
"esp_ble_mesh/mesh_core/access.c"
"esp_ble_mesh/mesh_core/adv.c"
"esp_ble_mesh/mesh_core/beacon.c"
"esp_ble_mesh/mesh_core/cfg_cli.c"
"esp_ble_mesh/mesh_core/cfg_srv.c"
"esp_ble_mesh/mesh_core/crypto.c"
"esp_ble_mesh/mesh_core/friend.c"
"esp_ble_mesh/mesh_core/health_cli.c"
"esp_ble_mesh/mesh_core/health_srv.c"
"esp_ble_mesh/mesh_core/local_operation.c"
"esp_ble_mesh/mesh_core/lpn.c"
"esp_ble_mesh/mesh_core/main.c"
"esp_ble_mesh/mesh_core/net.c"
"esp_ble_mesh/mesh_core/prov.c"
"esp_ble_mesh/mesh_core/provisioner_main.c"
"esp_ble_mesh/mesh_core/provisioner_prov.c"
"esp_ble_mesh/mesh_core/proxy_client.c"
"esp_ble_mesh/mesh_core/proxy_server.c"
"esp_ble_mesh/mesh_core/settings.c"
"esp_ble_mesh/mesh_core/test.c"
"esp_ble_mesh/mesh_core/transport.c"
"esp_ble_mesh/mesh_models/client/client_common.c"
"esp_ble_mesh/mesh_models/client/generic_client.c"
"esp_ble_mesh/mesh_models/client/lighting_client.c"
"esp_ble_mesh/mesh_models/client/sensor_client.c"
"esp_ble_mesh/mesh_models/client/time_scene_client.c"
"esp_ble_mesh/mesh_models/server/device_property.c"
"esp_ble_mesh/mesh_models/server/generic_server.c"
"esp_ble_mesh/mesh_models/server/lighting_server.c"
"esp_ble_mesh/mesh_models/server/sensor_server.c"
"esp_ble_mesh/mesh_models/server/server_common.c"
"esp_ble_mesh/mesh_models/server/state_binding.c"
"esp_ble_mesh/mesh_models/server/state_transition.c"
"esp_ble_mesh/mesh_models/server/time_scene_server.c")
endif()
if(CONFIG_NIMBLE_ENABLED)
if (CONFIG_BLE_MESH)
list(APPEND COMPONENT_PRIV_INCLUDEDIRS
common/btc/include
common/include)
list(APPEND COMPONENT_ADD_INCLUDEDIRS common/osi/include)
list(APPEND COMPONENT_SRCS "esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c"
"common/btc/core/btc_alarm.c"
"common/btc/core/btc_manage.c"
"common/btc/core/btc_task.c"
"common/osi/alarm.c"
"common/osi/allocator.c"
"common/osi/buffer.c"
"common/osi/config.c"
"common/osi/fixed_queue.c"
"common/osi/future.c"
"common/osi/hash_functions.c"
"common/osi/hash_map.c"
"common/osi/list.c"
"common/osi/mutex.c"
"common/osi/osi.c"
"common/osi/semaphore.c")
endif()
endif()
endif()
# requirements can't depend on config
set(COMPONENT_PRIV_REQUIRES nvs_flash)
set(COMPONENT_PRIV_REQUIRES nvs_flash nimble)
register_component()

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@
#include "esp_bt_main.h"
#include "esp_gap_bt_api.h"
#include "common/bt_trace.h"
#include "bta/bta_api.h"
#include "btc/btc_manage.h"
#include "btc_gap_bt.h"
#include "btc/btc_storage.h"

View File

@ -46,4 +46,13 @@ esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
arg.set_mtu.mtu = mtu;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatt_com_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
}
#if (BLE_INCLUDED == TRUE)
extern uint16_t L2CA_GetFreePktBufferNum_LE(void);
uint16_t esp_ble_get_sendable_packets_num ()
{
return L2CA_GetFreePktBufferNum_LE();
}
#endif

View File

@ -95,6 +95,10 @@ esp_err_t esp_spp_connect(esp_spp_sec_t sec_mask,
btc_spp_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (sec_mask != ESP_SPP_SEC_NONE && sec_mask != ESP_SPP_SEC_AUTHORIZE && sec_mask != ESP_SPP_SEC_AUTHENTICATE) {
LOG_WARN("Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHORIZE or ESP_SPP_SEC_AUTHENTICATE only\n");
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_SPP;
msg.act = BTC_SPP_ACT_CONNECT;
@ -133,6 +137,10 @@ esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
return ESP_ERR_INVALID_ARG;
}
if (sec_mask != ESP_SPP_SEC_NONE && sec_mask != ESP_SPP_SEC_AUTHORIZE && sec_mask != ESP_SPP_SEC_AUTHENTICATE) {
LOG_WARN("Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHORIZE or ESP_SPP_SEC_AUTHENTICATE only\n");
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_SPP;
msg.act = BTC_SPP_ACT_START_SRV;

View File

@ -83,6 +83,7 @@ typedef enum {
ESP_BLUFI_DH_PARAM_ERROR,
ESP_BLUFI_READ_PARAM_ERROR,
ESP_BLUFI_MAKE_PUBLIC_ERROR,
ESP_BLUFI_DATA_FORMAT_ERROR,
} esp_blufi_error_state_t;
/**

View File

@ -267,14 +267,25 @@ typedef enum {
typedef enum {
ESP_BLE_SM_PASSKEY = 0,
/* Authentication requirements of local device */
ESP_BLE_SM_AUTHEN_REQ_MODE,
/* The IO capability of local device */
ESP_BLE_SM_IOCAP_MODE,
/* Initiator Key Distribution/Generation */
ESP_BLE_SM_SET_INIT_KEY,
/* Responder Key Distribution/Generation */
ESP_BLE_SM_SET_RSP_KEY,
/* Maximum Encryption key size to support */
ESP_BLE_SM_MAX_KEY_SIZE,
/* Minimum Encryption key size requirement from Peer */
ESP_BLE_SM_MIN_KEY_SIZE,
/* Set static Passkey */
ESP_BLE_SM_SET_STATIC_PASSKEY,
/* Reset static Passkey */
ESP_BLE_SM_CLEAR_STATIC_PASSKEY,
/* Accept only specified SMP Authentication requirement */
ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH,
/* Enable/Disable OOB support */
ESP_BLE_SM_OOB_SUPPORT,
ESP_BLE_SM_MAX_PARAM,
} esp_ble_sm_param_t;
@ -589,7 +600,7 @@ typedef enum {
typedef enum {
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR = 0, /*!< BLE advertising address , device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID, /*!< BLE mesh link ID, it is for BLE mesh, device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE, /*!< BLE mesh beacon AD type, the format is | Len | 0x2B | Beacon Type | Beacon Data | */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE, /*!< BLE mesh beacon AD type, the format is | Len | 0x2B | Beacon Type | Beacon Data | */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV, /*!< BLE mesh provisioning service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1827 | .... |` */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV, /*!< BLE mesh adv with proxy service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1828 | .... |` */
} esp_ble_duplicate_exceptional_info_type_t;

View File

@ -361,13 +361,15 @@ esp_err_t esp_bt_gap_register_callback(esp_bt_gap_cb_t callback);
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode);
/**
* @brief Start device discovery. This function should be called after esp_bluedroid_enable() completes successfully.
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is started or halted.
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_RES_EVT if discovery result is got.
* @brief This function starts Inquiry and Name Discovery. It should be called after esp_bluedroid_enable() completes successfully.
* When Inquiry is halted and cached results do not contain device name, then Name Discovery will connect to the peer target to get the device name.
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT when Inquriry is started or Name Discovery is completed.
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_DISC_RES_EVT each time the two types of discovery results are got.
*
* @param[in] mode - inquiry mode
* @param[in] inq_len - inquiry duration in 1.28 sec units, ranging from 0x01 to 0x30
* @param[in] num_rsps - number of inquiry responses that can be received, value 0 indicates an unlimited number of responses
* @param[in] mode - Inquiry mode
* @param[in] inq_len - Inquiry duration in 1.28 sec units, ranging from 0x01 to 0x30. This parameter only specifies the total duration of the Inquiry process,
* - when this time expires, Inquiry will be halted.
* @param[in] num_rsps - Number of responses that can be received before the Inquiry is halted, value 0 indicates an unlimited number of responses.
*
* @return
* - ESP_OK : Succeed
@ -378,8 +380,9 @@ esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode);
esp_err_t esp_bt_gap_start_discovery(esp_bt_inq_mode_t mode, uint8_t inq_len, uint8_t num_rsps);
/**
* @brief Cancel device discovery. This function should be called after esp_bluedroid_enable() completes successfully
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is stopped.
* @brief Cancel Inquiry and Name Discovery. This function should be called after esp_bluedroid_enable() completes successfully.
* esp_bt_gap_cb_t will be called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if Inquiry or Name Discovery is cancelled by
* calling this function.
*
* @return
* - ESP_OK : Succeed

View File

@ -44,6 +44,10 @@ extern "C" {
*/
extern esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu);
#if (BLE_INCLUDED == TRUE)
extern uint16_t esp_ble_get_sendable_packets_num (void);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -34,7 +34,7 @@ extern "C" {
* All "ESP_GATT_UUID_xxx" is attribute types
*/
#define ESP_GATT_UUID_IMMEDIATE_ALERT_SVC 0x1802 /* Immediate alert Service*/
#define ESP_GATT_UUID_LINK_LOSS_SVC 0x1803 /* Link Loss Service*/
#define ESP_GATT_UUID_LINK_LOSS_SVC 0x1803 /* Link Loss Service*/
#define ESP_GATT_UUID_TX_POWER_SVC 0x1804 /* TX Power Service*/
#define ESP_GATT_UUID_CURRENT_TIME_SVC 0x1805 /* Current Time Service Service*/
#define ESP_GATT_UUID_REF_TIME_UPDATE_SVC 0x1806 /* Reference Time Update Service*/
@ -68,8 +68,14 @@ extern "C" {
#define ESP_GATT_UUID_CHAR_PRESENT_FORMAT 0x2904 /* Characteristic Presentation Format*/
#define ESP_GATT_UUID_CHAR_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
#define ESP_GATT_UUID_CHAR_VALID_RANGE 0x2906 /* Characteristic Valid Range */
#define ESP_GATT_UUID_EXT_RPT_REF_DESCR 0x2907
#define ESP_GATT_UUID_RPT_REF_DESCR 0x2908
#define ESP_GATT_UUID_EXT_RPT_REF_DESCR 0x2907 /* External Report Reference */
#define ESP_GATT_UUID_RPT_REF_DESCR 0x2908 /* Report Reference */
#define ESP_GATT_UUID_NUM_DIGITALS_DESCR 0x2909 /* Number of Digitals */
#define ESP_GATT_UUID_VALUE_TRIGGER_DESCR 0x290A /* Value Trigger Setting */
#define ESP_GATT_UUID_ENV_SENSING_CONFIG_DESCR 0x290B /* Environmental Sensing Configuration */
#define ESP_GATT_UUID_ENV_SENSING_MEASUREMENT_DESCR 0x290C /* Environmental Sensing Measurement */
#define ESP_GATT_UUID_ENV_SENSING_TRIGGER_DESCR 0x290D /* Environmental Sensing Trigger Setting */
#define ESP_GATT_UUID_TIME_TRIGGER_DESCR 0x290E /* Time Trigger Setting */
/* GAP Profile Attributes */
#define ESP_GATT_UUID_GAP_DEVICE_NAME 0x2A00
@ -299,7 +305,7 @@ typedef enum {
* @brief Attribute description (used to create database)
*/
typedef struct
{
{
uint16_t uuid_length; /*!< UUID length */
uint8_t *uuid_p; /*!< UUID value */
uint16_t perm; /*!< Attribute permission */
@ -348,23 +354,23 @@ typedef struct
/**
* @brief Gatt include service entry element
*/
typedef struct
typedef struct
{
uint16_t start_hdl; /*!< Gatt start handle value of included service */
uint16_t end_hdl; /*!< Gatt end handle value of included service */
uint16_t uuid; /*!< Gatt attribute value UUID of included service */
uint16_t start_hdl; /*!< Gatt start handle value of included service */
uint16_t end_hdl; /*!< Gatt end handle value of included service */
uint16_t uuid; /*!< Gatt attribute value UUID of included service */
} esp_gatts_incl_svc_desc_t; /*!< Gatt include service entry element */
/**
* @brief Gatt include 128 bit service entry element
*/
typedef struct
typedef struct
{
uint16_t start_hdl; /*!< Gatt start handle value of included 128 bit service */
uint16_t end_hdl; /*!< Gatt end handle value of included 128 bit service */
} esp_gatts_incl128_svc_desc_t; /*!< Gatt include 128 bit service entry element */
uint16_t start_hdl; /*!< Gatt start handle value of included 128 bit service */
uint16_t end_hdl; /*!< Gatt end handle value of included 128 bit service */
} esp_gatts_incl128_svc_desc_t; /*!< Gatt include 128 bit service entry element */
/// Gatt attribute value
/// Gatt attribute value
typedef struct {
uint8_t value[ESP_GATT_MAX_ATTR_LEN]; /*!< Gatt attribute value */
uint16_t handle; /*!< Gatt attribute handle */
@ -426,8 +432,8 @@ typedef struct {
/**
* @brief service element
*/
typedef struct {
bool is_primary; /*!< The service flag, true if the service is primary service, else is secondly service */
typedef struct {
bool is_primary; /*!< The service flag, true if the service is primary service, else is secondary service */
uint16_t start_handle; /*!< The start handle of the service */
uint16_t end_handle; /*!< The end handle of the service */
esp_bt_uuid_t uuid; /*!< The uuid of the service */

View File

@ -30,7 +30,7 @@ typedef enum {
ESP_SPP_NO_RESOURCE /*!< No more set pm control block */
} esp_spp_status_t;
/* Security Setting Mask */
/* Security Setting Mask, Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHORIZE or ESP_SPP_SEC_AUTHENTICATE only.*/
#define ESP_SPP_SEC_NONE 0x0000 /*!< No security. relate to BTA_SEC_NONE in bta/bta_api.h */
#define ESP_SPP_SEC_AUTHORIZE 0x0001 /*!< Authorization required (only needed for out going connection ) relate to BTA_SEC_AUTHORIZE in bta/bta_api.h*/
#define ESP_SPP_SEC_AUTHENTICATE 0x0012 /*!< Authentication required. relate to BTA_SEC_AUTHENTICATE in bta/bta_api.h*/
@ -229,7 +229,7 @@ esp_err_t esp_spp_start_discovery(esp_bd_addr_t bd_addr);
* When the connection is established or failed,
* the callback is called with ESP_SPP_OPEN_EVT.
*
* @param[in] sec_mask: Security Setting Mask .
* @param[in] sec_mask: Security Setting Mask. Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHORIZE or ESP_SPP_SEC_AUTHENTICATE only.
* @param[in] role: Master or slave.
* @param[in] remote_scn: Remote device bluetooth device SCN.
* @param[in] peer_bd_addr: Remote device bluetooth device address.
@ -260,7 +260,7 @@ esp_err_t esp_spp_disconnect(uint32_t handle);
* When the connection is established, the callback is called
* with ESP_SPP_SRV_OPEN_EVT.
*
* @param[in] sec_mask: Security Setting Mask .
* @param[in] sec_mask: Security Setting Mask. Security Setting Mask. Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHORIZE or ESP_SPP_SEC_AUTHENTICATE only.
* @param[in] role: Master or slave.
* @param[in] local_scn: The specific channel you want to get.
* If channel is 0, means get any channel.

View File

@ -41,6 +41,7 @@
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
#include "bta/bta_ar_api.h"
#endif
#include "bta/bta_api.h"
/*****************************************************************************
** Constants
@ -528,8 +529,21 @@ static void bta_av_proc_stream_evt(UINT8 handle, BD_ADDR bd_addr, UINT8 event, t
/* look up application event */
if ((p_data == NULL) || (p_data->hdr.err_code == 0)) {
p_msg->hdr.event = bta_av_stream_evt_ok[event];
if (p_msg->hdr.event == BTA_AV_STR_START_OK_EVT) {
BTA_DmCoexEventTrigger(BTA_COEX_EVT_STREAMING_STARTED);
} else if (p_msg->hdr.event == BTA_AV_STR_START_FAIL_EVT ||
p_msg->hdr.event == BTA_AV_STR_SUSPEND_CFM_EVT ||
p_msg->hdr.event == BTA_AV_STR_CLOSE_EVT) {
BTA_DmCoexEventTrigger(BTA_COEX_EVT_STREAMING_STOPPED);
}
} else {
p_msg->hdr.event = bta_av_stream_evt_fail[event];
if (p_msg->hdr.event == BTA_AV_STR_START_FAIL_EVT ||
p_msg->hdr.event == BTA_AV_STR_START_OK_EVT ||
p_msg->hdr.event == BTA_AV_STR_SUSPEND_CFM_EVT ||
p_msg->hdr.event == BTA_AV_STR_CLOSE_EVT) {
BTA_DmCoexEventTrigger(BTA_COEX_EVT_STREAMING_STOPPED);
}
}
p_msg->initiator = FALSE;

View File

@ -114,7 +114,7 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id,
p_buf->hdr.layer_specific = chnl;
p_buf->hdr.event = BTA_AV_API_REGISTER_EVT;
if (p_service_name) {
BCM_STRNCPY_S(p_buf->p_service_name, sizeof(p_buf->p_service_name), p_service_name, BTA_SERVICE_NAME_LEN);
BCM_STRNCPY_S(p_buf->p_service_name, p_service_name, BTA_SERVICE_NAME_LEN);
p_buf->p_service_name[BTA_SERVICE_NAME_LEN - 1] = 0;
} else {
p_buf->p_service_name[0] = 0;

View File

@ -40,8 +40,9 @@ const UINT32 bta_av_meta_caps_co_ids[] = {
AVRC_CO_BROADCOM
};
/* AVRCP cupported categories */
#define BTA_AV_RC_SUPF_CT (AVRC_SUPF_CT_CAT2)
/* AVRCP supported categories */
#define BTA_AV_RC_SNK_SUPF_CT (AVRC_SUPF_CT_CAT1)
#define BTA_AV_RC_SRC_SUPF_CT (AVRC_SUPF_CT_CAT2)
/* Added to modify
** 1. flush timeout
@ -62,9 +63,11 @@ const UINT16 bta_av_audio_flush_to[] = {
/* Note: Android doesnt support AVRC_SUPF_TG_GROUP_NAVI */
/* Note: if AVRC_SUPF_TG_GROUP_NAVI is set, bta_av_cfg.avrc_group should be TRUE */
#if AVRC_METADATA_INCLUDED == TRUE
#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
#define BTA_AV_RC_SNK_SUPF_TG (AVRC_SUPF_TG_CAT2) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
#define BTA_AV_RC_SRC_SUPF_TG (AVRC_SUPF_TG_CAT1) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
#else
#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1)
#define BTA_AV_RC_SNK_SUPF_TG (AVRC_SUPF_TG_CAT2)
#define BTA_AV_RC_SRC_SUPF_TG (AVRC_SUPF_TG_CAT1)
#endif
/*
@ -95,8 +98,10 @@ const tBTA_AV_CFG bta_av_cfg = {
48, /* AVRCP MTU at L2CAP for control channel */
#endif
BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */
BTA_AV_RC_SUPF_TG, /* AVRCP target categories */
BTA_AV_RC_SNK_SUPF_CT, /* AVRCP controller categories as SNK */
BTA_AV_RC_SNK_SUPF_TG, /* AVRCP target categories as SNK */
BTA_AV_RC_SRC_SUPF_CT, /* AVRCP controller categories as SRC */
BTA_AV_RC_SRC_SUPF_TG, /* AVRCP target categories as SRC */
672, /* AVDTP signaling channel MTU at L2CAP */
BTA_AV_MAX_A2DP_MTU, /* AVDTP audio transport channel MTU at L2CAP */
bta_av_audio_flush_to, /* AVDTP audio transport channel flush timeout */

View File

@ -483,8 +483,7 @@ static void bta_av_api_sink_enable(tBTA_AV_DATA *p_data)
activate_sink = p_data->hdr.layer_specific;
APPL_TRACE_DEBUG("bta_av_api_sink_enable %d \n", activate_sink)
char p_service_name[BTA_SERVICE_NAME_LEN + 1];
BCM_STRNCPY_S(p_service_name, sizeof(p_service_name),
BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN);
BCM_STRNCPY_S(p_service_name, BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN);
if (activate_sink) {
AVDT_SINK_Activate();
@ -526,7 +525,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
tBTA_UTL_COD cod;
UINT8 index = 0;
char p_avk_service_name[BTA_SERVICE_NAME_LEN + 1];
BCM_STRNCPY_S(p_avk_service_name, sizeof(p_avk_service_name), BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN);
BCM_STRNCPY_S(p_avk_service_name, BTIF_AVK_SERVICE_NAME, BTA_SERVICE_NAME_LEN);
memset(&cs, 0, sizeof(tAVDT_CS));
@ -571,9 +570,13 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
(UINT8)(bta_av_cb.sec_mask & (~BTA_SEC_AUTHORIZE)), BTA_ID_AV);
#endif
bta_ar_reg_avrc(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target\n", NULL,
p_bta_av_cfg->avrc_tg_cat, BTA_ID_AV);
if (p_data->api_reg.tsep == AVDT_TSEP_SRC) {
bta_ar_reg_avrc(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target\n", NULL,
p_bta_av_cfg->avrc_src_tg_cat, BTA_ID_AV);
} else {
bta_ar_reg_avrc(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target\n", NULL,
p_bta_av_cfg->avrc_snk_tg_cat, BTA_ID_AV);
}
#endif
}
@ -707,8 +710,13 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
}
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
/* create an SDP record as AVRC CT. */
bta_ar_reg_avrc(UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL, NULL,
p_bta_av_cfg->avrc_ct_cat, BTA_ID_AV);
if (p_data->api_reg.tsep == AVDT_TSEP_SRC) {
bta_ar_reg_avrc(UUID_SERVCLASS_AV_REMOTE_CONTROL, "AV Remote Control Controller\n", NULL,
p_bta_av_cfg->avrc_src_ct_cat, BTA_ID_AV);
} else {
bta_ar_reg_avrc(UUID_SERVCLASS_AV_REMOTE_CONTROL, "AV Remote Control Controller\n", NULL,
p_bta_av_cfg->avrc_snk_ct_cat, BTA_ID_AV);
}
#endif
}
}

View File

@ -323,6 +323,9 @@ void bta_dm_deinit_cb(void)
}
#endif
memset(&bta_dm_cb, 0, sizeof(bta_dm_cb));
#if BTA_DYNAMIC_MEMORY
xSemaphoreGive(deinit_semaphore);
#endif /* #if BTA_DYNAMIC_MEMORY */
}
/*******************************************************************************
@ -693,7 +696,6 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
if (p_data->set_visibility.pair_mode != BTA_DM_IGNORE || p_data->set_visibility.conn_paired_only != BTA_DM_IGNORE) {
BTM_SetPairableMode((BOOLEAN)(!(bta_dm_cb.disable_pair_mode)), bta_dm_cb.conn_paired_only);
}
}
/*******************************************************************************
@ -1684,7 +1686,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
if (SDP_FindServiceUUIDInRec(p_sdp_rec, &service_uuid)) {
/* send result back to app now, one by one */
bdcpy (result.disc_ble_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
BCM_STRNCPY_S((char *)result.disc_ble_res.bd_name, sizeof(BD_NAME), bta_dm_get_remname(), (BD_NAME_LEN));
BCM_STRNCPY_S((char *)result.disc_ble_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN));
result.disc_ble_res.bd_name[BD_NAME_LEN] = 0;
result.disc_ble_res.service.len = service_uuid.len;
result.disc_ble_res.service.uu.uuid16 = service_uuid.uu.uuid16;
@ -1825,8 +1827,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
}
bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME),
bta_dm_get_remname(), (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN - 1));
/* make sure the string is null terminated */
p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0;
@ -1852,8 +1853,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
p_msg->disc_result.result.disc_res.result = BTA_FAILURE;
p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found;
bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME),
bta_dm_get_remname(), (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN - 1));
/* make sure the string is null terminated */
p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0;
@ -2237,8 +2237,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found;
bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME),
bta_dm_get_remname(), (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN - 1));
/* make sure the string is terminated */
p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0;
@ -2423,8 +2422,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
p_msg->disc_result.result.disc_res.result = BTA_SUCCESS;
p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found;
bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME),
(char *)bta_dm_search_cb.peer_name, (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, (char *)bta_dm_search_cb.peer_name, (BD_NAME_LEN - 1));
/* make sure the string is terminated */
p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0;
@ -2568,7 +2566,7 @@ static void bta_dm_service_search_remname_cback (BD_ADDR bd_addr, DEV_CLASS dc,
rem_name.length = (BD_NAME_LEN - 1);
rem_name.remote_bd_name[(BD_NAME_LEN - 1)] = 0;
}
BCM_STRNCPY_S((char *)rem_name.remote_bd_name, sizeof(BD_NAME), (char *)bd_name, (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)rem_name.remote_bd_name, (char *)bd_name, (BD_NAME_LEN - 1));
rem_name.status = BTM_SUCCESS;
bta_dm_remname_cback(&rem_name);
@ -2611,7 +2609,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name)
/* remote name discovery is done but it could be failed */
bta_dm_search_cb.name_discover_done = TRUE;
BCM_STRNCPY_S((char *)bta_dm_search_cb.peer_name, sizeof(BD_NAME), (char *)p_remote_name->remote_bd_name, (BD_NAME_LEN));
BCM_STRNCPY_S((char *)bta_dm_search_cb.peer_name,(char *)p_remote_name->remote_bd_name, (BD_NAME_LEN));
bta_dm_search_cb.peer_name[BD_NAME_LEN] = 0;
BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
@ -2624,7 +2622,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name)
if ((p_msg = (tBTA_DM_REM_NAME *) osi_malloc(sizeof(tBTA_DM_REM_NAME))) != NULL) {
bdcpy (p_msg->result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
BCM_STRNCPY_S((char *)p_msg->result.disc_res.bd_name, sizeof(BD_NAME), (char *)p_remote_name->remote_bd_name, (BD_NAME_LEN));
BCM_STRNCPY_S((char *)p_msg->result.disc_res.bd_name, (char *)p_remote_name->remote_bd_name, (BD_NAME_LEN));
/* make sure the string is null terminated */
p_msg->result.disc_res.bd_name[BD_NAME_LEN] = 0;
@ -2656,7 +2654,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
bdcpy(sec_event.authorize.bd_addr, bd_addr);
memcpy(sec_event.authorize.dev_class, dev_class, DEV_CLASS_LEN);
BCM_STRNCPY_S((char *)sec_event.authorize.bd_name, sizeof(BD_NAME), (char *)bd_name, (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)sec_event.authorize.bd_name, (char *)bd_name, (BD_NAME_LEN - 1));
/* make sure the string is null terminated */
sec_event.authorize.bd_name[BD_NAME_LEN - 1] = 0;
@ -2768,7 +2766,7 @@ static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_
bdcpy(sec_event.pin_req.bd_addr, bd_addr);
BTA_COPY_DEVICE_CLASS(sec_event.pin_req.dev_class, dev_class);
BCM_STRNCPY_S((char *)sec_event.pin_req.bd_name, sizeof(BD_NAME), (char *)bd_name, (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)sec_event.pin_req.bd_name, (char *)bd_name, (BD_NAME_LEN - 1));
sec_event.pin_req.bd_name[BD_NAME_LEN - 1] = 0;
sec_event.pin_req.min_16_digit = min_16_digit;
@ -2938,8 +2936,7 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
copy these values into key_notif from cfm_req */
bdcpy(sec_event.key_notif.bd_addr, p_data->cfm_req.bd_addr);
BTA_COPY_DEVICE_CLASS(sec_event.key_notif.dev_class, p_data->cfm_req.dev_class);
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, sizeof(BD_NAME),
(char *)p_data->cfm_req.bd_name, (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, (char *)p_data->cfm_req.bd_name, (BD_NAME_LEN - 1));
sec_event.key_notif.bd_name[BD_NAME_LEN - 1] = 0;
}
}
@ -2960,8 +2957,7 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
} else {
bdcpy(sec_event.key_notif.bd_addr, p_data->key_notif.bd_addr);
BTA_COPY_DEVICE_CLASS(sec_event.key_notif.dev_class, p_data->key_notif.dev_class);
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, sizeof(BD_NAME),
(char *)p_data->key_notif.bd_name, (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, (char *)p_data->key_notif.bd_name, (BD_NAME_LEN - 1));
sec_event.key_notif.bd_name[BD_NAME_LEN - 1] = 0;
}
}
@ -2982,8 +2978,7 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
} else {
bdcpy(sec_event.key_notif.bd_addr, p_data->key_notif.bd_addr);
BTA_COPY_DEVICE_CLASS(sec_event.key_notif.dev_class, p_data->key_notif.dev_class);
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, sizeof(BD_NAME),
(char *)p_data->key_notif.bd_name, (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, (char *)p_data->key_notif.bd_name, (BD_NAME_LEN - 1));
sec_event.key_notif.bd_name[BD_NAME_LEN - 1] = 0;
}
}
@ -3012,7 +3007,7 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
bdcpy(sec_event.rmt_oob.bd_addr, p_data->rmt_oob.bd_addr);
BTA_COPY_DEVICE_CLASS(sec_event.rmt_oob.dev_class, p_data->rmt_oob.dev_class);
BCM_STRNCPY_S((char *)sec_event.rmt_oob.bd_name, sizeof(BD_NAME), (char *)p_data->rmt_oob.bd_name, (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)sec_event.rmt_oob.bd_name, (char *)p_data->rmt_oob.bd_name, (BD_NAME_LEN - 1));
sec_event.rmt_oob.bd_name[BD_NAME_LEN - 1] = 0;
bta_dm_cb.p_sec_cback(BTA_DM_SP_RMT_OOB_EVT, &sec_event);
@ -4348,8 +4343,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
bdcpy(sec_event.ble_req.bd_addr, bda);
p_name = BTM_SecReadDevName(bda);
if (p_name != NULL) {
BCM_STRNCPY_S((char *)sec_event.ble_req.bd_name,
sizeof(BD_NAME), p_name, (BD_NAME_LEN));
BCM_STRNCPY_S((char *)sec_event.ble_req.bd_name, p_name, (BD_NAME_LEN));
} else {
sec_event.ble_req.bd_name[0] = 0;
}
@ -4361,8 +4355,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
bdcpy(sec_event.key_notif.bd_addr, bda);
p_name = BTM_SecReadDevName(bda);
if (p_name != NULL) {
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name,
sizeof(BD_NAME), p_name, (BD_NAME_LEN));
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, p_name, (BD_NAME_LEN));
} else {
sec_event.key_notif.bd_name[0] = 0;
}
@ -4383,7 +4376,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
case BTM_LE_NC_REQ_EVT:
bdcpy(sec_event.key_notif.bd_addr, bda);
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, sizeof(BD_NAME), bta_dm_get_remname(), (BD_NAME_LEN));
BCM_STRNCPY_S((char *)sec_event.key_notif.bd_name, bta_dm_get_remname(), (BD_NAME_LEN));
sec_event.ble_req.bd_name[BD_NAME_LEN] = 0;
sec_event.key_notif.passkey = p_data->key_notif;
bta_dm_cb.p_sec_cback(BTA_DM_BLE_NC_REQ_EVT, &sec_event);
@ -4403,8 +4396,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
#endif
p_name = BTM_SecReadDevName(bda);
if (p_name != NULL) {
BCM_STRNCPY_S((char *)sec_event.auth_cmpl.bd_name,
sizeof(BD_NAME), p_name, (BD_NAME_LEN));
BCM_STRNCPY_S((char *)sec_event.auth_cmpl.bd_name, p_name, (BD_NAME_LEN));
} else {
sec_event.auth_cmpl.bd_name[0] = 0;
}
@ -5685,7 +5677,7 @@ static void bta_dm_gatt_disc_result(tBTA_GATT_ID service_id)
/* send result back to app now, one by one */
bdcpy (result.disc_ble_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
BCM_STRNCPY_S((char *)result.disc_ble_res.bd_name, sizeof(BD_NAME), bta_dm_get_remname(), (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)result.disc_ble_res.bd_name,bta_dm_get_remname(), (BD_NAME_LEN - 1));
result.disc_ble_res.bd_name[BD_NAME_LEN] = 0;
memcpy(&result.disc_ble_res.service, &service_id.uuid, sizeof(tBT_UUID));
@ -5727,8 +5719,7 @@ static void bta_dm_gatt_disc_complete(UINT16 conn_id, tBTA_GATT_STATUS status)
p_msg->disc_result.result.disc_res.num_uuids = 0;
p_msg->disc_result.result.disc_res.p_uuid_list = NULL;
bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, sizeof(BD_NAME),
bta_dm_get_remname(), (BD_NAME_LEN - 1));
BCM_STRNCPY_S((char *)p_msg->disc_result.result.disc_res.bd_name, bta_dm_get_remname(), (BD_NAME_LEN - 1));
/* make sure the string is terminated */
p_msg->disc_result.result.disc_res.bd_name[BD_NAME_LEN - 1] = 0;

View File

@ -174,7 +174,7 @@ void BTA_DmSetDeviceName(const char *p_name)
if ((p_msg = (tBTA_DM_API_SET_NAME *) osi_malloc(sizeof(tBTA_DM_API_SET_NAME))) != NULL) {
p_msg->hdr.event = BTA_DM_API_SET_NAME_EVT;
/* truncate the name if needed */
BCM_STRNCPY_S((char *)p_msg->name, sizeof(p_msg->name), p_name, BD_NAME_LEN - 1);
BCM_STRNCPY_S((char *)p_msg->name, p_name, BD_NAME_LEN - 1);
p_msg->name[BD_NAME_LEN - 1] = 0;
bta_sys_sendmsg(p_msg);
@ -736,7 +736,7 @@ UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr )
**
** Description This function adds a DI record to the local SDP database.
**
** Returns BTA_SUCCESS if record set sucessfully, otherwise error code.
** Returns BTA_SUCCESS if record set successfully, otherwise error code.
**
*******************************************************************************/
tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
@ -1819,7 +1819,7 @@ void BTA_DmBleConfigLocalIcon(uint16_t icon)
** p_cback: callback function associated to this adv instance.
** p_ref: reference data pointer to this adv instance.
**
** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
** Returns BTA_SUCCESS if command started successfully; otherwise failure.
**
*******************************************************************************/
void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
@ -1857,7 +1857,7 @@ void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
** Parameters inst_id: Adv instance to update the parameter.
** p_params: pointer to the adv parameter structure.
**
** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
** Returns BTA_SUCCESS if command started successfully; otherwise failure.
**
*******************************************************************************/
void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
@ -1892,7 +1892,7 @@ void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
** memory space can not be freed until BTA_BLE_MULTI_ADV_DATA_EVT
** is sent to application.
**
** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
** Returns BTA_SUCCESS if command started successfully; otherwise failure.
**
*******************************************************************************/
void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
@ -1925,7 +1925,7 @@ void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
**
** Parameter inst_id: instance ID to disable.
**
** Returns BTA_SUCCESS if command started sucessfully; otherwise failure.
** Returns BTA_SUCCESS if command started successfully; otherwise failure.
**
*******************************************************************************/
void BTA_BleDisableAdvInstance (UINT8 inst_id) //this function just used for vendor debug

View File

@ -228,9 +228,9 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
{{BTA_DM_PM_SNIFF3, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
{{BTA_DM_PM_SNIFF, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
{{BTA_DM_PM_SNIFF, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
{{BTA_DM_PM_RETRY, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
}

View File

@ -48,6 +48,7 @@ tBTE_APPL_CFG bte_appl_cfg = {
BTM_BLE_INITIATOR_KEY_SIZE,
BTM_BLE_RESPONDER_KEY_SIZE,
BTM_BLE_MAX_KEY_SIZE,
BTM_BLE_MIN_KEY_SIZE,
BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE,
BTM_BLE_OOB_DISABLE,
};
@ -407,7 +408,7 @@ void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key)
void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size)
{
#if (SMP_INCLUDED == TRUE)
if(ble_key_size >= BTM_BLE_MIN_KEY_SIZE && ble_key_size <= BTM_BLE_MAX_KEY_SIZE) {
if(ble_key_size >= bte_appl_cfg.ble_min_key_size && ble_key_size <= BTM_BLE_MAX_KEY_SIZE) {
bte_appl_cfg.ble_max_key_size = ble_key_size;
} else {
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
@ -415,6 +416,17 @@ void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size)
#endif ///SMP_INCLUDED == TRUE
}
void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size)
{
#if (SMP_INCLUDED == TRUE)
if(ble_key_size >= BTM_BLE_MIN_KEY_SIZE && ble_key_size <= bte_appl_cfg.ble_max_key_size) {
bte_appl_cfg.ble_min_key_size = ble_key_size;
} else {
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
}
#endif ///SMP_INCLUDED == TRUE
}
void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable)
{
#if (SMP_INCLUDED == TRUE)

View File

@ -28,6 +28,7 @@
#include "osi/allocator.h"
#include <string.h>
#include "esp_coexist.h"
/*****************************************************************************
** Constants and types
@ -452,3 +453,27 @@ BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg)
return TRUE;
}
void BTA_DmCoexEventTrigger(uint32_t event)
{
switch(event) {
case BTA_COEX_EVT_SCAN_STARTED:
case BTA_COEX_EVT_SCAN_STOPPED:
case BTA_COEX_EVT_SNIFF_ENTER:
case BTA_COEX_EVT_SNIFF_EXIT:
case BTA_COEX_EVT_A2DP_PAUSED_ENTER:
case BTA_COEX_EVT_A2DP_PAUSED_EXIT:
case BTA_COEX_EVT_ACL_CONNECTED:
case BTA_COEX_EVT_ACL_DISCONNECTED:
break;
case BTA_COEX_EVT_STREAMING_STARTED:
esp_coex_status_bit_set(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING);
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED);
break;
case BTA_COEX_EVT_STREAMING_STOPPED:
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING);
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED);
break;
default:
break;
}
}

View File

@ -25,7 +25,7 @@
#define BTA_DM_INT_H
#include "common/bt_target.h"
#include "freertos/semphr.h"
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
#include "bta/bta_gatt_api.h"
#endif
@ -1209,6 +1209,7 @@ extern tBTA_DM_DI_CB bta_dm_di_cb;
#else
extern tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
#define bta_dm_di_cb (*bta_dm_di_cb_ptr)
SemaphoreHandle_t deinit_semaphore;
#endif
extern BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg);

View File

@ -745,6 +745,8 @@ void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data)
void bta_gattc_disconncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data)
{
if (p_rcb) {
// Clear up the notification registration information by BD_ADDR
bta_gattc_clear_notif_registration_by_bda(p_rcb, p_data->int_conn.remote_bda);
bta_gattc_send_disconnect_cback(p_rcb,
p_data->int_conn.reason,
p_data->int_conn.remote_bda,

View File

@ -76,7 +76,7 @@ void BTA_GATTC_Disable(void)
** Description This function is called to register application callbacks
** with BTA GATTC module.
**
** Parameters p_app_uuid - applicaiton UUID
** Parameters p_app_uuid - application UUID
** p_client_cb - pointer to the application callback function.
**
** Returns None
@ -338,13 +338,13 @@ const tBTA_GATTC_DESCRIPTOR* BTA_GATTC_GetDescriptor(UINT16 conn_id, UINT16 hand
}
void BTA_GATTC_GetServiceWithUUID(UINT16 conn_id, tBT_UUID *svc_uuid,
btgatt_db_element_t **db, int *count)
btgatt_db_element_t **db, UINT16 *count)
{
bta_gattc_get_service_with_uuid(conn_id, svc_uuid, db, count);
}
void BTA_GATTC_GetAllChar(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
btgatt_db_element_t **db, int *count)
btgatt_db_element_t **db, UINT16 *count)
{
bta_gattc_get_db_with_opration(conn_id,
GATT_OP_GET_ALL_CHAR,
@ -359,7 +359,7 @@ void BTA_GATTC_GetAllChar(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle
}
void BTA_GATTC_GetAllDescriptor(UINT16 conn_id, UINT16 char_handle,
btgatt_db_element_t **db, int *count)
btgatt_db_element_t **db, UINT16 *count)
{
bta_gattc_get_db_with_opration(conn_id,
GATT_OP_GET_ALL_DESCRI,
@ -374,7 +374,7 @@ void BTA_GATTC_GetAllDescriptor(UINT16 conn_id, UINT16 char_handle,
}
void BTA_GATTC_GetCharByUUID(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, tBT_UUID char_uuid,
btgatt_db_element_t **db, int *count)
btgatt_db_element_t **db, UINT16 *count)
{
bta_gattc_get_db_with_opration(conn_id,
GATT_OP_GET_CHAR_BY_UUID,
@ -390,7 +390,7 @@ void BTA_GATTC_GetCharByUUID(UINT16 conn_id, UINT16 start_handle, UINT16 end_han
void BTA_GATTC_GetDescrByUUID(UINT16 conn_id, uint16_t start_handle, uint16_t end_handle,
tBT_UUID char_uuid, tBT_UUID descr_uuid,
btgatt_db_element_t **db, int *count)
btgatt_db_element_t **db, UINT16 *count)
{
bta_gattc_get_db_with_opration(conn_id,
GATT_OP_GET_DESCRI_BY_UUID,
@ -405,7 +405,7 @@ void BTA_GATTC_GetDescrByUUID(UINT16 conn_id, uint16_t start_handle, uint16_t en
}
void BTA_GATTC_GetDescrByCharHandle(UINT16 conn_id, UINT16 char_handle, tBT_UUID descr_uuid,
btgatt_db_element_t **db, int *count)
btgatt_db_element_t **db, UINT16 *count)
{
bta_gattc_get_db_with_opration(conn_id,
GATT_OP_GET_DESCRI_BY_HANDLE,
@ -420,7 +420,7 @@ void BTA_GATTC_GetDescrByCharHandle(UINT16 conn_id, UINT16 char_handle, tBT_UUID
}
void BTA_GATTC_GetIncludeService(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
tBT_UUID *incl_uuid, btgatt_db_element_t **db, int *count)
tBT_UUID *incl_uuid, btgatt_db_element_t **db, UINT16 *count)
{
bta_gattc_get_db_with_opration(conn_id,
GATT_OP_GET_INCLUDE_SVC,
@ -434,13 +434,13 @@ void BTA_GATTC_GetIncludeService(UINT16 conn_id, UINT16 start_handle, UINT16 end
count);
}
void BTA_GATTC_GetDBSize(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, int *count)
void BTA_GATTC_GetDBSize(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, UINT16 *count)
{
bta_gattc_get_db_size_handle(conn_id, start_handle, end_handle, count);
}
void BTA_GATTC_GetDBSizeByType(UINT16 conn_id, bt_gatt_db_attribute_type_t type,
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, int *count)
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, UINT16 *count)
{
bta_gattc_get_db_size_with_type_handle(conn_id, type, start_handle, end_handle, char_handle, count);
}
@ -459,7 +459,7 @@ void BTA_GATTC_GetDBSizeByType(UINT16 conn_id, bt_gatt_db_attribute_type_t type,
**
*******************************************************************************/
void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
btgatt_db_element_t **db, int *count)
btgatt_db_element_t **db, UINT16 *count)
{
bta_gattc_get_gatt_db(conn_id, start_handle, end_handle, db, count);
}

View File

@ -1227,7 +1227,7 @@ tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle)
void bta_gattc_get_service_with_uuid(UINT16 conn_id, tBT_UUID *svc_uuid,
btgatt_db_element_t **svc_db,
int *count)
UINT16 *count)
{
const list_t* svc = bta_gattc_get_services(conn_id);
if(!svc) {
@ -1301,7 +1301,7 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
tBT_UUID *descr_uuid,
UINT16 start_handle, UINT16 end_handle,
btgatt_db_element_t **char_db,
int *count)
UINT16 *count)
{
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
@ -1666,7 +1666,7 @@ static size_t bta_gattc_get_db_size(list_t *services,
return db_size;
}
void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, int *count)
void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, UINT16 *count)
{
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
@ -1685,7 +1685,7 @@ void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 en
}
void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute_type_t type,
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, int *count)
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, UINT16 *count)
{
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
@ -1732,7 +1732,7 @@ void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute
static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
UINT16 start_handle, UINT16 end_handle,
btgatt_db_element_t **db,
int *count)
UINT16 *count)
{
APPL_TRACE_DEBUG("%s: start_handle 0x%04x, end_handle 0x%04x",
__func__, start_handle, end_handle);
@ -1880,7 +1880,7 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
** Returns None.
**
*******************************************************************************/
void bta_gattc_get_gatt_db(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, btgatt_db_element_t **db, int *count)
void bta_gattc_get_gatt_db(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, btgatt_db_element_t **db, UINT16 *count)
{
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);

View File

@ -596,6 +596,30 @@ void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id,
return;
}
/*******************************************************************************
**
** Function bta_gattc_clear_notif_registration_by_bda
**
** Description Clear up the notification registration information by BD_ADDR.
**
**
** Returns None.
**
*******************************************************************************/
void bta_gattc_clear_notif_registration_by_bda(tBTA_GATTC_RCB *p_clrcb, BD_ADDR remote_bda)
{
if(p_clrcb == NULL) {
return;
}
for (uint8_t i = 0 ; i < BTA_GATTC_NOTIF_REG_MAX; i ++) {
if (p_clrcb->notif_reg[i].in_use &&
!bdcmp(p_clrcb->notif_reg[i].remote_bda, remote_bda))
{
memset(&p_clrcb->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
}
}
}
/*******************************************************************************
**
** Function bta_gattc_mark_bg_conn

View File

@ -1014,22 +1014,14 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
** Returns none.
**
*******************************************************************************/
extern void btc_congest_callback(tBTA_GATTS *param);
static void bta_gatts_cong_cback (UINT16 conn_id, BOOLEAN congested)
{
tBTA_GATTS_RCB *p_rcb;
tGATT_IF gatt_if;
tBTA_GATT_TRANSPORT transport;
tBTA_GATTS cb_data;
if (GATT_GetConnectionInfor(conn_id, &gatt_if, cb_data.req_data.remote_bda, &transport)) {
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
cb_data.congest.conn_id = conn_id;
cb_data.congest.congested = congested;
if (p_rcb && p_rcb->p_cback) {
cb_data.congest.conn_id = conn_id;
cb_data.congest.congested = congested;
(*p_rcb->p_cback)(BTA_GATTS_CONGEST_EVT, &cb_data);
}
}
btc_congest_callback(&cb_data);
}
#endif /* GATTS_INCLUDED */

View File

@ -76,7 +76,7 @@ void BTA_GATTS_Disable(void)
** Description This function is called to register application callbacks
** with BTA GATTS module.
**
** Parameters p_app_uuid - applicaiton UUID
** Parameters p_app_uuid - application UUID
** p_cback - pointer to the application callback function.
**
** Returns None
@ -347,7 +347,7 @@ void BTA_GATTS_DeleteService(UINT16 service_id)
** Description This function is called to start a service.
**
** Parameters service_id: the service ID to be started.
** sup_transport: supported trasnport.
** sup_transport: supported transport.
**
** Returns None.
**

View File

@ -498,6 +498,7 @@ extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR rem
extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, UINT8 role);
extern UINT8 bta_gattc_num_reg_app(void);
extern void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id, UINT16 start_handle, UINT16 end_handle);
extern void bta_gattc_clear_notif_registration_by_bda(tBTA_GATTC_RCB *p_clrcb, BD_ADDR remote_bda);
extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda);
/* discovery functions */
@ -511,12 +512,12 @@ extern const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle);
extern tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle);
extern tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle);
extern void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, int *count);
extern void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, UINT16 *count);
extern void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute_type_t type,
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, int *count);
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, UINT16 *count);
extern void bta_gattc_get_service_with_uuid(UINT16 conn_id, tBT_UUID *svc_uuid,
btgatt_db_element_t **svc_db,
int *count);
UINT16 *count);
extern void bta_gattc_get_db_with_opration(UINT16 conn_id,
bt_gatt_get_db_op_t op,
@ -526,9 +527,9 @@ extern void bta_gattc_get_db_with_opration(UINT16 conn_id,
tBT_UUID *descr_uuid,
UINT16 start_handle, UINT16 end_handle,
btgatt_db_element_t **char_db,
int *count);
UINT16 *count);
extern void bta_gattc_get_gatt_db(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, btgatt_db_element_t **db, int *count);
extern void bta_gattc_get_gatt_db(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, btgatt_db_element_t **db, UINT16 *count);
extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *attr);

View File

@ -141,7 +141,7 @@ void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features,
p_buf->features = features;
p_buf->sec_mask = sec_mask;
if (p_service_name) {
BCM_STRNCPY_S(p_buf->name, BTA_SERVICE_NAME_LEN + 1, p_service_name, BTA_SERVICE_NAME_LEN);
BCM_STRNCPY_S(p_buf->name, p_service_name, BTA_SERVICE_NAME_LEN);
p_buf->name[BTA_SERVICE_NAME_LEN] = 0;
} else {
p_buf->name[0] = '\0';

View File

@ -75,12 +75,12 @@ typedef struct {
/* CIND: storage room for indicators value range and their statuses */
static const tBTA_HF_CLIENT_INDICATOR bta_hf_client_indicators[BTA_HF_CLIENT_AT_SUPPORTED_INDICATOR_COUNT] = {
/* name | min | max | name length - used by parser */
{BTA_HF_CLIENT_INDICATOR_BATTERYCHG, 0, 5, sizeof(BTA_HF_CLIENT_INDICATOR_BATTERYCHG)},
{BTA_HF_CLIENT_INDICATOR_SIGNAL, 0, 5, sizeof(BTA_HF_CLIENT_INDICATOR_SIGNAL)},
{BTA_HF_CLIENT_INDICATOR_SERVICE, 0, 1, sizeof(BTA_HF_CLIENT_INDICATOR_SERVICE)},
{BTA_HF_CLIENT_INDICATOR_CALL, 0, 1, sizeof(BTA_HF_CLIENT_INDICATOR_CALL)},
{BTA_HF_CLIENT_INDICATOR_ROAM, 0, 1, sizeof(BTA_HF_CLIENT_INDICATOR_ROAM)},
{BTA_HF_CLIENT_INDICATOR_CALLSETUP, 0, 3, sizeof(BTA_HF_CLIENT_INDICATOR_CALLSETUP)},
{BTA_HF_CLIENT_INDICATOR_SERVICE, 0, 1, sizeof(BTA_HF_CLIENT_INDICATOR_SERVICE)},
{BTA_HF_CLIENT_INDICATOR_SIGNAL, 0, 5, sizeof(BTA_HF_CLIENT_INDICATOR_SIGNAL)},
{BTA_HF_CLIENT_INDICATOR_ROAM, 0, 1, sizeof(BTA_HF_CLIENT_INDICATOR_ROAM)},
{BTA_HF_CLIENT_INDICATOR_BATTERYCHG, 0, 5, sizeof(BTA_HF_CLIENT_INDICATOR_BATTERYCHG)},
{BTA_HF_CLIENT_INDICATOR_CALLHELD, 0, 2, sizeof(BTA_HF_CLIENT_INDICATOR_CALLHELD)}
};
@ -94,7 +94,7 @@ UINT32 service_index = 0;
BOOLEAN service_availability = TRUE;
/* helper functions for handling AT commands queueing */
static void bta_hf_client_handle_ok();
static void bta_hf_client_handle_ok(void);
static void bta_hf_client_clear_queued_at(void)
{
@ -268,7 +268,7 @@ static void bta_hf_client_start_at_hold_timer(void)
** No buffer parsing is being done here.
*******************************************************************************/
static void bta_hf_client_handle_ok()
static void bta_hf_client_handle_ok(void)
{
APPL_TRACE_DEBUG("%s", __FUNCTION__);
@ -342,7 +342,7 @@ static void bta_hf_client_handle_error(tBTA_HF_CLIENT_AT_RESULT_TYPE type, UINT1
bta_hf_client_send_queued_at();
}
static void bta_hf_client_handle_ring()
static void bta_hf_client_handle_ring(void)
{
APPL_TRACE_DEBUG("%s", __FUNCTION__);
bta_hf_client_evt_val(BTA_HF_CLIENT_RING_INDICATION, 0);
@ -427,7 +427,7 @@ static void bta_hf_client_handle_ciev(UINT32 index, UINT32 value)
APPL_TRACE_DEBUG("%s index: %u value: %u", __FUNCTION__, index, value);
if (index == 0 || index > BTA_HF_CLIENT_AT_INDICATOR_COUNT) {
if (index >= BTA_HF_CLIENT_AT_INDICATOR_COUNT) {
return;
}
@ -435,7 +435,7 @@ static void bta_hf_client_handle_ciev(UINT32 index, UINT32 value)
service_availability = value == 0 ? FALSE : TRUE;
}
realind = bta_hf_client_cb.scb.at_cb.indicator_lookup[index - 1];
realind = bta_hf_client_cb.scb.at_cb.indicator_lookup[index];
if (realind >= 0 && realind < BTA_HF_CLIENT_AT_SUPPORTED_INDICATOR_COUNT) {
/* get the real in-array index from lookup table by index it comes at */
@ -576,15 +576,17 @@ static void bta_hf_client_handle_btrh( UINT16 code)
/* Check if prefix match and skip spaces if any */
#define AT_CHECK_EVENT(buf, event) \
if (strncmp("\r\n"event, buf,sizeof("\r\n"event) - 1) != 0) return buf; \
buf += sizeof("\r\n"event) - 1; \
while (*buf == ' ') buf++;
if (strncmp("\r\n"event,buf,sizeof("\r\n"event) - 1) != 0) \
return buf; \
buf += sizeof("\r\n"event) - 1; \
while (*buf == ' ') buf++;
/* check for <cr><lf> and forward buffer if match */
#define AT_CHECK_RN(buf) \
if (strncmp("\r\n", buf, sizeof("\r\n") - 1) != 0) { \
APPL_TRACE_DEBUG("%s missing end <cr><lf>", __FUNCTION__); \
return NULL;} \
APPL_TRACE_ERROR("%s missing end <cr><lf>", __FUNCTION__); \
return NULL;\
} \
buf += sizeof("\r\n") - 1;
/* skip rest of AT string up to <cr> */
@ -1022,20 +1024,20 @@ static char *bta_hf_client_parse_clcc(char *buffer)
static char *bta_hf_client_parse_cnum(char *buffer)
{
char numstr[33]; /* spec forces 32 chars, plus one for \0*/
UINT16 type;
UINT16 service = 0; /* 0 in case this optional parameter is not being sent */
int type;
int service = 0; /* 0 in case this optional parameter is not being sent */
int res;
int offset;
AT_CHECK_EVENT(buffer, "+CNUM:");
res = sscanf(buffer, ",\"%32[^\"]\",%hu,,%hu%n", numstr, &type, &service, &offset);
res = sscanf(buffer, ",\"%32[^\"]\",%d%n,,%d%n", numstr, &type, &offset, &service, &offset);
if (res < 0) {
return NULL;
}
if (res == 0) {
res = sscanf(buffer, ",\"\",%hu,,%hu%n", &type, &service, &offset);
res = sscanf(buffer, ",\"\",%d%n,,%d%n", &type, &offset, &service, &offset);
if (res < 0) {
return NULL;
}
@ -1045,7 +1047,7 @@ static char *bta_hf_client_parse_cnum(char *buffer)
numstr[0] = '\0';
}
if (res < 3) {
if (res < 2) {
return NULL;
}
@ -1257,7 +1259,7 @@ static void bta_hf_client_at_parse_start(void)
for (i = 0; i < bta_hf_client_psraser_cb_count; i++) {
tmp = bta_hf_client_parser_cb[i](buf);
if (tmp == NULL) {
APPL_TRACE_ERROR("HFPCient: AT event/reply parsing failed, skipping");
APPL_TRACE_ERROR("HFPCient: AT event/reply parsing failed, skipping %d", i);
tmp = bta_hf_client_skip_unknown(buf);
break;
}

View File

@ -850,7 +850,7 @@ void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB *p_dev_cb, UINT8 srvc_inst,
**
** Function bta_hh_le_open_cmpl
**
** Description HID over GATT connection sucessfully opened
** Description HID over GATT connection successfully opened
**
*******************************************************************************/
void bta_hh_le_open_cmpl(tBTA_HH_DEV_CB *p_cb)
@ -1556,7 +1556,7 @@ void bta_hh_le_srvc_search_cmpl(tBTA_GATTC_SEARCH_CMPL *p_data)
/* close the connection and report service discovery complete with error */
bta_hh_le_api_disc_act(p_dev_cb);
}
/* GATT service discovery sucessfully finished */
/* GATT service discovery successfully finished */
else {
if (p_dev_cb->disc_active & BTA_HH_LE_DISC_SCPS) {
p_dev_cb->disc_active &= ~BTA_HH_LE_DISC_SCPS;

View File

@ -589,10 +589,10 @@ typedef struct {
typedef union {
tBLE_BD_ADDR target_addr;
tBTA_DM_BLE_PF_LOCAL_NAME_COND local_name; /* lcoal name filtering */
tBTA_DM_BLE_PF_MANU_COND manu_data; /* manufactuer data filtering */
tBTA_DM_BLE_PF_LOCAL_NAME_COND local_name; /* local name filtering */
tBTA_DM_BLE_PF_MANU_COND manu_data; /* manufacturer data filtering */
tBTA_DM_BLE_PF_UUID_COND srvc_uuid; /* service UUID filtering */
tBTA_DM_BLE_PF_UUID_COND solicitate_uuid; /* solicitated service UUID filtering */
tBTA_DM_BLE_PF_UUID_COND solicitate_uuid; /* solicited service UUID filtering */
tBTA_DM_BLE_PF_SRVC_PATTERN_COND srvc_data; /* service data pattern */
} tBTA_DM_BLE_PF_COND_PARAM;
@ -1204,7 +1204,7 @@ typedef UINT16 tBTA_DM_LP_MASK;
#define BTA_DM_PM_ACTIVE 0x40 /* prefers active mode */
#define BTA_DM_PM_RETRY 0x80 /* retry power mode based on current settings */
#define BTA_DM_PM_SUSPEND 0x04 /* prefers suspend mode */
#define BTA_DM_PM_NO_PREF 0x01 /* service has no prefernce on power mode setting. eg. connection to service got closed */
#define BTA_DM_PM_NO_PREF 0x01 /* service has no preference on power mode setting. eg. connection to service got closed */
typedef UINT8 tBTA_DM_PM_ACTION;
@ -1375,6 +1375,7 @@ typedef UINT8 tBTA_DM_LINK_TYPE;
#define ALLOW_ALL_FILTER 0x00
#define LOWEST_RSSI_VALUE 129
/*****************************************************************************
** External Function Declarations
*****************************************************************************/
@ -1732,7 +1733,7 @@ extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr );
**
** Description This function adds a DI record to the local SDP database.
**
** Returns BTA_SUCCESS if record set sucessfully, otherwise error code.
** Returns BTA_SUCCESS if record set successfully, otherwise error code.
**
*******************************************************************************/
extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
@ -2601,6 +2602,21 @@ extern void BTA_VendorInit (void);
*******************************************************************************/
extern void BTA_VendorCleanup (void);
enum {
BTA_COEX_EVT_SCAN_STARTED = 1,
BTA_COEX_EVT_SCAN_STOPPED,
BTA_COEX_EVT_ACL_CONNECTED,
BTA_COEX_EVT_ACL_DISCONNECTED,
BTA_COEX_EVT_STREAMING_STARTED,
BTA_COEX_EVT_STREAMING_STOPPED,
BTA_COEX_EVT_SNIFF_ENTER,
BTA_COEX_EVT_SNIFF_EXIT,
BTA_COEX_EVT_A2DP_PAUSED_ENTER,
BTA_COEX_EVT_A2DP_PAUSED_EXIT,
};
extern void BTA_DmCoexEventTrigger(uint32_t event);
#endif
#ifdef __cplusplus

View File

@ -509,8 +509,10 @@ typedef struct {
UINT32 company_id; /* AVRCP Company ID */
UINT16 avrc_mtu; /* AVRCP MTU at L2CAP for control channel */
UINT16 avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */
UINT16 avrc_ct_cat; /* AVRCP controller categories */
UINT16 avrc_tg_cat; /* AVRCP target categories */
UINT16 avrc_snk_ct_cat; /* AVRCP controller categories as SNK */
UINT16 avrc_snk_tg_cat; /* AVRCP target categories SNK */
UINT16 avrc_src_ct_cat; /* AVRCP controller categories as SRC */
UINT16 avrc_src_tg_cat; /* AVRCP target categories as SRC */
UINT16 sig_mtu; /* AVDTP signaling channel MTU at L2CAP */
UINT16 audio_mtu; /* AVDTP audio transport channel MTU at L2CAP */
const UINT16 *p_audio_flush_to;/* AVDTP audio transport channel flush timeout */

View File

@ -205,6 +205,8 @@ extern void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key);
extern void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size);
extern void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size);
extern void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable);
extern UINT8 bta_dm_co_ble_get_accept_auth_enable(void);

View File

@ -152,7 +152,7 @@ typedef UINT8 tBTA_GATT_STATUS;
#define BTA_GATTC_CLOSE_EVT 5 /* GATTC close request status event */
#define BTA_GATTC_SEARCH_CMPL_EVT 6 /* GATT discovery complete event */
#define BTA_GATTC_SEARCH_RES_EVT 7 /* GATT discovery result event */
#define BTA_GATTC_READ_DESCR_EVT 8 /* GATT read characterisitc descriptor event */
#define BTA_GATTC_READ_DESCR_EVT 8 /* GATT read characteristic descriptor event */
#define BTA_GATTC_WRITE_DESCR_EVT 9 /* GATT write characteristic descriptor event */
#define BTA_GATTC_NOTIF_EVT 10 /* GATT attribute notification event */
#define BTA_GATTC_PREP_WRITE_EVT 11 /* GATT prepare write event */
@ -739,7 +739,7 @@ extern void BTA_GATTC_Disable(void);
** Description This function is called to register application callbacks
** with BTA GATTC module.
**
** Parameters p_app_uuid - applicaiton UUID
** Parameters p_app_uuid - application UUID
** p_client_cb - pointer to the application callback function.
**
** Returns None
@ -867,32 +867,32 @@ extern const tBTA_GATTC_CHARACTERISTIC* BTA_GATTC_GetCharacteristic(UINT16 conn_
*******************************************************************************/
extern const tBTA_GATTC_DESCRIPTOR* BTA_GATTC_GetDescriptor(UINT16 conn_id, UINT16 handle);
extern void BTA_GATTC_GetServiceWithUUID(UINT16 conn_id, tBT_UUID *svc_uuid,
btgatt_db_element_t **db, int *count);
extern void BTA_GATTC_GetServiceWithUUID(UINT16 conn_id, tBT_UUID *svc_uuid,
btgatt_db_element_t **db, UINT16 *count);
extern void BTA_GATTC_GetAllChar(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
btgatt_db_element_t **db, int *count);
btgatt_db_element_t **db, UINT16 *count);
extern void BTA_GATTC_GetAllDescriptor(UINT16 conn_id, UINT16 char_handle,
btgatt_db_element_t **db, int *count);
btgatt_db_element_t **db, UINT16 *count);
extern void BTA_GATTC_GetCharByUUID(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, tBT_UUID char_uuid,
btgatt_db_element_t **db, int *count);
btgatt_db_element_t **db, UINT16 *count);
extern void BTA_GATTC_GetDescrByUUID(UINT16 conn_id, uint16_t start_handle, uint16_t end_handle,
tBT_UUID char_uuid, tBT_UUID descr_uuid,
btgatt_db_element_t **db, int *count);
btgatt_db_element_t **db, UINT16 *count);
extern void BTA_GATTC_GetDescrByCharHandle(UINT16 conn_id, UINT16 char_handle, tBT_UUID descr_uuid,
btgatt_db_element_t **db, int *count);
btgatt_db_element_t **db, UINT16 *count);
extern void BTA_GATTC_GetIncludeService(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
tBT_UUID *incl_uuid, btgatt_db_element_t **db, int *count);
tBT_UUID *incl_uuid, btgatt_db_element_t **db, UINT16 *count);
extern void BTA_GATTC_GetDBSize(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, int *count);
extern void BTA_GATTC_GetDBSize(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, UINT16 *count);
extern void BTA_GATTC_GetDBSizeByType(UINT16 conn_id, bt_gatt_db_attribute_type_t type,
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, int *count);
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, UINT16 *count);
/*******************************************************************************
**
@ -907,7 +907,7 @@ extern void BTA_GATTC_GetDBSizeByType(UINT16 conn_id, bt_gatt_db_attribute_type_
**
*******************************************************************************/
extern void BTA_GATTC_GetGattDb(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle,
btgatt_db_element_t **db, int *count);
btgatt_db_element_t **db, UINT16 *count);
/*******************************************************************************
**
@ -1202,7 +1202,7 @@ extern void BTA_GATTS_Disable(void);
** Description This function is called to register application callbacks
** with BTA GATTS module.
**
** Parameters p_app_uuid - applicaiton UUID
** Parameters p_app_uuid - application UUID
** p_cback - pointer to the application callback function.
**
** Returns None
@ -1325,7 +1325,7 @@ extern void BTA_GATTS_DeleteService(UINT16 service_id);
** Description This function is called to start a service.
**
** Parameters service_id: the service ID to be started.
** sup_transport: supported trasnport.
** sup_transport: supported transport.
**
** Returns None.
**

View File

@ -115,15 +115,16 @@ typedef UINT8 tBTA_HF_CLIENT_EVT;
typedef UINT8 tBTA_HF_CLIENT_STATUS;
/* indicator type */
#define BTA_HF_CLIENT_IND_BATTCH 0 /* Battery charge indicator */
#define BTA_HF_CLIENT_IND_SIGNAL 1 /* Signal Strength indicator */
#define BTA_HF_CLIENT_IND_SERVICE 2 /* Service availability indicator */
#define BTA_HF_CLIENT_IND_CALL 3 /* Standard call status indicator*/
#define BTA_HF_CLIENT_IND_ROAM 4 /* Roaming status indicator */
#define BTA_HF_CLIENT_IND_CALLSETUP 5 /* Call setup status indicator */
#define BTA_HF_CLIENT_IND_CALLHELD 6 /* Call hold status indicator */
/* indicator constants HFP 1.1 and later */
#define BTA_HF_CLIENT_IND_CALL 0 /* position of call indicator */
#define BTA_HF_CLIENT_IND_CALLSETUP 1 /* position of callsetup indicator */
#define BTA_HF_CLIENT_IND_SERVICE 2 /* position of service indicator */
/* indicator constants HFP 1.5 and later */
#define BTA_HF_CLIENT_IND_SIGNAL 3 /* position of signal strength indicator */
#define BTA_HF_CLIENT_IND_ROAM 4 /* position of roaming indicator */
#define BTA_HF_CLIENT_IND_BATTCH 5 /* position of battery charge indicator */
#define BTA_HF_CLIENT_IND_CALLHELD 6 /* position of callheld indicator */
#define BTA_HF_CLIENT_IND_BEARER 7 /* position of bearer indicator */
typedef UINT8 tBTA_HF_CLIENT_IND_TYPE;
/* AT commands */

View File

@ -80,7 +80,7 @@ static void _btc_storage_save(void)
//delete device info
string_to_bdaddr(need_remove_section, &bd_addr);
BTM_SecDeleteDevice(bd_addr.address, BT_TRANSPORT_LE);
//delet config info
//delete config info
if(btc_config_remove_section(need_remove_section)) {
BTIF_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the last device info : %s", need_remove_section);
}
@ -893,11 +893,12 @@ bt_status_t btc_storage_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev
if (_btc_storage_get_ble_bonding_key(&bd_addr, BTM_LE_KEY_PID, buffer, sizeof(tBTM_LE_PID_KEYS)) == BT_STATUS_SUCCESS) {
bond_dev->bond_key.key_mask |= ESP_BLE_ID_KEY_MASK;
tBTM_LE_PID_KEYS *pid_key = (tBTM_LE_PID_KEYS *) buffer;
memcpy(&bond_dev->bond_key.pid_key.irk, pid_key->irk, BT_OCTET16_LEN);
//Note: The memory size of the pid_key.addr_type in bond_key is different from that of (tBTM_LE_PID_KEYS) *pid_key.
memcpy(&bond_dev->bond_key.pid_key.irk, pid_key->irk, ESP_BT_OCTET16_LEN);
bond_dev->bond_key.pid_key.addr_type = pid_key->addr_type;
memcpy(&bond_dev->bond_key.pid_key.static_addr, pid_key->static_addr, sizeof(BD_ADDR));
memcpy(&bond_dev->bond_key.pid_key.static_addr, pid_key->static_addr, ESP_BD_ADDR_LEN);
}
//serch for the next bond device
//search for the next bond device
bond_dev++;
}
btc_config_unlock();

View File

@ -706,8 +706,12 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
pairing_cb.ble.is_pid_key_rcvd = TRUE;
memcpy(&pairing_cb.ble.pid_key, &p_data->ble_key.p_key_value->pid_key,
sizeof(tBTM_LE_PID_KEYS));
memcpy(&param.ble_security.ble_key.p_key_value.pid_key,
&p_data->ble_key.p_key_value->pid_key, sizeof(tBTM_LE_PID_KEYS));
//Note: The memory size of the addr_type in ble_security.ble_key.p_key_value.pid_key is different from that of p_data->ble_key.p_key_value->pid_key.
memcpy(&param.ble_security.ble_key.p_key_value.pid_key.irk,
&p_data->ble_key.p_key_value->pid_key.irk, ESP_BT_OCTET16_LEN);
param.ble_security.ble_key.p_key_value.pid_key.addr_type = p_data->ble_key.p_key_value->pid_key.addr_type;
memcpy(&param.ble_security.ble_key.p_key_value.pid_key.static_addr,
&p_data->ble_key.p_key_value->pid_key.static_addr, ESP_BD_ADDR_LEN);
break;
}
case BTM_LE_KEY_PCSRK: {

View File

@ -67,11 +67,18 @@ static void btc_init_bluetooth(void)
//load the ble local key which has been stored in the flash
btc_dm_load_ble_local_keys();
#endif /* #if (SMP_INCLUDED) */
#if BTA_DYNAMIC_MEMORY
deinit_semaphore = xSemaphoreCreateBinary();
#endif /* #if BTA_DYNAMIC_MEMORY */
}
static void btc_deinit_bluetooth(void)
{
/* Wait for the disable operation to complete */
#if BTA_DYNAMIC_MEMORY
xSemaphoreTake(deinit_semaphore, BTA_DISABLE_DELAY / portTICK_PERIOD_MS);
#endif /* #if BTA_DYNAMIC_MEMORY */
btc_gap_ble_deinit();
bta_dm_sm_deinit();
#if (GATTC_INCLUDED)
@ -87,6 +94,10 @@ static void btc_deinit_bluetooth(void)
osi_alarm_deinit();
osi_alarm_delete_mux();
future_ready(*btc_main_get_future_p(BTC_MAIN_DEINIT_FUTURE), FUTURE_SUCCESS);
#if BTA_DYNAMIC_MEMORY
vSemaphoreDelete(deinit_semaphore);
deinit_semaphore = NULL;
#endif /* #if BTA_DYNAMIC_MEMORY */
}
void btc_main_call_handler(btc_msg_t *msg)

View File

@ -147,6 +147,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
if (blufi_env.prepare_buf == NULL) {
blufi_env.prepare_buf = osi_malloc(BLUFI_PREPAIR_BUF_MAX_SIZE);
blufi_env.prepare_len = 0;
if (blufi_env.prepare_buf == NULL) {
BLUFI_TRACE_ERROR("Blufi prep no mem\n");
status = GATT_NO_RESOURCES;
@ -174,6 +175,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
if (blufi_env.prepare_buf) {
osi_free(blufi_env.prepare_buf);
blufi_env.prepare_buf = NULL;
blufi_env.prepare_len = 0;
}
BLUFI_TRACE_ERROR("write data error , error code 0x%x\n", status);
return;
@ -209,6 +211,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
if (blufi_env.prepare_buf) {
osi_free(blufi_env.prepare_buf);
blufi_env.prepare_buf = NULL;
blufi_env.prepare_len = 0;
}
break;
@ -426,11 +429,19 @@ static void btc_blufi_recv_handler(uint8_t *data, int len)
blufi_env.aggr_buf = osi_malloc(blufi_env.total_len);
if (blufi_env.aggr_buf == NULL) {
BTC_TRACE_ERROR("%s no mem, len %d\n", __func__, blufi_env.total_len);
btc_blufi_report_error(ESP_BLUFI_DH_MALLOC_ERROR);
return;
}
}
memcpy(blufi_env.aggr_buf + blufi_env.offset, hdr->data + 2, hdr->data_len - 2);
blufi_env.offset += (hdr->data_len - 2);
if (blufi_env.offset + hdr->data_len - 2 <= blufi_env.total_len){
memcpy(blufi_env.aggr_buf + blufi_env.offset, hdr->data + 2, hdr->data_len - 2);
blufi_env.offset += (hdr->data_len - 2);
} else {
BTC_TRACE_ERROR("%s payload is longer than packet length, len %d \n", __func__, blufi_env.total_len);
btc_blufi_report_error(ESP_BLUFI_DATA_FORMAT_ERROR);
return;
}
} else {
if (blufi_env.offset > 0) { /* if previous pkt is frag */
memcpy(blufi_env.aggr_buf + blufi_env.offset, hdr->data, hdr->data_len);
@ -585,7 +596,7 @@ static void btc_blufi_wifi_conn_report(uint8_t opmode, uint8_t sta_conn_state, u
*p++ = info->softap_max_conn_num;
}
if (info->softap_channel_set) {
*p++ = BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_MAX_CONN_NUM;
*p++ = BLUFI_TYPE_DATA_SUBTYPE_SOFTAP_CHANNEL;
*p++ = 1;
*p++ = info->softap_channel;
}

View File

@ -117,7 +117,7 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
APPL_TRACE_DEBUG("BTC MEDIA (A2DP-DATA) EVENT %u", ctrl);
if (btc_aa_ctrl_cb.a2dp_cmd_pending != ESP_A2D_MEDIA_CTRL_NONE) {
APPL_TRACE_DEBUG("un-acked a2dp cmd: %u", btc_aa_ctrl_cb.a2dp_cmd_pending);
APPL_TRACE_WARNING("un-acked a2dp cmd: %u", btc_aa_ctrl_cb.a2dp_cmd_pending);
a2dp_cmd_acknowledge(ctrl, ESP_A2D_MEDIA_CTRL_ACK_BUSY);
return;
}
@ -179,6 +179,11 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
/* local suspend */
if (btc_av_stream_started_ready()) {
btc_dispatch_sm_event(BTC_AV_SUSPEND_STREAM_REQ_EVT, NULL, 0);
#if (BTC_AV_SINK_INCLUDED == TRUE)
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
}
#endif
} else {
/* we are not in started state; just ack back ok. This can happen if we are
remotely suspended; clear REMOTE SUSPEND Flag */

View File

@ -828,6 +828,8 @@ static void btc_a2dp_sink_thread_cleanup(UNUSED_ATTR void *context)
fixed_queue_free(btc_aa_snk_cb.RxSbcQ, osi_free_func);
btc_aa_snk_cb.RxSbcQ = NULL;
future_ready(btc_a2dp_sink_future, NULL);
}

View File

@ -1664,6 +1664,8 @@ static void btc_a2dp_source_thread_cleanup(UNUSED_ATTR void *context)
fixed_queue_free(btc_aa_src_cb.TxAaQ, osi_free_func);
btc_aa_src_cb.TxAaQ = NULL;
future_ready(btc_a2dp_source_future, NULL);
}

View File

@ -251,7 +251,7 @@ static void handle_rc_attributes_rsp ( tAVRC_MSG_VENDOR *vendor_msg)
btc_avrc_ct_cb_to_app(ESP_AVRC_CT_METADATA_RSP_EVT, &param[i]);
attr_index += (int) vendor_msg->p_vendor_data[7 + attr_index] + 8;
attr_index += attr_length + 8;
}
}

View File

@ -1189,6 +1189,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
bta_dm_co_ble_set_max_key_size(key_size);
break;
}
case ESP_BLE_SM_MIN_KEY_SIZE: {
uint8_t key_size = 0;
STREAM_TO_UINT8(key_size, value);
bta_dm_co_ble_set_min_key_size(key_size);
break;
}
case ESP_BLE_SM_SET_STATIC_PASSKEY: {
uint32_t passkey = 0;
for(uint8_t i = 0; i < arg->set_security_param.len; i++)

View File

@ -830,11 +830,14 @@ void btc_gap_bt_busy_level_updated(uint8_t bl_flags)
param.disc_st_chg.state = ESP_BT_GAP_DISCOVERY_STARTED;
btc_gap_bt_cb_to_app(ESP_BT_GAP_DISC_STATE_CHANGED_EVT, &param);
btc_gap_bt_inquiry_in_progress = true;
} else if (bl_flags == BTM_BL_INQUIRY_CANCELLED ||
bl_flags == BTM_BL_INQUIRY_COMPLETE) {
} else if (bl_flags == BTM_BL_INQUIRY_CANCELLED) {
param.disc_st_chg.state = ESP_BT_GAP_DISCOVERY_STOPPED;
btc_gap_bt_cb_to_app(ESP_BT_GAP_DISC_STATE_CHANGED_EVT, &param);
btc_gap_bt_inquiry_in_progress = false;
} else if (bl_flags == BTM_BL_INQUIRY_COMPLETE) {
/* The Inquiry Complete event is not transported to app layer,
since the app only cares about the Name Discovery Complete event */
btc_gap_bt_inquiry_in_progress = false;
}
}

View File

@ -315,7 +315,7 @@ esp_gatt_status_t btc_ble_gattc_get_service(uint16_t conn_id, esp_bt_uuid_t *svc
{
esp_gatt_status_t status;
btgatt_db_element_t *db = NULL;
int svc_num = 0;
uint16_t svc_num = 0;
tBT_UUID *bta_uuid = NULL;
if (svc_uuid) {
bta_uuid = osi_malloc(sizeof(tBT_UUID));
@ -324,7 +324,7 @@ esp_gatt_status_t btc_ble_gattc_get_service(uint16_t conn_id, esp_bt_uuid_t *svc
BTA_GATTC_GetServiceWithUUID(conn_id, bta_uuid, &db, &svc_num);
if ((status = btc_gattc_check_valid_param(svc_num, offset)) != ESP_GATT_OK) {
if ((status = btc_gattc_check_valid_param((int)svc_num, offset)) != ESP_GATT_OK) {
if (db) {
osi_free(db);
}
@ -334,7 +334,7 @@ esp_gatt_status_t btc_ble_gattc_get_service(uint16_t conn_id, esp_bt_uuid_t *svc
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)svc_num, ESP_GATT_DB_PRIMARY_SERVICE, offset, (void *)result, db);
btc_gattc_fill_gatt_db_conversion(*count, svc_num, ESP_GATT_DB_PRIMARY_SERVICE, offset, (void *)result, db);
}
*count = svc_num;
@ -356,17 +356,17 @@ esp_gatt_status_t btc_ble_gattc_get_all_char(uint16_t conn_id,
{
esp_gatt_status_t status;
btgatt_db_element_t *db = NULL;
int char_num = 0;
uint16_t char_num = 0;
BTA_GATTC_GetAllChar(conn_id, start_handle, end_handle, &db, &char_num);
if ((status = btc_gattc_check_valid_param(char_num, offset)) != ESP_GATT_OK) {
if ((status = btc_gattc_check_valid_param((int)char_num, offset)) != ESP_GATT_OK) {
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)char_num, ESP_GATT_DB_CHARACTERISTIC, offset, (void *)result, db);
btc_gattc_fill_gatt_db_conversion(*count, char_num, ESP_GATT_DB_CHARACTERISTIC, offset, (void *)result, db);
}
*count = char_num;
@ -384,17 +384,17 @@ esp_gatt_status_t btc_ble_gattc_get_all_descr(uint16_t conn_id,
{
esp_gatt_status_t status;
btgatt_db_element_t *db = NULL;
int descr_num = 0;
uint16_t descr_num = 0;
BTA_GATTC_GetAllDescriptor(conn_id, char_handle, &db, &descr_num);
if ((status = btc_gattc_check_valid_param(descr_num, offset)) != ESP_GATT_OK) {
if ((status = btc_gattc_check_valid_param((int)descr_num, offset)) != ESP_GATT_OK) {
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)descr_num, ESP_GATT_DB_DESCRIPTOR, offset, (void *)result, db);
btc_gattc_fill_gatt_db_conversion(*count, descr_num, ESP_GATT_DB_DESCRIPTOR, offset, (void *)result, db);
}
*count = descr_num;
@ -414,19 +414,19 @@ esp_gatt_status_t btc_ble_gattc_get_char_by_uuid(uint16_t conn_id,
{
esp_gatt_status_t status;
btgatt_db_element_t *db = NULL;
int char_num = 0;
uint16_t char_num = 0;
tBT_UUID bta_uuid = {0};
btc_to_bta_uuid(&bta_uuid, &char_uuid);
BTA_GATTC_GetCharByUUID(conn_id, start_handle, end_handle, bta_uuid, &db, &char_num);
if ((status = btc_gattc_check_valid_param(char_num, 0)) != ESP_GATT_OK) {
if ((status = btc_gattc_check_valid_param((int)char_num, 0)) != ESP_GATT_OK) {
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)char_num, ESP_GATT_DB_CHARACTERISTIC, 0, (void *)result, db);
btc_gattc_fill_gatt_db_conversion(*count, char_num, ESP_GATT_DB_CHARACTERISTIC, 0, (void *)result, db);
}
*count = char_num;
@ -447,7 +447,7 @@ esp_gatt_status_t btc_ble_gattc_get_descr_by_uuid(uint16_t conn_id,
{
esp_gatt_status_t status;
btgatt_db_element_t *db = NULL;
int descr_num = 0;
uint16_t descr_num = 0;
tBT_UUID bta_char_uuid = {0};
tBT_UUID bta_descr_uuid = {0};
btc_to_bta_uuid(&bta_char_uuid, &char_uuid);
@ -456,14 +456,14 @@ esp_gatt_status_t btc_ble_gattc_get_descr_by_uuid(uint16_t conn_id,
BTA_GATTC_GetDescrByUUID(conn_id, start_handle, end_handle,
bta_char_uuid, bta_descr_uuid, &db, &descr_num);
if ((status = btc_gattc_check_valid_param(descr_num, 0)) != ESP_GATT_OK) {
if ((status = btc_gattc_check_valid_param((int)descr_num, 0)) != ESP_GATT_OK) {
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)descr_num, ESP_GATT_DB_DESCRIPTOR, 0, (void *)result, db);
btc_gattc_fill_gatt_db_conversion(*count, descr_num, ESP_GATT_DB_DESCRIPTOR, 0, (void *)result, db);
}
*count = descr_num;
@ -482,20 +482,20 @@ esp_gatt_status_t btc_ble_gattc_get_descr_by_char_handle(uint16_t conn_id,
{
esp_gatt_status_t status;
btgatt_db_element_t *db = NULL;
int descr_num = 0;
uint16_t descr_num = 0;
tBT_UUID bta_descr_uuid = {0};
btc_to_bta_uuid(&bta_descr_uuid, &descr_uuid);
BTA_GATTC_GetDescrByCharHandle(conn_id, char_handle, bta_descr_uuid, &db, &descr_num);
if ((status = btc_gattc_check_valid_param(descr_num, 0)) != ESP_GATT_OK) {
if ((status = btc_gattc_check_valid_param((int)descr_num, 0)) != ESP_GATT_OK) {
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)descr_num, ESP_GATT_DB_DESCRIPTOR, 0, (void *)result, db);
btc_gattc_fill_gatt_db_conversion(*count, descr_num, ESP_GATT_DB_DESCRIPTOR, 0, (void *)result, db);
}
*count = descr_num;
@ -516,7 +516,7 @@ esp_gatt_status_t btc_ble_gattc_get_include_service(uint16_t conn_id,
{
esp_gatt_status_t status;
btgatt_db_element_t *db = NULL;
int incl_num = 0;
uint16_t incl_num = 0;
tBT_UUID bta_uuid = {0};
if (incl_uuid != NULL) {
@ -526,14 +526,14 @@ esp_gatt_status_t btc_ble_gattc_get_include_service(uint16_t conn_id,
BTA_GATTC_GetIncludeService(conn_id, start_handle, end_handle, NULL, &db, &incl_num);
}
if ((status = btc_gattc_check_valid_param(incl_num, 0)) != ESP_GATT_OK) {
if ((status = btc_gattc_check_valid_param((int)incl_num, 0)) != ESP_GATT_OK) {
if (db) {
osi_free(db);
}
*count = 0;
return status;
}else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)incl_num, ESP_GATT_DB_INCLUDED_SERVICE, 0, (void *)result, db);
btc_gattc_fill_gatt_db_conversion(*count, incl_num, ESP_GATT_DB_INCLUDED_SERVICE, 0, (void *)result, db);
}
*count = incl_num;
@ -552,9 +552,9 @@ esp_gatt_status_t btc_ble_gattc_get_attr_count(uint16_t conn_id,
uint16_t *count)
{
if (type == ESP_GATT_DB_ALL) {
BTA_GATTC_GetDBSize(conn_id, start_handle, end_handle, (int *)count);
BTA_GATTC_GetDBSize(conn_id, start_handle, end_handle, count);
} else {
BTA_GATTC_GetDBSizeByType(conn_id, type, start_handle, end_handle, char_handle, (int *)count);
BTA_GATTC_GetDBSizeByType(conn_id, type, start_handle, end_handle, char_handle, count);
}
return ESP_GATT_OK;
@ -564,7 +564,7 @@ esp_gatt_status_t btc_ble_gattc_get_db(uint16_t conn_id, uint16_t start_handle,
esp_gattc_db_elem_t *db, uint16_t *count)
{
btgatt_db_element_t *get_db = NULL;
int num = 0;
uint16_t num = 0;
tBT_UUID bta_uuid;
uint16_t db_size = 0;
BTA_GATTC_GetGattDb(conn_id, start_handle, end_handle, &get_db, &num);

View File

@ -389,7 +389,13 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
case ESP_GATT_UUID_CHAR_AGG_FORMAT:
case ESP_GATT_UUID_CHAR_VALID_RANGE:
case ESP_GATT_UUID_EXT_RPT_REF_DESCR:
case ESP_GATT_UUID_RPT_REF_DESCR:{
case ESP_GATT_UUID_RPT_REF_DESCR:
case ESP_GATT_UUID_NUM_DIGITALS_DESCR:
case ESP_GATT_UUID_VALUE_TRIGGER_DESCR:
case ESP_GATT_UUID_ENV_SENSING_CONFIG_DESCR:
case ESP_GATT_UUID_ENV_SENSING_MEASUREMENT_DESCR:
case ESP_GATT_UUID_ENV_SENSING_TRIGGER_DESCR:
case ESP_GATT_UUID_TIME_TRIGGER_DESCR: {
uint16_t svc_hal = btc_creat_tab_env.svc_start_hdl;
tBT_UUID bta_char_uuid;
esp_bt_uuid_t uuid_temp;
@ -449,7 +455,7 @@ static esp_gatt_status_t btc_gatts_check_valid_attr_tab(esp_gatts_attr_db_t *gat
case ESP_GATT_UUID_PRI_SERVICE:
case ESP_GATT_UUID_SEC_SERVICE:
if (++svc_num > 1) {
BTC_TRACE_ERROR("Each service table can only created one primary service or secondly service.");
BTC_TRACE_ERROR("Each service table can only created one primary service or secondary service.");
return ESP_GATT_ERROR;
}
break;
@ -961,4 +967,13 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
btc_gatts_cb_param_copy_free(msg, p_data);
}
void btc_congest_callback(tBTA_GATTS *param)
{
esp_ble_gatts_cb_param_t esp_param;
esp_gatt_if_t gatts_if = BTC_GATT_GET_GATT_IF(param->congest.conn_id);
esp_param.congest.conn_id = BTC_GATT_GET_CONN_ID(param->congest.conn_id);
esp_param.congest.congested = param->congest.congested;
btc_gatts_cb_to_app(ESP_GATTS_CONGEST_EVT, gatts_if, &esp_param);
}
#endif ///GATTS_INCLUDED

View File

@ -16,6 +16,7 @@
#define __BTC_GAP_BT_H__
#include "common/bt_target.h"
#include "common/bt_defs.h"
#include "esp_bt_defs.h"
#include "esp_gap_bt_api.h"
#include "btc/btc_task.h"

View File

@ -21,7 +21,7 @@
#include <stdlib.h>
#include <stdint.h>
#include "common/bt_trace.h"
#include "bt_common.h"
#include "common/bt_target.h"
#define UNUSED(x) (void)(x)
@ -65,31 +65,6 @@ typedef struct {
uint8_t uu[16];
} bt_uuid_t;
/** Bluetooth Error Status */
/** We need to build on this */
/* relate to ESP_BT_STATUS_xxx in esp_bt_defs.h */
typedef enum {
BT_STATUS_SUCCESS = 0,
BT_STATUS_FAIL,
BT_STATUS_NOT_READY,
BT_STATUS_NOMEM,
BT_STATUS_BUSY,
BT_STATUS_DONE, /* request already completed */
BT_STATUS_UNSUPPORTED,
BT_STATUS_PARM_INVALID,
BT_STATUS_UNHANDLED,
BT_STATUS_AUTH_FAILURE,
BT_STATUS_RMT_DEV_DOWN,
BT_STATUS_AUTH_REJECTED,
BT_STATUS_INVALID_STATIC_RAND_ADDR,
BT_STATUS_PENDING,
BT_STATUS_UNACCEPT_CONN_INTERVAL,
BT_STATUS_PARAM_OUT_OF_RANGE,
BT_STATUS_TIMEOUT,
BT_STATUS_MEMORY_FULL,
} bt_status_t;
#ifndef CPU_LITTLE_ENDIAN
#define CPU_LITTLE_ENDIAN
#endif

View File

@ -20,6 +20,8 @@
#ifndef BT_TARGET_H
#define BT_TARGET_H
#include "bt_common.h"
#ifndef BUILDCFG
#define BUILDCFG
#endif
@ -98,6 +100,10 @@
#define CLASSIC_BT_INCLUDED FALSE
#endif /* CLASSIC_BT_INCLUDED */
#ifndef CLASSIC_BT_GATT_INCLUDED
#define CLASSIC_BT_GATT_INCLUDED FALSE
#endif /* CLASSIC_BT_GATT_INCLUDED */
#ifndef CONFIG_GATTC_CACHE_NVS_FLASH
#define CONFIG_GATTC_CACHE_NVS_FLASH FALSE
#endif /* CONFIG_GATTC_CACHE_NVS_FLASH */
@ -151,13 +157,13 @@
#ifndef CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM
#define BLE_ADV_REPORT_FLOW_CONTROL_NUM 100
#else
#else
#define BLE_ADV_REPORT_FLOW_CONTROL_NUM CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM
#endif /* CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM */
#ifndef CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD
#define BLE_ADV_REPORT_DISCARD_THRSHOLD 20
#else
#else
#define BLE_ADV_REPORT_DISCARD_THRSHOLD CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD
#endif /* CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD */
@ -345,10 +351,6 @@
#define BTA_AV_CO_CP_SCMS_T FALSE//FALSE
#endif
#ifndef QUEUE_CONGEST_SIZE
#define QUEUE_CONGEST_SIZE 40
#endif
#ifndef CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK
#define SCAN_QUEUE_CONGEST_CHECK FALSE
#else

View File

@ -23,38 +23,7 @@
#include <stdio.h>
#include "stack/bt_types.h"
#ifndef LOG_LOCAL_LEVEL
#ifndef BOOTLOADER_BUILD
#define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL
#else
#define LOG_LOCAL_LEVEL CONFIG_LOG_BOOTLOADER_LEVEL
#endif
#endif
#include "esp_log.h"
// Mapping between ESP_LOG_LEVEL and BT_TRACE_LEVEL
#if (LOG_LOCAL_LEVEL >= 4)
#define LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL+1)
#else
#define LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL
#endif
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define BT_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_INITIAL_TRACE_LEVEL, LOG_LOCAL_LEVEL_MAPPING) >= BT_TRACE_LEVEL_##LEVEL)
//#define TAG "BT"
#define BT_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BT_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BT_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BT_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BT_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#ifndef assert
#define assert(x) do { if (!(x)) BT_PRINT_E("bt host error %s %u\n", __FILE__, __LINE__); } while (0)
#endif
#include "bt_common.h"
inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
{
@ -324,18 +293,6 @@ inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
#define BTIF_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif
#ifdef CONFIG_BTC_INITIAL_TRACE_LEVEL
#define BTC_INITIAL_TRACE_LEVEL CONFIG_BTC_INITIAL_TRACE_LEVEL
#else
#define BTC_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif
#ifdef CONFIG_OSI_INITIAL_TRACE_LEVEL
#define OSI_INITIAL_TRACE_LEVEL CONFIG_OSI_INITIAL_TRACE_LEVEL
#else
#define OSI_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
#endif
#ifdef CONFIG_BLUFI_INITIAL_TRACE_LEVEL
#define BLUFI_INITIAL_TRACE_LEVEL CONFIG_BLUFI_INITIAL_TRACE_LEVEL
#else
@ -497,22 +454,6 @@ extern UINT8 btif_trace_level;
#define HCI_TRACE_EVENT(fmt, args...) {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(HCI,EVENT)) BT_PRINT_D("BT_HCI", fmt,## args);}
#define HCI_TRACE_DEBUG(fmt, args...) {if (HCI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(HCI,DEBUG)) BT_PRINT_D("BT_HCI", fmt,## args);}
/* define traces for BTC */
#define BTC_TRACE_ERROR(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BTC, ERROR)) BT_PRINT_E("BT_BTC", fmt, ## args);}
#define BTC_TRACE_WARNING(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BTC, WARNING)) BT_PRINT_W("BT_BTC", fmt, ## args);}
#define BTC_TRACE_API(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BTC,API)) BT_PRINT_I("BT_BTC", fmt, ## args);}
#define BTC_TRACE_EVENT(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BTC,EVENT)) BT_PRINT_D("BT_BTC", fmt, ## args);}
#define BTC_TRACE_DEBUG(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BTC,DEBUG)) BT_PRINT_D("BT_BTC", fmt, ## args);}
#define BTC_TRACE_VERBOSE(fmt, args...) {if (BTC_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(BTC,VERBOSE)) BT_PRINT_V("BT_BTC", fmt, ## args);}
/* define traces for OSI */
#define OSI_TRACE_ERROR(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(OSI, ERROR)) BT_PRINT_E("BT_OSI", fmt, ## args);}
#define OSI_TRACE_WARNING(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(OSI, WARNING)) BT_PRINT_W("BT_OSI", fmt, ## args);}
#define OSI_TRACE_API(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(OSI,API)) BT_PRINT_I("BT_OSI", fmt, ## args);}
#define OSI_TRACE_EVENT(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(OSI,EVENT)) BT_PRINT_D("BT_OSI", fmt, ## args);}
#define OSI_TRACE_DEBUG(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(OSI,DEBUG)) BT_PRINT_D("BT_OSI", fmt, ## args);}
#define OSI_TRACE_VERBOSE(fmt, args...) {if (OSI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_VERBOSE && BT_LOG_LEVEL_CHECK(OSI,VERBOSE)) BT_PRINT_V("BT_OSI", fmt, ## args);}
/* define traces for BLUFI */
#define BLUFI_TRACE_ERROR(fmt, args...) {if (BLUFI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BLUFI, ERROR)) BT_PRINT_E("BT_BLUFI", fmt, ## args);}
#define BLUFI_TRACE_WARNING(fmt, args...) {if (BLUFI_INITIAL_TRACE_LEVEL >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BLUFI, WARNING)) BT_PRINT_W("BT_BLUFI", fmt, ## args);}
@ -671,22 +612,6 @@ extern UINT8 btif_trace_level;
#define APPL_TRACE_DEBUG(fmt, args...)
#define APPL_TRACE_VERBOSE(fmt, args...)
/* define traces for BTC */
#define BTC_TRACE_ERROR(fmt, args...)
#define BTC_TRACE_WARNING(fmt, args...)
#define BTC_TRACE_API(fmt, args...)
#define BTC_TRACE_EVENT(fmt, args...)
#define BTC_TRACE_DEBUG(fmt, args...)
#define BTC_TRACE_VERBOSE(fmt, args...)
/* define traces for OSI */
#define OSI_TRACE_ERROR(fmt, args...)
#define OSI_TRACE_WARNING(fmt, args...)
#define OSI_TRACE_API(fmt, args...)
#define OSI_TRACE_EVENT(fmt, args...)
#define OSI_TRACE_DEBUG(fmt, args...)
#define OSI_TRACE_VERBOSE(fmt, args...)
/* define traces for BLUFI */
#define BLUFI_TRACE_ERROR(fmt, args...)
#define BLUFI_TRACE_WARNING(fmt, args...)

View File

@ -31,6 +31,7 @@ typedef struct {
UINT8 ble_init_key;
UINT8 ble_resp_key;
UINT8 ble_max_key_size;
UINT8 ble_min_key_size;
UINT8 ble_accept_auth_enable;
UINT8 oob_support;
#endif
@ -48,4 +49,4 @@ typedef struct {
#endif
} tBTE_BT_APPL_CFG;
extern tBTE_BT_APPL_CFG bte_bt_appl_cfg;
extern tBTE_BT_APPL_CFG bte_bt_appl_cfg;

View File

@ -189,10 +189,10 @@ task_post_status_t hci_hal_h4_task_post(task_post_t timeout)
evt.par = 0;
if (xQueueSend(xHciH4Queue, &evt, timeout) != pdTRUE) {
return TASK_POST_SUCCESS;
return TASK_POST_FAIL;
}
return TASK_POST_FAIL;
return TASK_POST_SUCCESS;
}
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)

View File

@ -88,6 +88,13 @@ static void fragment_and_dispatch(BT_HDR *packet)
controller->get_acl_data_size_ble();
max_packet_size = max_data_size + HCI_ACL_PREAMBLE_SIZE;
if((packet->len > max_packet_size) && (packet->layer_specific == 0) && (event == MSG_STACK_TO_HC_HCI_ACL)) {
packet->event = MSG_HC_TO_STACK_L2C_SEG_XMIT;
current_fragment_packet = NULL;
callbacks->transmit_finished(packet, false);
return;
}
remaining_length = packet->len;
STREAM_TO_UINT16(continuation_handle, stream);
continuation_handle = APPLY_CONTINUATION_FLAG(continuation_handle);

View File

@ -366,4 +366,9 @@ void BTE_DeinitStack(void)
#if (defined(A2D_INCLUDED) && A2D_INCLUDED == TRUE)
A2D_Deinit();
#endif
#if (defined(RFCOMM_INCLUDED) && RFCOMM_INCLUDED == TRUE)
RFCOMM_Deinit();
#endif
}

View File

@ -1195,7 +1195,7 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
len = AVDT_MAX_CNAME_SIZE;
}
*p++ = (UINT8)len;
BCM_STRNCPY_S((char *)p, len + 1, (char *)p_data->cname, len + 1);
BCM_STRNCPY_S((char *)p, (char *)p_data->cname, AVDT_MAX_CNAME_SIZE + 1);
p += len;
break;
}

View File

@ -127,7 +127,7 @@ static void avdt_sec_check_complete_term (BD_ADDR bd_addr, tBT_TRANSPORT transpo
** Returns void
**
*******************************************************************************/
static void avdt_sec_check_complete_orig (BD_ADDR bd_addr, tBT_TRANSPORT trasnport,
static void avdt_sec_check_complete_orig (BD_ADDR bd_addr, tBT_TRANSPORT transport,
void *p_ref_data, UINT8 res)
{
tAVDT_CCB *p_ccb = NULL;

View File

@ -2069,7 +2069,7 @@ void BTM_BleGetWhiteListSize(uint16_t *length)
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
if (p_cb->white_list_avail_size == 0) {
BTM_TRACE_DEBUG("%s Whitelist full.", __func__);
BTM_TRACE_WARNING("%s Whitelist full.", __func__);
}
*length = p_cb->white_list_avail_size;
return;

View File

@ -121,8 +121,7 @@ BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE d
if (bd_name && bd_name[0]) {
p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN;
BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name),
(char *)bd_name, BTM_MAX_REM_BD_NAME_LEN);
BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name,(char *)bd_name, BTM_MAX_REM_BD_NAME_LEN);
}
p_dev_rec->device_type |= dev_type;
p_dev_rec->ble.ble_addr_type = addr_type;

View File

@ -913,7 +913,7 @@ tBTM_STATUS btm_ble_clear_scan_pf_filter(tBTM_BLE_SCAN_COND_OP action,
/* clear the general filter entry */
if (NULL == p_target) {
/* clear manufactuer data filter */
/* clear manufacturer data filter */
st = btm_ble_update_pf_manu_data(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL,
BTM_BLE_PF_MANU_DATA, cb_evt, ref_value);
if (BTM_CMD_STARTED == st) {
@ -1205,7 +1205,7 @@ tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP action,
st = btm_ble_update_addr_filter(action, filt_index, p_cond);
break;
/* filter on service/solicitated UUID */
/* filter on service/solicited UUID */
case BTM_BLE_PF_SRVC_UUID:
case BTM_BLE_PF_SRVC_SOL_UUID:
st = btm_ble_update_uuid_filter(action, filt_index, cond_type, p_cond, 0, ref_value);

View File

@ -586,7 +586,7 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_s
}
#endif
if (start && p_cb->adv_mode == BTM_BLE_ADV_DISABLE) {
if (start) {
/* update adv params */
if (!btsnd_hcic_ble_write_adv_params ((UINT16)(p_cb->adv_interval_min ? p_cb->adv_interval_min :
BTM_BLE_GAP_ADV_INT),
@ -606,19 +606,13 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_s
}
status = btm_ble_start_adv ();
} else if (!start && p_cb->adv_mode == BTM_BLE_ADV_ENABLE) {
} else {
//save the stop adv callback to the BTM env.
p_cb->p_stop_adv_cb = p_stop_adv_cback;
status = btm_ble_stop_adv();
#if BLE_PRIVACY_SPT == TRUE
btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, TRUE);
#endif
} else {
/*
1. start adv when adv has already started (not used)
2. stop adv shen adv has already stoped
*/
status = BTM_SUCCESS;
}
return status;
}
@ -3920,7 +3914,7 @@ tBTM_STATUS btm_ble_stop_adv(void)
{
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
tBTM_STATUS rt = BTM_SUCCESS;
if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) {
if (p_cb) {
osi_mutex_lock(&adv_enable_lock, OSI_MUTEX_MAX_TIMEOUT);
UINT8 temp_adv_mode = p_cb->adv_mode;
BOOLEAN temp_fast_adv_on = p_cb->fast_adv_on;

View File

@ -292,8 +292,11 @@ void btm_ble_add_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len)
}
} else if (status == HCI_ERR_MEMORY_FULL) { /* BT_ERROR_CODE_MEMORY_CAPACITY_EXCEEDED */
btm_cb.ble_ctr_cb.resolving_list_avail_size = 0;
BTM_TRACE_DEBUG("%s Resolving list Full ", __func__);
BTM_TRACE_WARNING("%s Resolving list Full ", __func__);
} else {
BTM_TRACE_ERROR("%s Add resolving list error %d ", __func__, status);
}
}
/*******************************************************************************
@ -811,6 +814,8 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
} else {
btm_ble_enable_resolving_list(BTM_BLE_RL_INIT);
}
} else {
BTM_TRACE_WARNING("%s Resolving list full ", __func__);
}
} else {
BTM_TRACE_DEBUG("Device already in Resolving list\n");

View File

@ -81,7 +81,7 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name,
p_dev_rec->sec_flags = BTM_SEC_IN_USE;
memcpy (p_dev_rec->bd_addr, bd_addr, BD_ADDR_LEN);
p_dev_rec->hci_handle = BTM_GetHCIConnHandle (bd_addr, BT_TRANSPORT_BR_EDR);
p_dev_rec->ble_hci_handle = BTM_GetHCIConnHandle (bd_addr, BT_TRANSPORT_LE);
#if BLE_INCLUDED == TRUE
/* use default value for background connection params */
/* update conn params, use default value for background connection params */
@ -107,8 +107,7 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name,
if (bd_name && bd_name[0]) {
p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN;
BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name),
(char *)bd_name, BTM_MAX_REM_BD_NAME_LEN);
BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, (char *)bd_name, BTM_MAX_REM_BD_NAME_LEN);
}
p_dev_rec->num_read_pages = 0;

View File

@ -457,7 +457,7 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
/* Save the device name if local storage is enabled */
p = (UINT8 *)btm_cb.cfg.bd_name;
if (p != (UINT8 *)p_name) {
BCM_STRNCPY_S(btm_cb.cfg.bd_name, sizeof(btm_cb.cfg.bd_name), p_name, BTM_MAX_LOC_BD_NAME_LEN);
BCM_STRNCPY_S(btm_cb.cfg.bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
btm_cb.cfg.bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
}
#else

View File

@ -583,7 +583,7 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, const char
if (is_originator) {
p_srec->orig_mx_chan_id = mx_chan_id;
#if BTM_SEC_SERVICE_NAME_LEN > 0
BCM_STRNCPY_S ((char *)p_srec->orig_service_name, sizeof(p_srec->orig_service_name), p_name, BTM_SEC_SERVICE_NAME_LEN);
BCM_STRNCPY_S ((char *)p_srec->orig_service_name, p_name, BTM_SEC_SERVICE_NAME_LEN);
#endif
/* clear out the old setting, just in case it exists */
#if (L2CAP_UCD_INCLUDED == TRUE)
@ -628,7 +628,7 @@ static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, const char
} else {
p_srec->term_mx_chan_id = mx_chan_id;
#if BTM_SEC_SERVICE_NAME_LEN > 0
BCM_STRNCPY_S ((char *)p_srec->term_service_name, sizeof(p_srec->term_service_name), p_name, BTM_SEC_SERVICE_NAME_LEN);
BCM_STRNCPY_S ((char *)p_srec->term_service_name, p_name, BTM_SEC_SERVICE_NAME_LEN);
#endif
/* clear out the old setting, just in case it exists */
#if (L2CAP_UCD_INCLUDED == TRUE)
@ -3010,7 +3010,7 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
if (p_dev_rec) {
old_sec_state = p_dev_rec->sec_state;
if (status == HCI_SUCCESS) {
BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name), (char *)p_bd_name, BTM_MAX_REM_BD_NAME_LEN);
BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, (char *)p_bd_name, BTM_MAX_REM_BD_NAME_LEN);
p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN;
BTM_TRACE_EVENT ("setting BTM_SEC_NAME_KNOWN sec_flags:0x%x\n", p_dev_rec->sec_flags);
} else {
@ -3506,7 +3506,7 @@ void btm_proc_sp_req_evt (tBTM_SP_EVT event, UINT8 *p)
memcpy (evt_data.cfm_req.bd_addr, p_dev_rec->bd_addr, BD_ADDR_LEN);
memcpy (evt_data.cfm_req.dev_class, p_dev_rec->dev_class, DEV_CLASS_LEN);
BCM_STRNCPY_S ((char *)evt_data.cfm_req.bd_name, sizeof(evt_data.cfm_req.bd_name), (char *)p_dev_rec->sec_bd_name, BTM_MAX_REM_BD_NAME_LEN);
BCM_STRNCPY_S ((char *)evt_data.cfm_req.bd_name, (char *)p_dev_rec->sec_bd_name, BTM_MAX_REM_BD_NAME_LEN);
switch (event) {
case BTM_SP_CFM_REQ_EVT:
@ -3731,7 +3731,7 @@ void btm_rem_oob_req (UINT8 *p)
btm_cb.api.p_sp_callback) {
memcpy (evt_data.bd_addr, p_dev_rec->bd_addr, BD_ADDR_LEN);
memcpy (evt_data.dev_class, p_dev_rec->dev_class, DEV_CLASS_LEN);
BCM_STRNCPY_S((char *)evt_data.bd_name, sizeof(evt_data.bd_name), (char *)p_dev_rec->sec_bd_name, BTM_MAX_REM_BD_NAME_LEN + 1);
BCM_STRNCPY_S((char *)evt_data.bd_name, (char *)p_dev_rec->sec_bd_name, BTM_MAX_REM_BD_NAME_LEN + 1);
evt_data.bd_name[BTM_MAX_REM_BD_NAME_LEN] = 0;
btm_sec_change_pairing_state(BTM_PAIR_STATE_WAIT_LOCAL_OOB_RSP);

View File

@ -1106,7 +1106,7 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_
void btm_sec_link_key_request (UINT8 *p_bda);
void btm_sec_pin_code_request (UINT8 *p_bda);
void btm_sec_update_clock_offset (UINT16 handle, UINT16 clock_offset);
void btm_sec_dev_rec_cback_event (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 res, BOOLEAN is_le_trasnport);
void btm_sec_dev_rec_cback_event (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 res, BOOLEAN is_le_transport);
void btm_sec_set_peer_sec_caps (tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec);
#if BLE_INCLUDED == TRUE

View File

@ -240,7 +240,7 @@ UINT16 BTU_BleAclPktSize(void)
bool BTU_check_queue_is_congest(void)
{
UBaseType_t wait_size = uxQueueMessagesWaiting(xBtuQueue);
if(wait_size >= QUEUE_CONGEST_SIZE ) {
if(wait_size >= BT_QUEUE_CONGEST_SIZE ) {
return true;
}
return false;

View File

@ -455,7 +455,7 @@ BT_HDR *attp_build_sr_msg(tGATT_TCB *p_tcb, UINT8 op_code, tGATT_SR_MSG *p_msg)
** Parameter p_tcb: pointer to the connecton control block.
** p_msg: pointer to message parameters structure.
**
** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
** Returns GATT_SUCCESS if successfully sent; otherwise error code.
**
**
*******************************************************************************/
@ -526,7 +526,7 @@ tGATT_STATUS attp_cl_send_cmd(tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 cmd_code,
** op_code: message op code.
** p_msg: pointer to message parameters structure.
**
** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
** Returns GATT_SUCCESS if successfully sent; otherwise error code.
**
**
*******************************************************************************/

View File

@ -80,7 +80,7 @@ UINT8 GATT_SetTraceLevel (UINT8 new_level)
**
** Parameter p_hndl_range: pointer to allocated handles information
**
** Returns TRUE if handle range is added sucessfully; otherwise FALSE.
** Returns TRUE if handle range is added successfully; otherwise FALSE.
**
*******************************************************************************/
@ -382,7 +382,7 @@ BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, UINT16 svc_
GATT_TRACE_DEBUG ("GATTS_DeleteService");
if (p_reg == NULL) {
GATT_TRACE_ERROR ("Applicaiton not foud");
GATT_TRACE_ERROR ("Application not found");
return (FALSE);
}
p_app_uuid128 = &p_reg->app_uuid128;
@ -434,7 +434,7 @@ BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, UINT16 svc_
** p_cback : application service callback functions.
** sup_transport : supported transport(s) for this primary service
**
** return GATT_SUCCESS if sucessfully started; otherwise error code.
** return GATT_SUCCESS if successfully started; otherwise error code.
**
*******************************************************************************/
tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
@ -443,9 +443,9 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
tGATT_SR_REG *p_sreg;
tGATT_HDL_LIST_ELEM *p_list = NULL;
UINT8 i_sreg;
#if (SDP_INCLUDED == TRUE)
#if (SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE)
tBT_UUID *p_uuid;
#endif ///SDP_INCLUDED == TRUE
#endif ///SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE
tGATT_REG *p_reg = gatt_get_regcb(gatt_if);
tGATTS_PENDING_NEW_SRV_START *p_buf;
@ -454,7 +454,7 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
if (p_reg == NULL) {
/* Not found */
GATT_TRACE_ERROR ("Applicaiton not found ");
GATT_TRACE_ERROR ("Application not found ");
return GATT_NOT_FOUND;
}
@ -484,10 +484,10 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
case GATT_TRANSPORT_BR_EDR:
case GATT_TRANSPORT_LE_BR_EDR:
if (p_sreg->type == GATT_UUID_PRI_SERVICE) {
#if (SDP_INCLUDED == TRUE)
#if (SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE)
p_uuid = gatts_get_service_uuid (p_sreg->p_db);
p_sreg->sdp_handle = gatt_add_sdp_record(p_uuid, p_sreg->s_hdl, p_sreg->e_hdl);
#endif ///SDP_INCLUDED == TRUE
#endif ///SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE
}
break;
default:
@ -539,11 +539,11 @@ void GATTS_StopService (UINT16 service_handle)
/* Index 0 is reserved for GATT, and is never stopped */
if ( (ii > 0) && (ii < GATT_MAX_SR_PROFILES) && (gatt_cb.sr_reg[ii].in_use) ) {
#if(SDP_INCLUDED == TRUE)
#if(SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE)
if (gatt_cb.sr_reg[ii].sdp_handle) {
SDP_DeleteRecord(gatt_cb.sr_reg[ii].sdp_handle);
}
#endif ///SDP_INCLUDED == TRUE
#endif ///SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE
gatt_remove_a_srv_from_list(&gatt_cb.srv_list_info, &gatt_cb.srv_list[ii]);
gatt_cb.srv_list[ii].in_use = FALSE;
memset (&gatt_cb.sr_reg[ii], 0, sizeof(tGATT_SR_REG));
@ -562,7 +562,7 @@ void GATTS_StopService (UINT16 service_handle)
** val_len: Length of the indicated attribute value.
** p_val: Pointer to the indicated attribute value data.
**
** Returns GATT_SUCCESS if sucessfully sent or queued; otherwise error code.
** Returns GATT_SUCCESS if successfully sent or queued; otherwise error code.
**
*******************************************************************************/
tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_handle, UINT16 val_len, UINT8 *p_val)
@ -629,7 +629,7 @@ tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_handle, U
** val_len: Length of the indicated attribute value.
** p_val: Pointer to the indicated attribute value data.
**
** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
** Returns GATT_SUCCESS if successfully sent; otherwise error code.
**
*******************************************************************************/
tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle,
@ -677,7 +677,7 @@ tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle,
** status: response status
** p_msg: pointer to message parameters structure.
**
** Returns GATT_SUCCESS if sucessfully sent; otherwise error code.
** Returns GATT_SUCCESS if successfully sent; otherwise error code.
**
*******************************************************************************/
tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
@ -1054,7 +1054,7 @@ tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, tGATT_VALUE *p_
** the server.
**
** Parameters conn_id: connection identifier.
** is_execute - to execute or cancel the prepare write requet(s)
** is_execute - to execute or cancel the prepare write request(s)
**
** Returns GATT_SUCCESS if command started successfully.
**
@ -1232,7 +1232,7 @@ tGATT_IF GATT_Register (tBT_UUID *p_app_uuid128, tGATT_CBACK *p_cb_info)
**
** Description This function deregistered the application from GATT.
**
** Parameters gatt_if: applicaiton interface.
** Parameters gatt_if: application interface.
**
** Returns None.
**
@ -1309,7 +1309,7 @@ void GATT_Deregister (tGATT_IF gatt_if)
** callbacks for registered interface. Function may call back
** with connection status and queued notifications
**
** Parameter gatt_if: applicaiton interface.
** Parameter gatt_if: application interface.
**
** Returns None.
**
@ -1342,13 +1342,13 @@ void GATT_StartIf (tGATT_IF gatt_if)
**
** Function GATT_Connect
**
** Description This function initiate a connecttion to a remote device on GATT
** Description This function initiate a connection to a remote device on GATT
** channel.
**
** Parameters gatt_if: applicaiton interface
** Parameters gatt_if: application interface
** bd_addr: peer device address.
** bd_addr_type: peer device address type.
** is_direct: is a direct conenection or a background auto connection
** is_direct: is a direct connection or a background auto connection
**
** Returns TRUE if connection started; FALSE if connection start failure.
**
@ -1532,10 +1532,10 @@ tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr)
** interface
**
** Parameters conn_id: connection id (input)
** p_gatt_if: applicaiton interface (output)
** p_gatt_if: application interface (output)
** bd_addr: peer device address. (output)
**
** Returns TRUE the ligical link information is found for conn_id
** Returns TRUE the logical link information is found for conn_id
**
*******************************************************************************/
BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if, BD_ADDR bd_addr,
@ -1567,7 +1567,7 @@ BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if, BD_ADDR bd_
** Description This function find the conn_id if the logical link for BD address
** and applciation interface is connected
**
** Parameters gatt_if: applicaiton interface (input)
** Parameters gatt_if: application interface (input)
** bd_addr: peer device address. (input)
** p_conn_id: connection id (output)
** transport: transport option
@ -1599,7 +1599,7 @@ BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, UINT16 *p_c
** Description This function start or stop LE advertisement and listen for
** connection.
**
** Parameters gatt_if: applicaiton interface
** Parameters gatt_if: application interface
** p_bd_addr: listen for specific address connection, or NULL for
** listen to all device connection.
** start: start or stop listening.

View File

@ -392,7 +392,7 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb,
p_rsp->len += (len + 2);
*p_len -= (len + 2);
} else {
GATT_TRACE_ERROR("format mismatch");
GATT_TRACE_WARNING("format mismatch");
status = GATT_NO_RESOURCES;
break;
}

View File

@ -47,7 +47,7 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
UINT16 reason, tBT_TRANSPORT transport);
static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf);
static void gatt_le_cong_cback(BD_ADDR remote_bda, BOOLEAN congest);
#if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 l2cap_cid,
UINT16 psm, UINT8 l2cap_id);
static void gatt_l2cif_connect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
@ -56,9 +56,9 @@ static void gatt_l2cif_config_cfm_cback (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cf
static void gatt_l2cif_disconnect_ind_cback (UINT16 l2cap_cid, BOOLEAN ack_needed);
static void gatt_l2cif_disconnect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
static void gatt_l2cif_data_ind_cback (UINT16 l2cap_cid, BT_HDR *p_msg);
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
static void gatt_send_conn_cback (tGATT_TCB *p_tcb);
#if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
static void gatt_l2cif_congest_cback (UINT16 cid, BOOLEAN congested);
static const tL2CAP_APPL_INFO dyn_info = {
gatt_l2cif_connect_ind_cback,
@ -73,7 +73,7 @@ static const tL2CAP_APPL_INFO dyn_info = {
gatt_l2cif_congest_cback,
NULL
} ;
#endif ///SMP_INCLUDED == TRUE
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
#if GATT_DYNAMIC_MEMORY == FALSE
tGATT_CB gatt_cb;
@ -125,12 +125,13 @@ void gatt_init (void)
fixed_reg.default_idle_tout = 0xffff; /* 0xffff default idle timeout */
L2CA_RegisterFixedChannel (L2CAP_ATT_CID, &fixed_reg);
#if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
/* Now, register with L2CAP for ATT PSM over BR/EDR */
if (!L2CA_Register (BT_PSM_ATT, (tL2CAP_APPL_INFO *) &dyn_info)) {
GATT_TRACE_ERROR ("ATT Dynamic Registration failed");
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0);
BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0);
@ -221,12 +222,12 @@ BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p
if (transport == BT_TRANSPORT_LE) {
p_tcb->att_lcid = L2CAP_ATT_CID;
gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda, bd_addr_type);
#if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
} else {
if ((p_tcb->att_lcid = L2CA_ConnectReq(BT_PSM_ATT, rem_bda)) != 0) {
gatt_ret = TRUE;
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
}
@ -262,10 +263,10 @@ BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb)
gatt_set_ch_state(p_tcb, GATT_CH_CLOSING);
ret = L2CA_CancelBleConnectReq (p_tcb->peer_bda);
}
#if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
} else {
ret = L2CA_DisconnectReq(p_tcb->att_lcid);
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
}
} else {
GATT_TRACE_DEBUG ("gatt_disconnect already in closing state");
@ -581,7 +582,7 @@ static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf)
** Returns void
**
*******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
{
/* do we already have a control channel for this peer? */
@ -887,7 +888,7 @@ static void gatt_l2cif_congest_cback (UINT16 lcid, BOOLEAN congested)
}
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
/*******************************************************************************
**
@ -1027,7 +1028,7 @@ void gatt_add_a_bonded_dev_for_srv_chg (BD_ADDR bda)
** Description This function is called to send a service changed indication to
** the specified bd address
**
** Returns GATT_SUCCESS if sucessfully sent; otherwise error code
** Returns GATT_SUCCESS if successfully sent; otherwise error code
**
*******************************************************************************/
#if (GATTS_INCLUDED == TRUE)

View File

@ -669,7 +669,7 @@ static tGATT_STATUS gatt_build_primary_service_rsp (BT_HDR *p_msg, tGATT_TCB *p_
** Description fill the find information response information in the given
** buffer.
**
** Returns TRUE: if data filled sucessfully.
** Returns TRUE: if data filled successfully.
** FALSE: packet full, or format mismatch.
**
*******************************************************************************/
@ -962,7 +962,7 @@ static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
if ((p_buf = attp_build_sr_msg(p_tcb, GATT_RSP_MTU, (tGATT_SR_MSG *) &p_tcb->payload_size)) != NULL) {
attp_send_sr_msg (p_tcb, p_buf);
/* Notify all registered applicaiton with new MTU size. Us a transaction ID */
/* Notify all registered application with new MTU size. Us a transaction ID */
/* of 0, as no response is allowed from applcations */
for (i = 0; i < GATT_MAX_APPS; i ++) {
@ -1087,6 +1087,7 @@ void gatts_process_read_by_type_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
}
} else {
attp_send_sr_msg(p_tcb, p_msg);
gatt_dequeue_sr_cmd(p_tcb);
}
}

Some files were not shown because too many files have changed in this diff Show More