mirror of
https://github.com/espressif/esp-idf.git
synced 2026-06-11 11:42:39 +02:00
Compare commits
343 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ccb4cf5b7 | |||
| f8e24754d1 | |||
| 86975b7e8f | |||
| c2bb7d7cd6 | |||
| cc3ba7186f | |||
| 7d28c02fd5 | |||
| 3becdd7850 | |||
| ef11260310 | |||
| 7b39d5e5c5 | |||
| d5b0b36758 | |||
| 0a609be968 | |||
| 148a269808 | |||
| 5b11428f00 | |||
| 4cd7fd89f5 | |||
| ceb56a7a72 | |||
| ebfa74310c | |||
| b482ba117d | |||
| 07735424a2 | |||
| f2f5a237c0 | |||
| 3be1c70d46 | |||
| beb34b5390 | |||
| 3991084777 | |||
| 088439c634 | |||
| dbd05d8986 | |||
| 7c5dd19c83 | |||
| a6fb161309 | |||
| 0929dbbc9b | |||
| 4c27f9ced8 | |||
| b800dfe6f1 | |||
| caa1ef0cb6 | |||
| 97e7c14f4e | |||
| c157c696e7 | |||
| d900cb5a35 | |||
| 4cb729283d | |||
| 6a3e160aaf | |||
| 70ecb7ec94 | |||
| 21e2c417e8 | |||
| 3ca82d5923 | |||
| 7af04d857f | |||
| e070e1886f | |||
| 6da2bec1e8 | |||
| 73345bae44 | |||
| 2d26163019 | |||
| ff2624f09c | |||
| 11d141e87d | |||
| 91f29bef17 | |||
| 8ed62223cd | |||
| de7a50dca0 | |||
| a9eac4a124 | |||
| 3e27184c38 | |||
| 5758b739f1 | |||
| 2d7124e319 | |||
| 232408981d | |||
| 9821e533db | |||
| 6d8990f39b | |||
| 83a9a4dc70 | |||
| 630ffde6bb | |||
| 6af30250a8 | |||
| 30d2f13358 | |||
| d7569b5862 | |||
| db9979701a | |||
| dca5ed2263 | |||
| 0ef3af367d | |||
| 9afe47425b | |||
| f5d33fa889 | |||
| 29cef5a9cc | |||
| 40171d7307 | |||
| e64bae3a0c | |||
| a71fad46d4 | |||
| 2c9acce0ff | |||
| 8e58b31a69 | |||
| bf152907a4 | |||
| 47ca5d53df | |||
| c1fe8ceb83 | |||
| db38c37cf7 | |||
| 71ce87c79e | |||
| 611c300a92 | |||
| b7eb82d191 | |||
| 933674301f | |||
| 3b2e231ae3 | |||
| 881cd4310c | |||
| 13e6e9f592 | |||
| cfc73a6de7 | |||
| 62e359a4e1 | |||
| ab4024c84e | |||
| f4ee20165e | |||
| e443467f37 | |||
| a6f990ffb9 | |||
| 43561a40d2 | |||
| 55f5c2e08d | |||
| e4418f4f92 | |||
| 968728bf95 | |||
| 2073a6e738 | |||
| 95b72a96f8 | |||
| 2617dee69f | |||
| f94db7bba7 | |||
| f7f02c9a43 | |||
| 52f0b86965 | |||
| 12bbe0f39b | |||
| 536b2d8a65 | |||
| f5ab51c9b7 | |||
| 8a5c712730 | |||
| 2287c28b41 | |||
| 129ac11c31 | |||
| 166918e802 | |||
| 4b028cca86 | |||
| a9d266b921 | |||
| dc9c2f3b60 | |||
| ae1389afd9 | |||
| 92f1d7ae39 | |||
| f73c972280 | |||
| 378a5b159a | |||
| 2ef218059b | |||
| 28a8349fb8 | |||
| 4acc941c3d | |||
| 4ae01f0c9d | |||
| 2c4e0cf878 | |||
| 4b739249c2 | |||
| b3f4755ac2 | |||
| 9185c370dc | |||
| b62182d75a | |||
| 890a341db4 | |||
| 04815c2d27 | |||
| 0af6d8ffe3 | |||
| 43b2563f5a | |||
| 16586524e9 | |||
| f60acb2196 | |||
| 1d2a9efa55 | |||
| 5ab4a9da51 | |||
| b63be2e08e | |||
| 6cf4e14671 | |||
| 39f7d1ad0b | |||
| d3a29c2d08 | |||
| 31a8a488f0 | |||
| b908d4325b | |||
| 54c148d289 | |||
| 60b937b5ca | |||
| b816edac3c | |||
| 2ee0f98d05 | |||
| f83296e448 | |||
| 09515bdfde | |||
| 081b623a34 | |||
| 871e95087e | |||
| a3b3f9ae2d | |||
| fb6f343ce5 | |||
| e1069de9aa | |||
| a219e9f819 | |||
| 8f8113f5cd | |||
| cf3647fe40 | |||
| 06651c0951 | |||
| d54fadef41 | |||
| 3b4353da5d | |||
| 261c5bf6a8 | |||
| 6132d7bce3 | |||
| 1db04ae574 | |||
| 6d4adb46f3 | |||
| e681f449bc | |||
| f3725a7821 | |||
| 34f6773471 | |||
| d0e7fd4369 | |||
| 13a3edee8a | |||
| 56866567ae | |||
| bc83d470e3 | |||
| a298d32d65 | |||
| 172a216edb | |||
| d5923f0e2e | |||
| cd9249970f | |||
| 676a27c7cf | |||
| 33121c3311 | |||
| 38509b2b95 | |||
| e821c22a8c | |||
| 8c363321db | |||
| ce279988c3 | |||
| 7200b8bf77 | |||
| 7e5cd986a9 | |||
| fa1e983028 | |||
| 71e344da20 | |||
| 620bba3a66 | |||
| 8f7f32c0a5 | |||
| 3cbbc3bbac | |||
| 5c42c831f5 | |||
| 8c57aa0242 | |||
| 0d5609ba92 | |||
| e209307297 | |||
| 4ac347b295 | |||
| fc3aa765cf | |||
| 31c94b25c5 | |||
| 5b8d1c9da3 | |||
| 7f784c84d2 | |||
| 532c8847c7 | |||
| 6dc31101ce | |||
| 7d9330d1af | |||
| 618aa6a3a4 | |||
| 762bf705bb | |||
| 5988e77a3a | |||
| 26e7f3fde6 | |||
| ba2ff1876f | |||
| 0757e019f4 | |||
| c68390f922 | |||
| 8e3a1876cb | |||
| cc8652d8d2 | |||
| 3cd8538f53 | |||
| 0033b31442 | |||
| 56afb3bd1c | |||
| e622ee0f41 | |||
| 2d50291b05 | |||
| c9b1e1df60 | |||
| 9a72c11e6e | |||
| 39dbe7daa8 | |||
| 554a28e8a1 | |||
| 7a2885885c | |||
| d154723a84 | |||
| 16918e400e | |||
| 510f726935 | |||
| 3295ed0995 | |||
| 924895f832 | |||
| 403268a13a | |||
| 6b3da6b188 | |||
| 93b4c71595 | |||
| d6badc53eb | |||
| cb7aaae35e | |||
| 18533e132a | |||
| 7a7128c7a3 | |||
| 208d87742c | |||
| dd76df7aee | |||
| deba35d2e5 | |||
| 9fdc36ed57 | |||
| 184f2f0fd6 | |||
| b36f4aa813 | |||
| 4b6ac69c04 | |||
| c7d73901d0 | |||
| 76cc8c1c0c | |||
| 38a2be75a9 | |||
| c85fc16282 | |||
| ab888394c3 | |||
| b8a2b77f70 | |||
| ef8341b5bc | |||
| c31217d193 | |||
| 16a56e2e7a | |||
| 1b3c6fb1a1 | |||
| f7177095cf | |||
| 0e89436769 | |||
| 40067fb50f | |||
| 167c21b987 | |||
| a2f00b0adf | |||
| feecafeb0e | |||
| 7bbbf2d4b3 | |||
| 21fb5085bd | |||
| 82a80005b9 | |||
| b354c11db7 | |||
| e5672e5d7f | |||
| 3e972a3ffe | |||
| 8bd09fb0a5 | |||
| e90c90d1f6 | |||
| 2f72645320 | |||
| 4be28a798f | |||
| eed94b87e2 | |||
| a218d4b925 | |||
| 015f523939 | |||
| 7196573605 | |||
| 4a698ffb75 | |||
| 3368783bf0 | |||
| 7e0e514127 | |||
| 541c267af3 | |||
| bbfe9f4efa | |||
| 9bd172356e | |||
| 1b8dd9f173 | |||
| dd33cec716 | |||
| 1cb29ac446 | |||
| 7b368fc211 | |||
| d6ceb4a31a | |||
| d5f9eb65e9 | |||
| ce3d20dcd2 | |||
| 1dc461ba80 | |||
| f03382b0ff | |||
| 2ecd007974 | |||
| c6e32c1a61 | |||
| 2f26bb2e65 | |||
| 3be2b430d1 | |||
| ff01bcfd88 | |||
| 8442255ccc | |||
| c92e677da4 | |||
| 6d2faf4172 | |||
| 826146e985 | |||
| 2faf3c9c34 | |||
| 3fedc3eb28 | |||
| 4148beca50 | |||
| c71b38c467 | |||
| 8e2b189252 | |||
| dca83700f2 | |||
| 37e131f76b | |||
| c76f00373f | |||
| 24a713b3c4 | |||
| 88fe438524 | |||
| 7f1fd0b8d3 | |||
| 2c91bc7a50 | |||
| 3cec8d0122 | |||
| 6381817006 | |||
| 14a6b33d5e | |||
| 6505f82a80 | |||
| c05a0ae6c3 | |||
| 2a9555f5dd | |||
| f72df315f7 | |||
| e7a263938b | |||
| 3ed0f8e113 | |||
| 7e1ccb56a7 | |||
| 50a0b00afa | |||
| be8f34065d | |||
| d0eab0f3ee | |||
| 7a530be302 | |||
| b692bda09b | |||
| e4a83f856e | |||
| e25152a031 | |||
| 885aec7aba | |||
| 0c2419d798 | |||
| a3a58546bc | |||
| 2f2f0fbcbd | |||
| ec4c75b692 | |||
| 90ddbaac16 | |||
| 0176f912b6 | |||
| 615376d14a | |||
| fe516fb7c2 | |||
| f5c805160b | |||
| 00e3f7f6b6 | |||
| d6b316c375 | |||
| bc04b1f53b | |||
| 50ceb45e6f | |||
| 646c7a7515 | |||
| cc7e91e1a3 | |||
| 725f0a7545 | |||
| bd0984226e | |||
| f330bb50b2 | |||
| 4f1e27fa76 | |||
| 16755a2c51 | |||
| 936b99d756 | |||
| c88cc4950e | |||
| 54e5e440b1 | |||
| e8bcda3512 | |||
| 35a30072f4 | |||
| edb0374b9d | |||
| 78539acdd1 | |||
| a1546e0714 | |||
| 8ff6afd29f |
@@ -156,10 +156,10 @@ exclude =
|
||||
components/protocomm/python/sec0_pb2.py,
|
||||
components/protocomm/python/sec1_pb2.py,
|
||||
components/protocomm/python/session_pb2.py,
|
||||
components/wifi_provisioning/python/wifi_scan_pb2.py,
|
||||
components/wifi_provisioning/python/wifi_config_pb2.py,
|
||||
components/wifi_provisioning/python/wifi_constants_pb2.py,
|
||||
examples/provisioning/custom_config/components/custom_provisioning/python/custom_config_pb2.py,
|
||||
# temporary list (should be empty)
|
||||
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py,
|
||||
tools/esp_app_trace/pylibelf,
|
||||
tools/mass_mfg/mfg_gen.py,
|
||||
|
||||
+163
-859
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
# .readthedocs.yml
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF and ePub
|
||||
formats:
|
||||
- pdf
|
||||
|
||||
# Optionally set the version of Python and requirements required to build your docs
|
||||
python:
|
||||
version: 2.7
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
||||
|
||||
# We need to list all the submodules included in documentation build by Doxygen
|
||||
submodules:
|
||||
include:
|
||||
- components/mqtt/esp-mqtt
|
||||
@@ -8,9 +8,16 @@ PARTTOOL_PY := $(PYTHON) $(IDF_PATH)/components/partition_table/parttool.py
|
||||
# Generate blank partition file
|
||||
BLANK_OTA_DATA_FILE = $(BUILD_DIR_BASE)/ota_data_initial.bin
|
||||
|
||||
$(BLANK_OTA_DATA_FILE): partition_table_get_info $(PARTITION_TABLE_BIN) | check_python_dependencies
|
||||
# Copy PARTITION_TABLE_CSV_PATH definition here from $IDF_PATH/components/partition_table/Makefile.projbuild
|
||||
# to avoid undefined variables warning for PARTITION_TABLE_CSV_PATH
|
||||
ifndef PARTITION_TABLE_CSV_PATH
|
||||
PARTITION_TABLE_ROOT := $(call dequote,$(if $(CONFIG_PARTITION_TABLE_CUSTOM),$(PROJECT_PATH),$(IDF_PATH)/components/partition_table))
|
||||
PARTITION_TABLE_CSV_PATH := $(call dequote,$(abspath $(PARTITION_TABLE_ROOT)/$(call dequote,$(CONFIG_PARTITION_TABLE_FILENAME))))
|
||||
endif
|
||||
|
||||
$(BLANK_OTA_DATA_FILE): partition_table_get_info $(PARTITION_TABLE_CSV_PATH) | check_python_dependencies
|
||||
$(shell if [ "$(OTA_DATA_OFFSET)" != "" ] && [ "$(OTA_DATA_SIZE)" != "" ]; then \
|
||||
$(PARTTOOL_PY) --partition-type data --partition-subtype ota --partition-table-file $(PARTITION_TABLE_BIN) \
|
||||
$(PARTTOOL_PY) --partition-type data --partition-subtype ota --partition-table-file $(PARTITION_TABLE_CSV_PATH) \
|
||||
-q generate_blank_partition_file --output $(BLANK_OTA_DATA_FILE); \
|
||||
fi; )
|
||||
$(eval BLANK_OTA_DATA_FILE = $(shell if [ "$(OTA_DATA_OFFSET)" != "" ] && [ "$(OTA_DATA_SIZE)" != "" ]; then \
|
||||
@@ -22,11 +29,11 @@ blank_ota_data: $(BLANK_OTA_DATA_FILE)
|
||||
# expand to empty values.
|
||||
ESPTOOL_ALL_FLASH_ARGS += $(OTA_DATA_OFFSET) $(BLANK_OTA_DATA_FILE)
|
||||
|
||||
erase_otadata: $(PARTITION_TABLE_BIN) partition_table_get_info | check_python_dependencies
|
||||
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_BIN) erase_otadata
|
||||
erase_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_python_dependencies
|
||||
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_CSV_PATH) erase_otadata
|
||||
|
||||
read_otadata: $(PARTITION_TABLE_BIN) partition_table_get_info | check_python_dependencies
|
||||
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_BIN) read_otadata
|
||||
read_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_python_dependencies
|
||||
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_CSV_PATH) read_otadata
|
||||
|
||||
erase_ota: erase_otadata
|
||||
@echo "WARNING: erase_ota is deprecated. Use erase_otadata instead."
|
||||
|
||||
@@ -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][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][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);
|
||||
|
||||
@@ -504,16 +504,5 @@ menu "Security features"
|
||||
|
||||
Only set this option in testing environments.
|
||||
|
||||
config SECURE_BOOT_TEST_MODE
|
||||
bool "Secure boot test mode: don't permanently set any eFuses"
|
||||
depends on SECURE_BOOT_INSECURE
|
||||
default N
|
||||
help
|
||||
If this option is set, all permanent secure boot changes (via eFuse) are disabled.
|
||||
|
||||
Log output will state changes which would be applied, but they will not be.
|
||||
|
||||
This option is for testing purposes only - it completely disables secure boot protection.
|
||||
|
||||
endmenu # Potentially Insecure
|
||||
endmenu # Security features
|
||||
|
||||
@@ -49,10 +49,11 @@ if((NOT CONFIG_SECURE_BOOT_ENABLED) OR
|
||||
CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH)
|
||||
externalproject_add(bootloader
|
||||
# TODO: support overriding the bootloader in COMPONENT_PATHS
|
||||
SOURCE_DIR "${IDF_PATH}/components/bootloader/subproject"
|
||||
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject"
|
||||
BINARY_DIR "${bootloader_build_dir}"
|
||||
CMAKE_ARGS -DSDKCONFIG=${SDKCONFIG} -DIDF_PATH=${IDF_PATH}
|
||||
-DSECURE_BOOT_SIGNING_KEY=${secure_boot_signing_key}
|
||||
-DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR}
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_ALWAYS 1 # no easy way around this...
|
||||
BUILD_BYPRODUCTS ${bootloader_binary_files}
|
||||
|
||||
@@ -27,9 +27,9 @@ target_linker_script(bootloader.elf
|
||||
# as cmake won't attach linker args to a header-only library, attach
|
||||
# linker args directly to the bootloader.elf
|
||||
set(ESP32_BOOTLOADER_LINKER_SCRIPTS
|
||||
"../../esp32/ld/esp32.rom.ld"
|
||||
"../../esp32/ld/esp32.rom.spiram_incompatible_fns.ld"
|
||||
"../../esp32/ld/esp32.peripherals.ld")
|
||||
"${IDF_PATH}/components/esp32/ld/esp32.rom.ld"
|
||||
"${IDF_PATH}/components/esp32/ld/esp32.rom.spiram_incompatible_fns.ld"
|
||||
"${IDF_PATH}/components/esp32/ld/esp32.peripherals.ld")
|
||||
|
||||
target_linker_script(bootloader.elf ${ESP32_BOOTLOADER_LINKER_SCRIPTS})
|
||||
|
||||
|
||||
@@ -136,3 +136,16 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
|
||||
* - ESP_FAIL: mapping is fail.
|
||||
*/
|
||||
esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t *partition, esp_app_desc_t *app_desc);
|
||||
|
||||
/**
|
||||
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
|
||||
*/
|
||||
void bootloader_common_vddsdio_configure();
|
||||
|
||||
/**
|
||||
* @brief Set the flash CS setup and hold time.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
void bootloader_common_set_flash_cs_timing();
|
||||
|
||||
@@ -46,6 +46,25 @@ static inline bool esp_secure_boot_enabled(void) {
|
||||
return REG_READ(EFUSE_BLK0_RDATA6_REG) & EFUSE_RD_ABS_DONE_0;
|
||||
}
|
||||
|
||||
/** @brief Generate secure digest from bootloader image
|
||||
*
|
||||
* @important This function is intended to be called from bootloader code only.
|
||||
*
|
||||
* If secure boot is not yet enabled for bootloader, this will:
|
||||
* 1) generate the secure boot key and burn it on EFUSE
|
||||
* (without enabling R/W protection)
|
||||
* 2) generate the digest from bootloader and save it
|
||||
* to flash address 0x0
|
||||
*
|
||||
* If first boot gets interrupted after calling this function
|
||||
* but before esp_secure_boot_permanently_enable() is called, then
|
||||
* the key burned on EFUSE will not be regenerated, unless manually
|
||||
* done using espefuse.py tool
|
||||
*
|
||||
* @return ESP_OK if secure boot digest is generated
|
||||
* successfully or found to be already present
|
||||
*/
|
||||
esp_err_t esp_secure_boot_generate_digest(void);
|
||||
|
||||
/** @brief Enable secure boot if it is not already enabled.
|
||||
*
|
||||
@@ -54,9 +73,13 @@ static inline bool esp_secure_boot_enabled(void) {
|
||||
*
|
||||
* @important This function is intended to be called from bootloader code only.
|
||||
*
|
||||
* @important This will enable r/w protection of secure boot key on EFUSE,
|
||||
* therefore it is to be ensured that esp_secure_boot_generate_digest()
|
||||
* is called before this
|
||||
*
|
||||
* If secure boot is not yet enabled for bootloader, this will
|
||||
* generate the secure boot digest and enable secure boot by blowing
|
||||
* the EFUSE_RD_ABS_DONE_0 efuse.
|
||||
* 1) enable R/W protection of secure boot key on EFUSE
|
||||
* 2) enable secure boot by blowing the EFUSE_RD_ABS_DONE_0 efuse.
|
||||
*
|
||||
* This function does not verify secure boot of the bootloader (the
|
||||
* ROM bootloader does this.)
|
||||
@@ -64,7 +87,6 @@ static inline bool esp_secure_boot_enabled(void) {
|
||||
* Will fail if efuses have been part-burned in a way that indicates
|
||||
* secure boot should not or could not be correctly enabled.
|
||||
*
|
||||
*
|
||||
* @return ESP_ERR_INVALID_STATE if efuse state doesn't allow
|
||||
* secure boot to be enabled cleanly. ESP_OK if secure boot
|
||||
* is enabled on this chip from now on.
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/spi_reg.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "bootloader_sha.h"
|
||||
#include "sys/param.h"
|
||||
@@ -257,3 +260,28 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void bootloader_common_vddsdio_configure()
|
||||
{
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) { // VDDSDIO regulator is enabled @ 1.8V
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
ets_delay_us(10); // wait for regulator to become stable
|
||||
}
|
||||
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
|
||||
}
|
||||
|
||||
void bootloader_common_set_flash_cs_timing()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -33,12 +33,10 @@
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "soc/gpio_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/rtc_wdt.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
@@ -50,6 +48,7 @@
|
||||
#include "bootloader_random.h"
|
||||
#include "bootloader_config.h"
|
||||
#include "bootloader_clock.h"
|
||||
#include "bootloader_common.h"
|
||||
|
||||
#include "flash_qio_mode.h"
|
||||
|
||||
@@ -63,7 +62,6 @@ 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 vddsdio_configure();
|
||||
static void flash_gpio_configure(const esp_image_header_t* pfhdr);
|
||||
static void uart_console_configure(void);
|
||||
static void wdt_reset_check(void);
|
||||
@@ -119,7 +117,7 @@ esp_err_t bootloader_init()
|
||||
|
||||
static esp_err_t bootloader_main()
|
||||
{
|
||||
vddsdio_configure();
|
||||
bootloader_common_vddsdio_configure();
|
||||
/* Read and keep flash ID, for further use. */
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
esp_image_header_t fhdr;
|
||||
@@ -287,21 +285,6 @@ static void print_flash_info(const esp_image_header_t* phdr)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vddsdio_configure()
|
||||
{
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) { // VDDSDIO regulator is enabled @ 1.8V
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
ets_delay_us(10); // wait for regulator to become stable
|
||||
}
|
||||
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
|
||||
}
|
||||
|
||||
#define FLASH_CLK_IO 6
|
||||
#define FLASH_CS_IO 11
|
||||
#define FLASH_SPIQ_IO 7
|
||||
@@ -322,10 +305,11 @@ static void IRAM_ATTR flash_gpio_configure(const esp_image_header_t* pfhdr)
|
||||
int drv = 2;
|
||||
switch (pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN;
|
||||
spi_cache_dummy = SPI0_R_QIO_DUMMY_CYCLELEN;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN; //qio 3
|
||||
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:
|
||||
@@ -350,6 +334,10 @@ static void IRAM_ATTR flash_gpio_configure(const esp_image_header_t* pfhdr)
|
||||
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;
|
||||
}
|
||||
@@ -409,6 +397,9 @@ static void IRAM_ATTR flash_gpio_configure(const esp_image_header_t* pfhdr)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// improve the flash cs timing.
|
||||
bootloader_common_set_flash_cs_timing();
|
||||
}
|
||||
|
||||
static void uart_console_configure(void)
|
||||
@@ -442,10 +433,18 @@ static void uart_console_configure(void)
|
||||
// (arrays should be optimized away by the compiler)
|
||||
const uint32_t tx_idx_list[3] = { U0TXD_OUT_IDX, U1TXD_OUT_IDX, U2TXD_OUT_IDX };
|
||||
const uint32_t rx_idx_list[3] = { U0RXD_IN_IDX, U1RXD_IN_IDX, U2RXD_IN_IDX };
|
||||
const uint32_t uart_reset[3] = { DPORT_UART_RST, DPORT_UART1_RST, DPORT_UART2_RST };
|
||||
const uint32_t tx_idx = tx_idx_list[uart_num];
|
||||
const uint32_t rx_idx = rx_idx_list[uart_num];
|
||||
|
||||
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[uart_rx_gpio]);
|
||||
gpio_pad_pullup(uart_rx_gpio);
|
||||
|
||||
gpio_matrix_out(uart_tx_gpio, tx_idx, 0, 0);
|
||||
gpio_matrix_in(uart_rx_gpio, rx_idx, 0);
|
||||
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, uart_reset[uart_num]);
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, uart_reset[uart_num]);
|
||||
}
|
||||
#endif // CONFIG_CONSOLE_UART_CUSTOM
|
||||
|
||||
|
||||
@@ -478,24 +478,71 @@ void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_
|
||||
// Copy loaded segments to RAM, set up caches for mapped segments, and start application.
|
||||
static void load_image(const esp_image_metadata_t* image_data)
|
||||
{
|
||||
/**
|
||||
* Rough steps for a first boot, when encryption and secure boot are both disabled:
|
||||
* 1) Generate secure boot key and write to EFUSE.
|
||||
* 2) Write plaintext digest based on plaintext bootloader
|
||||
* 3) Generate flash encryption key and write to EFUSE.
|
||||
* 4) Encrypt flash in-place including bootloader, then digest,
|
||||
* then app partitions and other encrypted partitions
|
||||
* 5) Burn EFUSE to enable flash encryption (FLASH_CRYPT_CNT)
|
||||
* 6) Burn EFUSE to enable secure boot (ABS_DONE_0)
|
||||
*
|
||||
* If power failure happens during Step 1, probably the next boot will continue from Step 2.
|
||||
* There is some small chance that EFUSEs will be part-way through being written so will be
|
||||
* somehow corrupted here. Thankfully this window of time is very small, but if that's the
|
||||
* case, one has to use the espefuse tool to manually set the remaining bits and enable R/W
|
||||
* protection. Once the relevant EFUSE bits are set and R/W protected, Step 1 will be skipped
|
||||
* successfully on further reboots.
|
||||
*
|
||||
* If power failure happens during Step 2, Step 1 will be skipped and Step 2 repeated:
|
||||
* the digest will get re-written on the next boot.
|
||||
*
|
||||
* If power failure happens during Step 3, it's possible that EFUSE was partially written
|
||||
* with the generated flash encryption key, though the time window for that would again
|
||||
* be very small. On reboot, Step 1 will be skipped and Step 2 repeated, though, Step 3
|
||||
* may fail due to the above mentioned reason, in which case, one has to use the espefuse
|
||||
* tool to manually set the remaining bits and enable R/W protection. Once the relevant EFUSE
|
||||
* bits are set and R/W protected, Step 3 will be skipped successfully on further reboots.
|
||||
*
|
||||
* If power failure happens after start of 4 and before end of 5, the next boot will fail
|
||||
* (bootloader header is encrypted and flash encryption isn't enabled yet, so it looks like
|
||||
* noise to the ROM bootloader). The check in the ROM is pretty basic so if the first byte of
|
||||
* ciphertext happens to be the magic byte E9 then it may try to boot, but it will definitely
|
||||
* crash (no chance that the remaining ciphertext will look like a valid bootloader image).
|
||||
* Only solution is to reflash with all plaintext and the whole process starts again: skips
|
||||
* Step 1, repeats Step 2, skips Step 3, etc.
|
||||
*
|
||||
* If power failure happens after 5 but before 6, the device will reboot with flash
|
||||
* encryption on and will regenerate an encrypted digest in Step 2. This should still
|
||||
* be valid as the input data for the digest is read via flash cache (so will be decrypted)
|
||||
* and the code in secure_boot_generate() tells bootloader_flash_write() to encrypt the data
|
||||
* on write if flash encryption is enabled. Steps 3 - 5 are skipped (encryption already on),
|
||||
* then Step 6 enables secure boot.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_FLASH_ENCRYPTION_ENABLED)
|
||||
esp_err_t err;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
/* Generate secure digest from this bootloader to protect future
|
||||
modifications */
|
||||
ESP_LOGI(TAG, "Checking secure boot...");
|
||||
err = esp_secure_boot_permanently_enable();
|
||||
/* Steps 1 & 2 (see above for full description):
|
||||
* 1) Generate secure boot EFUSE key
|
||||
* 2) Compute digest of plaintext bootloader
|
||||
*/
|
||||
err = esp_secure_boot_generate_digest();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Bootloader digest generation failed (%d). SECURE BOOT IS NOT ENABLED.", err);
|
||||
/* Allow booting to continue, as the failure is probably
|
||||
due to user-configured EFUSEs for testing...
|
||||
*/
|
||||
ESP_LOGE(TAG, "Bootloader digest generation for secure boot failed (%d).", err);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
|
||||
/* encrypt flash */
|
||||
/* Steps 3, 4 & 5 (see above for full description):
|
||||
* 3) Generate flash encryption EFUSE key
|
||||
* 4) Encrypt flash contents
|
||||
* 5) Burn EFUSE to enable flash encryption
|
||||
*/
|
||||
ESP_LOGI(TAG, "Checking flash encryption...");
|
||||
bool flash_encryption_enabled = esp_flash_encryption_enabled();
|
||||
err = esp_flash_encrypt_check_and_update();
|
||||
@@ -503,7 +550,24 @@ static void load_image(const esp_image_metadata_t* image_data)
|
||||
ESP_LOGE(TAG, "Flash encryption check failed (%d).", err);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
/* Step 6 (see above for full description):
|
||||
* 6) Burn EFUSE to enable secure boot
|
||||
*/
|
||||
ESP_LOGI(TAG, "Checking secure boot...");
|
||||
err = esp_secure_boot_permanently_enable();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "FAILED TO ENABLE SECURE BOOT (%d).", err);
|
||||
/* Panic here as secure boot is not properly enabled
|
||||
due to one of the reasons in above function
|
||||
*/
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
|
||||
if (!flash_encryption_enabled && esp_flash_encryption_enabled()) {
|
||||
/* Flash encryption was just enabled for the first time,
|
||||
so issue a system reset to ensure flash encryption
|
||||
|
||||
@@ -368,24 +368,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:
|
||||
|
||||
@@ -163,7 +163,7 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
|
||||
|
||||
/* If the last flash_crypt_cnt bit is burned or write-disabled, the
|
||||
device can't re-encrypt itself. */
|
||||
if (flash_crypt_wr_dis || flash_crypt_cnt == 0xFF) {
|
||||
if (flash_crypt_wr_dis) {
|
||||
ESP_LOGE(TAG, "Cannot re-encrypt data (FLASH_CRYPT_CNT 0x%02x write disabled %d", flash_crypt_cnt, flash_crypt_wr_dis);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -200,8 +200,8 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
|
||||
ESP_LOGD(TAG, "All flash regions checked for encryption pass");
|
||||
|
||||
/* Set least significant 0-bit in flash_crypt_cnt */
|
||||
int ffs_inv = __builtin_ffs((~flash_crypt_cnt) & 0xFF);
|
||||
/* ffs_inv shouldn't be zero, as zero implies flash_crypt_cnt == 0xFF */
|
||||
int ffs_inv = __builtin_ffs((~flash_crypt_cnt) & EFUSE_RD_FLASH_CRYPT_CNT);
|
||||
/* ffs_inv shouldn't be zero, as zero implies flash_crypt_cnt == EFUSE_RD_FLASH_CRYPT_CNT (0x7F) */
|
||||
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);
|
||||
@@ -225,18 +225,18 @@ static esp_err_t encrypt_bootloader()
|
||||
return err;
|
||||
}
|
||||
|
||||
if (esp_secure_boot_enabled()) {
|
||||
/* If secure boot is enabled and bootloader was plaintext, also
|
||||
need to encrypt secure boot IV+digest.
|
||||
*/
|
||||
ESP_LOGD(TAG, "Encrypting secure bootloader IV & digest...");
|
||||
err = esp_flash_encrypt_region(FLASH_OFFS_SECURE_BOOT_IV_DIGEST,
|
||||
FLASH_SECTOR_SIZE);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to encrypt bootloader IV & digest in place: 0x%x", err);
|
||||
return err;
|
||||
}
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
/* If secure boot is enabled and bootloader was plaintext, also
|
||||
* need to encrypt secure boot IV+digest.
|
||||
*/
|
||||
ESP_LOGD(TAG, "Encrypting secure bootloader IV & digest...");
|
||||
err = esp_flash_encrypt_region(FLASH_OFFS_SECURE_BOOT_IV_DIGEST,
|
||||
FLASH_SECTOR_SIZE);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to encrypt bootloader IV & digest in place: 0x%x", err);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
ESP_LOGW(TAG, "no valid bootloader was found");
|
||||
|
||||
@@ -36,6 +36,12 @@
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_efuse.h"
|
||||
|
||||
/* The following API implementations are used only when called
|
||||
* from the bootloader code.
|
||||
*/
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
|
||||
static const char* TAG = "secure_boot";
|
||||
|
||||
/**
|
||||
@@ -95,18 +101,15 @@ static bool secure_boot_generate(uint32_t image_len){
|
||||
/* Burn values written to the efuse write registers */
|
||||
static inline void burn_efuses()
|
||||
{
|
||||
#ifdef CONFIG_SECURE_BOOT_TEST_MODE
|
||||
ESP_LOGE(TAG, "SECURE BOOT TEST MODE. Not really burning any efuses! NOT SECURE");
|
||||
#else
|
||||
esp_efuse_burn_new_values();
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
esp_err_t esp_secure_boot_generate_digest(void)
|
||||
{
|
||||
esp_err_t err;
|
||||
if (esp_secure_boot_enabled())
|
||||
{
|
||||
ESP_LOGI(TAG, "bootloader secure boot is already enabled, continuing..");
|
||||
if (esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "bootloader secure boot is already enabled."
|
||||
" No need to generate digest. continuing..");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -124,6 +127,7 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Generate secure boot key and keep in EFUSE */
|
||||
uint32_t dis_reg = REG_READ(EFUSE_BLK0_RDATA0_REG);
|
||||
bool efuse_key_read_protected = dis_reg & EFUSE_RD_DIS_BLK2;
|
||||
bool efuse_key_write_protected = dis_reg & EFUSE_WR_DIS_BLK2;
|
||||
@@ -140,16 +144,11 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
ESP_LOGI(TAG, "Generating new secure boot key...");
|
||||
esp_efuse_write_random_key(EFUSE_BLK2_WDATA0_REG);
|
||||
burn_efuses();
|
||||
ESP_LOGI(TAG, "Read & write protecting new key...");
|
||||
REG_WRITE(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_BLK2 | EFUSE_RD_DIS_BLK2);
|
||||
burn_efuses();
|
||||
efuse_key_read_protected = true;
|
||||
efuse_key_write_protected = true;
|
||||
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Using pre-loaded secure boot key in EFUSE block 2");
|
||||
}
|
||||
|
||||
/* Generate secure boot digest using programmed key in EFUSE */
|
||||
ESP_LOGI(TAG, "Generating secure boot digest...");
|
||||
uint32_t image_len = bootloader_data.image_len;
|
||||
if(bootloader_data.image.hash_appended) {
|
||||
@@ -162,7 +161,28 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
}
|
||||
ESP_LOGI(TAG, "Digest generation complete.");
|
||||
|
||||
#ifndef CONFIG_SECURE_BOOT_TEST_MODE
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_secure_boot_permanently_enable(void)
|
||||
{
|
||||
if (esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "bootloader secure boot is already enabled, continuing..");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
uint32_t dis_reg = REG_READ(EFUSE_BLK0_RDATA0_REG);
|
||||
bool efuse_key_read_protected = dis_reg & EFUSE_RD_DIS_BLK2;
|
||||
bool efuse_key_write_protected = dis_reg & EFUSE_WR_DIS_BLK2;
|
||||
if (efuse_key_read_protected == false
|
||||
&& efuse_key_write_protected == false) {
|
||||
ESP_LOGI(TAG, "Read & write protecting new key...");
|
||||
REG_WRITE(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_BLK2 | EFUSE_RD_DIS_BLK2);
|
||||
burn_efuses();
|
||||
efuse_key_read_protected = true;
|
||||
efuse_key_write_protected = true;
|
||||
}
|
||||
|
||||
if (!efuse_key_read_protected) {
|
||||
ESP_LOGE(TAG, "Pre-loaded key is not read protected. Refusing to blow secure boot efuse.");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@@ -171,7 +191,6 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
ESP_LOGE(TAG, "Pre-loaded key is not write protected. Refusing to blow secure boot efuse.");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "blowing secure boot efuse...");
|
||||
ESP_LOGD(TAG, "before updating, EFUSE_BLK0_RDATA6 %x", REG_READ(EFUSE_BLK0_RDATA6_REG));
|
||||
@@ -200,11 +219,9 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
ESP_LOGI(TAG, "secure boot is now enabled for bootloader image");
|
||||
return ESP_OK;
|
||||
} else {
|
||||
#ifdef CONFIG_SECURE_BOOT_TEST_MODE
|
||||
ESP_LOGE(TAG, "secure boot not enabled due to test mode");
|
||||
#else
|
||||
ESP_LOGE(TAG, "secure boot not enabled for bootloader image, EFUSE_RD_ABS_DONE_0 is probably write protected!");
|
||||
#endif
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #ifdef BOOTLOADER_BUILD
|
||||
|
||||
@@ -21,12 +21,7 @@
|
||||
|
||||
#include "uECC.h"
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
#include "rom/sha.h"
|
||||
typedef SHA_CTX sha_context;
|
||||
#else
|
||||
#include "hwcrypto/sha.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 esp-idf SHA function */
|
||||
esp_sha(SHA2_256, data, length, digest);
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
@@ -258,6 +258,40 @@ menu Bluetooth
|
||||
The full scan function is mainly used to provide BLE scan performance.
|
||||
This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
|
||||
|
||||
config BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
bool "BLE adv report flow control supported"
|
||||
depends on (BTDM_CONTROLLER_MODE_BTDM || BTDM_CONTROLLER_MODE_BLE_ONLY)
|
||||
default y
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
advertising reports will be discarded by the controller if the number of unprocessed advertising
|
||||
reports exceeds the size of BLE adv report flow control.
|
||||
|
||||
config BLE_ADV_REPORT_FLOW_CONTROL_NUM
|
||||
int "BLE adv report flow control number"
|
||||
depends on BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
range 50 1000
|
||||
default 100
|
||||
help
|
||||
The number of unprocessed advertising report that Bluedroid can save.If you set
|
||||
`BLE_ADV_REPORT_FLOW_CONTROL_NUM` to a small value, this may cause adv packets lost.
|
||||
If you set `BLE_ADV_REPORT_FLOW_CONTROL_NUM` to a large value, Bluedroid may cache a
|
||||
lot of adv packets and this may cause system memory run out. For example, if you set
|
||||
it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
|
||||
`BLE_ADV_REPORT_FLOW_CONTROL_NUM` according to your system free memory and handle adv
|
||||
packets as fast as possible, otherwise it will cause adv packets lost.
|
||||
|
||||
config BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
int "BLE adv lost event threshold value"
|
||||
depends on BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
range 1 1000
|
||||
default 20
|
||||
help
|
||||
When adv report flow control is enabled, The ADV lost event will be generated when the number
|
||||
of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
|
||||
If you set `BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
|
||||
endmenu
|
||||
|
||||
menuconfig BLUEDROID_ENABLED
|
||||
@@ -1229,6 +1263,16 @@ menu Bluetooth
|
||||
Bluedroid will report adv data or scan response to application layer immediately.
|
||||
|
||||
# Memory reserved at start of DRAM for Bluetooth stack
|
||||
|
||||
config BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT
|
||||
int "Timeout of BLE connection establishment"
|
||||
depends on BLUEDROID_ENABLED
|
||||
range 1 60
|
||||
default 30
|
||||
help
|
||||
Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection
|
||||
establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered.
|
||||
|
||||
config BT_RESERVE_DRAM
|
||||
hex
|
||||
default 0xdb5c if BT_ENABLED
|
||||
|
||||
@@ -457,7 +457,7 @@ esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_ex
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (!device_info){
|
||||
if (!device_info && type <= ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@@ -465,7 +465,9 @@ esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_ex
|
||||
msg.act = BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST;
|
||||
arg.update_duplicate_exceptional_list.subcode = ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_ADD;
|
||||
arg.update_duplicate_exceptional_list.info_type = type;
|
||||
memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t));
|
||||
if (device_info) {
|
||||
memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t));
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
@@ -479,7 +481,7 @@ esp_err_t esp_ble_gap_remove_duplicate_scan_exceptional_device(esp_ble_duplicate
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (!device_info){
|
||||
if (!device_info && type <= ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@@ -487,7 +489,9 @@ esp_err_t esp_ble_gap_remove_duplicate_scan_exceptional_device(esp_ble_duplicate
|
||||
msg.act = BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST;
|
||||
arg.update_duplicate_exceptional_list.subcode = ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_REMOVE;
|
||||
arg.update_duplicate_exceptional_list.info_type = type;
|
||||
memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t));
|
||||
if (device_info) {
|
||||
memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t));
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
|
||||
@@ -558,6 +558,7 @@ typedef enum {
|
||||
ESP_GAP_SEARCH_DISC_CMPL_EVT = 4, /*!< Discovery complete. */
|
||||
ESP_GAP_SEARCH_DI_DISC_CMPL_EVT = 5, /*!< Discovery complete. */
|
||||
ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT = 6, /*!< Search cancelled */
|
||||
ESP_GAP_SEARCH_INQ_DISCARD_NUM_EVT = 7, /*!< The number of pkt discarded by flow control */
|
||||
} esp_gap_search_evt_t;
|
||||
|
||||
/**
|
||||
@@ -588,12 +589,18 @@ 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_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;
|
||||
|
||||
typedef enum {
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST = BLE_BIT(0), /*!< duplicate scan exceptional addr list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = (BLE_BIT(0) | BLE_BIT(1)), /*!< duplicate scan exceptional all list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST = BLE_BIT(0), /*!< duplicate scan exceptional addr list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_BEACON_TYPE_LIST = BLE_BIT(2), /*!< duplicate scan exceptional mesh beacon type list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROV_SRV_ADV_LIST = BLE_BIT(3), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SRV_ADV_LIST = BLE_BIT(4), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = 0xFFFF, /*!< duplicate scan exceptional all list */
|
||||
} esp_duplicate_scan_exceptional_list_type_t;
|
||||
|
||||
typedef uint8_t esp_duplicate_info_t[ESP_BD_ADDR_LEN];
|
||||
@@ -635,6 +642,7 @@ typedef union {
|
||||
int num_resps; /*!< Scan result number */
|
||||
uint8_t adv_data_len; /*!< Adv data length */
|
||||
uint8_t scan_rsp_len; /*!< Scan response length */
|
||||
uint32_t num_dis; /*!< The number of discard packets */
|
||||
} scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
|
||||
@@ -1049,6 +1057,7 @@ esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr);
|
||||
*
|
||||
*
|
||||
* @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t
|
||||
* when type is MESH_BEACON_TYPE, MESH_PROV_SRV_ADV or MESH_PROXY_SRV_ADV , device_info is invalid.
|
||||
* @param[in] device_info: the device information.
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
@@ -1061,6 +1070,7 @@ esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_ex
|
||||
*
|
||||
*
|
||||
* @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t
|
||||
* when type is MESH_BEACON_TYPE, MESH_PROV_SRV_ADV or MESH_PROXY_SRV_ADV , device_info is invalid.
|
||||
* @param[in] device_info: the device information.
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
|
||||
@@ -1293,9 +1293,10 @@ void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
/* if SBC is used by the SNK as INT, discover req is not sent in bta_av_config_ind.
|
||||
* call disc_res now */
|
||||
/* this is called in A2DP SRC path only, In case of SINK we don't need it */
|
||||
if (local_sep == AVDT_TSEP_SRC)
|
||||
if (local_sep == AVDT_TSEP_SRC) {
|
||||
p_scb->p_cos->disc_res(p_scb->hndl, num, num, 0, p_scb->peer_addr,
|
||||
UUID_SERVCLASS_AUDIO_SOURCE);
|
||||
}
|
||||
} else {
|
||||
/* we do not know the peer device and it is using non-SBC codec
|
||||
* we need to know all the SEPs on SNK */
|
||||
|
||||
@@ -829,10 +829,11 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
if (p_data->rc_msg.msg.pass.op_id == AVRC_ID_VENDOR) {
|
||||
p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL;
|
||||
#if (AVRC_METADATA_INCLUDED == TRUE)
|
||||
if (p_cb->features & BTA_AV_FEAT_METADATA)
|
||||
if (p_cb->features & BTA_AV_FEAT_METADATA) {
|
||||
p_data->rc_msg.msg.hdr.ctype =
|
||||
bta_av_group_navi_supported(p_data->rc_msg.msg.pass.pass_len,
|
||||
p_data->rc_msg.msg.pass.p_pass_data, is_inquiry);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
p_data->rc_msg.msg.hdr.ctype = bta_av_op_supported(p_data->rc_msg.msg.pass.op_id, is_inquiry);
|
||||
@@ -890,7 +891,9 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
evt = bta_av_proc_meta_cmd (&rc_rsp, &p_data->rc_msg, &ctype);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
evt = BTA_AV_VENDOR_CMD_EVT;
|
||||
}
|
||||
}
|
||||
/* else if configured to support vendor specific and it's a response */
|
||||
else if ((p_cb->features & BTA_AV_FEAT_VENDOR) &&
|
||||
@@ -902,7 +905,9 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
evt = BTA_AV_META_MSG_EVT;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
evt = BTA_AV_VENDOR_RSP_EVT;
|
||||
}
|
||||
|
||||
}
|
||||
/* else if not configured to support vendor specific and it's a command */
|
||||
|
||||
@@ -1268,7 +1268,7 @@ BOOLEAN bta_av_hdl_event(BT_HDR *p_msg)
|
||||
** Returns char *
|
||||
**
|
||||
*******************************************************************************/
|
||||
static char *bta_av_st_code(UINT8 state)
|
||||
UNUSED_ATTR static char *bta_av_st_code(UINT8 state)
|
||||
{
|
||||
switch (state) {
|
||||
case BTA_AV_INIT_ST: return "INIT";
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
#include "bta/bta_av_co.h"
|
||||
#include "bta_av_int.h"
|
||||
#include "osi/osi.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
@@ -564,7 +565,7 @@ void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb)
|
||||
** Returns char *
|
||||
**
|
||||
*******************************************************************************/
|
||||
static char *bta_av_sst_code(UINT8 state)
|
||||
UNUSED_ATTR static char *bta_av_sst_code(UINT8 state)
|
||||
{
|
||||
switch (state) {
|
||||
case BTA_AV_INIT_SST: return "INIT";
|
||||
|
||||
@@ -127,6 +127,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
|
||||
static void bta_dm_observe_cmpl_cb(void *p_result);
|
||||
static void bta_dm_observe_discard_cb (uint32_t num_dis);
|
||||
static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle);
|
||||
extern void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8 *p_uuid128);
|
||||
static void bta_dm_disable_timer_cback(TIMER_LIST_ENT *p_tle);
|
||||
@@ -635,13 +636,15 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
|
||||
|
||||
/* set modes for Discoverability and connectability if not ignore */
|
||||
if (p_data->set_visibility.disc_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) {
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE)
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) {
|
||||
p_data->set_visibility.disc_mode =
|
||||
((p_data->set_visibility.disc_mode & ~BTA_DM_LE_IGNORE) | le_disc_mode);
|
||||
}
|
||||
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE)
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) {
|
||||
p_data->set_visibility.disc_mode =
|
||||
((p_data->set_visibility.disc_mode & ~BTA_DM_IGNORE) | disc_mode);
|
||||
}
|
||||
|
||||
BTM_SetDiscoverability(p_data->set_visibility.disc_mode,
|
||||
bta_dm_cb.inquiry_scan_window,
|
||||
@@ -649,13 +652,15 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
|
||||
if (p_data->set_visibility.conn_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) {
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE)
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) {
|
||||
p_data->set_visibility.conn_mode =
|
||||
((p_data->set_visibility.conn_mode & ~BTA_DM_LE_IGNORE) | le_conn_mode);
|
||||
}
|
||||
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE)
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) {
|
||||
p_data->set_visibility.conn_mode =
|
||||
((p_data->set_visibility.conn_mode & ~BTA_DM_IGNORE) | conn_mode);
|
||||
}
|
||||
|
||||
BTM_SetConnectability(p_data->set_visibility.conn_mode,
|
||||
bta_dm_cb.page_scan_window,
|
||||
@@ -1900,10 +1905,12 @@ void bta_dm_disc_result (tBTA_DM_MSG *p_data)
|
||||
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
/* if any BR/EDR service discovery has been done, report the event */
|
||||
if ((bta_dm_search_cb.services & ((BTA_ALL_SERVICE_MASK | BTA_USER_SERVICE_MASK ) & ~BTA_BLE_SERVICE_MASK)))
|
||||
#endif
|
||||
if ((bta_dm_search_cb.services & ((BTA_ALL_SERVICE_MASK | BTA_USER_SERVICE_MASK ) & ~BTA_BLE_SERVICE_MASK))) {
|
||||
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
|
||||
|
||||
}
|
||||
#else
|
||||
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
|
||||
#endif
|
||||
tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG));
|
||||
|
||||
/* send a message to change state */
|
||||
@@ -2169,9 +2176,10 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
|
||||
}
|
||||
|
||||
/* last one? clear the BLE service bit if all discovery has been done */
|
||||
if (bta_dm_search_cb.uuid_to_search == 0)
|
||||
if (bta_dm_search_cb.uuid_to_search == 0) {
|
||||
bta_dm_search_cb.services_to_search &=
|
||||
(tBTA_SERVICE_MASK)(~(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index)));
|
||||
}
|
||||
|
||||
} else
|
||||
#endif
|
||||
@@ -3654,11 +3662,11 @@ static char *bta_dm_get_remname(void)
|
||||
char *p_temp;
|
||||
|
||||
/* If the name isn't already stored, try retrieving from BTM */
|
||||
if (*p_name == '\0')
|
||||
if (*p_name == '\0') {
|
||||
if ((p_temp = BTM_SecReadDevName(bta_dm_search_cb.peer_bdaddr)) != NULL) {
|
||||
p_name = p_temp;
|
||||
}
|
||||
|
||||
}
|
||||
return p_name;
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE
|
||||
@@ -4273,6 +4281,28 @@ static void bta_dm_observe_cmpl_cb (void *p_result)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_observe_discard_cb
|
||||
**
|
||||
** Description Callback for BLE Observe lost
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_dm_observe_discard_cb (uint32_t num_dis)
|
||||
{
|
||||
tBTA_DM_SEARCH data;
|
||||
|
||||
APPL_TRACE_DEBUG("bta_dm_observe_discard_cb");
|
||||
|
||||
data.inq_dis.num_dis = num_dis;
|
||||
if (bta_dm_search_cb.p_scan_cback) {
|
||||
bta_dm_search_cb.p_scan_cback(BTA_DM_INQ_DISCARD_NUM_EVT, &data);
|
||||
}
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -4815,7 +4845,7 @@ void bta_dm_ble_scan (tBTA_DM_MSG *p_data)
|
||||
bta_dm_search_cb.p_scan_cback = p_data->ble_scan.p_cback;
|
||||
|
||||
if ((status = BTM_BleScan(TRUE, p_data->ble_scan.duration,
|
||||
bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb)) != BTM_CMD_STARTED) {
|
||||
bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb, bta_dm_observe_discard_cb)) != BTM_CMD_STARTED) {
|
||||
APPL_TRACE_WARNING(" %s start scan failed. status=0x%x\n", __FUNCTION__, status);
|
||||
}
|
||||
|
||||
@@ -4825,7 +4855,7 @@ void bta_dm_ble_scan (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
} else {
|
||||
bta_dm_search_cb.p_scan_cback = NULL;
|
||||
status = BTM_BleScan(FALSE, 0, NULL, NULL);
|
||||
status = BTM_BleScan(FALSE, 0, NULL, NULL, NULL);
|
||||
|
||||
if (status != BTM_CMD_STARTED){
|
||||
APPL_TRACE_WARNING(" %s stop scan failed, status=0x%x\n", __FUNCTION__, status);
|
||||
@@ -5219,9 +5249,10 @@ void bta_dm_ble_setup_storage (tBTA_DM_MSG *p_data)
|
||||
p_data->ble_set_storage.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_CFG_STRG_EVT, p_data->ble_set_storage.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -5249,9 +5280,10 @@ void bta_dm_ble_enable_batch_scan (tBTA_DM_MSG *p_data)
|
||||
p_data->ble_enable_scan.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_ENABLE_EVT, p_data->ble_enable_scan.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -5275,9 +5307,10 @@ void bta_dm_ble_disable_batch_scan (tBTA_DM_MSG *p_data)
|
||||
btm_status = BTM_BleDisableBatchScan(p_data->ble_disable_scan.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_DISABLE_EVT, p_data->ble_enable_scan.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -5301,9 +5334,10 @@ void bta_dm_ble_read_scan_reports(tBTA_DM_MSG *p_data)
|
||||
p_data->ble_read_reports.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_READ_REPTS_EVT, p_data->ble_enable_scan.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -5433,10 +5467,11 @@ void bta_dm_cfg_filter_cond (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
if (p_data->ble_cfg_filter_cond.p_filt_cfg_cback)
|
||||
if (p_data->ble_cfg_filter_cond.p_filt_cfg_cback) {
|
||||
p_data->ble_cfg_filter_cond.p_filt_cfg_cback(BTA_DM_BLE_PF_CONFIG_EVT,
|
||||
p_data->ble_cfg_filter_cond.cond_type, 0, status,
|
||||
p_data->ble_cfg_filter_cond.ref_value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5467,9 +5502,10 @@ void bta_dm_enable_scan_filter(tBTA_DM_MSG *p_data)
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_data->ble_enable_scan_filt.p_filt_status_cback)
|
||||
if (p_data->ble_enable_scan_filt.p_filt_status_cback) {
|
||||
p_data->ble_enable_scan_filt.p_filt_status_cback (BTA_DM_BLE_PF_ENABLE_EVT,
|
||||
p_data->ble_enable_scan_filt.ref_value, status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5503,9 +5539,10 @@ void bta_dm_scan_filter_param_setup (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
if (p_data->ble_scan_filt_param_setup.p_filt_param_cback)
|
||||
if (p_data->ble_scan_filt_param_setup.p_filt_param_cback) {
|
||||
p_data->ble_scan_filt_param_setup.p_filt_param_cback (BTA_DM_BLE_PF_ENABLE_EVT, 0,
|
||||
p_data->ble_scan_filt_param_setup.ref_value, status);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -5815,6 +5852,8 @@ void bta_dm_proc_open_evt(tBTA_GATTC_OPEN *p_data)
|
||||
((p2[0]) << 24) + ((p2[1]) << 16) + ((p2[2]) << 8) + (p2[3]),
|
||||
((p2[4]) << 8) + p2[5]);
|
||||
|
||||
UNUSED(p1);
|
||||
UNUSED(p2);
|
||||
APPL_TRACE_DEBUG("BTA_GATTC_OPEN_EVT conn_id = %d client_if=%d status = %d" ,
|
||||
p_data->conn_id,
|
||||
p_data->client_if,
|
||||
|
||||
@@ -1038,9 +1038,10 @@ static void bta_dm_pm_hid_check(BOOLEAN bScoActive)
|
||||
bta_dm_pm_set_sniff_policy( bta_dm_find_peer_device(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr), bScoActive);
|
||||
|
||||
/* if we had disabled link policy, seems like the hid device stop retrying SNIFF after a few tries. force sniff if needed */
|
||||
if (!bScoActive)
|
||||
if (!bScoActive) {
|
||||
bta_dm_pm_set_mode(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr, BTA_DM_PM_NO_ACTION,
|
||||
BTA_DM_PM_RESTART);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -531,7 +531,9 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
|
||||
if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, TRUE, FALSE)) {
|
||||
/* always call open to hold a connection */
|
||||
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, p_data->remote_addr_type, FALSE, p_data->transport)) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
uint8_t *bda = (uint8_t *)p_data->remote_bda;
|
||||
#endif
|
||||
status = BTA_GATT_ERROR;
|
||||
APPL_TRACE_ERROR("%s unable to connect to remote bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
__func__, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
@@ -674,7 +676,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
|
||||
//register service change
|
||||
bta_gattc_register_service_change_notify(p_clcb->bta_conn_id, p_clcb->bda);
|
||||
} else
|
||||
} else
|
||||
#endif
|
||||
{ /* cache is building */
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
|
||||
@@ -1071,8 +1073,9 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data))
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tGATT_READ_PARAM read_param;
|
||||
memset (&read_param, 0 ,sizeof(tGATT_READ_PARAM));
|
||||
@@ -1140,8 +1143,9 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data))
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tBTA_GATT_STATUS status = BTA_GATT_OK;
|
||||
tGATT_VALUE attr;
|
||||
@@ -1742,7 +1746,7 @@ void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_m
|
||||
tBTA_GATTC gattc_cb = {0};
|
||||
gattc_cb.set_assoc.client_if = p_msg->api_assoc.client_if;
|
||||
BOOLEAN state = FALSE;
|
||||
tBTA_GATTC_CLCB *p_assoc_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_assoc.client_if,
|
||||
tBTA_GATTC_CLCB *p_assoc_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_assoc.client_if,
|
||||
p_msg->api_assoc.assoc_addr, BTA_TRANSPORT_LE);
|
||||
tBTA_GATTC_RCB *p_clrcb = bta_gattc_cl_get_regcb(p_msg->api_assoc.client_if);
|
||||
if (p_assoc_clcb != NULL) {
|
||||
@@ -1783,7 +1787,7 @@ void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_m
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ static char *bta_gattc_attr_type[] = {
|
||||
};
|
||||
/* utility functions */
|
||||
|
||||
bool display_cache_attribute(void *data, void *context)
|
||||
bool display_cache_attribute(void *data, void *context)
|
||||
{
|
||||
//tBTA_GATTC_CACHE_ATTR *p_attr = data;
|
||||
//APPL_TRACE_ERROR("\t Attr handle[%d] uuid[0x%04x] type[%s] prop[0x%1x]",
|
||||
@@ -102,7 +102,7 @@ bool display_cache_attribute(void *data, void *context)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool display_cache_service(void *data, void *context)
|
||||
bool display_cache_service(void *data, void *context)
|
||||
{
|
||||
tBTA_GATTC_SERVICE *p_cur_srvc = data;
|
||||
APPL_TRACE_API("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]",
|
||||
@@ -213,9 +213,9 @@ static void bta_gattc_free(void *ptr)
|
||||
osi_free(ptr);
|
||||
}
|
||||
|
||||
void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE *p_new_srvc)
|
||||
void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE *p_new_srvc)
|
||||
{
|
||||
// services/p_new_srvc is NULL
|
||||
// services/p_new_srvc is NULL
|
||||
if (!services || !p_new_srvc) {
|
||||
APPL_TRACE_ERROR("%s services/p_new_srvc is NULL", __func__);
|
||||
return;
|
||||
@@ -243,7 +243,7 @@ void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,8 +314,9 @@ static tBTA_GATT_STATUS bta_gattc_add_char_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
/* TODO(jpawlowski): We should use attribute handle, not value handle to refer to characteristic.
|
||||
This is just a temporary workaround.
|
||||
*/
|
||||
if (service->e_handle < value_handle)
|
||||
if (service->e_handle < value_handle) {
|
||||
service->e_handle = value_handle;
|
||||
}
|
||||
|
||||
tBTA_GATTC_CHARACTERISTIC *characteristic = osi_malloc(sizeof(tBTA_GATTC_CHARACTERISTIC));
|
||||
if (!characteristic) {
|
||||
@@ -554,10 +555,10 @@ void bta_gattc_update_include_service(const list_t *services) {
|
||||
if(include_service && !include_service->included_service) {
|
||||
//update
|
||||
include_service->included_service = bta_gattc_find_matching_service(services, include_service->incl_srvc_s_handle);
|
||||
if(!include_service->included_service) {
|
||||
if(!include_service->included_service) {
|
||||
//not match, free it
|
||||
list_remove(service->included_svc, include_service);
|
||||
osi_free(include_service);
|
||||
osi_free(include_service);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -980,12 +981,13 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
|
||||
p_data->value.incl_service.e_handle,
|
||||
p_data->value.incl_service.service_type);
|
||||
|
||||
if (!pri_srvc)
|
||||
if (!pri_srvc) {
|
||||
bta_gattc_add_srvc_to_list(p_srvc_cb,
|
||||
p_data->value.incl_service.s_handle,
|
||||
p_data->value.incl_service.e_handle,
|
||||
p_data->value.incl_service.service_type,
|
||||
FALSE);
|
||||
}
|
||||
/* add into database */
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb,
|
||||
p_data->handle,
|
||||
@@ -1007,8 +1009,8 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
|
||||
|
||||
case GATT_DISC_CHAR_DSCPT:
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb,
|
||||
p_data->handle,
|
||||
&p_data->type,
|
||||
p_data->handle,
|
||||
&p_data->type,
|
||||
0,
|
||||
0 /* incl_srvc_s_handle */,
|
||||
0 /* incl_srvc_e_handle */,
|
||||
@@ -1023,8 +1025,9 @@ void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if ( p_clcb && (status != GATT_SUCCESS || p_clcb->status != GATT_SUCCESS) ) {
|
||||
if (status == GATT_SUCCESS)
|
||||
if (status == GATT_SUCCESS) {
|
||||
p_clcb->status = status;
|
||||
}
|
||||
bta_gattc_sm_execute(p_clcb, BTA_GATTC_DISCOVER_CMPL_EVT, NULL);
|
||||
return;
|
||||
}
|
||||
@@ -1071,15 +1074,17 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
{
|
||||
tBTA_GATTC cb_data;
|
||||
|
||||
if (!p_clcb->p_srcb->p_srvc_cache || list_is_empty(p_clcb->p_srcb->p_srvc_cache))
|
||||
if (!p_clcb->p_srcb->p_srvc_cache || list_is_empty(p_clcb->p_srcb->p_srvc_cache)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (list_node_t *sn = list_begin(p_clcb->p_srcb->p_srvc_cache);
|
||||
sn != list_end(p_clcb->p_srcb->p_srvc_cache); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *p_cache = list_node(sn);
|
||||
|
||||
if (!bta_gattc_uuid_compare(p_uuid, &p_cache->uuid, FALSE))
|
||||
if (!bta_gattc_uuid_compare(p_uuid, &p_cache->uuid, FALSE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
|
||||
APPL_TRACE_DEBUG("found service [0x%04x], inst[%d] handle [%d]",
|
||||
@@ -1087,8 +1092,9 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
p_cache->handle,
|
||||
p_cache->s_handle);
|
||||
#endif
|
||||
if (!p_clcb->p_rcb->p_cback)
|
||||
if (!p_clcb->p_rcb->p_cback) {
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(&cb_data, 0, sizeof(tBTA_GATTC));
|
||||
|
||||
@@ -1103,8 +1109,9 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
}
|
||||
|
||||
list_t* bta_gattc_get_services_srcb(tBTA_GATTC_SERV *p_srcb) {
|
||||
if (!p_srcb || !p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache))
|
||||
if (!p_srcb || !p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return p_srcb->p_srvc_cache;
|
||||
}
|
||||
@@ -1112,8 +1119,9 @@ list_t* bta_gattc_get_services_srcb(tBTA_GATTC_SERV *p_srcb) {
|
||||
const list_t* bta_gattc_get_services(UINT16 conn_id) {
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL )
|
||||
if (p_clcb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
|
||||
@@ -1121,63 +1129,68 @@ const list_t* bta_gattc_get_services(UINT16 conn_id) {
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERVICE* bta_gattc_find_matching_service(const list_t *services, UINT16 handle) {
|
||||
if (!services || list_is_empty(services))
|
||||
if (!services || list_is_empty(services)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (list_node_t *sn = list_begin(services);
|
||||
sn != list_end(services); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *service = list_node(sn);
|
||||
|
||||
if (handle >= service->s_handle && handle <= service->e_handle)
|
||||
if (handle >= service->s_handle && handle <= service->e_handle) {
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
{
|
||||
const list_t *services = bta_gattc_get_services_srcb(p_srcb);
|
||||
|
||||
return bta_gattc_find_matching_service(services, handle);
|
||||
}
|
||||
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle)
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
const list_t *services = bta_gattc_get_services(conn_id);
|
||||
|
||||
return bta_gattc_find_matching_service(services, handle);
|
||||
}
|
||||
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
{
|
||||
const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle);
|
||||
|
||||
if (!service)
|
||||
if (!service) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (list_node_t *cn = list_begin(service->characteristics);
|
||||
cn != list_end(service->characteristics); cn = list_next(cn)) {
|
||||
tBTA_GATTC_CHARACTERISTIC *p_char = list_node(cn);
|
||||
if (handle == p_char->handle)
|
||||
if (handle == p_char->handle) {
|
||||
return p_char;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle)
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL )
|
||||
if (p_clcb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
return bta_gattc_get_characteristic_srcb(p_srcb, handle);
|
||||
}
|
||||
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
{
|
||||
const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle);
|
||||
|
||||
@@ -1191,20 +1204,22 @@ tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, U
|
||||
for (list_node_t *dn = list_begin(p_char->descriptors);
|
||||
dn != list_end(p_char->descriptors); dn = list_next(dn)) {
|
||||
tBTA_GATTC_DESCRIPTOR *p_desc = list_node(dn);
|
||||
if (handle == p_desc->handle)
|
||||
if (handle == p_desc->handle) {
|
||||
return p_desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle)
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL )
|
||||
if (p_clcb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
return bta_gattc_get_descriptor_srcb(p_srcb, handle);
|
||||
@@ -1443,7 +1458,7 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1476,7 +1491,7 @@ static size_t bta_gattc_get_db_size_with_type(list_t *services,
|
||||
}
|
||||
|
||||
if (type == BTGATT_DB_PRIMARY_SERVICE || type == BTGATT_DB_SECONDARY_SERVICE) {
|
||||
if ((type == BTGATT_DB_PRIMARY_SERVICE && p_cur_srvc->is_primary) ||
|
||||
if ((type == BTGATT_DB_PRIMARY_SERVICE && p_cur_srvc->is_primary) ||
|
||||
(type == BTGATT_DB_SECONDARY_SERVICE && !p_cur_srvc->is_primary)) {
|
||||
// if the current service is the last service in the db, need to ensure the current service start handle is not less than the start_handle.
|
||||
if (!svc_length) {
|
||||
@@ -1572,10 +1587,11 @@ static size_t bta_gattc_get_db_size_with_type(list_t *services,
|
||||
** Returns number of elements inside db from start_handle to end_handle
|
||||
*******************************************************************************/
|
||||
static size_t bta_gattc_get_db_size(list_t *services,
|
||||
UINT16 start_handle, UINT16 end_handle)
|
||||
UINT16 start_handle, UINT16 end_handle)
|
||||
{
|
||||
if (!services || list_is_empty(services))
|
||||
if (!services || list_is_empty(services)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t db_size = 0;
|
||||
UINT16 svc_length = list_length(services) - 1;
|
||||
@@ -1598,9 +1614,10 @@ static size_t bta_gattc_get_db_size(list_t *services,
|
||||
} else {
|
||||
db_size++;
|
||||
}
|
||||
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics))
|
||||
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *cn = list_begin(p_cur_srvc->characteristics);
|
||||
cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) {
|
||||
@@ -1657,7 +1674,7 @@ void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 en
|
||||
*count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
*count = 0;
|
||||
@@ -1676,7 +1693,7 @@ void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute
|
||||
*count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
*count = 0;
|
||||
@@ -1694,7 +1711,7 @@ void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute
|
||||
}
|
||||
}
|
||||
*count = bta_gattc_get_db_size_with_type(p_srcb->p_srvc_cache, type, NULL, start_handle, end_handle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1786,8 +1803,9 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
p_char->properties);
|
||||
curr_db_attr++;
|
||||
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors))
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *dn = list_begin(p_char->descriptors);
|
||||
dn != list_end(p_char->descriptors); dn = list_next(dn)) {
|
||||
@@ -1815,8 +1833,9 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
}
|
||||
}
|
||||
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc))
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *isn = list_begin(p_cur_srvc->included_svc);
|
||||
isn != list_end(p_cur_srvc->included_svc); isn = list_next(isn)) {
|
||||
@@ -1983,8 +2002,9 @@ void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_han
|
||||
*******************************************************************************/
|
||||
void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
{
|
||||
if (!p_srvc_cb->p_srvc_cache || list_is_empty(p_srvc_cb->p_srvc_cache))
|
||||
if (!p_srvc_cb->p_srvc_cache || list_is_empty(p_srvc_cb->p_srvc_cache)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
size_t db_size = bta_gattc_get_db_size(p_srvc_cb->p_srvc_cache, 0x0000, 0xFFFF);
|
||||
@@ -2017,8 +2037,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
sn != list_end(p_srvc_cb->p_srvc_cache); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *p_cur_srvc = list_node(sn);
|
||||
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics))
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *cn = list_begin(p_cur_srvc->characteristics);
|
||||
cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) {
|
||||
@@ -2034,8 +2055,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
0 /* incl_srvc_e_handle */,
|
||||
FALSE);
|
||||
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors))
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *dn = list_begin(p_char->descriptors);
|
||||
dn != list_end(p_char->descriptors); dn = list_next(dn)) {
|
||||
@@ -2053,8 +2075,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
}
|
||||
}
|
||||
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc))
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *an = list_begin(p_cur_srvc->included_svc);
|
||||
an != list_end(p_cur_srvc->included_svc); an = list_next(an)) {
|
||||
|
||||
@@ -261,14 +261,18 @@ tBTA_GATT_STATUS bta_gattc_co_cache_open(BD_ADDR server_bda, BOOLEAN to_save, UI
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS bta_gattc_co_cache_load(tBTA_GATTC_NV_ATTR *attr, UINT8 index)
|
||||
{
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
UINT16 num_attr = 0;
|
||||
#endif
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ERROR;
|
||||
size_t length = 0;
|
||||
// Read the size of memory space required for blob
|
||||
nvs_get_blob(cache_env.cache_addr[index].cache_fp, cache_key, NULL, &length);
|
||||
// Read previously saved blob if available
|
||||
esp_err_t err_code = nvs_get_blob(cache_env.cache_addr[index].cache_fp, cache_key, attr, &length);
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
num_attr = length / sizeof(tBTA_GATTC_NV_ATTR);
|
||||
#endif
|
||||
status = (err_code == ESP_OK && length != 0) ? BTA_GATT_OK : BTA_GATT_ERROR;
|
||||
APPL_TRACE_DEBUG("%s() - read=%d, status=%d, err_code = %d",
|
||||
__func__, num_attr, status, err_code);
|
||||
@@ -323,6 +327,9 @@ void bta_gattc_co_cache_save (BD_ADDR server_bda, UINT16 num_attr,
|
||||
status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_STACK_NO_LOG
|
||||
(void) status;
|
||||
#endif
|
||||
APPL_TRACE_DEBUG("%s() wrote hash_key = %x%x%x%x, num_attr = %d, status = %d.", __func__, hash_key[0], hash_key[1], hash_key[2], hash_key[3], num_attr, status);
|
||||
}
|
||||
|
||||
|
||||
@@ -416,8 +416,9 @@ tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda)
|
||||
|
||||
if (p_tcb != NULL)
|
||||
{
|
||||
if (p_tcb->p_srvc_cache != NULL)
|
||||
if (p_tcb->p_srvc_cache != NULL) {
|
||||
list_free(p_tcb->p_srvc_cache);
|
||||
}
|
||||
osi_free(p_tcb->p_srvc_list);
|
||||
p_tcb->p_srvc_list = NULL;
|
||||
//osi_free_and_reset((void **)&p_tcb->p_srvc_list);
|
||||
@@ -583,8 +584,9 @@ void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id,
|
||||
* clear boundaries are always around service.
|
||||
*/
|
||||
handle = p_clrcb->notif_reg[i].handle;
|
||||
if (handle >= start_handle && handle <= end_handle)
|
||||
if (handle >= start_handle && handle <= end_handle) {
|
||||
memset(&p_clrcb->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -637,8 +639,9 @@ BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda
|
||||
}
|
||||
if (!add) {
|
||||
if (remote_bda_ptr) {
|
||||
// bdstr_t bdstr = {0};
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
char bdstr[18] = {0};
|
||||
#endif
|
||||
APPL_TRACE_ERROR("%s unable to find the bg connection mask for: %s", __func__,
|
||||
bdaddr_to_string((bt_bdaddr_t *)remote_bda_ptr, bdstr, sizeof(bdstr)));
|
||||
}
|
||||
@@ -936,8 +939,9 @@ void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src)
|
||||
|
||||
if (p_src->len == LEN_UUID_16 || p_src->len == LEN_UUID_32)
|
||||
{
|
||||
for(i=0; i != 16; ++i)
|
||||
for(i=0; i != 16; ++i) {
|
||||
p_dest->uu[i] = base_uuid[i];
|
||||
}
|
||||
}
|
||||
|
||||
switch (p_src->len)
|
||||
|
||||
@@ -403,7 +403,7 @@ void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
UINT16 attr_id = 0;
|
||||
tBTA_GATTS cb_data;
|
||||
|
||||
tGATT_ATTR_VAL *p_attr_val = NULL;
|
||||
tGATT_ATTR_VAL *p_attr_val = NULL;
|
||||
tGATTS_ATTR_CONTROL *p_control = NULL;
|
||||
|
||||
if(p_msg->api_add_char.attr_val.attr_max_len != 0){
|
||||
@@ -665,17 +665,18 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
&gatt_if, remote_bda, &transport)) {
|
||||
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
|
||||
|
||||
if (p_msg->api_indicate.need_confirm)
|
||||
if (p_msg->api_indicate.need_confirm) {
|
||||
|
||||
status = GATTS_HandleValueIndication (p_msg->api_indicate.hdr.layer_specific,
|
||||
p_msg->api_indicate.attr_id,
|
||||
p_msg->api_indicate.len,
|
||||
p_msg->api_indicate.value);
|
||||
else
|
||||
} else {
|
||||
status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
|
||||
p_msg->api_indicate.attr_id,
|
||||
p_msg->api_indicate.len,
|
||||
p_msg->api_indicate.value);
|
||||
}
|
||||
|
||||
/* if over BR_EDR, inform PM for mode change */
|
||||
if (transport == BTA_TRANSPORT_BR_EDR) {
|
||||
@@ -858,13 +859,13 @@ void bta_gatts_send_service_change_indication (tBTA_GATTS_DATA *p_msg)
|
||||
memcpy(bd_addr, p_msg->api_send_service_change.remote_bda, BD_ADDR_LEN);
|
||||
status = GATT_SendServiceChangeIndication(bd_addr);
|
||||
} else {
|
||||
status = GATT_SendServiceChangeIndication(NULL);
|
||||
status = GATT_SendServiceChangeIndication(NULL);
|
||||
}
|
||||
if (p_rcb && p_rcb->p_cback) {
|
||||
service_change.status = status;
|
||||
service_change.server_if = p_msg->api_send_service_change.server_if;
|
||||
(*p_rcb->p_cback)(BTA_GATTS_SEND_SERVICE_CHANGE_EVT, (tBTA_GATTS *)&service_change);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -940,7 +941,7 @@ static void bta_gatts_send_request_cback (UINT16 conn_id,
|
||||
cb_data.req_data.p_data = (tBTA_GATTS_REQ_DATA *)p_data;
|
||||
|
||||
if(req_type == BTA_GATTS_CONF_EVT) {
|
||||
cb_data.req_data.handle = p_data->handle;
|
||||
cb_data.req_data.handle = p_data->handle;
|
||||
}
|
||||
(*p_rcb->p_cback)(req_type, &cb_data);
|
||||
} else {
|
||||
|
||||
@@ -1159,6 +1159,7 @@ static char *bta_hf_client_skip_unknown(char *buffer)
|
||||
buffer = tmp + 2;
|
||||
|
||||
APPL_TRACE_DEBUG("%s %.*s", __FUNCTION__, buffer - start - 2, start);
|
||||
UNUSED(start);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -308,6 +308,7 @@ static void bta_hf_client_sco_disc_cback(UINT16 sco_idx)
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
tBTM_STATUS status = BTM_ConfigScoPath(BTM_SCO_ROUTE_PCM, NULL, NULL, TRUE);
|
||||
APPL_TRACE_DEBUG("%s close config status = %d", __FUNCTION__, status);
|
||||
UNUSED(status);
|
||||
/* SCO clean up here */
|
||||
bta_hf_client_sco_co_close();
|
||||
#endif
|
||||
|
||||
@@ -101,8 +101,10 @@ void bta_hh_api_enable(tBTA_HH_DATA *p_data)
|
||||
bta_hh_le_enable();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* signal BTA call back event */
|
||||
(* bta_hh_cb.p_cback)(BTA_HH_ENABLE_EVT, (tBTA_HH *)&status);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -901,7 +903,9 @@ void bta_hh_get_dscp_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
bta_hh_le_get_dscp_act(p_cb);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
(*bta_hh_cb.p_cback)(BTA_HH_GET_DSCP_EVT, (tBTA_HH *)&p_cb->dscp_info);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -934,11 +938,10 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
dev_info.status = BTA_HH_OK;
|
||||
} else
|
||||
#endif
|
||||
|
||||
{
|
||||
if (HID_HostAddDev(p_dev_info->bda, p_dev_info->attr_mask, &dev_handle)\
|
||||
== HID_SUCCESS) {
|
||||
dev_info.handle = dev_handle;
|
||||
dev_info.status = BTA_HH_OK;
|
||||
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
/* update DI information */
|
||||
@@ -966,6 +969,7 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
/* update cb_index[] map */
|
||||
bta_hh_cb.cb_index[dev_handle] = p_cb->index;
|
||||
}
|
||||
}
|
||||
} else { /* device already been added */
|
||||
dev_info.handle = p_cb->hid_handle;
|
||||
dev_info.status = BTA_HH_OK;
|
||||
|
||||
@@ -2183,9 +2183,10 @@ void bta_hh_le_write_char_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_b
|
||||
case GATT_UUID_HID_BT_KB_INPUT:
|
||||
case GATT_UUID_HID_BT_MOUSE_INPUT:
|
||||
case GATT_UUID_HID_REPORT:
|
||||
if (p_data->status == BTA_GATT_OK)
|
||||
if (p_data->status == BTA_GATT_OK) {
|
||||
p_dev_cb->hid_srvc[hid_inst_id].report[p_dev_cb->clt_cfg_idx].client_cfg_value =
|
||||
BTA_GATT_CLT_CONFIG_NOTIFICATION;
|
||||
}
|
||||
p_dev_cb->clt_cfg_idx ++;
|
||||
bta_hh_le_write_rpt_clt_cfg(p_dev_cb, hid_inst_id);
|
||||
|
||||
|
||||
@@ -75,11 +75,12 @@ UINT8 bta_hh_find_cb(BD_ADDR bda)
|
||||
return xx;
|
||||
}
|
||||
#if BTA_HH_DEBUG
|
||||
else
|
||||
else {
|
||||
APPL_TRACE_DEBUG("in_use ? [%d] kdev[%d].hid_handle = %d state = [%d]",
|
||||
bta_hh_cb.kdev[xx].in_use, xx,
|
||||
bta_hh_cb.kdev[xx].hid_handle,
|
||||
bta_hh_cb.kdev[xx].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -123,7 +124,9 @@ void bta_hh_clean_up_kdev(tBTA_HH_DEV_CB *p_cb)
|
||||
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = BTA_HH_IDX_INVALID;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
bta_hh_cb.cb_index[p_cb->hid_handle] = BTA_HH_IDX_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset device control block */
|
||||
@@ -486,11 +489,12 @@ UINT8 bta_hh_dev_handle_to_cb_idx(UINT8 dev_handle)
|
||||
#endif
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* regular HID device checking */
|
||||
if (dev_handle < BTA_HH_MAX_KNOWN ) {
|
||||
index = bta_hh_cb.cb_index[dev_handle];
|
||||
}
|
||||
|
||||
}
|
||||
return index;
|
||||
|
||||
}
|
||||
|
||||
@@ -1024,6 +1024,7 @@ typedef struct {
|
||||
#define BTA_DM_DISC_CMPL_EVT 4 /* Discovery complete. */
|
||||
#define BTA_DM_DI_DISC_CMPL_EVT 5 /* Discovery complete. */
|
||||
#define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
|
||||
#define BTA_DM_INQ_DISCARD_NUM_EVT 7 /* The number of inquiry discarded packets */
|
||||
|
||||
typedef UINT8 tBTA_DM_SEARCH_EVT;
|
||||
|
||||
@@ -1055,6 +1056,11 @@ typedef struct {
|
||||
UINT8 num_resps; /* Number of inquiry responses. */
|
||||
} tBTA_DM_INQ_CMPL;
|
||||
|
||||
/* Structure associated with BTA_DM_INQ_DISCARD_NUM_EVT */
|
||||
typedef struct {
|
||||
UINT32 num_dis; /* The number of inquiry discarded packets. */
|
||||
} tBTA_DM_INQ_DISCARD;
|
||||
|
||||
/* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
@@ -1092,6 +1098,7 @@ typedef union {
|
||||
tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
|
||||
tBTA_DM_DISC_BLE_RES disc_ble_res; /* Discovery result for GATT based service */
|
||||
tBTA_DM_DI_DISC_CMPL di_disc; /* DI discovery result for a peer device */
|
||||
tBTA_DM_INQ_DISCARD inq_dis; /* the discarded packets information of inquiry */
|
||||
} tBTA_DM_SEARCH;
|
||||
|
||||
/* Structure of search callback event and structures */
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/osi.h"
|
||||
#include "stack/bt_types.h"
|
||||
#include "bta/utl.h"
|
||||
#include "bta/bta_sys.h"
|
||||
@@ -137,7 +138,7 @@ UINT8 bta_jv_alloc_sec_id(void)
|
||||
return ret;
|
||||
|
||||
}
|
||||
static int get_sec_id_used(void)
|
||||
UNUSED_ATTR static int get_sec_id_used(void)
|
||||
{
|
||||
int i;
|
||||
int used = 0;
|
||||
@@ -146,12 +147,13 @@ static int get_sec_id_used(void)
|
||||
used++;
|
||||
}
|
||||
}
|
||||
if (used == BTA_JV_NUM_SERVICE_ID)
|
||||
if (used == BTA_JV_NUM_SERVICE_ID) {
|
||||
APPL_TRACE_ERROR("get_sec_id_used, sec id exceeds the limit:%d",
|
||||
BTA_JV_NUM_SERVICE_ID);
|
||||
}
|
||||
return used;
|
||||
}
|
||||
static int get_rfc_cb_used(void)
|
||||
UNUSED_ATTR static int get_rfc_cb_used(void)
|
||||
{
|
||||
int i;
|
||||
int used = 0;
|
||||
@@ -160,9 +162,10 @@ static int get_rfc_cb_used(void)
|
||||
used++;
|
||||
}
|
||||
}
|
||||
if (used == BTA_JV_MAX_RFC_CONN)
|
||||
if (used == BTA_JV_MAX_RFC_CONN) {
|
||||
APPL_TRACE_ERROR("get_sec_id_used, rfc ctrl block exceeds the limit:%d",
|
||||
BTA_JV_MAX_RFC_CONN);
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
@@ -474,19 +477,21 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
|
||||
< BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) {
|
||||
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(bta_jv_cb.rfc_cb[hi].rfc_hdl[si]);
|
||||
if (p_pcb) {
|
||||
if (NULL == p_pcb->p_pm_cb)
|
||||
if (NULL == p_pcb->p_pm_cb) {
|
||||
APPL_TRACE_WARNING("%s(jv_handle:"
|
||||
" 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to "
|
||||
"pm_cb?", __func__, jv_handle, p_pcb->port_handle, i);
|
||||
}
|
||||
p_cb = &p_pcb->p_pm_cb;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (jv_handle < BTA_JV_MAX_L2C_CONN) {
|
||||
tBTA_JV_L2C_CB *p_l2c_cb = &bta_jv_cb.l2c_cb[jv_handle];
|
||||
if (NULL == p_l2c_cb->p_pm_cb)
|
||||
if (NULL == p_l2c_cb->p_pm_cb) {
|
||||
APPL_TRACE_WARNING("%s(jv_handle: "
|
||||
"0x%x): p_pm_cb: %d: no link to pm_cb?", __func__, jv_handle, i);
|
||||
}
|
||||
p_cb = &p_l2c_cb->p_pm_cb;
|
||||
}
|
||||
}
|
||||
@@ -742,9 +747,10 @@ void bta_jv_get_channel_id(tBTA_JV_MSG *p_data)
|
||||
bta_jv_cb.scn[channel - 1] = TRUE;
|
||||
scn = (UINT8) channel;
|
||||
}
|
||||
if (bta_jv_cb.p_dm_cback)
|
||||
if (bta_jv_cb.p_dm_cback) {
|
||||
bta_jv_cb.p_dm_cback(BTA_JV_GET_SCN_EVT, (tBTA_JV *)&scn,
|
||||
p_data->alloc_channel.user_data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case BTA_JV_CONN_TYPE_L2CAP:
|
||||
@@ -998,6 +1004,9 @@ static bool create_base_record(const uint32_t sdp_handle, const char *name, cons
|
||||
APPL_TRACE_DEBUG("create_base_record: successfully created base service "
|
||||
"record, handle: 0x%08x, scn: %d, name: %s, with_obex: %d",
|
||||
sdp_handle, channel, name, with_obex);
|
||||
|
||||
UNUSED(stage);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1031,6 +1040,8 @@ static int add_spp_sdp(const char *name, const int channel) {
|
||||
|
||||
APPL_TRACE_DEBUG("add_spp_sdp: service registered successfully, "
|
||||
"service_name: %s, handle 0x%08x)", name, handle);
|
||||
UNUSED(stage);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -1523,6 +1534,7 @@ static int bta_jv_port_data_co_cback(UINT16 port_handle, UINT8 *buf, UINT16 len,
|
||||
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(port_handle);
|
||||
int ret = 0;
|
||||
APPL_TRACE_DEBUG("%s, p_cb:%p, p_pcb:%p, len:%d, type:%d", __func__, p_cb, p_pcb, len, type);
|
||||
UNUSED(p_cb);
|
||||
if (p_pcb != NULL) {
|
||||
switch (type) {
|
||||
case DATA_CO_CALLBACK_TYPE_INCOMING:
|
||||
|
||||
@@ -750,7 +750,9 @@ static void _btc_read_le_key(const uint8_t key_type, const size_t key_len, bt_bd
|
||||
*device_added = true;
|
||||
}
|
||||
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
char bd_str[20] = {0};
|
||||
#endif
|
||||
BTC_TRACE_DEBUG("%s() Adding key type %d for %s", __func__,
|
||||
key_type, bdaddr_to_string(&bd_addr, bd_str, sizeof(bd_str)));
|
||||
BTA_DmAddBleKey(bta_bd_addr, (tBTA_LE_KEY_VALUE *)buffer, key_type);
|
||||
|
||||
@@ -290,6 +290,9 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
|
||||
}
|
||||
|
||||
#if (CONFIG_BT_STACK_NO_LOG)
|
||||
(void) status;
|
||||
#endif
|
||||
BTC_TRACE_DEBUG("%s, authentication status = %x", __func__, status);
|
||||
return;
|
||||
|
||||
|
||||
@@ -170,6 +170,14 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
status, &rsp);
|
||||
|
||||
if(status != GATT_SUCCESS) {
|
||||
if (blufi_env.prepare_buf) {
|
||||
osi_free(blufi_env.prepare_buf);
|
||||
blufi_env.prepare_buf = NULL;
|
||||
}
|
||||
BLUFI_TRACE_ERROR("write data error , error code 0x%x\n", status);
|
||||
return;
|
||||
}
|
||||
memcpy(blufi_env.prepare_buf + p_data->req_data.p_data->write_req.offset,
|
||||
p_data->req_data.p_data->write_req.value,
|
||||
p_data->req_data.p_data->write_req.len);
|
||||
@@ -194,7 +202,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
GATT_SUCCESS, NULL);
|
||||
|
||||
if (p_data->req_data.p_data->exec_write == GATT_PREP_WRITE_EXEC) {
|
||||
if (blufi_env.prepare_buf && p_data->req_data.p_data->exec_write == GATT_PREP_WRITE_EXEC) {
|
||||
btc_blufi_recv_handler(blufi_env.prepare_buf, blufi_env.prepare_len);
|
||||
}
|
||||
|
||||
|
||||
@@ -615,6 +615,7 @@ static void btc_a2dp_sink_handle_decoder_reset(tBTC_MEDIA_SINK_CFG_UPDATE *p_msg
|
||||
|
||||
int frames_to_process = ((freq_multiple) / (num_blocks * num_subbands)) + 1;
|
||||
APPL_TRACE_EVENT(" Frames to be processed in 20 ms %d\n", frames_to_process);
|
||||
UNUSED(frames_to_process);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -495,10 +495,11 @@ static UINT64 time_now_us()
|
||||
static void log_tstamps_us(char *comment)
|
||||
{
|
||||
static UINT64 prev_us = 0;
|
||||
const UINT64 now_us = time_now_us();
|
||||
UINT64 now_us = time_now_us();
|
||||
APPL_TRACE_DEBUG("[%s] ts %08llu, diff : %08llu, queue sz %d", comment, now_us, now_us - prev_us,
|
||||
fixed_queue_length(btc_aa_src_cb.TxAaQ));
|
||||
prev_us = now_us;
|
||||
UNUSED(prev_us);
|
||||
}
|
||||
|
||||
/* when true media task discards any tx frames */
|
||||
|
||||
@@ -1199,10 +1199,13 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
BTC_TRACE_ERROR("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d\n", a2d_status);
|
||||
}
|
||||
}
|
||||
UNUSED(que_len);
|
||||
}
|
||||
#else
|
||||
static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
{
|
||||
UNUSED(event);
|
||||
UNUSED(p_data);
|
||||
BTC_TRACE_WARNING("%s : event %u\n", __func__, event);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -335,6 +335,8 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp)
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s DUT does not support AVRCP controller role", __FUNCTION__);
|
||||
}
|
||||
|
||||
UNUSED(status);
|
||||
#else
|
||||
BTC_TRACE_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__);
|
||||
#endif
|
||||
|
||||
@@ -604,6 +604,9 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
|
||||
case BTA_DM_SEARCH_CANCEL_CMPL_EVT:
|
||||
BTC_TRACE_DEBUG("BTA_DM_SEARCH_CANCEL_CMPL_EVT\n");
|
||||
break;
|
||||
case BTA_DM_INQ_DISCARD_NUM_EVT:
|
||||
param.scan_rst.num_dis = p_data->inq_dis.num_dis;
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s : Unknown event 0x%x\n", __FUNCTION__, event);
|
||||
return;
|
||||
|
||||
@@ -715,10 +715,13 @@ void btc_gatts_call_handler(btc_msg_t *msg)
|
||||
#else
|
||||
//BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type);
|
||||
#endif
|
||||
/*
|
||||
not support background connection
|
||||
// Mark background connections
|
||||
if (!arg->open.is_direct) {
|
||||
BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL);
|
||||
}
|
||||
*/
|
||||
|
||||
transport = BTA_GATT_TRANSPORT_LE;
|
||||
|
||||
|
||||
@@ -195,8 +195,9 @@ bt_status_t btc_hf_client_init(void)
|
||||
*******************************************************************************/
|
||||
static bt_status_t connect_int( bt_bdaddr_t *bd_addr, uint16_t uuid )
|
||||
{
|
||||
if (is_connected(bd_addr))
|
||||
if (is_connected(bd_addr)) {
|
||||
return BT_STATUS_BUSY;
|
||||
}
|
||||
|
||||
btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_CONNECTING;
|
||||
bdcpy(btc_hf_client_cb.connected_bda.address, bd_addr->address);
|
||||
@@ -713,14 +714,14 @@ static void process_ind_evt(tBTA_HF_CLIENT_IND *ind)
|
||||
{
|
||||
esp_hf_client_cb_param_t param;
|
||||
memset(¶m, 0, sizeof(esp_hf_client_cb_param_t));
|
||||
|
||||
|
||||
switch (ind->type)
|
||||
{
|
||||
case BTA_HF_CLIENT_IND_CALL:
|
||||
param.call.status = ind->value;
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CIND_CALL_EVT, ¶m);
|
||||
break;
|
||||
|
||||
|
||||
case BTA_HF_CLIENT_IND_CALLSETUP:
|
||||
param.call_setup.status = ind->value;
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CIND_CALL_SETUP_EVT, ¶m);
|
||||
@@ -787,6 +788,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
BTC_TRACE_WARNING("%s: HF CLient open failed, but another device connected. status=%d state=%d connected device=%s",
|
||||
__FUNCTION__, p_data->open.status, btc_hf_client_cb.state, bdaddr_to_string(&btc_hf_client_cb.connected_bda, bdstr, sizeof(bdstr)));
|
||||
UNUSED(bdstr);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -795,18 +797,20 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
param.conn_stat.state = btc_hf_client_cb.state;
|
||||
param.conn_stat.peer_feat = 0;
|
||||
param.conn_stat.chld_feat = 0;
|
||||
|
||||
|
||||
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
|
||||
if (btc_hf_client_cb.state == ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED)
|
||||
bdsetany(btc_hf_client_cb.connected_bda.address);
|
||||
|
||||
if (p_data->open.status != BTA_HF_CLIENT_SUCCESS)
|
||||
if (btc_hf_client_cb.state == ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED) {
|
||||
bdsetany(btc_hf_client_cb.connected_bda.address);
|
||||
}
|
||||
|
||||
if (p_data->open.status != BTA_HF_CLIENT_SUCCESS) {
|
||||
btc_queue_advance();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -820,13 +824,13 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
param.conn_stat.state = btc_hf_client_cb.state;
|
||||
param.conn_stat.peer_feat = btc_hf_client_cb.peer_feat;
|
||||
param.conn_stat.chld_feat = btc_hf_client_cb.chld_feat;
|
||||
|
||||
|
||||
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
|
||||
|
||||
/* Inform the application about in-band ringtone */
|
||||
if (btc_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_INBAND)
|
||||
{
|
||||
@@ -839,7 +843,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
|
||||
btc_queue_advance();
|
||||
break;
|
||||
|
||||
|
||||
case BTA_HF_CLIENT_CLOSE_EVT:
|
||||
btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
|
||||
do {
|
||||
@@ -847,7 +851,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
param.conn_stat.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
|
||||
param.conn_stat.peer_feat = 0;
|
||||
param.conn_stat.chld_feat = 0;
|
||||
|
||||
|
||||
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
|
||||
@@ -980,7 +984,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
memset(¶m, 0, sizeof(esp_hf_client_cb_param_t));
|
||||
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED;
|
||||
memcpy(param.audio_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
sizeof(esp_bd_addr_t));
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
break;
|
||||
@@ -989,7 +993,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
memset(¶m, 0, sizeof(esp_hf_client_cb_param_t));
|
||||
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC;
|
||||
memcpy(param.audio_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
sizeof(esp_bd_addr_t));
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
break;
|
||||
|
||||
@@ -315,6 +315,7 @@ static void btc_spp_init(btc_spp_args_t *arg)
|
||||
{
|
||||
if (osi_mutex_new(&spp_local_param.spp_slot_mutex) != 0) {
|
||||
BTC_TRACE_ERROR("%s osi_mutex_new failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
spp_local_param.spp_mode = arg->init.mode;
|
||||
spp_local_param.spp_slot_id = 0;
|
||||
@@ -323,6 +324,10 @@ static void btc_spp_init(btc_spp_args_t *arg)
|
||||
|
||||
static void btc_spp_uninit(void)
|
||||
{
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
return;
|
||||
}
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) {
|
||||
|
||||
@@ -143,11 +143,35 @@
|
||||
#define SMP_SLAVE_CON_PARAMS_UPD_ENABLE FALSE
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL FALSE
|
||||
#else
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
#endif /* CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED */
|
||||
|
||||
#ifndef CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL_NUM 100
|
||||
#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
|
||||
#define BLE_ADV_REPORT_DISCARD_THRSHOLD CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
#endif /* CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD */
|
||||
|
||||
#if (CONFIG_BT_ACL_CONNECTIONS)
|
||||
#define MAX_ACL_CONNECTIONS CONFIG_BT_ACL_CONNECTIONS
|
||||
#define GATT_MAX_PHY_CHANNEL CONFIG_BT_ACL_CONNECTIONS
|
||||
#endif /* CONFIG_BT_ACL_CONNECTIONS */
|
||||
|
||||
#if(CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT)
|
||||
#define BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT
|
||||
#else
|
||||
#define BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT 30
|
||||
#endif
|
||||
|
||||
//------------------Added from bdroid_buildcfg.h---------------------
|
||||
#ifndef L2CAP_EXTFEA_SUPPORTED_MASK
|
||||
#define L2CAP_EXTFEA_SUPPORTED_MASK (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS)
|
||||
|
||||
@@ -100,7 +100,11 @@ static void start_up(void)
|
||||
response = AWAIT_COMMAND(packet_factory->make_set_c2h_flow_control(HCI_HOST_FLOW_CTRL_ACL_ON));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
// Enable adv flow control
|
||||
response = AWAIT_COMMAND(packet_factory->make_set_adv_report_flow_control(HCI_HOST_FLOW_CTRL_ADV_REPORT_ON, (uint16_t)BLE_ADV_REPORT_FLOW_CONTROL_NUM, (uint16_t)BLE_ADV_REPORT_DISCARD_THRSHOLD));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
#endif
|
||||
// Tell the controller about our buffer sizes and buffer counts next
|
||||
// TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10?
|
||||
response = AWAIT_COMMAND(
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#define CASE_RETURN_STR(const) case const: return #const;
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
static const char *interop_feature_string(const interop_feature_t feature)
|
||||
{
|
||||
switch (feature) {
|
||||
@@ -36,7 +37,7 @@ static const char *interop_feature_string(const interop_feature_t feature)
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
#endif // (!CONFIG_BT_STACK_NO_LOG)
|
||||
// Interface functions
|
||||
bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr)
|
||||
{
|
||||
@@ -47,7 +48,9 @@ bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr)
|
||||
for (size_t i = 0; i != db_size; ++i) {
|
||||
if (feature == interop_database[i].feature &&
|
||||
memcmp(addr, &interop_database[i].addr, interop_database[i].len) == 0) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
char bdstr[20] = {0};
|
||||
#endif
|
||||
LOG_WARN("%s() Device %s is a match for interop workaround %s", __func__,
|
||||
bdaddr_to_string(addr, bdstr, sizeof(bdstr)), interop_feature_string(feature));
|
||||
return true;
|
||||
|
||||
@@ -145,9 +145,10 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
|
||||
for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) {
|
||||
if (*(ps16GenBufPtr) < s32BitSlice + 2) {
|
||||
*(ps16GenArrPtr) = 0;
|
||||
} else
|
||||
} else {
|
||||
*(ps16GenArrPtr) = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ?
|
||||
(SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16;
|
||||
}
|
||||
|
||||
ps16GenBufPtr++;
|
||||
ps16GenArrPtr++;
|
||||
|
||||
@@ -132,9 +132,10 @@ void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams)
|
||||
for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) {
|
||||
if (*ps16GenBufPtr < s32BitSlice + 2) {
|
||||
*ps16GenArrPtr = 0;
|
||||
} else
|
||||
} else {
|
||||
*ps16GenArrPtr = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ?
|
||||
(SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16;
|
||||
}
|
||||
ps16GenBufPtr++;
|
||||
ps16GenArrPtr++;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ static const uint16_t outbound_event_types[] = {
|
||||
typedef struct {
|
||||
size_t buffer_size;
|
||||
fixed_queue_t *rx_q;
|
||||
uint16_t adv_free_num;
|
||||
} hci_hal_env_t;
|
||||
|
||||
|
||||
@@ -81,6 +82,7 @@ static void hci_hal_env_init(
|
||||
assert(max_buffer_count > 0);
|
||||
|
||||
hci_hal_env.buffer_size = buffer_size;
|
||||
hci_hal_env.adv_free_num = 0;
|
||||
|
||||
hci_hal_env.rx_q = fixed_queue_new(max_buffer_count);
|
||||
if (hci_hal_env.rx_q) {
|
||||
@@ -102,8 +104,11 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
|
||||
{
|
||||
assert(upper_callbacks != NULL);
|
||||
callbacks = upper_callbacks;
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, BLE_ADV_REPORT_FLOW_CONTROL_NUM + L2CAP_HOST_FC_ACL_BUFS + QUEUE_SIZE_MAX); // adv flow control num + ACL flow control num + hci cmd numeber
|
||||
#else
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, QUEUE_SIZE_MAX);
|
||||
#endif
|
||||
|
||||
xHciH4Queue = xQueueCreate(HCI_H4_QUEUE_LEN, sizeof(BtTaskEvt_t));
|
||||
xTaskCreatePinnedToCore(hci_hal_h4_rx_handler, HCI_H4_TASK_NAME, HCI_H4_TASK_STACK_SIZE, NULL, HCI_H4_TASK_PRIO, &xHciH4TaskHandle, HCI_H4_TASK_PINNED_TO_CORE);
|
||||
@@ -184,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)
|
||||
@@ -223,12 +228,37 @@ static void hci_packet_complete(BT_HDR *packet){
|
||||
bool host_recv_adv_packet(BT_HDR *packet)
|
||||
{
|
||||
assert(packet);
|
||||
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT && packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT) {
|
||||
return true;
|
||||
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT) {
|
||||
if(packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
|| packet->data[3] == HCI_BLE_ADV_DISCARD_REPORT_EVT
|
||||
#endif
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
static void hci_update_adv_report_flow_control(BT_HDR *packet)
|
||||
{
|
||||
// this is adv packet
|
||||
if(host_recv_adv_packet(packet)) {
|
||||
// update adv free number
|
||||
hci_hal_env.adv_free_num ++;
|
||||
if (esp_vhci_host_check_send_available()){
|
||||
// send hci cmd
|
||||
btsnd_hcic_ble_update_adv_report_flow_control(hci_hal_env.adv_free_num);
|
||||
hci_hal_env.adv_free_num = 0;
|
||||
} else {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
{
|
||||
uint8_t type, hdr_size;
|
||||
@@ -247,8 +277,10 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
packet->offset++;
|
||||
packet->len--;
|
||||
if (type == HCI_BLE_EVENT) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
uint8_t len = 0;
|
||||
STREAM_TO_UINT8(len, stream);
|
||||
#endif
|
||||
HCI_TRACE_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n",
|
||||
packet->len, len);
|
||||
osi_free(packet);
|
||||
@@ -282,6 +314,11 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
osi_free(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
hci_update_adv_report_flow_control(packet);
|
||||
#endif
|
||||
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
if(BTU_check_queue_is_congest() && host_recv_adv_packet(packet)) {
|
||||
HCI_TRACE_ERROR("BtuQueue is congested");
|
||||
@@ -289,7 +326,6 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
|
||||
callbacks->packet_ready(packet);
|
||||
}
|
||||
|
||||
@@ -317,7 +317,11 @@ static void event_command_ready(fixed_queue_t *queue)
|
||||
|
||||
wait_entry = fixed_queue_dequeue(queue);
|
||||
|
||||
if(wait_entry->opcode == HCI_HOST_NUM_PACKETS_DONE){
|
||||
if(wait_entry->opcode == HCI_HOST_NUM_PACKETS_DONE
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
|| wait_entry->opcode == HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL
|
||||
#endif
|
||||
){
|
||||
packet_fragmenter->fragment_and_dispatch(wait_entry->command);
|
||||
osi_free(wait_entry->command);
|
||||
osi_free(wait_entry);
|
||||
|
||||
@@ -53,6 +53,18 @@ static BT_HDR *make_set_c2h_flow_control(uint8_t enable)
|
||||
return packet;
|
||||
}
|
||||
|
||||
static BT_HDR *make_set_adv_report_flow_control(uint8_t enable, uint16_t num, uint16_t lost_threshold)
|
||||
{
|
||||
uint8_t *stream;
|
||||
const uint8_t parameter_size = 1 + 2 + 2;
|
||||
BT_HDR *packet = make_command(HCI_VENDOR_BLE_SET_ADV_FLOW_CONTROL, parameter_size, &stream);
|
||||
|
||||
UINT8_TO_STREAM(stream, enable);
|
||||
UINT16_TO_STREAM(stream, num);
|
||||
UINT16_TO_STREAM(stream, lost_threshold);
|
||||
return packet;
|
||||
}
|
||||
|
||||
static BT_HDR *make_host_buffer_size(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count)
|
||||
{
|
||||
uint8_t *stream;
|
||||
@@ -239,6 +251,7 @@ static const hci_packet_factory_t interface = {
|
||||
make_reset,
|
||||
make_read_buffer_size,
|
||||
make_set_c2h_flow_control,
|
||||
make_set_adv_report_flow_control,
|
||||
make_host_buffer_size,
|
||||
make_read_local_version_info,
|
||||
make_read_bd_addr,
|
||||
|
||||
@@ -26,6 +26,7 @@ typedef struct {
|
||||
BT_HDR *(*make_reset)(void);
|
||||
BT_HDR *(*make_read_buffer_size)(void);
|
||||
BT_HDR *(*make_set_c2h_flow_control)(uint8_t enable);
|
||||
BT_HDR *(*make_set_adv_report_flow_control)(uint8_t enable, uint16_t num, uint16_t lost_threshold);
|
||||
BT_HDR *(*make_host_buffer_size)(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count);
|
||||
BT_HDR *(*make_read_local_version_info)(void);
|
||||
BT_HDR *(*make_read_bd_addr)(void);
|
||||
|
||||
@@ -61,8 +61,9 @@ bool list_contains(const list_t *list, const void *data)
|
||||
assert(data != NULL);
|
||||
|
||||
for (const list_node_t *node = list_begin(list); node != list_end(list); node = list_next(node)) {
|
||||
if (list_node(node) == data)
|
||||
if (list_node(node) == data) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -201,8 +202,9 @@ list_node_t *list_foreach(const list_t *list, list_iter_cb callback, void *conte
|
||||
|
||||
for (list_node_t *node = list->head; node; ) {
|
||||
list_node_t *next = node->next;
|
||||
if (!callback(node->data, context))
|
||||
if (!callback(node->data, context)) {
|
||||
return node;
|
||||
}
|
||||
node = next;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -605,8 +605,9 @@ void avct_lcb_free_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
|
||||
{
|
||||
UNUSED(p_lcb);
|
||||
|
||||
if (p_data == NULL)
|
||||
if (p_data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
osi_free(p_data->p_buf);
|
||||
p_data->p_buf = NULL;
|
||||
|
||||
@@ -345,8 +345,10 @@ UINT8 *avdt_scb_hdl_report(tAVDT_SCB *p_scb, UINT8 *p, UINT16 len)
|
||||
p += 2;
|
||||
BE_STREAM_TO_UINT32(ssrc, p);
|
||||
|
||||
UNUSED(ssrc);
|
||||
UNUSED(o_p);
|
||||
UNUSED(o_v);
|
||||
UNUSED(o_cc);
|
||||
|
||||
switch (pt) {
|
||||
case AVDT_RTCP_PT_SR: /* the packet type - SR (Sender Report) */
|
||||
@@ -627,15 +629,19 @@ void avdt_scb_hdl_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
|
||||
avdt_scb_hdl_pkt_frag(p_scb, p_data);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if AVDT_REPORTING == TRUE
|
||||
if (p_data->p_pkt->layer_specific == AVDT_CHAN_REPORT) {
|
||||
p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset;
|
||||
avdt_scb_hdl_report(p_scb, p, p_data->p_pkt->len);
|
||||
osi_free(p_data->p_pkt);
|
||||
p_data->p_pkt = NULL;
|
||||
osi_free(p_data->p_pkt);
|
||||
p_data->p_pkt = NULL;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
avdt_scb_hdl_pkt_no_frag(p_scb, p_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1303,7 +1309,9 @@ void avdt_scb_hdl_write_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
if (fixed_queue_is_empty(p_scb->frag_q))
|
||||
#endif
|
||||
{
|
||||
avdt_scb_hdl_write_req_no_frag(p_scb, p_data);
|
||||
}
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
else {
|
||||
avdt_scb_hdl_write_req_frag(p_scb, p_data);
|
||||
|
||||
@@ -120,10 +120,11 @@ BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value)
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
if (!result)
|
||||
if (!result) {
|
||||
AVRC_TRACE_ERROR(
|
||||
"avrc_is_valid_player_attrib_value() found not matching attrib(x%x)-value(x%x) pair!",
|
||||
attrib, value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -261,9 +261,10 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
|
||||
#if BLE_INCLUDED == TRUE
|
||||
p->transport = transport;
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
if (transport == BT_TRANSPORT_LE)
|
||||
if (transport == BT_TRANSPORT_LE) {
|
||||
btm_ble_refresh_local_resolvable_private_addr(bda,
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr);
|
||||
}
|
||||
#else
|
||||
p->conn_addr_type = BLE_ADDR_PUBLIC;
|
||||
memcpy(p->conn_addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN);
|
||||
@@ -2495,15 +2496,17 @@ void btm_acl_chk_peer_pkt_type_support (tACL_CONN *p, UINT16 *p_pkt_type)
|
||||
}
|
||||
|
||||
/* 2 and 3 MPS support? */
|
||||
if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
|
||||
if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) {
|
||||
/* Not supported. Add 'not_supported' mask for all 2MPS packet types */
|
||||
*p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
|
||||
BTM_ACL_PKT_TYPES_MASK_NO_2_DH5);
|
||||
}
|
||||
|
||||
if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
|
||||
if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) {
|
||||
/* Not supported. Add 'not_supported' mask for all 3MPS packet types */
|
||||
*p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 +
|
||||
BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
|
||||
}
|
||||
|
||||
/* EDR 3 and 5 slot support? */
|
||||
if (HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])
|
||||
|
||||
@@ -66,7 +66,7 @@ extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr);
|
||||
** bd_name - Name of the peer device. NULL if unknown.
|
||||
** dev_type - Remote device's device type.
|
||||
** addr_type - LE device address type.
|
||||
** auth_mode - auth mode
|
||||
** auth_mode - auth mode
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
@@ -887,8 +887,9 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
return BTM_SEC_OK;
|
||||
}
|
||||
|
||||
if (security_required & BTM_SEC_OUT_MITM)
|
||||
if (security_required & BTM_SEC_OUT_MITM) {
|
||||
auth_req |= BTM_LE_AUTH_REQ_MITM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -898,8 +899,9 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
return BTM_SEC_OK;
|
||||
}
|
||||
|
||||
if (security_required & BTM_SEC_IN_MITM)
|
||||
if (security_required & BTM_SEC_IN_MITM) {
|
||||
auth_req |= BTM_LE_AUTH_REQ_MITM;
|
||||
}
|
||||
}
|
||||
|
||||
tBTM_BLE_SEC_REQ_ACT ble_sec_act = BTM_BLE_SEC_REQ_ACT_NONE;
|
||||
@@ -907,11 +909,13 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
|
||||
BTM_TRACE_DEBUG ("%s ble_sec_act %d", __func__ , ble_sec_act);
|
||||
|
||||
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_DISCARD)
|
||||
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_DISCARD) {
|
||||
return BTM_SEC_ENC_PENDING;
|
||||
}
|
||||
|
||||
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_NONE)
|
||||
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_NONE) {
|
||||
return BTM_SEC_OK;
|
||||
}
|
||||
|
||||
UINT8 sec_flag = 0;
|
||||
BTM_GetSecurityFlagsByTransport(bdaddr, &sec_flag, BT_TRANSPORT_LE);
|
||||
@@ -920,11 +924,13 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
BOOLEAN is_key_mitm = FALSE;
|
||||
if (sec_flag & (BTM_SEC_FLAG_ENCRYPTED| BTM_SEC_FLAG_LKEY_KNOWN))
|
||||
{
|
||||
if (sec_flag & BTM_SEC_FLAG_ENCRYPTED)
|
||||
if (sec_flag & BTM_SEC_FLAG_ENCRYPTED) {
|
||||
is_link_encrypted = TRUE;
|
||||
}
|
||||
|
||||
if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED)
|
||||
if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED) {
|
||||
is_key_mitm = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (auth_req & BTM_LE_AUTH_REQ_MITM)
|
||||
@@ -933,16 +939,18 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
{
|
||||
return BTM_SEC_ENCRYPT_MITM;
|
||||
} else {
|
||||
if (is_link_encrypted)
|
||||
if (is_link_encrypted) {
|
||||
return BTM_SEC_OK;
|
||||
else
|
||||
} else {
|
||||
return BTM_SEC_ENCRYPT;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (is_link_encrypted)
|
||||
if (is_link_encrypted) {
|
||||
return BTM_SEC_OK;
|
||||
else
|
||||
} else {
|
||||
return BTM_SEC_ENCRYPT_NO_MITM;
|
||||
}
|
||||
}
|
||||
|
||||
return BTM_SEC_OK;
|
||||
@@ -1012,8 +1020,9 @@ BOOLEAN btm_ble_start_sec_check(BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originat
|
||||
break;
|
||||
}
|
||||
|
||||
if (ble_sec_act == BTM_BLE_SEC_NONE)
|
||||
if (ble_sec_act == BTM_BLE_SEC_NONE) {
|
||||
return status;
|
||||
}
|
||||
|
||||
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_LE);
|
||||
p_lcb->sec_act = sec_act;
|
||||
@@ -1997,9 +2006,18 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
|
||||
btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
btm_ble_update_mode_operation(role, bda, status);
|
||||
BOOLEAN bg_con = btm_ble_update_mode_operation(role, bda, status);
|
||||
if (status != HCI_SUCCESS && !bg_con) {
|
||||
// notify connection failed
|
||||
l2c_link_hci_disc_comp (handle, status);
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/* Notify security manager */
|
||||
btm_sec_disconnected (handle, status);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -312,9 +312,10 @@ void btm_ble_scan_pf_cmpl_cback(tBTM_VSC_CMPL *p_params)
|
||||
if (HCI_SUCCESS == status) {
|
||||
if (memcmp(&btm_ble_adv_filt_cb.cur_filter_target.bda, &na_bda, BD_ADDR_LEN) == 0) {
|
||||
btm_ble_cs_update_pf_counter(action, cond_type, NULL, num_avail);
|
||||
} else
|
||||
} else {
|
||||
btm_ble_cs_update_pf_counter(action, cond_type,
|
||||
&btm_ble_adv_filt_cb.cur_filter_target, num_avail);
|
||||
}
|
||||
}
|
||||
|
||||
/* send ADV PF operation complete */
|
||||
@@ -855,9 +856,10 @@ tBTM_STATUS btm_ble_update_uuid_filter(tBTM_BLE_SCAN_COND_OP action,
|
||||
len,
|
||||
param,
|
||||
btm_ble_scan_pf_cmpl_cback)) != BTM_NO_RESOURCES) {
|
||||
if (p_uuid_cond && p_uuid_cond->p_target_addr)
|
||||
if (p_uuid_cond && p_uuid_cond->p_target_addr) {
|
||||
memcpy(&btm_ble_adv_filt_cb.cur_filter_target, p_uuid_cond->p_target_addr,
|
||||
sizeof(tBLE_BD_ADDR));
|
||||
}
|
||||
else {
|
||||
memset(&btm_ble_adv_filt_cb.cur_filter_target, 0, sizeof(tBLE_BD_ADDR));
|
||||
}
|
||||
@@ -914,15 +916,17 @@ tBTM_STATUS btm_ble_clear_scan_pf_filter(tBTM_BLE_SCAN_COND_OP action,
|
||||
/* clear manufactuer 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)
|
||||
if (BTM_CMD_STARTED == st) {
|
||||
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_MANU_DATA, cb_evt,
|
||||
ref_value, NULL, NULL);
|
||||
}
|
||||
|
||||
/* clear local name filter */
|
||||
st = btm_ble_update_pf_local_name(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL);
|
||||
if (BTM_CMD_STARTED == st)
|
||||
if (BTM_CMD_STARTED == st) {
|
||||
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_LOCAL_NAME, cb_evt,
|
||||
ref_value, NULL, NULL);
|
||||
}
|
||||
|
||||
/* update the counter for service data */
|
||||
st = btm_ble_update_srvc_data_change(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL);
|
||||
@@ -936,16 +940,18 @@ tBTM_STATUS btm_ble_clear_scan_pf_filter(tBTM_BLE_SCAN_COND_OP action,
|
||||
|
||||
st = btm_ble_update_uuid_filter(BTM_BLE_SCAN_COND_CLEAR, filt_index,
|
||||
BTM_BLE_PF_SRVC_SOL_UUID, NULL, cb_evt, ref_value);
|
||||
if (BTM_CMD_STARTED == st)
|
||||
if (BTM_CMD_STARTED == st) {
|
||||
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_SOL_UUID, cb_evt,
|
||||
ref_value, NULL, NULL);
|
||||
}
|
||||
|
||||
/* clear service data filter */
|
||||
st = btm_ble_update_pf_manu_data(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL,
|
||||
BTM_BLE_PF_SRVC_DATA_PATTERN, cb_evt, ref_value);
|
||||
if (BTM_CMD_STARTED == st)
|
||||
if (BTM_CMD_STARTED == st) {
|
||||
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_SRVC_DATA, cb_evt,
|
||||
ref_value, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* select feature based on control block settings */
|
||||
@@ -1053,9 +1059,10 @@ tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, tBTM_BLE_PF_FILT_INDEX filt_i
|
||||
|
||||
if (cmn_ble_vsc_cb.version_supported == BTM_VSC_CHIP_CAPABILITY_L_VERSION) {
|
||||
len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN;
|
||||
} else
|
||||
} else {
|
||||
len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN +
|
||||
BTM_BLE_ADV_FILT_TRACK_NUM;
|
||||
}
|
||||
|
||||
if ((st = BTM_VendorSpecificCommand (HCI_BLE_ADV_FILTER_OCF,
|
||||
(UINT8)len,
|
||||
|
||||
@@ -427,9 +427,10 @@ void btm_ble_batchscan_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
|
||||
if (0 == num_records) {
|
||||
btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records,
|
||||
&p_data, &data_len);
|
||||
if (NULL != ble_batchscan_cb.p_scan_rep_cback)
|
||||
if (NULL != ble_batchscan_cb.p_scan_rep_cback) {
|
||||
ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format, num_records,
|
||||
data_len, p_data, status);
|
||||
}
|
||||
} else {
|
||||
if ((len - 4) > 0) {
|
||||
btm_ble_batchscan_enq_rep_data(report_format, num_records, p, len - 4);
|
||||
@@ -439,9 +440,10 @@ void btm_ble_batchscan_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
|
||||
btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records,
|
||||
&p_data, &data_len);
|
||||
/* Send whatever is available, in case of a command failure */
|
||||
if (NULL != ble_batchscan_cb.p_scan_rep_cback && NULL != p_data)
|
||||
if (NULL != ble_batchscan_cb.p_scan_rep_cback && NULL != p_data) {
|
||||
ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format,
|
||||
num_records, data_len, p_data, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,10 @@ void btm_ble_cont_energy_cmpl_cback (tBTM_VSC_CMPL *p_params)
|
||||
BTM_TRACE_DEBUG("energy_info status=%d,tx_t=%u, rx_t=%u, ener_used=%u, idle_t=%u",
|
||||
status, total_tx_time, total_rx_time, total_energy_used, total_idle_time);
|
||||
|
||||
if (NULL != ble_energy_info_cb.p_ener_cback)
|
||||
if (NULL != ble_energy_info_cb.p_ener_cback) {
|
||||
ble_energy_info_cb.p_ener_cback(total_tx_time, total_rx_time, total_idle_time,
|
||||
total_energy_used, status);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ void btm_sem_init(void)
|
||||
osi_sem_new(&adv_data_sem, 1, 0);
|
||||
osi_sem_new(&adv_param_sem, 1, 0);
|
||||
osi_sem_new(&scan_enable_sem, 1, 0);
|
||||
osi_sem_new(&scan_param_sem, 1, 0);
|
||||
osi_sem_new(&scan_param_sem, 1, 0);
|
||||
}
|
||||
|
||||
void btm_sem_free(void)
|
||||
@@ -334,9 +334,10 @@ void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy)
|
||||
/* if adv active, stop and restart */
|
||||
btm_ble_stop_adv ();
|
||||
|
||||
if (p_cb->connectable_mode & BTM_BLE_CONNECTABLE)
|
||||
if (p_cb->connectable_mode & BTM_BLE_CONNECTABLE) {
|
||||
p_cb->evt_type = btm_set_conn_mode_adv_init_addr(p_cb, p_addr_ptr, &init_addr_type,
|
||||
&p_cb->adv_addr_type);
|
||||
}
|
||||
|
||||
btsnd_hcic_ble_write_adv_params ((UINT16)(p_cb->adv_interval_min ? p_cb->adv_interval_min :
|
||||
BTM_BLE_GAP_ADV_SLOW_INT),
|
||||
@@ -493,7 +494,7 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
|
||||
tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb)
|
||||
tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb, tBTM_INQ_DIS_CB *p_discard_cb)
|
||||
{
|
||||
tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var;
|
||||
tBTM_STATUS status = BTM_WRONG_MODE;
|
||||
@@ -511,6 +512,7 @@ tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
|
||||
|
||||
btm_cb.ble_ctr_cb.p_scan_results_cb = p_results_cb;
|
||||
btm_cb.ble_ctr_cb.p_scan_cmpl_cb = p_cmpl_cb;
|
||||
btm_cb.ble_ctr_cb.p_obs_discard_cb = p_discard_cb;
|
||||
status = BTM_CMD_STARTED;
|
||||
|
||||
/* scan is not started */
|
||||
@@ -755,6 +757,7 @@ extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_c
|
||||
|
||||
void BTM_VendorHciEchoCmdCallback(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
if (!p1) {
|
||||
return;
|
||||
}
|
||||
@@ -762,6 +765,7 @@ void BTM_VendorHciEchoCmdCallback(tBTM_VSC_CMPL *p1)
|
||||
uint8_t status, echo;
|
||||
STREAM_TO_UINT8 (status, p);
|
||||
STREAM_TO_UINT8 (echo, p);
|
||||
#endif
|
||||
BTM_TRACE_DEBUG("%s status 0x%x echo 0x%x", __func__, status, echo);
|
||||
}
|
||||
|
||||
@@ -780,7 +784,7 @@ void BTM_VendorHciEchoCmdTest(uint8_t echo)
|
||||
{
|
||||
BTM_VendorSpecificCommand (HCI_VENDOR_COMMON_ECHO_CMD_OPCODE,
|
||||
1,
|
||||
&echo,
|
||||
&echo,
|
||||
BTM_VendorHciEchoCmdCallback);
|
||||
}
|
||||
|
||||
@@ -1296,7 +1300,7 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
}
|
||||
|
||||
if(own_bda_type == BLE_ADDR_RANDOM) {
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) {
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) {
|
||||
//close privacy
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
|
||||
@@ -1305,9 +1309,9 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
#endif
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN);
|
||||
// set address to controller
|
||||
// set address to controller
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr);
|
||||
|
||||
|
||||
} else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
|
||||
@@ -1317,7 +1321,7 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
if(adv_cb) {
|
||||
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
|
||||
}
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
} else if(own_bda_type == BLE_ADDR_PUBLIC_ID || own_bda_type == BLE_ADDR_RANDOM_ID) {
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
|
||||
@@ -1332,7 +1336,7 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
if(adv_cb) {
|
||||
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
|
||||
}
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
#endif
|
||||
if(own_bda_type == BLE_ADDR_PUBLIC_ID) {
|
||||
@@ -1349,17 +1353,17 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
if(adv_cb) {
|
||||
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
|
||||
}
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
}
|
||||
|
||||
if (!BTM_BLE_ISVALID_PARAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
|
||||
!BTM_BLE_ISVALID_PARAM(adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) {
|
||||
BTM_TRACE_ERROR ("adv_int_min or adv_int_max is invalid\n");
|
||||
BTM_TRACE_ERROR ("adv_int_min or adv_int_max is invalid\n");
|
||||
if(adv_cb) {
|
||||
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
|
||||
}
|
||||
@@ -1390,7 +1394,7 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
}
|
||||
|
||||
BTM_TRACE_EVENT ("update params for an active adv\n");
|
||||
|
||||
|
||||
tBTM_STATUS status = BTM_SUCCESS;
|
||||
/* update adv params */
|
||||
if (btsnd_hcic_ble_write_adv_params (adv_int_min,
|
||||
@@ -1418,7 +1422,7 @@ tBTM_STATUS BTM_BleStartAdv(void)
|
||||
}
|
||||
|
||||
btm_ble_stop_adv();
|
||||
|
||||
|
||||
status = btm_ble_start_adv();
|
||||
|
||||
return status;
|
||||
@@ -1537,35 +1541,35 @@ tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
BTM_BleConfigPrivacy(FALSE, NULL);
|
||||
}
|
||||
#endif
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN);
|
||||
// set address to controller
|
||||
// set address to controller
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr);
|
||||
|
||||
|
||||
} else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr);
|
||||
}else {
|
||||
BTM_TRACE_ERROR ("No random address yet, please set random address and try\n");
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
} else if(addr_type_own == BLE_ADDR_PUBLIC_ID || addr_type_own == BLE_ADDR_RANDOM_ID) {
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
|
||||
addr_type_own = BLE_ADDR_RANDOM;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr);
|
||||
} else {
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
if(btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
|
||||
BTM_TRACE_ERROR ("Error state\n");
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
#endif
|
||||
if(addr_type_own == BLE_ADDR_PUBLIC_ID) {
|
||||
addr_type_own = BLE_ADDR_PUBLIC;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
} else {
|
||||
//own_bda_type == BLE_ADDR_RANDOM_ID
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) {
|
||||
@@ -1575,12 +1579,12 @@ tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr);
|
||||
} else {
|
||||
BTM_TRACE_ERROR ("No RPA and no random address yet, please set RPA or random address and try\n");
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
}
|
||||
|
||||
/* If not supporting extended scan support, use the older range for checking */
|
||||
@@ -1709,7 +1713,7 @@ tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_le
|
||||
** Returns status
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info,
|
||||
tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info,
|
||||
tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb)
|
||||
{
|
||||
tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb;
|
||||
@@ -1728,11 +1732,31 @@ tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type
|
||||
device_info_array[2] = (type >> 8) & 0xff;
|
||||
device_info_array[3] = (type >> 16) & 0xff;
|
||||
device_info_array[4] = (type >> 24) & 0xff;
|
||||
if(type == BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR) {
|
||||
bt_rcopy(&device_info_array[5], device_info, BD_ADDR_LEN);
|
||||
} else {
|
||||
memcpy(&device_info_array[5], device_info, 4);
|
||||
switch (type)
|
||||
{
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR:
|
||||
bt_rcopy(&device_info_array[5], device_info, BD_ADDR_LEN);
|
||||
break;
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID:
|
||||
memcpy(&device_info_array[5], device_info, 4);
|
||||
break;
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE:
|
||||
//do nothing
|
||||
break;
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV:
|
||||
//do nothing
|
||||
break;
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV:
|
||||
//do nothing
|
||||
break;
|
||||
default:
|
||||
//do nothing
|
||||
break;
|
||||
}
|
||||
if(status == BTM_ILLEGAL_VALUE) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = BTM_VendorSpecificCommand(HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST, 1 + 4 + BD_ADDR_LEN, device_info_array, NULL);
|
||||
if(status == BTM_CMD_STARTED) {
|
||||
status = BTM_SUCCESS;
|
||||
@@ -1862,8 +1886,9 @@ tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len)
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr)
|
||||
{
|
||||
if (rand_addr == NULL)
|
||||
if (rand_addr == NULL) {
|
||||
return BTM_SET_STATIC_RAND_ADDR_FAIL;
|
||||
}
|
||||
|
||||
if (!(btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_SCAN || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_ADV || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_IDLE)) {
|
||||
BTM_TRACE_ERROR("Advertising or scaning now, can't set randaddress %d", btm_cb.ble_ctr_cb.inq_var.state);
|
||||
@@ -1930,7 +1955,7 @@ BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type)
|
||||
memset(addr, 0, BD_ADDR_LEN);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -2913,7 +2938,7 @@ void btm_ble_cache_adv_data(BD_ADDR bda, tBTM_INQ_RESULTS *p_cur, UINT8 data_len
|
||||
memset(p_le_inq_cb->adv_data_cache, 0, BTM_BLE_CACHE_ADV_DATA_MAX);
|
||||
p_cur->adv_data_len = 0;
|
||||
p_cur->scan_rsp_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Clear the adv cache if the addresses are not equal
|
||||
if(memcmp(bda, p_le_inq_cb->adv_addr, BD_ADDR_LEN) != 0) {
|
||||
@@ -3367,7 +3392,7 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
|
||||
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
|
||||
temp_addr_type = addr_type;
|
||||
memcpy(temp_bda, bda, BD_ADDR_LEN);
|
||||
|
||||
|
||||
/* map address to security record */
|
||||
match = btm_identity_addr_to_random_pseudo(bda, &addr_type, FALSE);
|
||||
|
||||
@@ -3490,13 +3515,13 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
|
||||
0x02 Scannable undirected advertising (ADV_SCAN_IND)
|
||||
0x03 Non connectable undirected advertising (ADV_NONCONN_IND)
|
||||
0x04 Scan Response (SCAN_RSP)
|
||||
0x05-0xFF Reserved for future use
|
||||
0x05-0xFF Reserved for future use
|
||||
*/
|
||||
//if scan duplicate is enabled, the adv packet without scan response is allowed to report to higher layer
|
||||
if(p_le_inq_cb->scan_duplicate_filter == BTM_BLE_SCAN_DUPLICATE_ENABLE) {
|
||||
/*
|
||||
Bluedroid will put the advertising packet and scan response into a packet and send it to the higher layer.
|
||||
If two advertising packets are not with the same address, or can't be combined into a packet, then the first advertising
|
||||
If two advertising packets are not with the same address, or can't be combined into a packet, then the first advertising
|
||||
packet will be discarded. So we added the following judgment:
|
||||
1. For different addresses, send the last advertising packet to higher layer
|
||||
2. For same address and same advertising type (not scan response), send the last advertising packet to higher layer
|
||||
@@ -3602,6 +3627,17 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
|
||||
}
|
||||
}
|
||||
|
||||
void btm_ble_process_adv_discard_evt(UINT8 *p)
|
||||
{
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
uint32_t num_dis = 0;
|
||||
STREAM_TO_UINT32 (num_dis, p);
|
||||
tBTM_INQ_DIS_CB *p_obs_discard_cb = btm_cb.ble_ctr_cb.p_obs_discard_cb;
|
||||
if(p_obs_discard_cb) {
|
||||
(p_obs_discard_cb)(num_dis);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_start_scan
|
||||
@@ -3845,7 +3881,7 @@ tBTM_STATUS btm_ble_start_adv(void)
|
||||
btm_execute_wl_dev_operation();
|
||||
btm_cb.ble_ctr_cb.wl_state |= BTM_BLE_WL_ADV;
|
||||
}
|
||||
/* The complete event comes up immediately after the 'btsnd_hcic_ble_set_adv_enable' being called in dual core,
|
||||
/* The complete event comes up immediately after the 'btsnd_hcic_ble_set_adv_enable' being called in dual core,
|
||||
this causes the 'adv_mode' and 'state' not be set yet, so we set the state first */
|
||||
tBTM_BLE_GAP_STATE temp_state = p_cb->state;
|
||||
UINT8 adv_mode = p_cb->adv_mode;
|
||||
@@ -4139,7 +4175,7 @@ BOOLEAN btm_ble_clear_topology_mask (tBTM_BLE_STATE_MASK request_state_mask)
|
||||
**
|
||||
** Description Get BLE topology bit mask
|
||||
**
|
||||
** Returns state mask.
|
||||
** Returns state mask.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_BLE_STATE_MASK btm_ble_get_topology_mask (void)
|
||||
@@ -4193,8 +4229,9 @@ void btm_ble_update_link_topology_mask(UINT8 link_role, BOOLEAN increase)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bd_addr, UINT8 status)
|
||||
BOOLEAN btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bd_addr, UINT8 status)
|
||||
{
|
||||
BOOLEAN bg_con = FALSE;
|
||||
if (status == HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT) {
|
||||
btm_cb.ble_ctr_cb.inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
|
||||
/* make device fall back into undirected adv mode by default */
|
||||
@@ -4213,8 +4250,10 @@ void btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bd_addr, UINT8 statu
|
||||
now in order */
|
||||
if (btm_ble_get_conn_st() == BLE_CONN_IDLE && status != HCI_ERR_HOST_REJECT_RESOURCES &&
|
||||
!btm_send_pending_direct_conn()) {
|
||||
btm_ble_resume_bg_conn();
|
||||
bg_con = btm_ble_resume_bg_conn();
|
||||
}
|
||||
|
||||
return bg_con;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -521,9 +521,10 @@ tBTM_STATUS btm_ble_read_resolving_list_entry(tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
btm_ble_resolving_list_vsc_op_cmpl);
|
||||
}
|
||||
|
||||
if (st == BTM_CMD_STARTED)
|
||||
if (st == BTM_CMD_STARTED) {
|
||||
btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
|
||||
BTM_BLE_META_READ_IRK_ENTRY);
|
||||
}
|
||||
|
||||
return st;
|
||||
}
|
||||
@@ -799,9 +800,10 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
}
|
||||
}
|
||||
|
||||
if (rt)
|
||||
if (rt) {
|
||||
btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
|
||||
BTM_BLE_META_ADD_IRK_ENTRY);
|
||||
}
|
||||
|
||||
/* if resolving list has been turned on, re-enable it */
|
||||
if (rl_mask) {
|
||||
|
||||
@@ -207,8 +207,9 @@ BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr, tBT_TRANSPORT transport)
|
||||
extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bd_addr);
|
||||
if (p_dev_rec == NULL)
|
||||
if (p_dev_rec == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_dev_rec->sec_flags = 0;
|
||||
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
|
||||
|
||||
@@ -273,13 +273,15 @@ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_feat
|
||||
btm_cb.btm_acl_pkt_types_supported = (BTM_ACL_PKT_TYPES_MASK_DH1 +
|
||||
BTM_ACL_PKT_TYPES_MASK_DM1);
|
||||
|
||||
if (HCI_3_SLOT_PACKETS_SUPPORTED(p_features))
|
||||
if (HCI_3_SLOT_PACKETS_SUPPORTED(p_features)) {
|
||||
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH3 +
|
||||
BTM_ACL_PKT_TYPES_MASK_DM3);
|
||||
}
|
||||
|
||||
if (HCI_5_SLOT_PACKETS_SUPPORTED(p_features))
|
||||
if (HCI_5_SLOT_PACKETS_SUPPORTED(p_features)) {
|
||||
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH5 +
|
||||
BTM_ACL_PKT_TYPES_MASK_DM5);
|
||||
}
|
||||
|
||||
/* Add in EDR related ACL types */
|
||||
if (!HCI_EDR_ACL_2MPS_SUPPORTED(p_features)) {
|
||||
@@ -297,13 +299,15 @@ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_feat
|
||||
/* Check to see if 3 and 5 slot packets are available */
|
||||
if (HCI_EDR_ACL_2MPS_SUPPORTED(p_features) ||
|
||||
HCI_EDR_ACL_3MPS_SUPPORTED(p_features)) {
|
||||
if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features))
|
||||
if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features)) {
|
||||
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
|
||||
BTM_ACL_PKT_TYPES_MASK_NO_3_DH3);
|
||||
}
|
||||
|
||||
if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features))
|
||||
if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features)) {
|
||||
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 +
|
||||
BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
|
||||
}
|
||||
}
|
||||
|
||||
BTM_TRACE_DEBUG("Local supported ACL packet types: 0x%04x",
|
||||
|
||||
@@ -1042,9 +1042,10 @@ tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb
|
||||
return btm_ble_read_remote_name(remote_bda, p_cur, p_cb);
|
||||
} else
|
||||
#endif
|
||||
|
||||
{
|
||||
return (btm_initiate_rem_name (remote_bda, p_cur, BTM_RMT_NAME_EXT,
|
||||
BTM_EXT_RMT_NAME_TIMEOUT, p_cb));
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1080,11 +1081,13 @@ tBTM_STATUS BTM_CancelRemoteDeviceName (void)
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (btsnd_hcic_rmt_name_req_cancel (p_inq->remname_bda)) {
|
||||
return (BTM_CMD_STARTED);
|
||||
} else {
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return (BTM_WRONG_MODE);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,9 @@ const UINT8 btm_pm_md_comp_matrix[BTM_PM_NUM_SET_MODES * BTM_PM_NUM_SET_MODES] =
|
||||
/* function prototype */
|
||||
static int btm_pm_find_acl_ind(BD_ADDR remote_bda);
|
||||
static tBTM_STATUS btm_pm_snd_md_req( UINT8 pm_id, int link_ind, tBTM_PM_PWR_MD *p_mode );
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
static const char *mode_to_string(tBTM_PM_MODE mode);
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef BTM_PM_DEBUG
|
||||
@@ -950,6 +952,7 @@ tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void)
|
||||
}
|
||||
}
|
||||
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
static const char *mode_to_string(tBTM_PM_MODE mode)
|
||||
{
|
||||
switch (mode) {
|
||||
@@ -960,3 +963,4 @@ static const char *mode_to_string(tBTM_PM_MODE mode)
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -887,7 +887,9 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin,
|
||||
#ifdef APPL_AUTH_WRITE_EXCEPTION
|
||||
if (!(APPL_AUTH_WRITE_EXCEPTION)(p_dev_rec->bd_addr))
|
||||
#endif
|
||||
{
|
||||
btsnd_hcic_write_auth_enable (TRUE);
|
||||
}
|
||||
|
||||
btm_cb.acl_disc_reason = 0xff ;
|
||||
|
||||
@@ -907,9 +909,10 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin,
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
|
||||
p_dev_rec->sec_flags &= ~BTM_SEC_LINK_KEY_AUTHED;
|
||||
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_AUTH_FAILURE);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -949,7 +952,9 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec;
|
||||
tBTM_STATUS status;
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
UINT8 *p_features;
|
||||
#endif
|
||||
UINT8 ii;
|
||||
tACL_CONN *p = btm_bda_to_acl(bd_addr, transport);
|
||||
BTM_TRACE_API ("btm_sec_bond_by_transport BDA: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
@@ -1042,7 +1047,9 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
|
||||
}
|
||||
|
||||
for (ii = 0; ii <= HCI_EXT_FEATURES_PAGE_MAX; ii++) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
p_features = p_dev_rec->features[ii];
|
||||
#endif
|
||||
BTM_TRACE_EVENT(" remote_features page[%1d] = %02x-%02x-%02x-%02x\n",
|
||||
ii, p_features[0], p_features[1], p_features[2], p_features[3]);
|
||||
BTM_TRACE_EVENT(" %02x-%02x-%02x-%02x\n",
|
||||
@@ -1396,7 +1403,9 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
rc = btm_sec_execute_procedure (p_dev_rec);
|
||||
}
|
||||
|
||||
if (rc != BTM_CMD_STARTED && rc != BTM_BUSY) {
|
||||
if (p_callback) {
|
||||
@@ -2163,9 +2172,10 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle
|
||||
"rmt_support_for_sc : %d -> fail pairing\n", __FUNCTION__,
|
||||
local_supports_sc,
|
||||
p_dev_rec->remote_supports_secure_connections);
|
||||
if (p_callback)
|
||||
if (p_callback) {
|
||||
(*p_callback) (bd_addr, transport, (void *)p_ref_data,
|
||||
BTM_MODE4_LEVEL4_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
return (BTM_MODE4_LEVEL4_NOT_SUPPORTED);
|
||||
}
|
||||
@@ -2525,9 +2535,10 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
|
||||
"remote_support_for_sc %d: fail pairing\n", __FUNCTION__,
|
||||
local_supports_sc, p_dev_rec->remote_supports_secure_connections);
|
||||
|
||||
if (p_callback)
|
||||
if (p_callback) {
|
||||
(*p_callback) (bd_addr, transport, (void *)p_ref_data,
|
||||
BTM_MODE4_LEVEL4_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
return (BTM_MODE4_LEVEL4_NOT_SUPPORTED);
|
||||
}
|
||||
@@ -3013,9 +3024,10 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
|
||||
|
||||
/* Notify all clients waiting for name to be resolved */
|
||||
for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) {
|
||||
if (btm_cb.p_rmt_name_callback[i] && p_bd_addr)
|
||||
if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) {
|
||||
(*btm_cb.p_rmt_name_callback[i])(p_bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dev_class[0] = 0;
|
||||
@@ -3100,9 +3112,10 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
|
||||
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
|
||||
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -3128,10 +3141,11 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
|
||||
/* that some authentication has been completed */
|
||||
/* This is required when different entities receive link notification and auth complete */
|
||||
if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)) {
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3907,10 +3921,11 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
|
||||
/* User probably Disabled the keyboard while it was asleap. Let her try */
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
/* report the suthentication status */
|
||||
if (old_state != BTM_PAIR_STATE_IDLE)
|
||||
if (old_state != BTM_PAIR_STATE_IDLE) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, status);
|
||||
}
|
||||
}
|
||||
|
||||
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
|
||||
@@ -4181,9 +4196,10 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle)
|
||||
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
|
||||
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
@@ -4408,10 +4424,11 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
|
||||
res = FALSE;
|
||||
}
|
||||
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_SUCCESS);
|
||||
}
|
||||
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
|
||||
|
||||
@@ -4717,9 +4734,10 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
|
||||
if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)
|
||||
/* for derived key, always send authentication callback for BR channel */
|
||||
|| ltk_derived_lk) {
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
/* We will save link key only if the user authorized it - BTE report link key in all cases */
|
||||
@@ -4829,10 +4847,11 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_cb->pairing_bda,
|
||||
NULL,
|
||||
name, HCI_ERR_CONNECTION_TOUT);
|
||||
} else
|
||||
} else {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_CONNECTION_TOUT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -4888,10 +4907,11 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_cb->pairing_bda,
|
||||
NULL,
|
||||
name, HCI_ERR_CONNECTION_TOUT);
|
||||
} else
|
||||
} else {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_CONNECTION_TOUT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -5520,10 +5540,11 @@ static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle)
|
||||
*******************************************************************************/
|
||||
static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
{
|
||||
if (btm_cb.api.p_link_key_callback)
|
||||
if (btm_cb.api.p_link_key_callback) {
|
||||
(*btm_cb.api.p_link_key_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, p_dev_rec->link_key,
|
||||
p_dev_rec->link_key_type);
|
||||
}
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
@@ -5703,7 +5724,9 @@ void btm_sec_dev_rec_cback_event (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 res, BOOLEA
|
||||
(*p_callback) (p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE, p_dev_rec->p_ref_data, res);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
(*p_callback) (p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, p_dev_rec->p_ref_data, res);
|
||||
}
|
||||
}
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
btm_sec_check_pending_reqs();
|
||||
@@ -5761,7 +5784,9 @@ static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
#ifdef APPL_AUTH_WRITE_EXCEPTION
|
||||
if (!(APPL_AUTH_WRITE_EXCEPTION)(p_dev_rec->bd_addr))
|
||||
#endif
|
||||
{
|
||||
btsnd_hcic_write_auth_enable (TRUE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN);
|
||||
@@ -5913,8 +5938,9 @@ static BOOLEAN btm_sec_is_serv_level0(UINT16 psm)
|
||||
static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport,
|
||||
UINT8 encr_enable)
|
||||
{
|
||||
if (fixed_queue_is_empty(btm_cb.sec_pending_q))
|
||||
if (fixed_queue_is_empty(btm_cb.sec_pending_q)) {
|
||||
return;
|
||||
}
|
||||
|
||||
UINT8 res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING;
|
||||
list_t *list = fixed_queue_get_list(btm_cb.sec_pending_q);
|
||||
|
||||
@@ -279,8 +279,11 @@ typedef UINT16 tBTM_BLE_STATE_MASK;
|
||||
#define BTM_LE_RESOLVING_LIST_MAX 0x20
|
||||
#endif
|
||||
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR 0
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID 1
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR 0
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID 1
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE 2
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV 3
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV 4
|
||||
|
||||
typedef struct {
|
||||
BD_ADDR *resolve_q_random_pseudo;
|
||||
@@ -319,6 +322,7 @@ typedef struct {
|
||||
/* observer callback and timer */
|
||||
tBTM_INQ_RESULTS_CB *p_obs_results_cb;
|
||||
tBTM_CMPL_CB *p_obs_cmpl_cb;
|
||||
tBTM_INQ_DIS_CB *p_obs_discard_cb;
|
||||
TIMER_LIST_ENT obs_timer_ent;
|
||||
|
||||
/* scan callback and timer */
|
||||
@@ -368,6 +372,7 @@ extern "C" {
|
||||
|
||||
void btm_ble_timeout(TIMER_LIST_ENT *p_tle);
|
||||
void btm_ble_process_adv_pkt (UINT8 *p);
|
||||
void btm_ble_process_adv_discard_evt(UINT8 *p);
|
||||
void btm_ble_proc_scan_rsp_rpt (UINT8 *p);
|
||||
tBTM_STATUS btm_ble_read_remote_name(BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, tBTM_CMPL_CB *p_cb);
|
||||
BOOLEAN btm_ble_cancel_remote_name(BD_ADDR remote_bda);
|
||||
@@ -443,7 +448,7 @@ BOOLEAN btm_ble_start_auto_conn(BOOLEAN start);
|
||||
BOOLEAN btm_ble_start_select_conn(BOOLEAN start, tBTM_BLE_SEL_CBACK *p_select_cback);
|
||||
BOOLEAN btm_ble_renew_bg_conn_params(BOOLEAN add, BD_ADDR bd_addr);
|
||||
void btm_write_dir_conn_wl(BD_ADDR target_addr);
|
||||
void btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bda, UINT8 status);
|
||||
BOOLEAN btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bda, UINT8 status);
|
||||
BOOLEAN btm_execute_wl_dev_operation(void);
|
||||
void btm_ble_update_link_topology_mask(UINT8 role, BOOLEAN increase);
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len);
|
||||
#if BLE_INCLUDED == TRUE
|
||||
static void btu_ble_ll_conn_complete_evt (UINT8 *p, UINT16 evt_len);
|
||||
static void btu_ble_process_adv_pkt (UINT8 *p);
|
||||
static void btu_ble_process_adv_dis(UINT8 *p);
|
||||
static void btu_ble_read_remote_feat_evt (UINT8 *p);
|
||||
static void btu_ble_ll_conn_param_upd_evt (UINT8 *p, UINT16 evt_len);
|
||||
static void btu_ble_ll_get_conn_param_format_err_from_contoller (UINT8 status, UINT16 handle);
|
||||
@@ -342,6 +343,9 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
case HCI_BLE_ADV_PKT_RPT_EVT: /* result of inquiry */
|
||||
btu_ble_process_adv_pkt(p);
|
||||
break;
|
||||
case HCI_BLE_ADV_DISCARD_REPORT_EVT:
|
||||
btu_ble_process_adv_dis(p);
|
||||
break;
|
||||
case HCI_BLE_CONN_COMPLETE_EVT:
|
||||
btu_ble_ll_conn_complete_evt(p, hci_evt_len);
|
||||
break;
|
||||
@@ -1809,6 +1813,11 @@ static void btu_ble_process_adv_pkt (UINT8 *p)
|
||||
btm_ble_process_adv_pkt(p);
|
||||
}
|
||||
|
||||
static void btu_ble_process_adv_dis(UINT8 *p)
|
||||
{
|
||||
btm_ble_process_adv_discard_evt(p);
|
||||
}
|
||||
|
||||
static void btu_ble_ll_conn_complete_evt ( UINT8 *p, UINT16 evt_len)
|
||||
{
|
||||
btm_ble_conn_complete(p, evt_len, FALSE);
|
||||
|
||||
@@ -437,6 +437,9 @@ void gap_attr_db_init(void)
|
||||
memset (&app_uuid.uu.uuid128, 0x81, LEN_UUID_128);
|
||||
|
||||
status = GATTS_StartService(gap_cb.gatt_if, service_handle, GAP_TRANSPORT_SUPPORTED );
|
||||
#if (CONFIG_BT_STACK_NO_LOG)
|
||||
(void) status;
|
||||
#endif
|
||||
|
||||
GAP_TRACE_EVENT ("GAP App gatt_if: %d s_hdl = %d start_status=%d",
|
||||
gap_cb.gatt_if, service_handle, status);
|
||||
|
||||
@@ -292,7 +292,7 @@ UINT16 GATTS_AddIncludeService (UINT16 service_handle, UINT16 include_svc_handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
|
||||
tGATT_PERM perm, tGATT_CHAR_PROP property,
|
||||
tGATT_PERM perm, tGATT_CHAR_PROP property,
|
||||
tGATT_ATTR_VAL *attr_val, tGATTS_ATTR_CONTROL *control)
|
||||
{
|
||||
tGATT_HDL_LIST_ELEM *p_decl;
|
||||
@@ -311,7 +311,7 @@ UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
|
||||
return gatts_add_characteristic(&p_decl->svc_db,
|
||||
perm,
|
||||
property,
|
||||
p_char_uuid,
|
||||
p_char_uuid,
|
||||
attr_val, control);
|
||||
}
|
||||
/*******************************************************************************
|
||||
@@ -734,7 +734,7 @@ tGATT_STATUS GATTS_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *v
|
||||
return GATT_INVALID_ATTR_LEN;
|
||||
}
|
||||
if ((p_decl = gatt_find_hdl_buffer_by_attr_handle(attr_handle)) == NULL) {
|
||||
GATT_TRACE_DEBUG("Service not created\n");
|
||||
GATT_TRACE_DEBUG("Service not created\n");
|
||||
return GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
@@ -1161,14 +1161,19 @@ void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout, tBT_TRANSPORT trans
|
||||
if (p_tcb->att_lcid == L2CAP_ATT_CID) {
|
||||
status = L2CA_SetFixedChannelTout (bd_addr, L2CAP_ATT_CID, idle_tout);
|
||||
|
||||
if (idle_tout == GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP)
|
||||
if (idle_tout == GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP) {
|
||||
L2CA_SetIdleTimeoutByBdAddr(p_tcb->peer_bda,
|
||||
GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP, BT_TRANSPORT_LE);
|
||||
}
|
||||
} else {
|
||||
status = L2CA_SetIdleTimeout (p_tcb->att_lcid, idle_tout, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
#if (CONFIG_BT_STACK_NO_LOG)
|
||||
(void) status;
|
||||
#endif
|
||||
|
||||
GATT_TRACE_API ("GATT_SetIdleTimeout idle_tout=%d status=%d(1-OK 0-not performed)",
|
||||
idle_tout, status);
|
||||
}
|
||||
@@ -1507,7 +1512,7 @@ tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr)
|
||||
srv_chg_ind_pending = gatt_is_srv_chg_ind_pending(p_tcb);
|
||||
|
||||
if (!srv_chg_ind_pending) {
|
||||
status = gatt_send_srv_chg_ind(addr);
|
||||
status = gatt_send_srv_chg_ind(addr);
|
||||
} else {
|
||||
status = GATT_BUSY;
|
||||
GATT_TRACE_DEBUG("discard srv chg - already has one in the queue");
|
||||
|
||||
@@ -374,6 +374,10 @@ void gatt_profile_db_init (void)
|
||||
*/
|
||||
status = GATTS_StartService (gatt_cb.gatt_if, service_handle, GATTP_TRANSPORT_SUPPORTED );
|
||||
|
||||
#if (CONFIG_BT_STACK_NO_LOG)
|
||||
(void) status;
|
||||
#endif
|
||||
|
||||
GATT_TRACE_DEBUG ("gatt_profile_db_init: gatt_if=%d start status%d\n",
|
||||
gatt_cb.gatt_if, status);
|
||||
}
|
||||
|
||||
@@ -2140,7 +2140,9 @@ void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_data)
|
||||
UINT8 op = p_clcb->operation, disc_type = GATT_DISC_MAX;
|
||||
tGATT_DISC_CMPL_CB *p_disc_cmpl_cb = (p_clcb->p_reg) ? p_clcb->p_reg->app_cb.p_disc_cmpl_cb : NULL;
|
||||
UINT16 conn_id;
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
UINT8 operation;
|
||||
#endif
|
||||
|
||||
GATT_TRACE_DEBUG ("gatt_end_operation status=%d op=%d subtype=%d",
|
||||
status, p_clcb->operation, p_clcb->op_subtype);
|
||||
@@ -2182,7 +2184,10 @@ void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_data)
|
||||
osi_free(p_clcb->p_attr_buf);
|
||||
}
|
||||
|
||||
#if !CONFIG_BT_STACK_NO_LOG
|
||||
operation = p_clcb->operation;
|
||||
#endif
|
||||
|
||||
conn_id = p_clcb->conn_id;
|
||||
btu_stop_timer(&p_clcb->rsp_timer_ent);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE))
|
||||
#define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)osi_malloc(HCIC_PREAMBLE_SIZE + sizeof(BT_HDR) + paramlen))
|
||||
|
||||
#if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)
|
||||
|
||||
@@ -524,7 +524,7 @@ BOOLEAN btsnd_hcic_ble_encrypt (UINT8 *key, UINT8 key_len,
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF(sizeof(BT_HDR) + sizeof (void *) +
|
||||
if ((p = HCI_GET_CMD_BUF(sizeof (void *) +
|
||||
HCIC_PARAM_SIZE_BLE_ENCRYPT)) == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
@@ -563,7 +563,7 @@ BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback)
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF(sizeof(BT_HDR) + sizeof (void *) +
|
||||
if ((p = HCI_GET_CMD_BUF(sizeof (void *) +
|
||||
HCIC_PARAM_SIZE_BLE_RAND)) == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
@@ -999,5 +999,27 @@ BOOLEAN btsnd_hcic_ble_set_data_length(UINT16 conn_handle, UINT16 tx_octets, UIN
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_update_adv_report_flow_control (UINT16 num)
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL)) == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL;
|
||||
p->offset = 0;
|
||||
|
||||
UINT16_TO_STREAM (pp, HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL);
|
||||
UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL);
|
||||
UINT16_TO_STREAM (pp, num);
|
||||
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "btm_int.h" /* Included for UIPC_* macro definitions */
|
||||
|
||||
#define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE))
|
||||
#define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)osi_malloc(HCIC_PREAMBLE_SIZE + sizeof(BT_HDR) + paramlen))
|
||||
|
||||
BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration, UINT8 response_cnt)
|
||||
{
|
||||
|
||||
@@ -169,6 +169,8 @@ typedef void (tBTM_VS_EVT_CB) (UINT8 len, UINT8 *p);
|
||||
*/
|
||||
typedef void (tBTM_CMPL_CB) (void *p1);
|
||||
|
||||
typedef void (tBTM_INQ_DIS_CB) (uint32_t num_dis);
|
||||
|
||||
/* VSC callback function for notifying an application that a synchronous
|
||||
** BTM function is complete. The pointer contains the address of any returned data.
|
||||
*/
|
||||
@@ -677,7 +679,6 @@ typedef struct {
|
||||
UINT8 num_resp; /* Number of results from the current inquiry */
|
||||
} tBTM_INQUIRY_CMPL;
|
||||
|
||||
|
||||
/* Structure returned with remote name request */
|
||||
typedef struct {
|
||||
UINT16 status;
|
||||
|
||||
@@ -1272,7 +1272,7 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
|
||||
tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb);
|
||||
tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb, tBTM_INQ_DIS_CB *p_discard_cb);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -376,6 +376,8 @@
|
||||
#define HCI_SUBCODE_BLE_EXTENDED_SCAN_PARAMS 0x06
|
||||
#define HCI_SUBCODE_BLE_LONG_ADV 0x07
|
||||
#define HCI_SUBCODE_BLE_DUPLICATE_EXCEPTIONAL_LIST 0x08
|
||||
#define HCI_SUBCODE_BLE_SET_ADV_FLOW_CONTROL 0x09
|
||||
#define HCI_SUBCODE_BLE_ADV_REPORT_FLOW_CONTROL 0x0A
|
||||
#define HCI_SUBCODE_BLE_MAX 0x7F
|
||||
|
||||
//ESP BT subcode define
|
||||
@@ -415,6 +417,8 @@
|
||||
#define HCI_VENDOR_BLE_LONG_ADV_DATA HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_LONG_ADV)
|
||||
/* BLE update duplicate scan exceptional list */
|
||||
#define HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_DUPLICATE_EXCEPTIONAL_LIST)
|
||||
#define HCI_VENDOR_BLE_SET_ADV_FLOW_CONTROL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_SET_ADV_FLOW_CONTROL)
|
||||
#define HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_ADV_REPORT_FLOW_CONTROL)
|
||||
//ESP BT HCI CMD
|
||||
|
||||
/* subcode for multi adv feature */
|
||||
@@ -749,6 +753,8 @@
|
||||
#define HCI_BLE_DATA_LENGTH_CHANGE_EVT 0x07
|
||||
#define HCI_BLE_ENHANCED_CONN_COMPLETE_EVT 0x0a
|
||||
#define HCI_BLE_DIRECT_ADV_EVT 0x0b
|
||||
/* ESP vendor BLE Event sub code */
|
||||
#define HCI_BLE_ADV_DISCARD_REPORT_EVT 0XF0
|
||||
|
||||
/* Definitions for LE Channel Map */
|
||||
#define HCI_BLE_CHNL_MAP_SIZE 5
|
||||
|
||||
@@ -555,6 +555,10 @@ BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags); /* Write Voice
|
||||
#define HCI_HOST_FLOW_CTRL_SCO_ON 2
|
||||
#define HCI_HOST_FLOW_CTRL_BOTH_ON 3
|
||||
|
||||
#define HCI_HOST_FLOW_CTRL_ADV_REPORT_OFF 0
|
||||
#define HCI_HOST_FLOW_CTRL_ADV_REPORT_ON 1
|
||||
|
||||
|
||||
BOOLEAN btsnd_hcic_write_auto_flush_tout(UINT16 handle,
|
||||
UINT16 timeout); /* Write Retransmit Timout */
|
||||
|
||||
@@ -684,6 +688,7 @@ void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode,
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT 2
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6
|
||||
#define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11
|
||||
#define HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL 2
|
||||
|
||||
/* ULP HCI command */
|
||||
BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask);
|
||||
@@ -806,6 +811,8 @@ BOOLEAN btsnd_hcic_read_authenticated_payload_tout(UINT16 handle);
|
||||
BOOLEAN btsnd_hcic_write_authenticated_payload_tout(UINT16 handle,
|
||||
UINT16 timeout);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_update_adv_report_flow_control (UINT16 num);
|
||||
|
||||
#define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4
|
||||
|
||||
#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
#define L2CAP_WAIT_UNPARK_TOUT 2 /* 2 seconds */
|
||||
#define L2CAP_LINK_INFO_RESP_TOUT 2 /* 2 seconds */
|
||||
#define L2CAP_UPDATE_CONN_PARAM_TOUT 6 /* 6 seconds */
|
||||
#define L2CAP_BLE_LINK_CONNECT_TOUT 30 /* 30 seconds */
|
||||
#define L2CAP_BLE_LINK_CONNECT_TOUT BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT // configed in menuconfig
|
||||
#define L2CAP_BLE_CONN_PARAM_UPD_TOUT 30 /* 30 seconds */
|
||||
|
||||
/* quick timer uses millisecond unit */
|
||||
|
||||
@@ -270,17 +270,21 @@ UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_ERTM_INFO *p_e
|
||||
p_ccb->ertm_info = *p_ertm_info;
|
||||
|
||||
/* Replace default indicators with the actual default pool */
|
||||
if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
|
||||
if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
|
||||
p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE;
|
||||
}
|
||||
|
||||
if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
|
||||
if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
|
||||
p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE;
|
||||
}
|
||||
|
||||
if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
|
||||
if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
|
||||
p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;
|
||||
}
|
||||
|
||||
if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
|
||||
if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
|
||||
p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE;
|
||||
}
|
||||
|
||||
p_ccb->max_rx_mtu = p_ertm_info->user_rx_buf_size -
|
||||
(L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN);
|
||||
@@ -416,17 +420,21 @@ BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 re
|
||||
p_ccb->ertm_info = *p_ertm_info;
|
||||
|
||||
/* Replace default indicators with the actual default pool */
|
||||
if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
|
||||
if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
|
||||
p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE;
|
||||
}
|
||||
|
||||
if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
|
||||
if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
|
||||
p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE;
|
||||
}
|
||||
|
||||
if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
|
||||
if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
|
||||
p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;
|
||||
}
|
||||
|
||||
if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
|
||||
if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
|
||||
p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE;
|
||||
}
|
||||
|
||||
p_ccb->max_rx_mtu = p_ertm_info->user_rx_buf_size -
|
||||
(L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN);
|
||||
@@ -1340,8 +1348,9 @@ UINT16 L2CA_RegisterLECoc(UINT16 psm, tL2CAP_APPL_INFO *p_cb_info)
|
||||
for (vpsm = 0x0080; vpsm < 0x0100; vpsm++)
|
||||
{
|
||||
p_rcb = l2cu_find_ble_rcb_by_psm(vpsm);
|
||||
if (p_rcb == NULL)
|
||||
if (p_rcb == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
L2CAP_TRACE_API("%s Real PSM: 0x%04x Virtual PSM: 0x%04x", __func__, psm, vpsm);
|
||||
@@ -1390,20 +1399,24 @@ void L2CA_DeregisterLECoc(UINT16 psm)
|
||||
tL2C_LCB *p_lcb = &l2cb.lcb_pool[0];
|
||||
for (int i = 0; i < MAX_L2CAP_LINKS; i++, p_lcb++)
|
||||
{
|
||||
if (!p_lcb->in_use || p_lcb->transport != BT_TRANSPORT_LE)
|
||||
if (!p_lcb->in_use || p_lcb->transport != BT_TRANSPORT_LE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tL2C_CCB *p_ccb = p_lcb->ccb_queue.p_first_ccb;
|
||||
if ((p_ccb == NULL) || (p_lcb->link_state == LST_DISCONNECTING))
|
||||
if ((p_ccb == NULL) || (p_lcb->link_state == LST_DISCONNECTING)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p_ccb->in_use &&
|
||||
(p_ccb->chnl_state == CST_W4_L2CAP_DISCONNECT_RSP ||
|
||||
p_ccb->chnl_state == CST_W4_L2CA_DISCONNECT_RSP))
|
||||
p_ccb->chnl_state == CST_W4_L2CA_DISCONNECT_RSP)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p_ccb->p_rcb == p_rcb)
|
||||
if (p_ccb->p_rcb == p_rcb) {
|
||||
l2c_csm_execute(p_ccb, L2CEVT_L2CA_DISCONNECT_REQ, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
l2cu_release_rcb (p_rcb);
|
||||
@@ -1473,8 +1486,9 @@ UINT16 L2CA_ConnectLECocReq(UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_LE_CFG_INFO *p
|
||||
p_ccb->p_rcb = p_rcb;
|
||||
|
||||
/* Save the configuration */
|
||||
if (p_cfg)
|
||||
if (p_cfg) {
|
||||
memcpy(&p_ccb->local_conn_cfg, p_cfg, sizeof(tL2CAP_LE_CFG_INFO));
|
||||
}
|
||||
|
||||
/* If link is up, start the L2CAP connection */
|
||||
if (p_lcb->link_state == LST_CONNECTED)
|
||||
@@ -1549,8 +1563,9 @@ BOOLEAN L2CA_ConnectLECocRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 r
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (p_cfg)
|
||||
if (p_cfg) {
|
||||
memcpy(&p_ccb->local_conn_cfg, p_cfg, sizeof(tL2CAP_LE_CFG_INFO));
|
||||
}
|
||||
|
||||
if (result == L2CAP_CONN_OK)
|
||||
l2c_csm_execute (p_ccb, L2CEVT_L2CA_CONNECT_RSP, NULL);
|
||||
@@ -1589,8 +1604,9 @@ BOOLEAN L2CA_GetPeerLECocConfig (UINT16 lcid, tL2CAP_LE_CFG_INFO* peer_cfg)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (peer_cfg != NULL)
|
||||
if (peer_cfg != NULL) {
|
||||
memcpy(peer_cfg, &p_ccb->peer_conn_cfg, sizeof(tL2CAP_LE_CFG_INFO));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1675,7 +1691,9 @@ BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE
|
||||
peer_channel_mask = l2cb.l2c_ble_fixed_chnls_mask;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
peer_channel_mask = p_lcb->peer_chnl_mask[0];
|
||||
}
|
||||
|
||||
// Check for supported channel
|
||||
if (!(peer_channel_mask & (1 << fixed_cid))) {
|
||||
@@ -1795,7 +1813,9 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
|
||||
peer_channel_mask = l2cb.l2c_ble_fixed_chnls_mask;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
peer_channel_mask = p_lcb->peer_chnl_mask[0];
|
||||
}
|
||||
|
||||
if ((peer_channel_mask & (1 << fixed_cid)) == 0) {
|
||||
L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData() - peer does not support fixed chnl: 0x%04x", fixed_cid);
|
||||
|
||||
@@ -1260,8 +1260,9 @@ UINT32 CalConnectParamTimeout(tL2C_LCB *p_lcb)
|
||||
*******************************************************************************/
|
||||
void l2cble_credit_based_conn_req (tL2C_CCB *p_ccb)
|
||||
{
|
||||
if (!p_ccb)
|
||||
if (!p_ccb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE)
|
||||
{
|
||||
@@ -1285,8 +1286,9 @@ void l2cble_credit_based_conn_req (tL2C_CCB *p_ccb)
|
||||
*******************************************************************************/
|
||||
void l2cble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result)
|
||||
{
|
||||
if (!p_ccb)
|
||||
if (!p_ccb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE)
|
||||
{
|
||||
@@ -1310,8 +1312,9 @@ void l2cble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result)
|
||||
*******************************************************************************/
|
||||
void l2cble_send_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value)
|
||||
{
|
||||
if (!p_ccb)
|
||||
if (!p_ccb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE)
|
||||
{
|
||||
@@ -1337,8 +1340,9 @@ void l2cble_send_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value)
|
||||
void l2cble_send_peer_disc_req(tL2C_CCB *p_ccb)
|
||||
{
|
||||
L2CAP_TRACE_DEBUG ("%s",__func__);
|
||||
if (!p_ccb)
|
||||
if (!p_ccb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE)
|
||||
{
|
||||
@@ -1396,8 +1400,9 @@ void l2cble_sec_comp(BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data,
|
||||
if (sec_act == BTM_SEC_ENCRYPT_MITM)
|
||||
{
|
||||
BTM_GetSecurityFlagsByTransport(p_bda, &sec_flag, transport);
|
||||
if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED)
|
||||
if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED) {
|
||||
(*(p_buf->p_callback))(p_bda, BT_TRANSPORT_LE, p_buf->p_ref_data, status);
|
||||
}
|
||||
else
|
||||
{
|
||||
L2CAP_TRACE_DEBUG ("%s MITM Protection Not present", __func__);
|
||||
@@ -1425,11 +1430,12 @@ void l2cble_sec_comp(BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data,
|
||||
{
|
||||
p_buf = (tL2CAP_SEC_DATA*) fixed_queue_dequeue(p_lcb->le_sec_pending_q);
|
||||
|
||||
if (status != BTM_SUCCESS)
|
||||
if (status != BTM_SUCCESS) {
|
||||
(*(p_buf->p_callback))(p_bda, BT_TRANSPORT_LE, p_buf->p_ref_data, status);
|
||||
else
|
||||
} else {
|
||||
l2ble_sec_access_req(p_bda, p_buf->psm, p_buf->is_originator,
|
||||
p_buf->p_callback, p_buf->p_ref_data);
|
||||
}
|
||||
|
||||
osi_free(p_buf);
|
||||
}
|
||||
|
||||
@@ -837,10 +837,10 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data)
|
||||
if (p_ccb->local_cid >= L2CAP_FIRST_FIXED_CHNL &&
|
||||
p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL) {
|
||||
if (p_ccb->local_cid < L2CAP_BASE_APPL_CID) {
|
||||
if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)
|
||||
if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) {
|
||||
(*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)
|
||||
(p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr, (BT_HDR *)p_data);
|
||||
else {
|
||||
} else {
|
||||
osi_free (p_data);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -246,13 +246,13 @@ void l2c_fcr_cleanup (tL2C_CCB *p_ccb)
|
||||
|
||||
fixed_queue_free(p_fcrb->retrans_q, osi_free_func);
|
||||
p_fcrb->retrans_q = NULL;
|
||||
|
||||
|
||||
btu_free_quick_timer (&p_fcrb->ack_timer);
|
||||
memset(&p_fcrb->ack_timer, 0, sizeof(TIMER_LIST_ENT));
|
||||
|
||||
|
||||
btu_free_quick_timer (&p_ccb->fcrb.mon_retrans_timer);
|
||||
memset(&p_fcrb->mon_retrans_timer, 0, sizeof(TIMER_LIST_ENT));
|
||||
|
||||
|
||||
#if (L2CAP_ERTM_STATS == TRUE)
|
||||
if ( (p_ccb->local_cid >= L2CAP_BASE_APPL_CID) && (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) ) {
|
||||
UINT32 dur = osi_time_get_os_boottime_ms() - p_ccb->fcrb.connect_tick_count;
|
||||
@@ -1382,7 +1382,9 @@ static BOOLEAN do_sar_reassembly (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_wo
|
||||
(p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr, p_buf);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
l2c_csm_execute (p_ccb, L2CEVT_L2CAP_DATA, p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
return (packet_ok);
|
||||
@@ -2149,8 +2151,9 @@ static void l2c_fcr_collect_ack_delay (tL2C_CCB *p_ccb, UINT8 num_bufs_acked)
|
||||
|
||||
/* update sum, max and min of round trip delay of acking */
|
||||
list_t *list = NULL;
|
||||
if (! fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q))
|
||||
if (! fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) {
|
||||
list = fixed_queue_get_list(p_ccb->fcrb.waiting_for_ack_q);
|
||||
}
|
||||
if (list != NULL) {
|
||||
for (const list_node_t *node = list_begin(list), xx = 0;
|
||||
(node != list_end(list)) && (xx < num_bufs_acked);
|
||||
|
||||
@@ -191,11 +191,11 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda)
|
||||
l2cu_send_peer_info_req (p_lcb, L2CAP_EXTENDED_FEATURES_INFO_TYPE);
|
||||
|
||||
/* Tell BTM Acl management about the link */
|
||||
if ((p_dev_info = btm_find_dev (p_bda)) != NULL)
|
||||
if ((p_dev_info = btm_find_dev (p_bda)) != NULL) {
|
||||
btm_acl_created (ci.bd_addr, p_dev_info->dev_class,
|
||||
p_dev_info->sec_bd_name, handle,
|
||||
p_lcb->link_role, BT_TRANSPORT_BR_EDR);
|
||||
else {
|
||||
} else {
|
||||
btm_acl_created (ci.bd_addr, NULL, NULL, handle, p_lcb->link_role, BT_TRANSPORT_BR_EDR);
|
||||
}
|
||||
|
||||
@@ -399,8 +399,10 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
if (p_lcb->transport == BT_TRANSPORT_BR_EDR)
|
||||
#endif
|
||||
{
|
||||
/* Tell SCO management to drop any SCOs on this ACL */
|
||||
btm_sco_acl_removed (p_lcb->remote_bd_addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If waiting for disconnect and reconnect is pending start the reconnect now
|
||||
@@ -657,7 +659,7 @@ void l2c_info_timeout (tL2C_LCB *p_lcb)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -998,7 +1000,9 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf)
|
||||
l2cb.ble_check_round_robin = TRUE;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
l2cb.check_round_robin = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,10 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
|
||||
UINT8 pkt_type;
|
||||
tL2C_LCB *p_lcb;
|
||||
tL2C_CCB *p_ccb = NULL;
|
||||
UINT16 l2cap_len, rcv_cid, psm;
|
||||
UINT16 l2cap_len, rcv_cid;
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
UINT16 psm;
|
||||
#endif
|
||||
UINT16 credit;
|
||||
|
||||
/* Extract the handle */
|
||||
@@ -228,7 +231,9 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
|
||||
//counter_add("l2cap.ch2.rx.bytes", l2cap_len);
|
||||
//counter_add("l2cap.ch2.rx.pkts", 1);
|
||||
/* process_connectionless_data (p_lcb); */
|
||||
#if !CONFIG_BT_STACK_NO_LOG
|
||||
STREAM_TO_UINT16 (psm, p);
|
||||
#endif
|
||||
L2CAP_TRACE_DEBUG( "GOT CONNECTIONLESS DATA PSM:%d", psm ) ;
|
||||
|
||||
#if (L2CAP_UCD_INCLUDED == TRUE)
|
||||
@@ -237,7 +242,9 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
|
||||
/* nothing to do */
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
osi_free (p_msg);
|
||||
}
|
||||
}
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
else if (rcv_cid == L2CAP_BLE_SIGNALLING_CID) {
|
||||
@@ -263,9 +270,10 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
l2c_fcr_proc_pdu (p_ccb, p_msg);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
} else
|
||||
} else {
|
||||
(*l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)
|
||||
(rcv_cid, p_lcb->remote_bd_addr, p_msg);
|
||||
}
|
||||
} else {
|
||||
osi_free (p_msg);
|
||||
}
|
||||
@@ -395,7 +403,6 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
|
||||
STREAM_TO_UINT16 (rej_mtu, p);
|
||||
/* What to do with the MTU reject ? We have negotiated an MTU. For now */
|
||||
/* we will ignore it and let a higher protocol timeout take care of it */
|
||||
|
||||
L2CAP_TRACE_WARNING ("L2CAP - MTU rej Handle: %d MTU: %d", p_lcb->handle, rej_mtu);
|
||||
}
|
||||
if (rej_reason == L2CAP_CMD_REJ_INVALID_CID) {
|
||||
@@ -758,6 +765,7 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
|
||||
}
|
||||
}
|
||||
|
||||
UNUSED(rej_mtu);
|
||||
}
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
@@ -880,7 +888,7 @@ void l2c_free(void)
|
||||
l2cb.rcv_pending_q = NULL;
|
||||
#if L2C_DYNAMIC_MEMORY
|
||||
FREE_AND_RESET(l2c_cb_ptr);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -151,8 +151,10 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
if (p_lcb->transport == BT_TRANSPORT_BR_EDR)
|
||||
#endif
|
||||
{
|
||||
/* Release all SCO links */
|
||||
btm_remove_sco_links(p_lcb->remote_bd_addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_lcb->sent_not_acked > 0) {
|
||||
@@ -189,12 +191,13 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
|
||||
}
|
||||
|
||||
/* Tell BTM Acl management the link was removed */
|
||||
if ((p_lcb->link_state == LST_CONNECTED) || (p_lcb->link_state == LST_DISCONNECTING))
|
||||
if ((p_lcb->link_state == LST_CONNECTED) || (p_lcb->link_state == LST_DISCONNECTING)) {
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
btm_acl_removed (p_lcb->remote_bd_addr, p_lcb->transport);
|
||||
#else
|
||||
btm_acl_removed (p_lcb->remote_bd_addr, BT_TRANSPORT_BR_EDR);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Release any held buffers */
|
||||
if (p_lcb->link_xmit_data_q) {
|
||||
@@ -246,8 +249,9 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
|
||||
while (!fixed_queue_is_empty(p_lcb->le_sec_pending_q))
|
||||
{
|
||||
tL2CAP_SEC_DATA *p_buf = (tL2CAP_SEC_DATA*) fixed_queue_dequeue(p_lcb->le_sec_pending_q);
|
||||
if (p_buf->p_callback)
|
||||
if (p_buf->p_callback) {
|
||||
p_buf->p_callback(p_lcb->remote_bd_addr, p_lcb->transport, p_buf->p_ref_data, BTM_DEV_RESET);
|
||||
}
|
||||
osi_free(p_buf);
|
||||
}
|
||||
fixed_queue_free(p_lcb->le_sec_pending_q, NULL);
|
||||
@@ -1880,8 +1884,9 @@ tL2C_RCB *l2cu_find_ble_rcb_by_psm (UINT16 psm)
|
||||
|
||||
for (xx = 0; xx < BLE_MAX_L2CAP_CLIENTS; xx++, p_rcb++)
|
||||
{
|
||||
if ((p_rcb->in_use) && (p_rcb->psm == psm))
|
||||
if ((p_rcb->in_use) && (p_rcb->psm == psm)) {
|
||||
return (p_rcb);
|
||||
}
|
||||
}
|
||||
|
||||
/* If here, no match found */
|
||||
@@ -2862,7 +2867,7 @@ void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb)
|
||||
#endif
|
||||
}
|
||||
} else if ( (peer_channel_mask & (1 << (xx + L2CAP_FIRST_FIXED_CHNL)))
|
||||
&& (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL) )
|
||||
&& (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL) ) {
|
||||
#if BLE_INCLUDED == TRUE
|
||||
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL,
|
||||
p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport);
|
||||
@@ -2870,6 +2875,7 @@ void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb)
|
||||
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL,
|
||||
p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2960,8 +2966,9 @@ void l2cu_send_peer_ble_credit_based_conn_req (tL2C_CCB *p_ccb)
|
||||
UINT16 mps;
|
||||
UINT16 initial_credit;
|
||||
|
||||
if (!p_ccb)
|
||||
if (!p_ccb) {
|
||||
return;
|
||||
}
|
||||
p_lcb = p_ccb->p_lcb;
|
||||
|
||||
/* Create an identifier for this packet */
|
||||
@@ -3082,8 +3089,9 @@ void l2cu_send_peer_ble_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value
|
||||
UINT8 *p;
|
||||
tL2C_LCB *p_lcb = NULL;
|
||||
|
||||
if (!p_ccb)
|
||||
if (!p_ccb) {
|
||||
return;
|
||||
}
|
||||
p_lcb = p_ccb->p_lcb;
|
||||
|
||||
/* Create an identifier for this packet */
|
||||
@@ -3125,8 +3133,9 @@ void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB *p_ccb)
|
||||
tL2C_LCB *p_lcb = NULL;
|
||||
L2CAP_TRACE_DEBUG ("%s",__func__);
|
||||
|
||||
if (!p_ccb)
|
||||
if (!p_ccb) {
|
||||
return;
|
||||
}
|
||||
p_lcb = p_ccb->p_lcb;
|
||||
|
||||
/* Create an identifier for this packet */
|
||||
|
||||
@@ -1185,8 +1185,9 @@ int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len)
|
||||
while (max_len)
|
||||
{
|
||||
p_buf = (BT_HDR *)fixed_queue_try_peek_first(p_port->rx.queue);
|
||||
if (p_buf == NULL)
|
||||
if (p_buf == NULL){
|
||||
break;
|
||||
}
|
||||
|
||||
if (p_buf->len > max_len) {
|
||||
memcpy (p_data, (UINT8 *)(p_buf + 1) + p_buf->offset, max_len);
|
||||
|
||||
@@ -899,11 +899,11 @@ UINT16 SDP_DiDiscover( BD_ADDR remote_device, tSDP_DISCOVERY_DB *p_db,
|
||||
init_uuid.len = 2;
|
||||
init_uuid.uu.uuid16 = di_uuid;
|
||||
|
||||
if ( SDP_InitDiscoveryDb(p_db, len, num_uuids, &init_uuid, 0, NULL) )
|
||||
if ( SDP_InitDiscoveryDb(p_db, len, num_uuids, &init_uuid, 0, NULL) ) {
|
||||
if ( SDP_ServiceSearchRequest(remote_device, p_db, p_cb) ) {
|
||||
result = SDP_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
return SDP_DI_DISC_FAILED;
|
||||
|
||||
@@ -467,12 +467,13 @@ static void sdp_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed)
|
||||
SDP_TRACE_EVENT ("SDP - Rcvd L2CAP disc, CID: 0x%x\n", l2cap_cid);
|
||||
#if SDP_CLIENT_ENABLED == TRUE
|
||||
/* Tell the user if he has a callback */
|
||||
if (p_ccb->p_cb)
|
||||
if (p_ccb->p_cb) {
|
||||
(*p_ccb->p_cb) ((UINT16) ((p_ccb->con_state == SDP_STATE_CONNECTED) ?
|
||||
SDP_SUCCESS : SDP_CONN_FAILED));
|
||||
else if (p_ccb->p_cb2)
|
||||
} else if (p_ccb->p_cb2) {
|
||||
(*p_ccb->p_cb2) ((UINT16) ((p_ccb->con_state == SDP_STATE_CONNECTED) ?
|
||||
SDP_SUCCESS : SDP_CONN_FAILED), p_ccb->user_data);
|
||||
}
|
||||
|
||||
#endif
|
||||
sdpu_release_ccb (p_ccb);
|
||||
|
||||
@@ -242,6 +242,7 @@ UINT8 *sdpu_build_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr)
|
||||
} else
|
||||
|
||||
#endif /* 0xFFFF - 0xFF */
|
||||
{
|
||||
#if (SDP_MAX_ATTR_LEN > 0xFF)
|
||||
if (p_attr->len > 0xFF) {
|
||||
UINT8_TO_BE_STREAM (p_out, (p_attr->type << 3) | SIZE_IN_NEXT_WORD);
|
||||
@@ -253,7 +254,7 @@ UINT8 *sdpu_build_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr)
|
||||
UINT8_TO_BE_STREAM (p_out, (p_attr->type << 3) | SIZE_IN_NEXT_BYTE);
|
||||
UINT8_TO_BE_STREAM (p_out, p_attr->len);
|
||||
}
|
||||
|
||||
}
|
||||
if (p_attr->value_ptr != NULL) {
|
||||
ARRAY_TO_BE_STREAM (p_out, p_attr->value_ptr, (int)p_attr->len);
|
||||
}
|
||||
@@ -666,10 +667,10 @@ BOOLEAN sdpu_compare_uuid_arrays (UINT8 *p_uuid1, UINT32 len1, UINT8 *p_uuid2, U
|
||||
if (len1 == 2) {
|
||||
return ((p_uuid1[0] == p_uuid2[0]) && (p_uuid1[1] == p_uuid2[1]));
|
||||
}
|
||||
if (len1 == 4)
|
||||
if (len1 == 4) {
|
||||
return ( (p_uuid1[0] == p_uuid2[0]) && (p_uuid1[1] == p_uuid2[1])
|
||||
&& (p_uuid1[2] == p_uuid2[2]) && (p_uuid1[3] == p_uuid2[3]) );
|
||||
else {
|
||||
} else {
|
||||
return (memcmp (p_uuid1, p_uuid2, (size_t)len1) == 0);
|
||||
}
|
||||
} else if (len1 > len2) {
|
||||
@@ -926,6 +927,7 @@ UINT16 sdpu_get_attrib_entry_len(tSDP_ATTRIBUTE *p_attr)
|
||||
} else
|
||||
|
||||
#endif/* 0xFFFF - 0xFF */
|
||||
{
|
||||
#if (SDP_MAX_ATTR_LEN > 0xFF)
|
||||
if (p_attr->len > 0xFF) {
|
||||
len += 3;
|
||||
@@ -935,6 +937,7 @@ UINT16 sdpu_get_attrib_entry_len(tSDP_ATTRIBUTE *p_attr)
|
||||
{
|
||||
len += 2;
|
||||
}
|
||||
}
|
||||
len += p_attr->len;
|
||||
return len;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user