Merge branch 'release/v3.3' of https://github.com/espressif/esp-idf.git
This commit is contained in:
commit
7124a32fed
|
@ -33,8 +33,15 @@ variables:
|
|||
APPLY_BOT_FILTER_SCRIPT: "$CI_PROJECT_DIR/tools/ci/apply_bot_filter.py"
|
||||
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
|
||||
|
||||
# Docker images
|
||||
# Docker images
|
||||
BOT_DOCKER_IMAGE_TAG: ":latest"
|
||||
# target test repo parameters
|
||||
TEST_ENV_CONFIG_REPO: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/qa/ci-test-runner-configs.git"
|
||||
CI_AUTO_TEST_SCRIPT_REPO_URL: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/qa/auto_test_script.git"
|
||||
CI_AUTO_TEST_SCRIPT_REPO_BRANCH: "ci/v3.1"
|
||||
|
||||
# Versioned esp-idf-doc env image to use for all document building jobs
|
||||
ESP_IDF_DOC_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env:v5"
|
||||
|
||||
# When 'fetch' strategy is used, Gitlab removes untracked files before checking out
|
||||
# new revision. However if the new revision doesn't include some of the submodules
|
||||
|
@ -363,7 +370,11 @@ build_docker:
|
|||
DOCKER_TMP_IMAGE_NAME: "idf_tmp_image"
|
||||
before_script: []
|
||||
script:
|
||||
- export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
|
||||
- export LOCAL_CI_REPOSITORY_URL=$CI_REPOSITORY_URL
|
||||
- if [ -n "$LOCAL_GITLAB_HTTPS_HOST" ]; then export LOCAL_CI_REPOSITORY_URL="https://gitlab-ci-token:${CI_JOB_TOKEN}@${LOCAL_GITLAB_HTTPS_HOST}/${CI_PROJECT_PATH}"; fi
|
||||
- echo "Using repository at $LOCAL_CI_REPOSITORY_URL"
|
||||
- export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${LOCAL_CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
|
||||
|
||||
# Build
|
||||
- docker build --tag ${DOCKER_TMP_IMAGE_NAME} ${DOCKER_BUILD_ARGS} tools/docker/
|
||||
# We can't mount $PWD/examples/get-started/blink into the container, see https://gitlab.com/gitlab-org/gitlab-ce/issues/41227.
|
||||
|
@ -792,6 +803,18 @@ check_pipeline_triggered_by_label:
|
|||
# We want to make sure some jobs are always executed to detect regression.
|
||||
- test "$BOT_LABEL_REGULAR_TEST" = "true" || exit -1
|
||||
|
||||
# For release tag pipelines only, make sure the tag was created with 'git tag -a' so it will update
|
||||
# the version returned by 'git describe'
|
||||
check_version_tag:
|
||||
extends: .check_job_template
|
||||
only:
|
||||
refs:
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
script:
|
||||
- (git cat-file -t $CI_COMMIT_REF_NAME | grep tag) || echo "ESP-IDF versions must be annotated tags." && exit 1
|
||||
|
||||
assign_test:
|
||||
tags:
|
||||
- assign_test
|
||||
|
@ -806,6 +829,11 @@ assign_test:
|
|||
variables:
|
||||
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
|
||||
EXAMPLE_CONFIG_OUTPUT_PATH: "$CI_PROJECT_DIR/examples/test_configs"
|
||||
INTEGRATION_CONFIG_OUTPUT_PATH: "${CI_PROJECT_DIR}/components/idf_test/integration_test/CIConfigs"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
|
||||
ASSIGN_TEST_CASE_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIAssignTestCases.py"
|
||||
PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages"
|
||||
PYTHON_VER: 3.7.7
|
||||
artifacts:
|
||||
paths:
|
||||
- components/idf_test/*/CIConfigs
|
||||
|
@ -824,11 +852,11 @@ assign_test:
|
|||
# assign unit test cases
|
||||
- python $TEST_FW_PATH/CIAssignUnitTest.py $IDF_PATH/components/idf_test/unit_test/TestCaseAll.yml $IDF_PATH/.gitlab-ci.yml $IDF_PATH/components/idf_test/unit_test/CIConfigs
|
||||
# clone test script to assign tests
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
|
||||
- ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
# assgin integration test cases
|
||||
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin
|
||||
- python ${ASSIGN_TEST_CASE_SCRIPT} -t $TEST_CASE_FILE_PATH -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin -o $INTEGRATION_CONFIG_OUTPUT_PATH
|
||||
|
||||
.define_config_file_name: &define_config_file_name |
|
||||
JOB_NAME_PREFIX=$(echo ${CI_JOB_NAME} | awk '{print $1}')
|
||||
|
@ -870,7 +898,7 @@ assign_test:
|
|||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone test env configs
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
- cd $TEST_FW_PATH
|
||||
# run test
|
||||
|
@ -924,24 +952,28 @@ assign_test:
|
|||
variables:
|
||||
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
|
||||
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml"
|
||||
CONFIG_FILE_PATH: "${CI_PROJECT_DIR}/components/idf_test/integration_test/CIConfigs"
|
||||
KNOWN_ISSUE_FILE: "${CI_PROJECT_DIR}/components/idf_test/integration_test/KnownIssues"
|
||||
PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages"
|
||||
CI_RUNNER_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIRunner.py"
|
||||
PYTHON_VER: 3.7.7
|
||||
before_script: *add_gitlab_key_before
|
||||
script:
|
||||
- *define_config_file_name
|
||||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone local test env configs
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
- cd ci-test-runner-configs
|
||||
# clone test bench
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
|
||||
- ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
- cat ${KNOWN_ISSUE_FILE} >> ${TEST_CASE_FILE_PATH}/KnownIssues
|
||||
# run test
|
||||
- python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
|
||||
nvs_compatible_test:
|
||||
<<: *test_template
|
||||
|
@ -959,17 +991,17 @@ nvs_compatible_test:
|
|||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone local test env configs
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
- cd ci-test-runner-configs
|
||||
# clone test bench
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
- ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
|
||||
- ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
|
||||
# prepare nvs bins
|
||||
- ./Tools/prepare_nvs_bin.sh
|
||||
- cd auto_test_script
|
||||
- ./tools/prepare_nvs_bin.sh
|
||||
# run test
|
||||
- python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
|
||||
example_test_001:
|
||||
<<: *example_test_template
|
||||
|
@ -1324,7 +1356,7 @@ IT_002:
|
|||
|
||||
IT_003:
|
||||
<<: *test_template
|
||||
parallel: 13
|
||||
parallel: 14
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_5
|
||||
|
@ -1344,7 +1376,7 @@ IT_005:
|
|||
|
||||
IT_006:
|
||||
<<: *test_template
|
||||
parallel: 8
|
||||
parallel: 13
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
|
@ -1368,13 +1400,6 @@ IT_009:
|
|||
- ESP32_IDF
|
||||
- SSC_T1_3
|
||||
|
||||
IT_010:
|
||||
<<: *test_template
|
||||
parallel: 4
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
|
||||
IT_011:
|
||||
<<: *test_template
|
||||
tags:
|
||||
|
@ -1414,6 +1439,7 @@ IT_015:
|
|||
|
||||
IT_016:
|
||||
<<: *test_template
|
||||
allow_failure: true
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T50_MESH1
|
||||
|
@ -1426,7 +1452,6 @@ IT_017:
|
|||
|
||||
IT_018:
|
||||
<<: *test_template
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_9
|
||||
|
|
|
@ -40,6 +40,7 @@ SECTIONS
|
|||
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
|
||||
*liblog.a:(.literal .text .literal.* .text.*)
|
||||
*libgcc.a:(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_clock.*(.literal.esp_clk_apb_freq .text.esp_clk_apb_freq)
|
||||
*libbootloader_support.a:bootloader_common.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
|
@ -52,6 +53,7 @@ SECTIONS
|
|||
*libbootloader_support.a:secure_boot_signatures.*(.literal .text .literal.* .text.*)
|
||||
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libsoc.a:rtc_clk.*(.literal.rtc_clk_apb_freq_get .text.rtc_clk_apb_freq_get)
|
||||
*libsoc.a:rtc_wdt.*(.literal .text .literal.* .text.*)
|
||||
*libefuse.a:*.*(.literal .text .literal.* .text.*)
|
||||
*(.fini.literal)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#define FLASH_SECTOR_SIZE 0x1000
|
||||
#define FLASH_BLOCK_SIZE 0x10000
|
||||
#define MMAP_ALIGNED_MASK 0x0000FFFF
|
||||
|
||||
/* Provide a Flash API for bootloader_support code,
|
||||
that can be used from bootloader or app code.
|
||||
|
@ -35,7 +36,7 @@
|
|||
*
|
||||
* @return Number of free pages
|
||||
*/
|
||||
uint32_t bootloader_mmap_get_free_pages();
|
||||
uint32_t bootloader_mmap_get_free_pages(void);
|
||||
|
||||
/**
|
||||
* @brief Map a region of flash to data memory
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
typedef void *bootloader_sha256_handle_t;
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start();
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void);
|
||||
|
||||
void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len);
|
||||
|
||||
|
|
|
@ -62,3 +62,17 @@ __attribute__((noreturn)) void bootloader_utility_load_boot_image(const bootload
|
|||
* It is not recommended to call this function from an app (if called, the app will abort).
|
||||
*/
|
||||
__attribute__((noreturn)) void bootloader_reset(void);
|
||||
|
||||
/** @brief Generates the digest of the data between offset & offset+length.
|
||||
*
|
||||
* This function should be used when the size of the data is larger than 3.2MB.
|
||||
* The MMU capacity is 3.2MB (50 pages - 64KB each). This function generates the SHA-256
|
||||
* of the data in chunks of 3.2MB, considering the MMU capacity.
|
||||
*
|
||||
* @param[in] flash_offset Offset of the data in flash.
|
||||
* @param[in] len Length of data in bytes.
|
||||
* @param[out] digest Pointer to buffer where the digest is written, if ESP_OK is returned.
|
||||
*
|
||||
* @return ESP_OK if secure boot digest is generated successfully.
|
||||
*/
|
||||
esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest);
|
|
@ -26,6 +26,8 @@
|
|||
#include "esp_flash_partitions.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "bootloader_config.h"
|
||||
#include "bootloader_utility.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/rtc.h"
|
||||
|
@ -186,22 +188,7 @@ esp_err_t bootloader_common_get_sha256_of_partition (uint32_t address, uint32_t
|
|||
size = data.image_len;
|
||||
}
|
||||
// If image is type by data then hash is calculated for entire image.
|
||||
const void *partition_bin = bootloader_mmap(address, size);
|
||||
if (partition_bin == NULL) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", address, size);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
bootloader_sha256_handle_t sha_handle = bootloader_sha256_start();
|
||||
if (sha_handle == NULL) {
|
||||
bootloader_munmap(partition_bin);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
bootloader_sha256_data(sha_handle, partition_bin, size);
|
||||
bootloader_sha256_finish(sha_handle, out_sha_256);
|
||||
|
||||
bootloader_munmap(partition_bin);
|
||||
|
||||
return ESP_OK;
|
||||
return bootloader_sha256_flash_contents(address, size, out_sha_256);
|
||||
}
|
||||
|
||||
int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata, bool *valid_two_otadata, bool max)
|
||||
|
@ -247,13 +234,15 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
|
|||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
const uint8_t *image = bootloader_mmap(partition->offset, partition->size);
|
||||
const uint32_t app_desc_offset = sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t);
|
||||
const uint32_t mmap_size = app_desc_offset + sizeof(esp_app_desc_t);
|
||||
const uint8_t *image = bootloader_mmap(partition->offset, mmap_size);
|
||||
if (image == NULL) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, partition->size);
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, mmap_size);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
memcpy(app_desc, image + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t), sizeof(esp_app_desc_t));
|
||||
memcpy(app_desc, image + app_desc_offset, sizeof(esp_app_desc_t));
|
||||
bootloader_munmap(image);
|
||||
|
||||
if (app_desc->magic_word != ESP_APP_DESC_MAGIC_WORD) {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
// App version is a wrapper around mbedTLS SHA API
|
||||
#include <mbedtls/sha256.h>
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void)
|
||||
{
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)malloc(sizeof(mbedtls_sha256_context));
|
||||
if (!ctx) {
|
||||
|
@ -53,6 +53,7 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
|
|||
}
|
||||
mbedtls_sha256_free(ctx);
|
||||
free(handle);
|
||||
handle = NULL;
|
||||
}
|
||||
|
||||
#else // Bootloader version
|
||||
|
@ -70,7 +71,7 @@ static const size_t BLOCK_WORDS = (64/sizeof(uint32_t));
|
|||
// Words in final SHA256 digest
|
||||
static const size_t DIGEST_WORDS = (32/sizeof(uint32_t));
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void)
|
||||
{
|
||||
// Enable SHA hardware
|
||||
ets_sha_enable();
|
||||
|
|
|
@ -703,3 +703,39 @@ void bootloader_reset(void)
|
|||
abort(); /* This function should really not be called from application code */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest)
|
||||
{
|
||||
|
||||
if (digest == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* Handling firmware images larger than MMU capacity */
|
||||
uint32_t mmu_free_pages_count = bootloader_mmap_get_free_pages();
|
||||
bootloader_sha256_handle_t sha_handle = NULL;
|
||||
|
||||
sha_handle = bootloader_sha256_start();
|
||||
if (sha_handle == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
while (len > 0) {
|
||||
uint32_t mmu_page_offset = ((flash_offset & MMAP_ALIGNED_MASK) != 0) ? 1 : 0; /* Skip 1st MMU Page if it is already populated */
|
||||
uint32_t partial_image_len = MIN(len, ((mmu_free_pages_count - mmu_page_offset) * SPI_FLASH_MMU_PAGE_SIZE)); /* Read the image that fits in the free MMU pages */
|
||||
|
||||
const void * image = bootloader_mmap(flash_offset, partial_image_len);
|
||||
if (image == NULL) {
|
||||
bootloader_sha256_finish(sha_handle, NULL);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
bootloader_sha256_data(sha_handle, image, partial_image_len);
|
||||
bootloader_munmap(image);
|
||||
|
||||
flash_offset += partial_image_len;
|
||||
len -= partial_image_len;
|
||||
}
|
||||
bootloader_sha256_finish(sha_handle, digest);
|
||||
return ESP_OK;
|
||||
}
|
|
@ -293,6 +293,7 @@ if(CONFIG_BT_ENABLED)
|
|||
if(CONFIG_BLE_MESH)
|
||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS
|
||||
"esp_ble_mesh/mesh_common/include"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/include"
|
||||
"esp_ble_mesh/mesh_core"
|
||||
"esp_ble_mesh/mesh_core/include"
|
||||
"esp_ble_mesh/mesh_core/storage"
|
||||
|
@ -325,7 +326,21 @@ if(CONFIG_BT_ENABLED)
|
|||
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_aes_encrypt.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/utils.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_atomic.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_buf.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_common.c"
|
||||
|
@ -340,6 +355,7 @@ if(CONFIG_BT_ENABLED)
|
|||
"esp_ble_mesh/mesh_core/cfg_cli.c"
|
||||
"esp_ble_mesh/mesh_core/cfg_srv.c"
|
||||
"esp_ble_mesh/mesh_core/crypto.c"
|
||||
"esp_ble_mesh/mesh_core/fast_prov.c"
|
||||
"esp_ble_mesh/mesh_core/friend.c"
|
||||
"esp_ble_mesh/mesh_core/health_cli.c"
|
||||
"esp_ble_mesh/mesh_core/health_srv.c"
|
||||
|
@ -355,12 +371,12 @@ if(CONFIG_BT_ENABLED)
|
|||
"esp_ble_mesh/mesh_core/settings.c"
|
||||
"esp_ble_mesh/mesh_core/test.c"
|
||||
"esp_ble_mesh/mesh_core/transport.c"
|
||||
"esp_ble_mesh/mesh_models/common/device_property.c"
|
||||
"esp_ble_mesh/mesh_models/client/client_common.c"
|
||||
"esp_ble_mesh/mesh_models/client/generic_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/lighting_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/sensor_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/time_scene_client.c"
|
||||
"esp_ble_mesh/mesh_models/server/device_property.c"
|
||||
"esp_ble_mesh/mesh_models/server/generic_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/lighting_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/sensor_server.c"
|
||||
|
|
|
@ -89,6 +89,19 @@ menu Bluetooth
|
|||
default BTDM_CTRL_AUTO_LATENCY if BTDM_CONTROLLER_MODE_BTDM
|
||||
default n
|
||||
|
||||
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT
|
||||
bool "Legacy Authentication Vendor Specific Event Enable"
|
||||
depends on BTDM_CONTROLLER_MODE_BR_EDR_ONLY || BTDM_CONTROLLER_MODE_BTDM
|
||||
default y
|
||||
help
|
||||
To protect from BIAS attack during Legacy authentication,
|
||||
Legacy authentication Vendor specific event should be enabled
|
||||
|
||||
|
||||
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF
|
||||
bool
|
||||
default BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT if BTDM_CONTROLLER_MODE_BR_EDR_ONLY || BTDM_CONTROLLER_MODE_BTDM
|
||||
default 0
|
||||
|
||||
config BTDM_CONTROLLER_BLE_MAX_CONN_EFF
|
||||
int
|
||||
|
@ -1725,12 +1738,65 @@ if BLE_MESH
|
|||
option in the Bluetooth Controller section in menuconfig, which is
|
||||
"Scan Duplicate By Device Address and Advertising Data".
|
||||
|
||||
config BLE_MESH_ALLOC_FROM_PSRAM_FIRST
|
||||
bool "BLE Mesh will first allocate memory from PSRAM"
|
||||
choice BLE_MESH_MEM_ALLOC_MODE
|
||||
prompt "Memory allocation strategy"
|
||||
default BLE_MESH_MEM_ALLOC_MODE_INTERNAL
|
||||
help
|
||||
Allocation strategy for BLE Mesh stack, essentially provides ability to
|
||||
allocate all required dynamic allocations from,
|
||||
|
||||
- Internal DRAM memory only
|
||||
- External SPIRAM memory only
|
||||
- Either internal or external memory based on default malloc()
|
||||
behavior in ESP-IDF
|
||||
|
||||
Recommended mode here is always internal, since that is most preferred
|
||||
from security perspective. But if application requirement does not allow
|
||||
sufficient free internal memory then alternate mode can be selected.
|
||||
|
||||
config BLE_MESH_MEM_ALLOC_MODE_INTERNAL
|
||||
bool "Internal DRAM"
|
||||
|
||||
config BLE_MESH_ALLOC_FROM_PSRAM_FIRST
|
||||
bool "External SPIRAM"
|
||||
depends on SPIRAM_SUPPORT
|
||||
|
||||
config BLE_MESH_MEM_ALLOC_MODE_DEFAULT
|
||||
bool "Default alloc mode"
|
||||
depends on SPIRAM_SUPPORT
|
||||
help
|
||||
Enable this option to use the default memory allocation strategy when
|
||||
external SPIRAM is enabled. See the SPIRAM options for more details.
|
||||
|
||||
endchoice # BLE_MESH_MEM_ALLOC_MODE
|
||||
|
||||
config BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
bool "Enable FreeRTOS static allocation"
|
||||
depends on SUPPORT_STATIC_ALLOCATION && SPIRAM_SUPPORT
|
||||
default n
|
||||
help
|
||||
When this option is enabled, BLE Mesh stack will try to allocate memory
|
||||
from PSRAM firstly. This will save the internal RAM if PSRAM exists.
|
||||
Enable this option to use FreeRTOS static allocation APIs for BLE Mesh,
|
||||
which provides the ability to use different dynamic memory (i.e. SPIRAM)
|
||||
for FreeRTOS objects.
|
||||
If this option is disabled, the FreeRTOS static allocation APIs will not
|
||||
be used, and internal DRAM will be allocated for FreeRTOS objects.
|
||||
|
||||
choice BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
|
||||
prompt "Memory allocation for FreeRTOS objects"
|
||||
depends on BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
help
|
||||
Choose the memory to be used for FreeRTOS objects.
|
||||
|
||||
config BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||
bool "External SPIRAM"
|
||||
depends on SPIRAM_SUPPORT
|
||||
help
|
||||
If enabled, BLE Mesh allocates dynamic memory from external SPIRAM for
|
||||
FreeRTOS objects, i.e. mutex, queue, and task stack. External SPIRAM
|
||||
can only be used for task stack when SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
is enabled. See the SPIRAM options for more details.
|
||||
|
||||
endchoice # BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
|
||||
|
||||
config BLE_MESH_FAST_PROV
|
||||
bool "Enable BLE Mesh Fast Provisioning"
|
||||
|
@ -1906,7 +1972,7 @@ if BLE_MESH
|
|||
advertising bearer.
|
||||
|
||||
config BLE_MESH_NET_BUF_POOL_USAGE
|
||||
bool "BLE Mesh net buffer pool usage tracking"
|
||||
bool
|
||||
default y
|
||||
help
|
||||
Enable BLE Mesh net buffer pool tracking. This option is used to introduce another
|
||||
|
@ -1964,7 +2030,7 @@ if BLE_MESH
|
|||
config BLE_MESH_SEQ_STORE_RATE
|
||||
int "How often the sequence number gets updated in storage"
|
||||
range 0 1000000
|
||||
default 6
|
||||
default 0
|
||||
help
|
||||
This value defines how often the local sequence number gets updated in
|
||||
persistent storage (i.e. flash). e.g. a value of 100 means that the
|
||||
|
@ -1979,7 +2045,7 @@ if BLE_MESH
|
|||
config BLE_MESH_RPL_STORE_TIMEOUT
|
||||
int "Minimum frequency that the RPL gets updated in storage"
|
||||
range 0 1000000
|
||||
default 5
|
||||
default 0
|
||||
help
|
||||
This value defines in seconds how soon the RPL (Replay Protection List)
|
||||
gets written to persistent storage after a change occurs. If the node
|
||||
|
|
|
@ -213,7 +213,7 @@ esp_err_t esp_bt_gap_remove_bond_device(esp_bd_addr_t bd_addr)
|
|||
int esp_bt_gap_get_bond_device_num(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_FAIL;
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
return btc_storage_get_num_bt_bond_devices();
|
||||
}
|
||||
|
@ -221,7 +221,6 @@ int esp_bt_gap_get_bond_device_num(void)
|
|||
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
|
||||
{
|
||||
int ret;
|
||||
int dev_num_total;
|
||||
|
||||
if (dev_num == NULL || dev_list == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
|
@ -231,12 +230,7 @@ esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
|
|||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
dev_num_total = btc_storage_get_num_bt_bond_devices();
|
||||
if (*dev_num > dev_num_total) {
|
||||
*dev_num = dev_num_total;
|
||||
}
|
||||
|
||||
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, *dev_num);
|
||||
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, dev_num);
|
||||
|
||||
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
|
|
@ -50,9 +50,33 @@ esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
|
|||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern uint16_t L2CA_GetFreePktBufferNum_LE(void);
|
||||
/**
|
||||
* @brief This function is called to get currently sendable packets number on controller,
|
||||
* the function is called only in BLE running core and single connection now.
|
||||
*
|
||||
* @return
|
||||
* sendable packets number on controller
|
||||
*
|
||||
*/
|
||||
|
||||
uint16_t esp_ble_get_sendable_packets_num ()
|
||||
uint16_t esp_ble_get_sendable_packets_num (void)
|
||||
{
|
||||
return L2CA_GetFreePktBufferNum_LE();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function is used to query the number of available buffers for the current connection.
|
||||
* When you need to query the current available buffer number, it is recommended to use this API.
|
||||
* @param[in] conn_id: current connection id.
|
||||
*
|
||||
* @return
|
||||
* Number of available buffers for the current connection
|
||||
*
|
||||
*/
|
||||
extern UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id);
|
||||
uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid)
|
||||
{
|
||||
return L2CA_GetCurFreePktBufferNum_LE(connid);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -431,6 +431,9 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if,
|
|||
arg.write_char.value = value;
|
||||
arg.write_char.write_type = write_type;
|
||||
arg.write_char.auth_req = auth_req;
|
||||
if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
@ -462,6 +465,10 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
|||
arg.write_descr.write_type = write_type;
|
||||
arg.write_descr.auth_req = auth_req;
|
||||
|
||||
if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
|
|
@ -274,6 +274,9 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
|
|||
arg.send_ind.value_len = value_len;
|
||||
arg.send_ind.value = value;
|
||||
|
||||
if(need_confirm == false){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
|
||||
}
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t),
|
||||
btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
|
|
@ -154,6 +154,17 @@ esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
|
|||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_stop_srv(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_STOP_SRV;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data)
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ typedef enum {
|
|||
|
||||
/// A2DP media control commands
|
||||
typedef enum {
|
||||
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< dummy command */
|
||||
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< Not for application use, use inside stack only. */
|
||||
ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY, /*!< check whether AVDTP is connected, only used in A2DP source */
|
||||
ESP_A2D_MEDIA_CTRL_START, /*!< command to set up media transmission channel */
|
||||
ESP_A2D_MEDIA_CTRL_STOP, /*!< command to stop media transmission */
|
||||
|
|
|
@ -174,6 +174,7 @@ typedef enum {
|
|||
ESP_BT_GAP_KEY_NOTIF_EVT, /*!< Simple Pairing Passkey Notification */
|
||||
ESP_BT_GAP_KEY_REQ_EVT, /*!< Simple Pairing Passkey request */
|
||||
ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */
|
||||
ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< remove bond device complete event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
|
@ -271,6 +272,14 @@ typedef union {
|
|||
struct key_req_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
} key_req; /*!< passkey request parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT
|
||||
*/
|
||||
struct bt_remove_bond_dev_cmpl_evt_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */
|
||||
}remove_bond_dev_cmpl; /*!< Event parameter of ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,6 +46,7 @@ extern esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu);
|
|||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern uint16_t esp_ble_get_sendable_packets_num (void);
|
||||
extern uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -57,6 +57,7 @@ typedef enum {
|
|||
*/
|
||||
typedef enum {
|
||||
ESP_SPP_INIT_EVT = 0, /*!< When SPP is inited, the event comes */
|
||||
ESP_SPP_UNINIT_EVT = 1, /*!< When SPP is uninited, the event comes */
|
||||
ESP_SPP_DISCOVERY_COMP_EVT = 8, /*!< When SDP discovery complete, the event comes */
|
||||
ESP_SPP_OPEN_EVT = 26, /*!< When SPP Client connection open, the event comes */
|
||||
ESP_SPP_CLOSE_EVT = 27, /*!< When SPP connection closed, the event comes */
|
||||
|
@ -66,6 +67,7 @@ typedef enum {
|
|||
ESP_SPP_CONG_EVT = 31, /*!< When SPP connection congestion status changed, the event comes, only for ESP_SPP_MODE_CB */
|
||||
ESP_SPP_WRITE_EVT = 33, /*!< When SPP write operation completes, the event comes, only for ESP_SPP_MODE_CB */
|
||||
ESP_SPP_SRV_OPEN_EVT = 34, /*!< When SPP Server connection open, the event comes */
|
||||
ESP_SPP_SRV_STOP_EVT = 35, /*!< When SPP server stopped, the event comes */
|
||||
} esp_spp_cb_event_t;
|
||||
|
||||
|
||||
|
@ -80,6 +82,13 @@ typedef union {
|
|||
esp_spp_status_t status; /*!< status */
|
||||
} init; /*!< SPP callback param of SPP_INIT_EVT */
|
||||
|
||||
/**
|
||||
* @brief SPP_UNINIT_EVT
|
||||
*/
|
||||
struct spp_uninit_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
} uninit; /*!< SPP callback param of SPP_UNINIT_EVT */
|
||||
|
||||
/**
|
||||
* @brief SPP_DISCOVERY_COMP_EVT
|
||||
*/
|
||||
|
@ -128,6 +137,14 @@ typedef union {
|
|||
uint8_t sec_id; /*!< security ID used by this server */
|
||||
bool use_co; /*!< TRUE to use co_rfc_data */
|
||||
} start; /*!< SPP callback param of ESP_SPP_START_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_SRV_STOP_EVT
|
||||
*/
|
||||
struct spp_srv_stop_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
} srv_stop; /*!< SPP callback param of ESP_SPP_SRV_STOP_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_CL_INIT_EVT
|
||||
*/
|
||||
|
@ -273,6 +290,16 @@ esp_err_t esp_spp_disconnect(uint32_t handle);
|
|||
esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
|
||||
esp_spp_role_t role, uint8_t local_scn, const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function stops a SPP server
|
||||
* When the server is stopped successfully, the callback is called
|
||||
* with ESP_SPP_SRV_STOP_EVT.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_stop_srv(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to write data, only for ESP_SPP_MODE_CB.
|
||||
|
|
|
@ -61,7 +61,7 @@ static void bta_dm_sdp_callback (UINT16 sdp_status);
|
|||
#if (SMP_INCLUDED == TRUE)
|
||||
static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, UINT8 *service_name, UINT8 service_id, BOOLEAN is_originator);
|
||||
static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, BOOLEAN min_16_digit);
|
||||
static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, LINK_KEY key, UINT8 key_type);
|
||||
static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, LINK_KEY key, UINT8 key_type, BOOLEAN sc_support);
|
||||
static UINT8 bta_dm_authentication_complete_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, int result);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
static void bta_dm_local_name_cback(BD_ADDR bd_addr);
|
||||
|
@ -610,7 +610,7 @@ void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data)
|
|||
}
|
||||
}
|
||||
|
||||
void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data)
|
||||
void bta_dm_read_rssi(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
if (p_data->rssi.read_rssi_cb != NULL) {
|
||||
BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.transport, p_data->rssi.read_rssi_cb);
|
||||
|
@ -756,11 +756,13 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data)
|
|||
/* Take the link down first, and mark the device for removal when disconnected */
|
||||
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr)
|
||||
&& bta_dm_cb.device_list.peer_device[i].transport == transport) {
|
||||
#if BLE_INCLUDED == TRUE
|
||||
&& bta_dm_cb.device_list.peer_device[i].transport == transport
|
||||
#endif
|
||||
) {
|
||||
bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING;
|
||||
btm_remove_acl( p_dev->bd_addr, bta_dm_cb.device_list.peer_device[i].transport);
|
||||
APPL_TRACE_DEBUG("%s:transport = %d", __func__,
|
||||
bta_dm_cb.device_list.peer_device[i].transport);
|
||||
btm_remove_acl( p_dev->bd_addr, transport);
|
||||
APPL_TRACE_DEBUG("%s:transport = %d", __func__, transport);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -822,7 +824,7 @@ void bta_dm_add_device (tBTA_DM_MSG *p_data)
|
|||
|
||||
if (!BTM_SecAddDevice (p_dev->bd_addr, p_dc, p_dev->bd_name, p_dev->features,
|
||||
trusted_services_mask, p_lc, p_dev->key_type, p_dev->io_cap,
|
||||
p_dev->pin_length)) {
|
||||
p_dev->pin_length, p_dev->sc_support)) {
|
||||
APPL_TRACE_ERROR ("BTA_DM: Error adding device %08x%04x",
|
||||
(p_dev->bd_addr[0] << 24) + (p_dev->bd_addr[1] << 16) + (p_dev->bd_addr[2] << 8) + p_dev->bd_addr[3],
|
||||
(p_dev->bd_addr[4] << 8) + p_dev->bd_addr[5]);
|
||||
|
@ -2784,7 +2786,8 @@ static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_
|
|||
**
|
||||
*******************************************************************************/
|
||||
static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class,
|
||||
BD_NAME bd_name, LINK_KEY key, UINT8 key_type)
|
||||
BD_NAME bd_name, LINK_KEY key, UINT8 key_type,
|
||||
BOOLEAN sc_support)
|
||||
{
|
||||
tBTA_DM_SEC sec_event;
|
||||
tBTA_DM_AUTH_CMPL *p_auth_cmpl;
|
||||
|
@ -2806,6 +2809,7 @@ static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class,
|
|||
p_auth_cmpl->key_present = TRUE;
|
||||
p_auth_cmpl->key_type = key_type;
|
||||
p_auth_cmpl->success = TRUE;
|
||||
p_auth_cmpl->sc_support = sc_support;
|
||||
|
||||
memcpy(p_auth_cmpl->key, key, LINK_KEY_LEN);
|
||||
sec_event.auth_cmpl.fail_reason = HCI_SUCCESS;
|
||||
|
@ -3083,6 +3087,7 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data)
|
|||
|
||||
switch (p_msg->event) {
|
||||
case BTM_BL_CONN_EVT:
|
||||
p_msg->sc_downgrade = p_data->conn.sc_downgrade;
|
||||
p_msg->is_new = TRUE;
|
||||
bdcpy(p_msg->bd_addr, p_data->conn.p_bda);
|
||||
#if BLE_INCLUDED == TRUE
|
||||
|
@ -3309,6 +3314,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
|
|||
APPL_TRACE_DEBUG("%s info: 0x%x", __func__, bta_dm_cb.device_list.peer_device[i].info);
|
||||
|
||||
if (bta_dm_cb.p_sec_cback) {
|
||||
conn.link_up.sc_downgrade = p_data->acl_change.sc_downgrade;
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_LINK_UP_EVT, (tBTA_DM_SEC *)&conn);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -206,11 +206,11 @@ void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb)
|
|||
}
|
||||
}
|
||||
|
||||
void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb)
|
||||
void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb)
|
||||
{
|
||||
tBTA_DM_API_READ_RSSI *p_msg;
|
||||
if ((p_msg = (tBTA_DM_API_READ_RSSI *)osi_malloc(sizeof(tBTA_DM_API_READ_RSSI))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_READ_RSSI_EVT;
|
||||
p_msg->hdr.event = BTA_DM_API_READ_RSSI_EVT;
|
||||
memcpy(p_msg->remote_addr, remote_addr, sizeof(BD_ADDR));
|
||||
p_msg->transport = transport;
|
||||
p_msg->read_rssi_cb = cmpl_cb;
|
||||
|
@ -586,6 +586,7 @@ void BTA_DmPasskeyReqReply(BOOLEAN accept, BD_ADDR bd_addr, UINT32 passkey)
|
|||
}
|
||||
}
|
||||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmAddDevice
|
||||
|
@ -599,7 +600,8 @@ void BTA_DmPasskeyReqReply(BOOLEAN accept, BD_ADDR bd_addr, UINT32 passkey)
|
|||
*******************************************************************************/
|
||||
void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key,
|
||||
tBTA_SERVICE_MASK trusted_mask, BOOLEAN is_trusted,
|
||||
UINT8 key_type, tBTA_IO_CAP io_cap, UINT8 pin_length)
|
||||
UINT8 key_type, tBTA_IO_CAP io_cap, UINT8 pin_length,
|
||||
UINT8 sc_support)
|
||||
{
|
||||
|
||||
tBTA_DM_API_ADD_DEVICE *p_msg;
|
||||
|
@ -612,6 +614,7 @@ void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key,
|
|||
p_msg->tm = trusted_mask;
|
||||
p_msg->is_trusted = is_trusted;
|
||||
p_msg->io_cap = io_cap;
|
||||
p_msg->sc_support = sc_support;
|
||||
|
||||
if (link_key) {
|
||||
p_msg->link_key_known = TRUE;
|
||||
|
@ -662,7 +665,6 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr, tBT_TRANSPORT transport)
|
|||
|
||||
return BTA_SUCCESS;
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
|
|
@ -159,7 +159,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
|||
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
|
||||
bta_dm_update_white_list, /* BTA_DM_API_UPDATE_WHITE_LIST_EVT */
|
||||
bta_dm_ble_read_adv_tx_power, /* BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT */
|
||||
bta_dm_ble_read_rssi, /* BTA_DM_API_BLE_READ_RSSI_EVT */
|
||||
bta_dm_read_rssi, /* BTA_DM_API_READ_RSSI_EVT */
|
||||
bta_dm_ble_update_duplicate_exceptional_list,/* BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT */
|
||||
};
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ enum {
|
|||
BTA_DM_API_REMOVE_DEVICE_EVT,
|
||||
BTA_DM_API_UPDATE_WHITE_LIST_EVT,
|
||||
BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT,
|
||||
BTA_DM_API_BLE_READ_RSSI_EVT,
|
||||
BTA_DM_API_READ_RSSI_EVT,
|
||||
BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT,
|
||||
BTA_DM_MAX_EVT
|
||||
};
|
||||
|
@ -384,6 +384,7 @@ typedef struct {
|
|||
UINT8 new_role;
|
||||
BD_ADDR bd_addr;
|
||||
UINT8 hci_status;
|
||||
BOOLEAN sc_downgrade;
|
||||
#if BLE_INCLUDED == TRUE
|
||||
UINT16 handle;
|
||||
tBT_TRANSPORT transport;
|
||||
|
@ -425,6 +426,7 @@ typedef struct {
|
|||
BD_NAME bd_name;
|
||||
UINT8 features[BTA_FEATURE_BYTES_PER_PAGE * (BTA_EXT_FEATURES_PAGE_MAX + 1)];
|
||||
UINT8 pin_length;
|
||||
UINT8 sc_support;
|
||||
} tBTA_DM_API_ADD_DEVICE;
|
||||
|
||||
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
|
||||
|
@ -1224,7 +1226,7 @@ extern void bta_dm_disable (tBTA_DM_MSG *p_data);
|
|||
extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_update_white_list(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_read_rssi(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_visibility (tBTA_DM_MSG *p_data);
|
||||
|
||||
extern void bta_dm_set_scan_config(tBTA_DM_MSG *p_data);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
#include "bta_gattc_int.h"
|
||||
|
||||
#include "stack/l2c_api.h"
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
@ -603,6 +603,10 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
|
|||
memcpy(p_buf->p_value, p_value, len);
|
||||
}
|
||||
|
||||
if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
return;
|
||||
|
@ -650,6 +654,10 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
|
|||
memcpy(p_buf->p_value, p_data->p_value, p_data->len);
|
||||
}
|
||||
|
||||
if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "stack/btm_ble_api.h"
|
||||
#include <string.h>
|
||||
#include "osi/allocator.h"
|
||||
#include "stack/l2c_api.h"
|
||||
|
||||
static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
|
||||
static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req,
|
||||
|
@ -672,6 +673,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
|||
p_msg->api_indicate.len,
|
||||
p_msg->api_indicate.value);
|
||||
} else {
|
||||
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTU_NUM, NULL);
|
||||
status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
|
||||
p_msg->api_indicate.attr_id,
|
||||
p_msg->api_indicate.len,
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "bta/bta_gatt_api.h"
|
||||
#include "bta_gatts_int.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include "stack/l2c_api.h"
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
@ -426,6 +426,11 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat
|
|||
memcpy(p_buf->value, p_data, data_len);
|
||||
|
||||
}
|
||||
|
||||
if(need_confirm == false){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -769,6 +769,7 @@ typedef struct {
|
|||
tBLE_ADDR_TYPE addr_type; /* Peer device address type */
|
||||
tBT_DEVICE_TYPE dev_type;
|
||||
UINT8 auth_mode;
|
||||
BOOLEAN sc_support; /* Denotes if peer device supported secure connection while bonding. */
|
||||
} tBTA_DM_AUTH_CMPL;
|
||||
|
||||
|
||||
|
@ -784,6 +785,7 @@ typedef struct {
|
|||
|
||||
/* Structure associated with BTA_DM_LINK_UP_EVT */
|
||||
typedef struct {
|
||||
BOOLEAN sc_downgrade; /* Security downgrade state. */
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTA_TRANSPORT link_type;
|
||||
|
@ -924,7 +926,7 @@ typedef union {
|
|||
tBTA_DM_PIN_REQ pin_req; /* PIN request. */
|
||||
tBTA_DM_AUTH_CMPL auth_cmpl; /* Authentication complete indication. */
|
||||
tBTA_DM_AUTHORIZE authorize; /* Authorization request. */
|
||||
tBTA_DM_LINK_UP link_up; /* ACL connection down event */
|
||||
tBTA_DM_LINK_UP link_up; /* ACL connection up event */
|
||||
tBTA_DM_LINK_DOWN link_down; /* ACL connection down event */
|
||||
tBTA_DM_BUSY_LEVEL busy_level; /* System busy level */
|
||||
tBTA_DM_SP_CFM_REQ cfm_req; /* user confirm request */
|
||||
|
@ -1455,7 +1457,7 @@ extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA
|
|||
|
||||
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
|
||||
|
||||
extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
|
||||
extern void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -1684,7 +1686,8 @@ extern void BTA_DmPasskeyReqReply(BOOLEAN accept, BD_ADDR bd_addr, UINT32 passke
|
|||
extern void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class,
|
||||
LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask,
|
||||
BOOLEAN is_trusted, UINT8 key_type,
|
||||
tBTA_IO_CAP io_cap, UINT8 pin_length);
|
||||
tBTA_IO_CAP io_cap, UINT8 pin_length,
|
||||
UINT8 sc_support);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -2293,8 +2296,8 @@ extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_l
|
|||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
|
||||
BD_ADDR device_info,
|
||||
extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
|
||||
BD_ADDR device_info,
|
||||
tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_exceptional_list_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -129,11 +129,13 @@ typedef UINT8 tBTA_JV_CONN_STATE;
|
|||
/* Java I/F callback events */
|
||||
/* events received by tBTA_JV_DM_CBACK */
|
||||
#define BTA_JV_ENABLE_EVT 0 /* JV enabled */
|
||||
#define BTA_JV_DISABLE_EVT 1 /* JV disabled */
|
||||
#define BTA_JV_GET_SCN_EVT 6 /* Reserved an SCN */
|
||||
#define BTA_JV_GET_PSM_EVT 7 /* Reserved a PSM */
|
||||
#define BTA_JV_DISCOVERY_COMP_EVT 8 /* SDP discovery complete */
|
||||
#define BTA_JV_CREATE_RECORD_EVT 11 /* the result for BTA_JvCreateRecord */
|
||||
/* events received by tBTA_JV_L2CAP_CBACK */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
#define BTA_JV_L2CAP_OPEN_EVT 16 /* open status of L2CAP connection */
|
||||
#define BTA_JV_L2CAP_CLOSE_EVT 17 /* L2CAP connection closed */
|
||||
#define BTA_JV_L2CAP_START_EVT 18 /* L2CAP server started */
|
||||
|
@ -144,6 +146,7 @@ typedef UINT8 tBTA_JV_CONN_STATE;
|
|||
#define BTA_JV_L2CAP_RECEIVE_EVT 23 /* the result for BTA_JvL2capReceive*/
|
||||
#define BTA_JV_L2CAP_WRITE_EVT 24 /* the result for BTA_JvL2capWrite*/
|
||||
#define BTA_JV_L2CAP_WRITE_FIXED_EVT 25 /* the result for BTA_JvL2capWriteFixed */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/* events received by tBTA_JV_RFCOMM_CBACK */
|
||||
#define BTA_JV_RFCOMM_OPEN_EVT 26 /* open status of RFCOMM Client connection */
|
||||
|
@ -155,7 +158,8 @@ typedef UINT8 tBTA_JV_CONN_STATE;
|
|||
#define BTA_JV_RFCOMM_READ_EVT 32 /* the result for BTA_JvRfcommRead */
|
||||
#define BTA_JV_RFCOMM_WRITE_EVT 33 /* the result for BTA_JvRfcommWrite*/
|
||||
#define BTA_JV_RFCOMM_SRV_OPEN_EVT 34 /* open status of Server RFCOMM connection */
|
||||
#define BTA_JV_MAX_EVT 35 /* max number of JV events */
|
||||
#define BTA_JV_FREE_SCN_EVT 35 /* FREE an SCN */
|
||||
#define BTA_JV_MAX_EVT 36 /* max number of JV events */
|
||||
|
||||
typedef UINT16 tBTA_JV_EVT;
|
||||
|
||||
|
@ -178,6 +182,7 @@ typedef struct {
|
|||
UINT32 handle; /* The SDP handle */
|
||||
} tBTA_JV_CREATE_RECORD;
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/* data associated with BTA_JV_L2CAP_OPEN_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
|
@ -186,18 +191,6 @@ typedef struct {
|
|||
INT32 tx_mtu; /* The transmit MTU */
|
||||
} tBTA_JV_L2CAP_OPEN;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
INT32 tx_mtu; /* The transmit MTU */
|
||||
void **p_p_cback; /* set them for new socket */
|
||||
void **p_user_data;/* set them for new socket */
|
||||
|
||||
} tBTA_JV_L2CAP_LE_OPEN;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_CLOSE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
|
@ -255,6 +248,22 @@ typedef struct {
|
|||
BOOLEAN cong; /* congestion status */
|
||||
} tBTA_JV_L2CAP_WRITE;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
INT32 tx_mtu; /* The transmit MTU */
|
||||
void **p_p_cback; /* set them for new socket */
|
||||
void **p_user_data;/* set them for new socket */
|
||||
|
||||
} tBTA_JV_L2CAP_LE_OPEN;
|
||||
|
||||
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
|
||||
typedef struct {
|
||||
UINT32 handle; /* The connection handle */
|
||||
BT_HDR *p_buf; /* The incoming data */
|
||||
} tBTA_JV_LE_DATA_IND;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_WRITE_FIXED_EVT */
|
||||
typedef struct {
|
||||
|
@ -265,6 +274,7 @@ typedef struct {
|
|||
UINT16 len; /* The length of the data written. */
|
||||
BOOLEAN cong; /* congestion status */
|
||||
} tBTA_JV_L2CAP_WRITE_FIXED;
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_OPEN_EVT */
|
||||
typedef struct {
|
||||
|
@ -272,6 +282,7 @@ typedef struct {
|
|||
UINT32 handle; /* The connection handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
} tBTA_JV_RFCOMM_OPEN;
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
|
@ -280,7 +291,6 @@ typedef struct {
|
|||
BD_ADDR rem_bda; /* The peer address */
|
||||
} tBTA_JV_RFCOMM_SRV_OPEN;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_CLOSE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
|
@ -304,19 +314,13 @@ typedef struct {
|
|||
UINT8 sec_id; /* security ID used by this client */
|
||||
BOOLEAN use_co; /* TRUE to use co_rfc_data */
|
||||
} tBTA_JV_RFCOMM_CL_INIT;
|
||||
|
||||
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */
|
||||
typedef struct {
|
||||
UINT32 handle; /* The connection handle */
|
||||
BT_HDR *p_buf; /* The incoming data */
|
||||
} tBTA_JV_DATA_IND;
|
||||
|
||||
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
|
||||
typedef struct {
|
||||
UINT32 handle; /* The connection handle */
|
||||
BT_HDR *p_buf; /* The incoming data */
|
||||
} tBTA_JV_LE_DATA_IND;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_CONG_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
|
@ -356,6 +360,23 @@ typedef struct {
|
|||
tBTA_JV_CONN_STATE state; /* JV connection stata */
|
||||
} tBTA_JV_NOTIFY_PM_STATE_CHANGE;
|
||||
|
||||
/* indicate server at which status */
|
||||
typedef enum {
|
||||
BTA_JV_SERVER_START_FAILED,
|
||||
BTA_JV_SERVER_RUNNING,
|
||||
BTA_JV_SERVER_STATUS_MAX,
|
||||
} tBTA_JV_SERVER_STATUS;
|
||||
|
||||
typedef struct {
|
||||
tBTA_JV_SERVER_STATUS server_status;
|
||||
UINT32 slot_id;
|
||||
}tBTA_JV_FREE_SCN_USER_DATA;
|
||||
|
||||
/* data associated with BTA_JV_FREE_SCN_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Status of the operation */
|
||||
tBTA_JV_SERVER_STATUS server_status;
|
||||
} tBTA_JV_FREE_SCN;
|
||||
|
||||
/* union of data associated with JV callback */
|
||||
typedef union {
|
||||
|
@ -365,6 +386,7 @@ typedef union {
|
|||
UINT8 scn; /* BTA_JV_GET_SCN_EVT */
|
||||
UINT16 psm; /* BTA_JV_GET_PSM_EVT */
|
||||
tBTA_JV_CREATE_RECORD create_rec; /* BTA_JV_CREATE_RECORD_EVT */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
tBTA_JV_L2CAP_OPEN l2c_open; /* BTA_JV_L2CAP_OPEN_EVT */
|
||||
tBTA_JV_L2CAP_CLOSE l2c_close; /* BTA_JV_L2CAP_CLOSE_EVT */
|
||||
tBTA_JV_L2CAP_START l2c_start; /* BTA_JV_L2CAP_START_EVT */
|
||||
|
@ -372,6 +394,7 @@ typedef union {
|
|||
tBTA_JV_L2CAP_CONG l2c_cong; /* BTA_JV_L2CAP_CONG_EVT */
|
||||
tBTA_JV_L2CAP_READ l2c_read; /* BTA_JV_L2CAP_READ_EVT */
|
||||
tBTA_JV_L2CAP_WRITE l2c_write; /* BTA_JV_L2CAP_WRITE_EVT */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
tBTA_JV_RFCOMM_OPEN rfc_open; /* BTA_JV_RFCOMM_OPEN_EVT */
|
||||
tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open; /* BTA_JV_RFCOMM_SRV_OPEN_EVT */
|
||||
tBTA_JV_RFCOMM_CLOSE rfc_close; /* BTA_JV_RFCOMM_CLOSE_EVT */
|
||||
|
@ -382,9 +405,12 @@ typedef union {
|
|||
tBTA_JV_RFCOMM_WRITE rfc_write; /* BTA_JV_RFCOMM_WRITE_EVT */
|
||||
tBTA_JV_DATA_IND data_ind; /* BTA_JV_L2CAP_DATA_IND_EVT
|
||||
BTA_JV_RFCOMM_DATA_IND_EVT */
|
||||
tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
|
||||
tBTA_JV_FREE_SCN free_scn; /* BTA_JV_FREE_SCN_EVT */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
tBTA_JV_L2CAP_LE_OPEN l2c_le_open; /* BTA_JV_L2CAP_OPEN_EVT */
|
||||
tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
|
||||
tBTA_JV_L2CAP_WRITE_FIXED l2c_write_fixed; /* BTA_JV_L2CAP_WRITE_FIXED_EVT */
|
||||
#endif
|
||||
} tBTA_JV;
|
||||
|
||||
/* JAVA DM Interface callback */
|
||||
|
@ -393,8 +419,10 @@ typedef void (tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d
|
|||
/* JAVA RFCOMM interface callback */
|
||||
typedef void *(tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data);
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/* JAVA L2CAP interface callback */
|
||||
typedef void (tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_Data);
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/* JV configuration structure */
|
||||
typedef struct {
|
||||
|
@ -424,12 +452,25 @@ extern tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback);
|
|||
**
|
||||
** Function BTA_JvDisable
|
||||
**
|
||||
** Description Disable the Java I/F
|
||||
** Description Disable the Java I/F. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_JV_DISABLE_EVT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_JvDisable(void);
|
||||
extern void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvFree
|
||||
**
|
||||
** Description Free JV configuration
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_JvFree(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -484,12 +525,17 @@ extern tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data,
|
|||
**
|
||||
** Description This function frees a SCN/PSM that was used
|
||||
** by an application running over RFCOMM or L2CAP.
|
||||
** Parameters
|
||||
** channel The channel to free
|
||||
** conn_type one of BTA_JV_CONN_TYPE_
|
||||
** p_cback tBTA_JV_RFCOMM_CBACK is called with BTA_JV_FREE_SCN_EVT when server frees a SCN/PSM
|
||||
** user_data indicate the RFCOMM server status
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type);
|
||||
extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -532,6 +578,7 @@ extern tBTA_JV_STATUS BTA_JvCreateRecordByUser(const char *name, UINT32 channel,
|
|||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle);
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capConnectLE
|
||||
|
@ -739,6 +786,7 @@ extern tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id,
|
|||
extern tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id,
|
||||
tBTA_JV_L2CAP_CBACK *p_cback,
|
||||
UINT8 *p_data, UINT16 len, void *user_data);
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -769,7 +817,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
|
|||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -786,9 +834,9 @@ extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data);
|
|||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask,
|
||||
tBTA_JV_ROLE role, UINT8 local_scn, UINT8 max_session,
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
|
||||
UINT8 local_scn, UINT8 max_session,
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -815,8 +863,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void *user_data);
|
|||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id,
|
||||
UINT8 *p_data, UINT16 len);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -843,7 +890,6 @@ extern tBTA_JV_STATUS BTA_JvRfcommReady(UINT32 handle, UINT32 *p_data_size);
|
|||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
// extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -865,8 +911,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, U
|
|||
** BTA_JV_CONN_CLOSE to remove in case of connection close!
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id,
|
||||
tBTA_JV_CONN_STATE init_st);
|
||||
extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_STATE init_st);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
|
||||
|
||||
#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE)
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/* one of these exists for each client */
|
||||
struct fc_client {
|
||||
struct fc_client *next_all_list;
|
||||
|
@ -92,11 +93,10 @@ static void __attribute__((unused)) fc_init(void)
|
|||
pthread_once(&fc_init_once, fc_init_work);
|
||||
}
|
||||
|
||||
|
||||
static void fcchan_conn_chng_cbk(UINT16 chan, BD_ADDR bd_addr, BOOLEAN connected,
|
||||
UINT16 reason, tBT_TRANSPORT );
|
||||
static void fcchan_data_cbk(UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf);
|
||||
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
extern void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str);
|
||||
static inline void logu(const char *title, const uint8_t *p_uuid)
|
||||
|
@ -114,6 +114,10 @@ static void bta_jv_pm_conn_idle(tBTA_JV_PM_CB *p_cb);
|
|||
static void bta_jv_pm_state_change(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE state);
|
||||
tBTA_JV_STATUS bta_jv_set_pm_conn_state(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE
|
||||
new_st);
|
||||
static int find_rfc_pcb(void *user_data, tBTA_JV_RFC_CB **cb, tBTA_JV_PCB **pcb);
|
||||
static void bta_jv_port_mgmt_sr_cback(UINT32 code, UINT16 port_handle);
|
||||
static void bta_jv_port_event_sr_cback(UINT32 code, UINT16 port_handle);
|
||||
static int bta_jv_port_data_co_cback(UINT16 port_handle, UINT8 *buf, UINT16 len, int type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -288,6 +292,12 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
|
|||
BOOLEAN remove_server = FALSE;
|
||||
int close_pending = 0;
|
||||
|
||||
UINT8 used = 0, i, listen = 0;
|
||||
tPORT_STATE port_state;
|
||||
UINT32 event_mask = BTA_JV_RFC_EV_MASK;
|
||||
UINT32 scn_num = (UINT32)p_cb->scn;
|
||||
tBTA_JV evt_data;
|
||||
|
||||
if (!p_cb || !p_pcb) {
|
||||
APPL_TRACE_ERROR("bta_jv_free_sr_rfc_cb, p_cb or p_pcb cannot be null");
|
||||
return BTA_JV_FAILURE;
|
||||
|
@ -363,6 +373,57 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
|
|||
}
|
||||
p_pcb->handle = 0;
|
||||
p_cb->curr_sess--;
|
||||
|
||||
if ((p_cb->max_sess > 1) &&
|
||||
(p_cb->scn != 0) &&
|
||||
(p_cb->curr_sess == p_cb->max_sess - 1)) {
|
||||
|
||||
for (i = 0; i < p_cb->max_sess; i++) {
|
||||
if (p_cb->rfc_hdl[i] != 0) {
|
||||
p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[i] - 1];
|
||||
if (p_pcb->state == BTA_JV_ST_SR_LISTEN) {
|
||||
listen++;
|
||||
}
|
||||
used++;
|
||||
}
|
||||
}
|
||||
APPL_TRACE_DEBUG("%s max_sess=%d used:%d curr_sess:%d, listen:%d si:%d",
|
||||
__func__, p_cb->max_sess, used, p_cb->curr_sess, listen, si);
|
||||
if (used < p_cb->max_sess &&
|
||||
listen == 0 &&
|
||||
0 <= si &&
|
||||
si < BTA_JV_MAX_RFC_SR_SESSION) {
|
||||
/* make sure the server has a listen port */
|
||||
if ((RFCOMM_CreateConnection(p_cb->sec_id, p_cb->scn, TRUE,
|
||||
BTA_JV_DEF_RFC_MTU, (UINT8 *)bd_addr_any, &(p_cb->rfc_hdl[si]), bta_jv_port_mgmt_sr_cback) == PORT_SUCCESS) &&
|
||||
(p_cb->rfc_hdl[si] != 0)) {
|
||||
p_cb->curr_sess++;
|
||||
p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[si] - 1];
|
||||
p_pcb->state = BTA_JV_ST_SR_LISTEN;
|
||||
p_pcb->port_handle = p_cb->rfc_hdl[si];
|
||||
// p_pcb->user_data = p_pcb_open->user_data;
|
||||
|
||||
PORT_ClearKeepHandleFlag(p_pcb->port_handle);
|
||||
PORT_SetEventCallback(p_pcb->port_handle, bta_jv_port_event_sr_cback);
|
||||
PORT_SetDataCOCallback(p_pcb->port_handle, bta_jv_port_data_co_cback);
|
||||
PORT_SetEventMask(p_pcb->port_handle, event_mask);
|
||||
PORT_GetState(p_pcb->port_handle, &port_state);
|
||||
|
||||
port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);
|
||||
|
||||
PORT_SetState(p_pcb->port_handle, &port_state);
|
||||
p_pcb->handle = BTA_JV_RFC_H_S_TO_HDL(p_cb->handle, si);
|
||||
APPL_TRACE_DEBUG("%s: p_pcb->handle:0x%x, curr_sess:%d", __func__,
|
||||
p_pcb->handle, p_cb->curr_sess);
|
||||
|
||||
evt_data.rfc_srv_open.handle = 0;
|
||||
evt_data.rfc_srv_open.new_listen_handle = p_pcb->handle;
|
||||
evt_data.rfc_srv_open.status = BTA_JV_SUCCESS;
|
||||
p_pcb->user_data = p_cb->p_cback(BTA_JV_RFCOMM_SRV_OPEN_EVT, &evt_data, (void *)scn_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p_cb->curr_sess == 0) {
|
||||
p_cb->scn = 0;
|
||||
bta_jv_free_sec_id(&p_cb->sec_id);
|
||||
|
@ -377,6 +438,7 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
|
|||
return status;
|
||||
}
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_jv_free_l2c_cb
|
||||
|
@ -402,6 +464,7 @@ tBTA_JV_STATUS bta_jv_free_l2c_cb(tBTA_JV_L2C_CB *p_cb)
|
|||
p_cb->p_cback = NULL;
|
||||
return status;
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -456,10 +519,9 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
|
|||
}
|
||||
}
|
||||
|
||||
APPL_TRACE_API("%s(jv_handle: 0x%2x), idx: %d, "
|
||||
"app_id: 0x%x", __func__, jv_handle, i, bta_jv_cb.pm_cb[i].app_id);
|
||||
APPL_TRACE_API("%s, bd_counter = %d, "
|
||||
"appid_counter = %d", __func__, bd_counter, appid_counter);
|
||||
APPL_TRACE_API("%s(jv_handle: 0x%2x), idx: %d, app_id: 0x%x", __func__, jv_handle, i, bta_jv_cb.pm_cb[i].app_id);
|
||||
APPL_TRACE_API("%s, bd_counter = %d, appid_counter = %d", __func__, bd_counter, appid_counter);
|
||||
|
||||
if (bd_counter > 1) {
|
||||
bta_jv_pm_conn_idle(&bta_jv_cb.pm_cb[i]);
|
||||
}
|
||||
|
@ -478,14 +540,15 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
|
|||
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) {
|
||||
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);
|
||||
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 BTA_JV_L2CAP_INCLUDED
|
||||
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) {
|
||||
|
@ -495,6 +558,8 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
|
|||
p_cb = &p_l2c_cb->p_pm_cb;
|
||||
}
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
if (p_cb) {
|
||||
*p_cb = NULL;
|
||||
status = BTA_JV_SUCCESS;
|
||||
|
@ -537,7 +602,9 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
else {
|
||||
/* use jv handle for l2cap bd address retrieval */
|
||||
for (j = 0; j < BTA_JV_MAX_L2C_CONN; j++) {
|
||||
if (jv_handle == bta_jv_cb.l2c_cb[j].handle) {
|
||||
|
@ -552,6 +619,7 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
APPL_TRACE_API("bta_jv_alloc_set_pm_profile_cb(handle 0x%2x, app_id %d): "
|
||||
"idx: %d, (BTA_JV_PM_MAX_NUM: %d), pp_cb: %p", jv_handle, app_id,
|
||||
i, BTA_JV_PM_MAX_NUM, (void *)pp_cb);
|
||||
|
@ -634,7 +702,6 @@ BOOLEAN bta_jv_check_psm(UINT16 psm)
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -673,7 +740,12 @@ void bta_jv_enable(tBTA_JV_MSG *p_data)
|
|||
*******************************************************************************/
|
||||
void bta_jv_disable (tBTA_JV_MSG *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
tBTA_JV_STATUS evt_data;
|
||||
evt_data = BTA_JV_SUCCESS;
|
||||
// UNUSED(p_data);
|
||||
if (p_data->disable.p_cback) {
|
||||
p_data->disable.p_cback(BTA_JV_DISABLE_EVT, (tBTA_JV *)&evt_data, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -782,7 +854,16 @@ void bta_jv_get_channel_id(tBTA_JV_MSG *p_data)
|
|||
*******************************************************************************/
|
||||
void bta_jv_free_scn(tBTA_JV_MSG *p_data)
|
||||
{
|
||||
UINT16 scn = p_data->free_channel.scn;
|
||||
tBTA_JV_API_FREE_CHANNEL *fc = &(p_data->free_channel);
|
||||
UINT16 scn = fc->scn;
|
||||
tBTA_JV_FREE_SCN evt_data = {
|
||||
.status = BTA_JV_SUCCESS,
|
||||
.server_status = BTA_JV_SERVER_STATUS_MAX,
|
||||
};
|
||||
|
||||
tBTA_JV_FREE_SCN_USER_DATA *user_data = NULL;
|
||||
tBTA_JV_RFC_CB *p_cb = NULL;
|
||||
tBTA_JV_PCB *p_pcb = NULL;
|
||||
|
||||
switch (p_data->free_channel.type) {
|
||||
case BTA_JV_CONN_TYPE_RFCOMM: {
|
||||
|
@ -802,6 +883,19 @@ void bta_jv_free_scn(tBTA_JV_MSG *p_data)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (fc->user_data) {
|
||||
user_data = (tBTA_JV_FREE_SCN_USER_DATA *)fc->user_data;
|
||||
evt_data.server_status = user_data->server_status;
|
||||
if (user_data->server_status == BTA_JV_SERVER_RUNNING && find_rfc_pcb((void *)user_data->slot_id, &p_cb, &p_pcb)) {
|
||||
/* if call bta_jv_rfcomm_stop_server successfully, find_rfc_pcb shall return false */
|
||||
evt_data.status = BTA_JV_FAILURE;
|
||||
}
|
||||
|
||||
if (fc->p_cback) {
|
||||
fc->p_cback(BTA_JV_FREE_SCN_EVT, (tBTA_JV *)&evt_data, (void *)user_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
static inline tBT_UUID shorten_sdp_uuid(const tBT_UUID *u)
|
||||
{
|
||||
|
@ -1092,6 +1186,7 @@ void bta_jv_delete_record(tBTA_JV_MSG *p_data)
|
|||
}
|
||||
}
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_jv_l2cap_client_cback
|
||||
|
@ -1517,6 +1612,7 @@ void bta_jv_l2cap_write_fixed(tBTA_JV_MSG *p_data)
|
|||
|
||||
ls->p_cback(BTA_JV_L2CAP_WRITE_FIXED_EVT, (tBTA_JV *)&evt_data, ls->user_data);
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -1596,6 +1692,7 @@ static void bta_jv_port_mgmt_cl_cback(UINT32 code, UINT16 port_handle)
|
|||
evt_data.rfc_close.async = TRUE;
|
||||
if (p_pcb->state == BTA_JV_ST_CL_CLOSING) {
|
||||
evt_data.rfc_close.async = FALSE;
|
||||
evt_data.rfc_close.status = BTA_JV_SUCCESS;
|
||||
}
|
||||
//p_pcb->state = BTA_JV_ST_NONE;
|
||||
//p_pcb->cong = FALSE;
|
||||
|
@ -1760,9 +1857,10 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data)
|
|||
tBTA_JV_API_RFCOMM_CLOSE *cc = &(p_data->rfcomm_close);
|
||||
tBTA_JV_RFC_CB *p_cb = NULL;
|
||||
tBTA_JV_PCB *p_pcb = NULL;
|
||||
APPL_TRACE_DEBUG("bta_jv_rfcomm_close, rfc handle:%d", cc->handle);
|
||||
tBTA_JV evt_data;
|
||||
APPL_TRACE_DEBUG("%s, rfc handle:%d",__func__, cc->handle);
|
||||
if (!cc->handle) {
|
||||
APPL_TRACE_ERROR("bta_jv_rfcomm_close, rfc handle is null");
|
||||
APPL_TRACE_ERROR("%s, rfc handle is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1770,9 +1868,21 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data)
|
|||
if (!find_rfc_pcb(user_data, &p_cb, &p_pcb)) {
|
||||
return;
|
||||
}
|
||||
if(cc->p_cback) {
|
||||
evt_data.rfc_close.status = BTA_JV_SUCCESS;
|
||||
evt_data.rfc_close.port_status = PORT_LOCAL_CLOSED;
|
||||
evt_data.rfc_close.handle = cc->handle;
|
||||
evt_data.rfc_close.async = TRUE;
|
||||
if (p_pcb && (p_pcb->state == BTA_JV_ST_SR_LISTEN ||
|
||||
p_pcb->state == BTA_JV_ST_SR_OPEN ||
|
||||
p_pcb->state == BTA_JV_ST_CL_OPEN ||
|
||||
p_pcb->state == BTA_JV_ST_CL_OPENING)) {
|
||||
evt_data.rfc_close.async = FALSE;
|
||||
}
|
||||
cc->p_cback(BTA_JV_RFCOMM_CLOSE_EVT, (tBTA_JV *)&evt_data, user_data);
|
||||
}
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb);
|
||||
APPL_TRACE_DEBUG("bta_jv_rfcomm_close: sec id in use:%d, rfc_cb in use:%d",
|
||||
get_sec_id_used(), get_rfc_cb_used());
|
||||
APPL_TRACE_DEBUG("%s: sec id in use:%d, rfc_cb in use:%d", __func__, get_sec_id_used(), get_rfc_cb_used());
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -1976,6 +2086,8 @@ static tBTA_JV_PCB *bta_jv_add_rfc_port(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pcb
|
|||
p_pcb->handle, p_cb->curr_sess);
|
||||
}
|
||||
} else {
|
||||
/* avoid p_pcb always points to the last element of rfc_hdl */
|
||||
p_pcb = p_pcb_open;
|
||||
APPL_TRACE_ERROR("bta_jv_add_rfc_port, cannot create new rfc listen port");
|
||||
}
|
||||
}
|
||||
|
@ -2351,7 +2463,7 @@ static void bta_jv_pm_state_change(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE
|
|||
}
|
||||
/**********************************************************************************************/
|
||||
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
static struct fc_channel *fcchan_get(uint16_t chan, char create)
|
||||
{
|
||||
struct fc_channel *t = fc_channels;
|
||||
|
@ -2791,6 +2903,6 @@ extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data)
|
|||
fcclient_free(t);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
|
||||
|
|
|
@ -69,6 +69,16 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback)
|
|||
int i;
|
||||
|
||||
APPL_TRACE_API( "BTA_JvEnable");
|
||||
|
||||
#if BTA_DYNAMIC_MEMORY == TRUE
|
||||
/* Malloc buffer for JV configuration structure */
|
||||
p_bta_jv_cfg->p_sdp_raw_data = (UINT8 *)osi_malloc(p_bta_jv_cfg->sdp_raw_size);
|
||||
p_bta_jv_cfg->p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(p_bta_jv_cfg->sdp_db_size);
|
||||
if (p_bta_jv_cfg->p_sdp_raw_data == NULL || p_bta_jv_cfg->p_sdp_db == NULL) {
|
||||
return BTA_JV_NO_DATA;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_cback && FALSE == bta_sys_is_register(BTA_ID_JV)) {
|
||||
memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB));
|
||||
/* set handle to invalid value by default */
|
||||
|
@ -100,18 +110,39 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback)
|
|||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_JvDisable(void)
|
||||
void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
tBTA_JV_API_DISABLE *p_buf;
|
||||
|
||||
APPL_TRACE_API( "BTA_JvDisable");
|
||||
bta_sys_deregister(BTA_ID_JV);
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_JV_API_DISABLE_EVT;
|
||||
if ((p_buf = (tBTA_JV_API_DISABLE *) osi_malloc(sizeof(tBTA_JV_API_DISABLE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_JV_API_DISABLE_EVT;
|
||||
p_buf->p_cback = p_cback;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvFree
|
||||
**
|
||||
** Description Free JV configuration
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_JvFree(void)
|
||||
{
|
||||
#if BTA_DYNAMIC_MEMORY == TRUE
|
||||
/* Free buffer for JV configuration structure */
|
||||
osi_free(p_bta_jv_cfg->p_sdp_raw_data);
|
||||
osi_free(p_bta_jv_cfg->p_sdp_db);
|
||||
p_bta_jv_cfg->p_sdp_raw_data = NULL;
|
||||
p_bta_jv_cfg->p_sdp_db = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvIsEnable
|
||||
|
@ -199,12 +230,14 @@ tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data, INT32 channel)
|
|||
** Parameters
|
||||
** channel The channel to free
|
||||
** conn_type one of BTA_JV_CONN_TYPE_
|
||||
** p_cback tBTA_JV_RFCOMM_CBACK is called with when server
|
||||
** user_data indicate the RFCOMM server status
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type)
|
||||
tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data)
|
||||
{
|
||||
tBTA_JV_STATUS status = BTA_JV_FAILURE;
|
||||
tBTA_JV_API_FREE_CHANNEL *p_msg;
|
||||
|
@ -214,6 +247,8 @@ tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type)
|
|||
p_msg->hdr.event = BTA_JV_API_FREE_SCN_EVT;
|
||||
p_msg->scn = channel;
|
||||
p_msg->type = conn_type;
|
||||
p_msg->p_cback = p_cback;
|
||||
p_msg->user_data = user_data;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
status = BTA_JV_SUCCESS;
|
||||
}
|
||||
|
@ -310,6 +345,7 @@ tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle)
|
|||
return (status);
|
||||
}
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capConnectLE
|
||||
|
@ -823,6 +859,7 @@ tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_i
|
|||
|
||||
return (status);
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -868,19 +905,20 @@ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
|
|||
** Function BTA_JvRfcommClose
|
||||
**
|
||||
** Description This function closes an RFCOMM connection
|
||||
**
|
||||
** When the connection is established or failed,
|
||||
** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CLOSE_EVT
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data)
|
||||
tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data)
|
||||
{
|
||||
tBTA_JV_STATUS status = BTA_JV_FAILURE;
|
||||
tBTA_JV_API_RFCOMM_CLOSE *p_msg;
|
||||
UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1;
|
||||
UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle);
|
||||
|
||||
APPL_TRACE_API( "BTA_JvRfcommClose");
|
||||
APPL_TRACE_API( "%s", __func__);
|
||||
if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
|
||||
si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
|
||||
(p_msg = (tBTA_JV_API_RFCOMM_CLOSE *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_CLOSE))) != NULL) {
|
||||
|
@ -888,6 +926,7 @@ tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data)
|
|||
p_msg->handle = handle;
|
||||
p_msg->p_cb = &bta_jv_cb.rfc_cb[hi];
|
||||
p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1];
|
||||
p_msg->p_cback = p_cback;
|
||||
p_msg->user_data = user_data;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
status = BTA_JV_SUCCESS;
|
||||
|
|
|
@ -52,12 +52,14 @@ const tBTA_JV_ACTION bta_jv_action[] = {
|
|||
bta_jv_start_discovery, /* BTA_JV_API_START_DISCOVERY_EVT */
|
||||
bta_jv_create_record, /* BTA_JV_API_CREATE_RECORD_EVT */
|
||||
bta_jv_delete_record, /* BTA_JV_API_DELETE_RECORD_EVT */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
bta_jv_l2cap_connect, /* BTA_JV_API_L2CAP_CONNECT_EVT */
|
||||
bta_jv_l2cap_close, /* BTA_JV_API_L2CAP_CLOSE_EVT */
|
||||
bta_jv_l2cap_start_server, /* BTA_JV_API_L2CAP_START_SERVER_EVT */
|
||||
bta_jv_l2cap_stop_server, /* BTA_JV_API_L2CAP_STOP_SERVER_EVT */
|
||||
bta_jv_l2cap_read, /* BTA_JV_API_L2CAP_READ_EVT */
|
||||
bta_jv_l2cap_write, /* BTA_JV_API_L2CAP_WRITE_EVT */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
bta_jv_rfcomm_connect, /* BTA_JV_API_RFCOMM_CONNECT_EVT */
|
||||
bta_jv_rfcomm_close, /* BTA_JV_API_RFCOMM_CLOSE_EVT */
|
||||
bta_jv_rfcomm_start_server, /* BTA_JV_API_RFCOMM_START_SERVER_EVT */
|
||||
|
@ -66,11 +68,13 @@ const tBTA_JV_ACTION bta_jv_action[] = {
|
|||
bta_jv_rfcomm_write, /* BTA_JV_API_RFCOMM_WRITE_EVT */
|
||||
bta_jv_set_pm_profile, /* BTA_JV_API_SET_PM_PROFILE_EVT */
|
||||
bta_jv_change_pm_state, /* BTA_JV_API_PM_STATE_CHANGE_EVT */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
bta_jv_l2cap_connect_le, /* BTA_JV_API_L2CAP_CONNECT_LE_EVT */
|
||||
bta_jv_l2cap_start_server_le, /* BTA_JV_API_L2CAP_START_SERVER_LE_EVT */
|
||||
bta_jv_l2cap_stop_server_le, /* BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT */
|
||||
bta_jv_l2cap_write_fixed, /* BTA_JV_API_L2CAP_WRITE_FIXED_EVT */
|
||||
bta_jv_l2cap_close_fixed, /* BTA_JV_API_L2CAP_CLOSE_FIXED_EVT */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -48,12 +48,14 @@ enum {
|
|||
BTA_JV_API_START_DISCOVERY_EVT,
|
||||
BTA_JV_API_CREATE_RECORD_EVT,
|
||||
BTA_JV_API_DELETE_RECORD_EVT,
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
BTA_JV_API_L2CAP_CONNECT_EVT,
|
||||
BTA_JV_API_L2CAP_CLOSE_EVT,
|
||||
BTA_JV_API_L2CAP_START_SERVER_EVT,
|
||||
BTA_JV_API_L2CAP_STOP_SERVER_EVT,
|
||||
BTA_JV_API_L2CAP_READ_EVT,
|
||||
BTA_JV_API_L2CAP_WRITE_EVT,
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
BTA_JV_API_RFCOMM_CONNECT_EVT,
|
||||
BTA_JV_API_RFCOMM_CLOSE_EVT,
|
||||
BTA_JV_API_RFCOMM_START_SERVER_EVT,
|
||||
|
@ -62,11 +64,13 @@ enum {
|
|||
BTA_JV_API_RFCOMM_WRITE_EVT,
|
||||
BTA_JV_API_SET_PM_PROFILE_EVT,
|
||||
BTA_JV_API_PM_STATE_CHANGE_EVT,
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
BTA_JV_API_L2CAP_CONNECT_LE_EVT,
|
||||
BTA_JV_API_L2CAP_START_SERVER_LE_EVT,
|
||||
BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT,
|
||||
BTA_JV_API_L2CAP_WRITE_FIXED_EVT,
|
||||
BTA_JV_API_L2CAP_CLOSE_FIXED_EVT,
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
BTA_JV_MAX_INT_EVT
|
||||
};
|
||||
|
||||
|
@ -80,6 +84,12 @@ typedef struct {
|
|||
tBTA_JV_DM_CBACK *p_cback;
|
||||
} tBTA_JV_API_ENABLE;
|
||||
|
||||
/* data type for BTA_JV_API_DISABLE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback;
|
||||
} tBTA_JV_API_DISABLE;
|
||||
|
||||
/* data type for BTA_JV_API_START_DISCOVERY_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
|
@ -115,6 +125,8 @@ enum {
|
|||
BTA_JV_ST_SR_CLOSING
|
||||
} ;
|
||||
typedef UINT8 tBTA_JV_STATE;
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
#define BTA_JV_ST_CL_MAX BTA_JV_ST_CL_CLOSING
|
||||
/* JV L2CAP control block */
|
||||
typedef struct {
|
||||
|
@ -127,6 +139,7 @@ typedef struct {
|
|||
tBTA_JV_PM_CB *p_pm_cb; /* ptr to pm control block, NULL: unused */
|
||||
void *user_data; /* user data for callback from higher layers */
|
||||
} tBTA_JV_L2C_CB;
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
#define BTA_JV_RFC_HDL_MASK 0xFF
|
||||
#define BTA_JV_RFCOMM_MASK 0x80
|
||||
|
@ -156,6 +169,7 @@ typedef struct {
|
|||
int curr_sess; /* current sessions count*/
|
||||
} tBTA_JV_RFC_CB;
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/* data type for BTA_JV_API_L2CAP_CONNECT_EVT & BTA_JV_API_L2CAP_CONNECT_LE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
|
@ -233,6 +247,7 @@ typedef struct {
|
|||
UINT16 len;
|
||||
void *user_data;
|
||||
} tBTA_JV_API_L2CAP_WRITE_FIXED;
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/* data type for BTA_JV_API_RFCOMM_CONNECT_EVT */
|
||||
typedef struct {
|
||||
|
@ -300,6 +315,7 @@ typedef struct {
|
|||
UINT32 handle;
|
||||
tBTA_JV_RFC_CB *p_cb;
|
||||
tBTA_JV_PCB *p_pcb;
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback;
|
||||
void *user_data;
|
||||
} tBTA_JV_API_RFCOMM_CLOSE;
|
||||
|
||||
|
@ -326,6 +342,8 @@ typedef struct {
|
|||
BT_HDR hdr;
|
||||
INT32 type; /* One of BTA_JV_CONN_TYPE_ */
|
||||
UINT16 scn;
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback;
|
||||
void *user_data;
|
||||
} tBTA_JV_API_FREE_CHANNEL;
|
||||
|
||||
/* data type for BTA_JV_API_ALLOC_CHANNEL_EVT */
|
||||
|
@ -340,16 +358,20 @@ typedef union {
|
|||
/* GKI event buffer header */
|
||||
BT_HDR hdr;
|
||||
tBTA_JV_API_ENABLE enable;
|
||||
tBTA_JV_API_DISABLE disable;
|
||||
tBTA_JV_API_START_DISCOVERY start_discovery;
|
||||
tBTA_JV_API_ALLOC_CHANNEL alloc_channel;
|
||||
tBTA_JV_API_FREE_CHANNEL free_channel;
|
||||
tBTA_JV_API_CREATE_RECORD create_record;
|
||||
tBTA_JV_API_ADD_ATTRIBUTE add_attr;
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
tBTA_JV_API_L2CAP_CONNECT l2cap_connect;
|
||||
tBTA_JV_API_L2CAP_READ l2cap_read;
|
||||
tBTA_JV_API_L2CAP_WRITE l2cap_write;
|
||||
tBTA_JV_API_L2CAP_CLOSE l2cap_close;
|
||||
tBTA_JV_API_L2CAP_SERVER l2cap_server;
|
||||
tBTA_JV_API_L2CAP_WRITE_FIXED l2cap_write_fixed;
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
tBTA_JV_API_RFCOMM_CONNECT rfcomm_connect;
|
||||
tBTA_JV_API_RFCOMM_READ rfcomm_read;
|
||||
tBTA_JV_API_RFCOMM_WRITE rfcomm_write;
|
||||
|
@ -357,7 +379,6 @@ typedef union {
|
|||
tBTA_JV_API_PM_STATE_CHANGE change_pm_state;
|
||||
tBTA_JV_API_RFCOMM_CLOSE rfcomm_close;
|
||||
tBTA_JV_API_RFCOMM_SERVER rfcomm_server;
|
||||
tBTA_JV_API_L2CAP_WRITE_FIXED l2cap_write_fixed;
|
||||
} tBTA_JV_MSG;
|
||||
|
||||
/* JV control block */
|
||||
|
@ -368,7 +389,9 @@ typedef struct {
|
|||
UINT32 sdp_handle[BTA_JV_MAX_SDP_REC]; /* SDP records created */
|
||||
UINT8 *p_sel_raw_data;/* the raw data of last service select */
|
||||
tBTA_JV_DM_CBACK *p_dm_cback;
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
tBTA_JV_L2C_CB l2c_cb[BTA_JV_MAX_L2C_CONN]; /* index is GAP handle (index) */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
tBTA_JV_RFC_CB rfc_cb[BTA_JV_MAX_RFC_CONN];
|
||||
tBTA_JV_PCB port_cb[MAX_RFC_PORTS]; /* index of this array is
|
||||
the port_handle, */
|
||||
|
@ -407,12 +430,14 @@ extern void bta_jv_free_scn (tBTA_JV_MSG *p_data);
|
|||
extern void bta_jv_start_discovery (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_create_record (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_delete_record (tBTA_JV_MSG *p_data);
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
extern void bta_jv_l2cap_connect (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_close (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_start_server (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_stop_server (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_read (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_write (tBTA_JV_MSG *p_data);
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
extern void bta_jv_rfcomm_connect (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_rfcomm_close (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_rfcomm_start_server (tBTA_JV_MSG *p_data);
|
||||
|
@ -421,11 +446,12 @@ extern void bta_jv_rfcomm_read (tBTA_JV_MSG *p_data);
|
|||
extern void bta_jv_rfcomm_write (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_set_pm_profile (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_change_pm_state(tBTA_JV_MSG *p_data);
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
extern void bta_jv_l2cap_connect_le (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_start_server_le (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_stop_server_le (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_write_fixed (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data);
|
||||
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
|
||||
#endif /* BTA_JV_INT_H */
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "common/bt_target.h"
|
||||
#include "btc/btc_storage.h"
|
||||
#include "btc/btc_ble_storage.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
#include "btc_gap_ble.h"
|
||||
#include "btm_int.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
|
@ -299,6 +299,27 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
|||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
static void btc_dm_link_up_evt(tBTA_DM_LINK_UP *p_link_up)
|
||||
{
|
||||
BD_ADDR bd_addr;
|
||||
bt_bdaddr_t bt_bdaddr;
|
||||
|
||||
|
||||
if (p_link_up->sc_downgrade == 1) {
|
||||
memcpy(bt_bdaddr.address, p_link_up->bd_addr, sizeof(BD_ADDR));
|
||||
if (btc_storage_remove_bonded_device(&bt_bdaddr) == BT_STATUS_SUCCESS) {
|
||||
memcpy(bd_addr, p_link_up->bd_addr, sizeof(BD_ADDR));
|
||||
if (BTA_DmRemoveDevice(bd_addr, BT_TRANSPORT_BR_EDR) == BTA_SUCCESS) {
|
||||
BTC_TRACE_EVENT(" %s() Bonding information removed.", __FUNCTION__);
|
||||
} else {
|
||||
BTC_TRACE_ERROR(" %s() BTA_DmRemoveDevice error", __FUNCTION__);
|
||||
}
|
||||
} else {
|
||||
BTC_TRACE_ERROR(" %s() btc_storage_remove_bonded_device error", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
{
|
||||
/* Save link key, if not temporary */
|
||||
|
@ -322,7 +343,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
|||
__FUNCTION__, p_auth_cmpl->key_type);
|
||||
ret = btc_storage_add_bonded_device(&bd_addr,
|
||||
p_auth_cmpl->key, p_auth_cmpl->key_type,
|
||||
16);
|
||||
16, p_auth_cmpl->sc_support);
|
||||
BTC_ASSERTC(ret == BT_STATUS_SUCCESS, "storing link key failed", ret);
|
||||
} else {
|
||||
BTC_TRACE_DEBUG("%s: Temporary key. Not storing. key_type=0x%x",
|
||||
|
@ -383,11 +404,10 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
|||
memcpy(param.auth_cmpl.bda, p_auth_cmpl->bd_addr, ESP_BD_ADDR_LEN);
|
||||
memcpy(param.auth_cmpl.device_name, p_auth_cmpl->bd_name, ESP_BT_GAP_MAX_BDNAME_LEN + 1);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
|
@ -406,11 +426,10 @@ static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
|
|||
param.pin_req.min_16_digit = p_pin_req->min_16_digit;
|
||||
memcpy(param.pin_req.bda, p_pin_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
@ -434,11 +453,10 @@ static void btc_dm_sp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_cfm_req)
|
|||
param.cfm_req.num_val = p_cfm_req->num_val;
|
||||
memcpy(param.cfm_req.bda, p_cfm_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
@ -455,11 +473,10 @@ static void btc_dm_sp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_key_notif)
|
|||
param.key_notif.passkey = p_key_notif->passkey;
|
||||
memcpy(param.key_notif.bda, p_key_notif->bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
@ -475,16 +492,43 @@ static void btc_dm_sp_key_req_evt(tBTA_DM_SP_KEY_REQ *p_key_req)
|
|||
msg.act = BTC_GAP_BT_KEY_REQ_EVT;
|
||||
memcpy(param.key_req.bda, p_key_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
#endif /// BT_SSP_INCLUDED == TRUE
|
||||
|
||||
static void btc_dm_dev_unpaired_evt(tBTA_DM_LINK_DOWN *p_link_down)
|
||||
{
|
||||
esp_bt_gap_cb_param_t param;
|
||||
BTC_TRACE_DEBUG("%s",__func__);
|
||||
memcpy(param.remove_bond_dev_cmpl.bda, p_link_down->bd_addr, ESP_BD_ADDR_LEN);
|
||||
btm_set_bond_type_dev(p_link_down->bd_addr, BOND_TYPE_UNKNOWN);
|
||||
if (p_link_down->status == HCI_SUCCESS) {
|
||||
//remove the bonded key in the config and nvs flash.
|
||||
param.remove_bond_dev_cmpl.status = btc_storage_remove_bonded_device((bt_bdaddr_t *)param.remove_bond_dev_cmpl.bda);
|
||||
} else {
|
||||
param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT;
|
||||
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
tBTA_SERVICE_MASK btc_get_enabled_services_mask(void)
|
||||
{
|
||||
return btc_enabled_services;
|
||||
|
@ -622,16 +666,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
|
||||
case BTA_DM_DEV_UNPAIRED_EVT: {
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bt_bdaddr_t bd_addr;
|
||||
BTC_TRACE_DEBUG("BTA_DM_DEV_UNPAIRED_EVT");
|
||||
memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR));
|
||||
btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
|
||||
if (p_data->link_down.status == HCI_SUCCESS) {
|
||||
//remove the bonded key in the config and nvs flash.
|
||||
btc_storage_remove_bonded_device(&bd_addr);
|
||||
}
|
||||
#endif /* #if (SMP_INCLUDED == TRUE) */
|
||||
btc_dm_dev_unpaired_evt(&p_data->link_down);
|
||||
break;
|
||||
}
|
||||
case BTA_DM_BLE_DEV_UNPAIRED_EVT: {
|
||||
|
@ -664,12 +699,14 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||
break;
|
||||
}
|
||||
#endif /* BTC_GAP_BT_INCLUDED == TRUE */
|
||||
case BTA_DM_LINK_UP_EVT:
|
||||
case BTA_DM_LINK_DOWN_EVT:
|
||||
case BTA_DM_HW_ERROR_EVT:
|
||||
BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
|
||||
break;
|
||||
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
|
||||
case BTA_DM_LINK_UP_EVT:
|
||||
btc_dm_link_up_evt(&p_data->link_up);
|
||||
break;
|
||||
#if ((BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
|
||||
case BTA_DM_BLE_AUTH_CMPL_EVT: {
|
||||
rsp_app = true;
|
||||
ble_msg.act = ESP_GAP_BLE_AUTH_CMPL_EVT;
|
||||
|
@ -832,11 +869,10 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||
}
|
||||
|
||||
if (rsp_app) {
|
||||
ret = btc_transfer_context(&ble_msg, ¶m,
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&ble_msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
}
|
||||
btc_dm_sec_arg_deep_free(msg);
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
|
||||
LINK_KEY link_key,
|
||||
uint8_t key_type,
|
||||
uint8_t pin_length)
|
||||
uint8_t pin_length,
|
||||
BOOLEAN sc_support)
|
||||
{
|
||||
bdstr_t bdstr;
|
||||
|
||||
|
@ -48,6 +49,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
|
|||
int ret = btc_config_set_int(bdstr, BTC_STORAGE_LINK_KEY_TYPE_STR, (int)key_type);
|
||||
ret &= btc_config_set_int(bdstr, BTC_STORAGE_PIN_LENGTH_STR, (int)pin_length);
|
||||
ret &= btc_config_set_bin(bdstr, BTC_STORAGE_LINK_KEY_STR, link_key, sizeof(LINK_KEY));
|
||||
ret &= btc_config_set_bin(bdstr, BTC_STORAGE_SC_SUPPORT, (uint8_t *)&sc_support, sizeof(sc_support));
|
||||
/* write bonded info immediately */
|
||||
btc_config_flush();
|
||||
btc_config_unlock();
|
||||
|
@ -69,6 +71,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
|
|||
static bt_status_t btc_in_fetch_bonded_devices(int add)
|
||||
{
|
||||
BOOLEAN bt_linkkey_file_found = FALSE;
|
||||
UINT8 sc_support = 0;
|
||||
|
||||
btc_config_lock();
|
||||
for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end(); iter = btc_config_section_next(iter)) {
|
||||
|
@ -93,9 +96,11 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
|||
uint2devclass((UINT32)cod, dev_class);
|
||||
}
|
||||
btc_config_get_int(name, BTC_STORAGE_PIN_LENGTH_STR, &pin_length);
|
||||
size = sizeof(sc_support);
|
||||
btc_config_get_bin(name, BTC_STORAGE_SC_SUPPORT, &sc_support, &size);
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
BTA_DmAddDevice(bd_addr.address, dev_class, link_key, 0, 0,
|
||||
(UINT8)linkkey_type, 0, pin_length);
|
||||
(UINT8)linkkey_type, 0, pin_length, (UINT8)sc_support);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
bt_linkkey_file_found = TRUE;
|
||||
|
@ -160,6 +165,9 @@ bt_status_t btc_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr)
|
|||
if (btc_config_exist(bdstr, BTC_STORAGE_LINK_KEY_STR)) {
|
||||
ret &= btc_config_remove(bdstr, BTC_STORAGE_LINK_KEY_STR);
|
||||
}
|
||||
if (btc_config_exist(bdstr, BTC_STORAGE_SC_SUPPORT)) {
|
||||
ret &= btc_config_remove(bdstr, BTC_STORAGE_SC_SUPPORT);
|
||||
}
|
||||
/* write bonded info immediately */
|
||||
btc_config_flush();
|
||||
btc_config_unlock();
|
||||
|
@ -187,12 +195,12 @@ int btc_storage_get_num_bt_bond_devices(void)
|
|||
if (string_is_bdaddr(name) &&
|
||||
btc_config_exist(name, BTC_STORAGE_LINK_KEY_TYPE_STR) &&
|
||||
btc_config_exist(name, BTC_STORAGE_PIN_LENGTH_STR) &&
|
||||
btc_config_exist(name, BTC_STORAGE_SC_SUPPORT) &&
|
||||
btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) {
|
||||
num_dev++;
|
||||
}
|
||||
}
|
||||
btc_config_unlock();
|
||||
|
||||
return num_dev;
|
||||
}
|
||||
|
||||
|
@ -206,15 +214,17 @@ int btc_storage_get_num_bt_bond_devices(void)
|
|||
** BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num)
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *dev_num)
|
||||
{
|
||||
bt_bdaddr_t bd_addr;
|
||||
int in_dev_num = *dev_num; /* buffer size */
|
||||
int out_dev_num = 0; /* bond_dev size */
|
||||
|
||||
btc_config_lock();
|
||||
for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end();
|
||||
iter = btc_config_section_next(iter)) {
|
||||
|
||||
if (dev_num-- <= 0) {
|
||||
if (in_dev_num <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -223,13 +233,17 @@ bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int de
|
|||
if (string_is_bdaddr(name) &&
|
||||
btc_config_exist(name, BTC_STORAGE_LINK_KEY_TYPE_STR) &&
|
||||
btc_config_exist(name, BTC_STORAGE_PIN_LENGTH_STR) &&
|
||||
btc_config_exist(name, BTC_STORAGE_SC_SUPPORT) &&
|
||||
btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) {
|
||||
string_to_bdaddr(name, &bd_addr);
|
||||
memcpy(bond_dev, &bd_addr, sizeof(bt_bdaddr_t));
|
||||
in_dev_num--;
|
||||
out_dev_num++;
|
||||
bond_dev++;
|
||||
}
|
||||
}
|
||||
*dev_num = out_dev_num; /* out_dev_num <= in_dev_num */
|
||||
btc_config_unlock();
|
||||
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define BTC_STORAGE_LINK_KEY_STR "LinkKey" /* same as the ble */
|
||||
#define BTC_STORAGE_LINK_KEY_TYPE_STR "LinkKeyType"
|
||||
#define BTC_STORAGE_PIN_LENGTH_STR "PinLength"
|
||||
#define BTC_STORAGE_SC_SUPPORT "SCSupport"
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -40,7 +41,8 @@
|
|||
bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
|
||||
LINK_KEY link_key,
|
||||
uint8_t key_type,
|
||||
uint8_t pin_length);
|
||||
uint8_t pin_length,
|
||||
BOOLEAN sc_support);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -87,6 +89,6 @@ int btc_storage_get_num_bt_bond_devices(void);
|
|||
** BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num);
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *dev_num);
|
||||
|
||||
#endif /* BTC_STORAGE_H */
|
||||
|
|
|
@ -127,12 +127,16 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||
switch (ctrl) {
|
||||
case ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY:
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
if (btc_a2dp_source_is_task_shutting_down()) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
} else if ((btc_av_stream_ready() == TRUE) ||
|
||||
(btc_av_stream_started_ready() == TRUE)) {
|
||||
/* check whether av is ready to setup a2dp datapath */
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
if (btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||
if (btc_a2dp_source_is_task_shutting_down()) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
} else if ((btc_av_stream_ready() == TRUE) ||
|
||||
(btc_av_stream_started_ready() == TRUE)) {
|
||||
/* check whether av is ready to setup a2dp datapath */
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
} else {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
}
|
||||
} else {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
}
|
||||
|
@ -159,6 +163,10 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||
}
|
||||
break;
|
||||
case ESP_A2D_MEDIA_CTRL_STOP:
|
||||
if (btc_av_is_connected() == FALSE) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
break;
|
||||
}
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && !btc_a2dp_source_is_streaming() &&
|
||||
btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||
|
@ -174,7 +182,6 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ESP_A2D_MEDIA_CTRL_SUSPEND:
|
||||
/* local suspend */
|
||||
if (btc_av_stream_started_ready()) {
|
||||
|
@ -184,14 +191,15 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
} else if (btc_av_is_connected() == TRUE) {
|
||||
/* we are not in started state; just ack back ok. This can happen if we are
|
||||
remotely suspended; clear REMOTE SUSPEND Flag */
|
||||
btc_av_clear_remote_suspend_flag();
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
} else {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
APPL_TRACE_ERROR("### A2DP-MEDIA EVENT %u NOT HANDLED ###", ctrl);
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
|
|
|
@ -1120,7 +1120,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
|||
BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, btc_add_whitelist_complete_callback);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_READ_RSSI:
|
||||
BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
|
||||
BTA_DmReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_SET_CONN_PARAMS:
|
||||
BTA_DmSetBlePrefConnParams(arg->set_conn_params.bd_addr, arg->set_conn_params.min_conn_int,
|
||||
|
|
|
@ -633,7 +633,7 @@ static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data)
|
|||
|
||||
static void btc_gap_bt_read_rssi_delta(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback);
|
||||
BTA_DmReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback);
|
||||
}
|
||||
|
||||
static esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg)
|
||||
|
@ -852,6 +852,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
|||
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:
|
||||
case BTC_GAP_BT_AUTH_CMPL_EVT:
|
||||
case BTC_GAP_BT_PIN_REQ_EVT:
|
||||
case BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT:
|
||||
#if (BT_SSP_INCLUDED == TRUE)
|
||||
case BTC_GAP_BT_CFM_REQ_EVT:
|
||||
case BTC_GAP_BT_KEY_NOTIF_EVT:
|
||||
|
@ -905,6 +906,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
|||
break;
|
||||
}
|
||||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
case BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT:{
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT,(esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
|
|
|
@ -33,6 +33,7 @@ typedef enum {
|
|||
BTC_GAP_BT_KEY_NOTIF_EVT,
|
||||
BTC_GAP_BT_KEY_REQ_EVT,
|
||||
BTC_GAP_BT_READ_RSSI_DELTA_EVT,
|
||||
BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT,
|
||||
}btc_gap_bt_evt_t;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -35,6 +35,7 @@ typedef enum {
|
|||
BTC_SPP_ACT_CONNECT,
|
||||
BTC_SPP_ACT_DISCONNECT,
|
||||
BTC_SPP_ACT_START_SRV,
|
||||
BTC_SPP_ACT_STOP_SRV,
|
||||
BTC_SPP_ACT_WRITE,
|
||||
} btc_spp_act_t;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <sys/fcntl.h>
|
||||
#include "esp_vfs.h"
|
||||
#include "esp_vfs_dev.h"
|
||||
#include "stack/port_api.h"
|
||||
|
||||
#if (defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE)
|
||||
|
||||
|
@ -55,13 +56,20 @@ typedef struct {
|
|||
char service_name[ESP_SPP_SERVER_NAME_MAX + 1];
|
||||
} spp_slot_t;
|
||||
|
||||
static struct spp_local_param_t {
|
||||
spp_slot_t *spp_slots[BTA_JV_MAX_RFC_SR_SESSION + 1];
|
||||
typedef struct {
|
||||
spp_slot_t *spp_slots[MAX_RFC_PORTS + 1];
|
||||
uint32_t spp_slot_id;
|
||||
esp_spp_mode_t spp_mode;
|
||||
osi_mutex_t spp_slot_mutex;
|
||||
esp_vfs_id_t spp_vfs_id;
|
||||
} spp_local_param;
|
||||
} spp_local_param_t;
|
||||
|
||||
#if SPP_DYNAMIC_MEMORY == FALSE
|
||||
static spp_local_param_t spp_local_param;
|
||||
#else
|
||||
static spp_local_param_t *spp_local_param_ptr;
|
||||
#define spp_local_param (*spp_local_param_ptr)
|
||||
#endif
|
||||
|
||||
static void spp_osi_free(void *p)
|
||||
{
|
||||
|
@ -73,7 +81,7 @@ static spp_slot_t *spp_malloc_slot(void)
|
|||
if (++spp_local_param.spp_slot_id == 0) {
|
||||
spp_local_param.spp_slot_id = 1;
|
||||
}
|
||||
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] == NULL) {
|
||||
spp_local_param.spp_slots[i] = (spp_slot_t *)osi_malloc(sizeof(spp_slot_t));
|
||||
if (!spp_local_param.spp_slots[i]) {
|
||||
|
@ -81,6 +89,9 @@ static spp_slot_t *spp_malloc_slot(void)
|
|||
}
|
||||
spp_local_param.spp_slots[i]->id = spp_local_param.spp_slot_id;
|
||||
spp_local_param.spp_slots[i]->serial = i;
|
||||
spp_local_param.spp_slots[i]->sdp_handle = 0;
|
||||
spp_local_param.spp_slots[i]->rfc_handle = 0;
|
||||
spp_local_param.spp_slots[i]->rfc_port_handle = 0;
|
||||
spp_local_param.spp_slots[i]->connected = FALSE;
|
||||
spp_local_param.spp_slots[i]->write_data = NULL;
|
||||
spp_local_param.spp_slots[i]->list = list_new(spp_osi_free);
|
||||
|
@ -101,7 +112,7 @@ static spp_slot_t *spp_malloc_slot(void)
|
|||
|
||||
static spp_slot_t *spp_find_slot_by_id(uint32_t id)
|
||||
{
|
||||
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->id == id) {
|
||||
return spp_local_param.spp_slots[i];
|
||||
}
|
||||
|
@ -111,7 +122,7 @@ static spp_slot_t *spp_find_slot_by_id(uint32_t id)
|
|||
|
||||
static spp_slot_t *spp_find_slot_by_handle(uint32_t handle)
|
||||
{
|
||||
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->rfc_handle == handle) {
|
||||
return spp_local_param.spp_slots[i];
|
||||
}
|
||||
|
@ -121,7 +132,7 @@ static spp_slot_t *spp_find_slot_by_handle(uint32_t handle)
|
|||
|
||||
static spp_slot_t *spp_find_slot_by_fd(int fd)
|
||||
{
|
||||
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->fd == fd) {
|
||||
return spp_local_param.spp_slots[i];
|
||||
}
|
||||
|
@ -129,6 +140,16 @@ static spp_slot_t *spp_find_slot_by_fd(int fd)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static spp_slot_t *spp_find_slot_by_scn(uint32_t scn)
|
||||
{
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->scn == (uint8_t)scn) {
|
||||
return spp_local_param.spp_slots[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void spp_free_slot(spp_slot_t *slot)
|
||||
{
|
||||
if (!slot) {
|
||||
|
@ -160,15 +181,6 @@ static void btc_create_server_fail_cb(void)
|
|||
btc_spp_cb_to_app(ESP_SPP_START_EVT, ¶m);
|
||||
}
|
||||
|
||||
static void btc_disconnect_cb(uint32_t handle)
|
||||
{
|
||||
esp_spp_cb_param_t param;
|
||||
param.close.status = ESP_SPP_SUCCESS;
|
||||
param.close.handle = handle;
|
||||
param.close.async = FALSE;
|
||||
btc_spp_cb_to_app(ESP_SPP_CLOSE_EVT, ¶m);
|
||||
}
|
||||
|
||||
static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data)
|
||||
{
|
||||
bt_status_t status;
|
||||
|
@ -177,34 +189,53 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u
|
|||
|
||||
uint32_t id = (uintptr_t)user_data;
|
||||
spp_slot_t *slot, *slot_new;
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_WARNING("%s SPP have been deinit, incoming events ignore!\n", __func__);
|
||||
return new_user_data;
|
||||
}
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
switch (event) {
|
||||
case BTA_JV_RFCOMM_SRV_OPEN_EVT:
|
||||
case BTA_JV_RFCOMM_START_EVT:
|
||||
slot = spp_find_slot_by_id(id);
|
||||
if (!slot) {
|
||||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
|
||||
break;
|
||||
}
|
||||
slot_new = spp_malloc_slot();
|
||||
if (!slot_new) {
|
||||
BTC_TRACE_ERROR("%s unable to malloc RFCOMM slot!", __func__);
|
||||
slot->rfc_handle = p_data->rfc_start.handle;
|
||||
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_start.handle);
|
||||
break;
|
||||
case BTA_JV_RFCOMM_SRV_OPEN_EVT:
|
||||
slot = p_data->rfc_srv_open.handle ? spp_find_slot_by_id(id) : spp_find_slot_by_scn((uint32_t)user_data);
|
||||
if (!slot) {
|
||||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
|
||||
break;
|
||||
}
|
||||
new_user_data = (void *)(uintptr_t)slot_new->id;
|
||||
slot_new->security = slot->security;
|
||||
slot_new->role = slot->role;
|
||||
slot_new->scn = slot->scn;;
|
||||
slot_new->max_session = slot->max_session;
|
||||
strcpy(slot_new->service_name, slot->service_name);
|
||||
slot_new->sdp_handle = slot->sdp_handle;
|
||||
slot_new->rfc_handle = p_data->rfc_srv_open.new_listen_handle;
|
||||
slot_new->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.new_listen_handle);
|
||||
|
||||
memcpy(slot->addr, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN);
|
||||
slot->connected = TRUE;
|
||||
slot->rfc_handle = p_data->rfc_srv_open.handle;
|
||||
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.handle);
|
||||
BTA_JvSetPmProfile(p_data->rfc_srv_open.handle, BTA_JV_PM_ALL, BTA_JV_CONN_OPEN);
|
||||
if (p_data->rfc_srv_open.handle) {
|
||||
new_user_data = (void *)(uintptr_t)slot->id;
|
||||
memcpy(slot->addr, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN);
|
||||
slot->connected = TRUE;
|
||||
slot->rfc_handle = p_data->rfc_srv_open.handle;
|
||||
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.handle);
|
||||
BTA_JvSetPmProfile(p_data->rfc_srv_open.handle, BTA_JV_PM_ALL, BTA_JV_CONN_OPEN);
|
||||
}
|
||||
|
||||
if (p_data->rfc_srv_open.handle != p_data->rfc_srv_open.new_listen_handle) {
|
||||
slot_new = spp_malloc_slot();
|
||||
if (!slot_new) {
|
||||
BTC_TRACE_ERROR("%s unable to malloc RFCOMM slot!", __func__);
|
||||
break;
|
||||
}
|
||||
new_user_data = (void *)(uintptr_t)slot_new->id;
|
||||
slot_new->security = slot->security;
|
||||
slot_new->role = slot->role;
|
||||
slot_new->scn = slot->scn;
|
||||
slot_new->max_session = slot->max_session;
|
||||
strcpy(slot_new->service_name, slot->service_name);
|
||||
slot_new->sdp_handle = slot->sdp_handle;
|
||||
slot_new->rfc_handle = p_data->rfc_srv_open.new_listen_handle;
|
||||
slot_new->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.new_listen_handle);
|
||||
}
|
||||
break;
|
||||
case BTA_JV_RFCOMM_OPEN_EVT:
|
||||
slot = spp_find_slot_by_id(id);
|
||||
|
@ -223,14 +254,26 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u
|
|||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
|
||||
break;
|
||||
}
|
||||
if (slot->connected) {
|
||||
BTA_JvRfcommClose(slot->rfc_handle, (void *)slot->id);
|
||||
if (slot->connected && p_data->rfc_close.port_status != PORT_LOCAL_CLOSED) {
|
||||
BTA_JvRfcommClose(slot->rfc_handle, NULL, (void *)slot->id);
|
||||
}
|
||||
spp_free_slot(slot);
|
||||
p_data->rfc_close.status = BTA_JV_SUCCESS;
|
||||
break;
|
||||
case BTA_JV_RFCOMM_DATA_IND_EVT:
|
||||
break;
|
||||
case BTA_JV_FREE_SCN_EVT:
|
||||
if (user_data) {
|
||||
id = ((tBTA_JV_FREE_SCN_USER_DATA *)user_data)->slot_id;
|
||||
slot = spp_find_slot_by_id(id);
|
||||
if (slot) {
|
||||
spp_free_slot(slot);
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
|
||||
}
|
||||
osi_free(user_data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -292,8 +335,15 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d
|
|||
} else {
|
||||
BTC_TRACE_ERROR("%s unable to create record, start server fail!", __func__);
|
||||
btc_create_server_fail_cb();
|
||||
BTA_JvFreeChannel(slot->scn, BTA_JV_CONN_TYPE_RFCOMM);
|
||||
spp_free_slot(slot);
|
||||
tBTA_JV_FREE_SCN_USER_DATA *user_data = osi_malloc(sizeof(tBTA_JV_FREE_SCN_USER_DATA));
|
||||
if (user_data) {
|
||||
user_data->server_status = BTA_JV_SERVER_START_FAILED;
|
||||
user_data->slot_id = slot->id;
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s unable to malloc user data!", __func__);
|
||||
}
|
||||
BTA_JvFreeChannel(slot->scn, BTA_JV_CONN_TYPE_RFCOMM,
|
||||
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data);
|
||||
}
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
break;
|
||||
|
@ -313,6 +363,22 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d
|
|||
|
||||
static void btc_spp_init(btc_spp_args_t *arg)
|
||||
{
|
||||
if (spp_local_param.spp_slot_mutex) {
|
||||
esp_spp_cb_param_t param;
|
||||
param.init.status = ESP_SPP_FAILURE;
|
||||
btc_spp_cb_to_app(ESP_SPP_INIT_EVT, ¶m);
|
||||
BTC_TRACE_ERROR("%s SPP has been initiated, shall uninit first!", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
#if SPP_DYNAMIC_MEMORY == TRUE
|
||||
if ((spp_local_param_ptr = (spp_local_param_t *)osi_malloc(sizeof(spp_local_param_t))) == NULL) {
|
||||
BTC_TRACE_ERROR("%s malloc failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
memset((void *)spp_local_param_ptr, 0, sizeof(spp_local_param_t));
|
||||
#endif
|
||||
|
||||
if (osi_mutex_new(&spp_local_param.spp_slot_mutex) != 0) {
|
||||
BTC_TRACE_ERROR("%s osi_mutex_new failed\n", __func__);
|
||||
return;
|
||||
|
@ -324,40 +390,65 @@ static void btc_spp_init(btc_spp_args_t *arg)
|
|||
|
||||
static void btc_spp_uninit(void)
|
||||
{
|
||||
esp_spp_cb_param_t param;
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
param.uninit.status = ESP_SPP_FAILURE;
|
||||
btc_spp_cb_to_app(ESP_SPP_UNINIT_EVT, ¶m);
|
||||
BTC_TRACE_ERROR("%s SPP has not been initiated, shall init first!", __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++) {
|
||||
// first, remove all connection
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) {
|
||||
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle, (void *)spp_local_param.spp_slots[i]->id);
|
||||
spp_free_slot(spp_local_param.spp_slots[i]);
|
||||
spp_local_param.spp_slots[i] = NULL;
|
||||
}
|
||||
}
|
||||
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)) {
|
||||
BTA_JvRfcommStopServer(spp_local_param.spp_slots[i]->sdp_handle, (void *)spp_local_param.spp_slots[i]->id);
|
||||
BTA_JvDeleteRecord(spp_local_param.spp_slots[i]->sdp_handle);
|
||||
BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM);
|
||||
spp_free_slot(spp_local_param.spp_slots[i]);
|
||||
spp_local_param.spp_slots[i] = NULL;
|
||||
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle,(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb,
|
||||
(void *)spp_local_param.spp_slots[i]->id);
|
||||
}
|
||||
}
|
||||
// second, remove all server
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && !spp_local_param.spp_slots[i]->connected) {
|
||||
if (spp_local_param.spp_slots[i]->sdp_handle > 0) {
|
||||
BTA_JvDeleteRecord(spp_local_param.spp_slots[i]->sdp_handle);
|
||||
}
|
||||
|
||||
BTA_JvDisable();
|
||||
if (spp_local_param.spp_slots[i]->rfc_handle > 0) {
|
||||
BTA_JvRfcommStopServer(spp_local_param.spp_slots[i]->rfc_handle,
|
||||
(void *)spp_local_param.spp_slots[i]->id);
|
||||
}
|
||||
|
||||
tBTA_JV_FREE_SCN_USER_DATA *user_data = osi_malloc(sizeof(tBTA_JV_FREE_SCN_USER_DATA));
|
||||
if (user_data) {
|
||||
user_data->server_status = BTA_JV_SERVER_RUNNING;
|
||||
user_data->slot_id = spp_local_param.spp_slots[i]->id;
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s unable to malloc user data!", __func__);
|
||||
param.srv_stop.status = ESP_SPP_NO_RESOURCE;
|
||||
btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, ¶m);
|
||||
}
|
||||
BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM,
|
||||
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data);
|
||||
}
|
||||
}
|
||||
BTA_JvDisable((tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb);
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
osi_mutex_free(&spp_local_param.spp_slot_mutex);
|
||||
}
|
||||
|
||||
static void btc_spp_start_discovery(btc_spp_args_t *arg)
|
||||
{
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
return;
|
||||
}
|
||||
BTA_JvStartDiscovery(arg->start_discovery.bd_addr, arg->start_discovery.num_uuid, arg->start_discovery.p_uuid_list, NULL);
|
||||
}
|
||||
|
||||
static void btc_spp_connect(btc_spp_args_t *arg)
|
||||
{
|
||||
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);
|
||||
spp_slot_t *slot = spp_malloc_slot();
|
||||
if (!slot) {
|
||||
|
@ -376,6 +467,10 @@ static void btc_spp_connect(btc_spp_args_t *arg)
|
|||
|
||||
static void btc_spp_disconnect(btc_spp_args_t *arg)
|
||||
{
|
||||
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);
|
||||
spp_slot_t *slot = spp_find_slot_by_handle(arg->disconnect.handle);
|
||||
if (!slot) {
|
||||
|
@ -383,14 +478,16 @@ static void btc_spp_disconnect(btc_spp_args_t *arg)
|
|||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
return;
|
||||
}
|
||||
BTA_JvRfcommClose(arg->disconnect.handle, (void *)slot->id);
|
||||
btc_disconnect_cb(slot->rfc_handle);
|
||||
spp_free_slot(slot);
|
||||
BTA_JvRfcommClose(arg->disconnect.handle, (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)slot->id);
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
}
|
||||
|
||||
static void btc_spp_start_srv(btc_spp_args_t *arg)
|
||||
{
|
||||
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);
|
||||
spp_slot_t *slot = spp_malloc_slot();
|
||||
if (!slot) {
|
||||
|
@ -408,8 +505,54 @@ static void btc_spp_start_srv(btc_spp_args_t *arg)
|
|||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
}
|
||||
|
||||
static void btc_spp_stop_srv(void) {
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
return;
|
||||
}
|
||||
esp_spp_cb_param_t param;
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
// first, remove all connection
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) {
|
||||
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle,(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb,
|
||||
(void *)spp_local_param.spp_slots[i]->id);
|
||||
}
|
||||
}
|
||||
// second, remove all server
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && !spp_local_param.spp_slots[i]->connected) {
|
||||
if (spp_local_param.spp_slots[i]->sdp_handle > 0) {
|
||||
BTA_JvDeleteRecord(spp_local_param.spp_slots[i]->sdp_handle);
|
||||
}
|
||||
|
||||
if (spp_local_param.spp_slots[i]->rfc_handle > 0) {
|
||||
BTA_JvRfcommStopServer(spp_local_param.spp_slots[i]->rfc_handle,
|
||||
(void *)spp_local_param.spp_slots[i]->id);
|
||||
}
|
||||
|
||||
tBTA_JV_FREE_SCN_USER_DATA *user_data = osi_malloc(sizeof(tBTA_JV_FREE_SCN_USER_DATA));
|
||||
if (user_data) {
|
||||
user_data->server_status = BTA_JV_SERVER_RUNNING;
|
||||
user_data->slot_id = spp_local_param.spp_slots[i]->id;
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s unable to malloc user data!", __func__);
|
||||
param.srv_stop.status = ESP_SPP_NO_RESOURCE;
|
||||
btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, ¶m);
|
||||
}
|
||||
BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM,
|
||||
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data);
|
||||
}
|
||||
}
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
}
|
||||
|
||||
static void btc_spp_write(btc_spp_args_t *arg)
|
||||
{
|
||||
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);
|
||||
spp_slot_t *slot = spp_find_slot_by_handle(arg->write.handle);
|
||||
if (!slot) {
|
||||
|
@ -423,7 +566,7 @@ static void btc_spp_write(btc_spp_args_t *arg)
|
|||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
return;
|
||||
}
|
||||
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990);
|
||||
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0, BTA_JV_DEF_RFC_MTU);
|
||||
if (item_size != 0){
|
||||
slot->write_data = data;
|
||||
BTA_JvRfcommWrite(arg->write.handle, slot->id, item_size, data);
|
||||
|
@ -504,6 +647,9 @@ void btc_spp_call_handler(btc_msg_t *msg)
|
|||
case BTC_SPP_ACT_START_SRV:
|
||||
btc_spp_start_srv(arg);
|
||||
break;
|
||||
case BTC_SPP_ACT_STOP_SRV:
|
||||
btc_spp_stop_srv();
|
||||
break;
|
||||
case BTC_SPP_ACT_WRITE:
|
||||
btc_spp_write(arg);
|
||||
break;
|
||||
|
@ -562,22 +708,24 @@ void btc_spp_cb_handler(btc_msg_t *msg)
|
|||
btc_spp_cb_to_app(ESP_SPP_START_EVT, ¶m);
|
||||
break;
|
||||
case BTA_JV_RFCOMM_SRV_OPEN_EVT:
|
||||
if (spp_local_param.spp_mode == ESP_SPP_MODE_VFS) {
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
slot = spp_find_slot_by_handle(p_data->rfc_srv_open.handle);
|
||||
if (!slot) {
|
||||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
|
||||
if (p_data->rfc_srv_open.handle) {
|
||||
if (spp_local_param.spp_mode == ESP_SPP_MODE_VFS) {
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
slot = spp_find_slot_by_handle(p_data->rfc_srv_open.handle);
|
||||
if (!slot) {
|
||||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
break;
|
||||
}
|
||||
param.srv_open.fd = slot->fd;
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
break;
|
||||
}
|
||||
param.srv_open.fd = slot->fd;
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
param.srv_open.status = p_data->rfc_srv_open.status;
|
||||
param.srv_open.handle = p_data->rfc_srv_open.handle;
|
||||
param.srv_open.new_listen_handle = p_data->rfc_srv_open.new_listen_handle;
|
||||
memcpy(param.srv_open.rem_bda, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN);
|
||||
btc_spp_cb_to_app(ESP_SPP_SRV_OPEN_EVT, ¶m);
|
||||
}
|
||||
param.srv_open.status = p_data->rfc_srv_open.status;
|
||||
param.srv_open.handle = p_data->rfc_srv_open.handle;
|
||||
param.srv_open.new_listen_handle = p_data->rfc_srv_open.new_listen_handle;
|
||||
memcpy(param.srv_open.rem_bda, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN);
|
||||
btc_spp_cb_to_app(ESP_SPP_SRV_OPEN_EVT, ¶m);
|
||||
break;
|
||||
case BTA_JV_RFCOMM_WRITE_EVT:
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
@ -609,7 +757,7 @@ void btc_spp_cb_handler(btc_msg_t *msg)
|
|||
slot->write_data = NULL;
|
||||
}
|
||||
size_t item_size = 0;
|
||||
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990);
|
||||
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0, BTA_JV_DEF_RFC_MTU);
|
||||
if (item_size != 0){
|
||||
slot->write_data = data;
|
||||
BTA_JvRfcommWrite(slot->rfc_handle, slot->id, item_size, data);
|
||||
|
@ -645,7 +793,7 @@ void btc_spp_cb_handler(btc_msg_t *msg)
|
|||
slot->write_data = NULL;
|
||||
}
|
||||
size_t item_size = 0;
|
||||
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990);
|
||||
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0, BTA_JV_DEF_RFC_MTU);
|
||||
if (item_size != 0){
|
||||
slot->write_data = data;
|
||||
BTA_JvRfcommWrite(slot->rfc_handle, slot->id, item_size, data);
|
||||
|
@ -668,6 +816,22 @@ void btc_spp_cb_handler(btc_msg_t *msg)
|
|||
btc_spp_cb_to_app(ESP_SPP_DATA_IND_EVT, ¶m);
|
||||
osi_free (p_data->data_ind.p_buf);
|
||||
break;
|
||||
case BTA_JV_FREE_SCN_EVT:
|
||||
if (p_data->free_scn.server_status == BTA_JV_SERVER_RUNNING) {
|
||||
param.srv_stop.status = p_data->free_scn.status;
|
||||
btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, ¶m);
|
||||
}
|
||||
break;
|
||||
case BTA_JV_DISABLE_EVT:
|
||||
param.uninit.status = ESP_SPP_SUCCESS;
|
||||
BTA_JvFree();
|
||||
osi_mutex_free(&spp_local_param.spp_slot_mutex);
|
||||
#if SPP_DYNAMIC_MEMORY == TRUE
|
||||
osi_free(spp_local_param_ptr);
|
||||
spp_local_param_ptr = NULL;
|
||||
#endif
|
||||
btc_spp_cb_to_app(ESP_SPP_UNINIT_EVT, ¶m);
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_DEBUG("%s: Unhandled event (%d)!", __FUNCTION__, msg->act);
|
||||
break;
|
||||
|
@ -705,12 +869,16 @@ int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf)
|
|||
msg.act = BTA_JV_RFCOMM_DATA_IND_EVT;
|
||||
|
||||
uint32_t id = (uintptr_t)user_data;
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
spp_slot_t *slot = spp_find_slot_by_id(id);
|
||||
if (!slot) {
|
||||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
p_data.data_ind.handle = slot->rfc_handle;
|
||||
|
||||
|
@ -751,6 +919,10 @@ int bta_co_rfc_data_outgoing(void *user_data, uint8_t *buf, uint16_t size)
|
|||
|
||||
static ssize_t spp_vfs_write(int fd, const void * data, size_t size)
|
||||
{
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
spp_slot_t *slot = spp_find_slot_by_fd(fd);
|
||||
if (!slot) {
|
||||
|
@ -770,6 +942,10 @@ static ssize_t spp_vfs_write(int fd, const void * data, size_t size)
|
|||
}
|
||||
static int spp_vfs_close(int fd)
|
||||
{
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
spp_slot_t *slot = spp_find_slot_by_fd(fd);
|
||||
if (!slot) {
|
||||
|
@ -798,6 +974,10 @@ static bool incoming_list_2_ringbuf_read(spp_slot_t *slot)
|
|||
|
||||
static ssize_t spp_vfs_read(int fd, void * dst, size_t size)
|
||||
{
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
spp_slot_t *slot = spp_find_slot_by_fd(fd);
|
||||
if (!slot) {
|
||||
|
|
|
@ -96,6 +96,12 @@
|
|||
|
||||
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
|
||||
|
||||
/* This is set to enable use of GAP L2CAP connections. */
|
||||
#if (VND_BT_JV_BTA_L2CAP == TRUE)
|
||||
#define BTA_JV_L2CAP_INCLUDED TRUE
|
||||
#define GAP_CONN_INCLUDED TRUE
|
||||
#endif /* VND_BT_JV_BTA_L2CAP */
|
||||
|
||||
#ifndef CLASSIC_BT_INCLUDED
|
||||
#define CLASSIC_BT_INCLUDED FALSE
|
||||
#endif /* CLASSIC_BT_INCLUDED */
|
||||
|
@ -293,6 +299,19 @@
|
|||
#define BTA_SDP_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/* This is set to enable use of GAP L2CAP connections. */
|
||||
#ifndef VND_BT_JV_BTA_L2CAP
|
||||
#define VND_BT_JV_BTA_L2CAP FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_JV_L2CAP_INCLUDED
|
||||
#define BTA_JV_L2CAP_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef GAP_CONN_INCLUDED
|
||||
#define GAP_CONN_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Stack-layer components
|
||||
|
@ -1341,7 +1360,7 @@
|
|||
|
||||
/* The maximum number of ports supported. */
|
||||
#ifndef MAX_RFC_PORTS
|
||||
#define MAX_RFC_PORTS 16 /*max is 30*/
|
||||
#define MAX_RFC_PORTS 8 /*max is 30*/
|
||||
#endif
|
||||
|
||||
/* The maximum simultaneous links to different devices. */
|
||||
|
@ -1710,15 +1729,6 @@ Range: 2 octets
|
|||
#define GAP_INCLUDED TRUE
|
||||
#endif
|
||||
|
||||
/* This is set to enable use of GAP L2CAP connections. */
|
||||
#ifndef GAP_CONN_INCLUDED
|
||||
#if (GAP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
|
||||
#define GAP_CONN_INCLUDED TRUE
|
||||
#else
|
||||
#define GAP_CONN_INCLUDED FALSE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This is set to enable posting event for data write */
|
||||
#ifndef GAP_CONN_POST_EVT_INCLUDED
|
||||
#define GAP_CONN_POST_EVT_INCLUDED FALSE
|
||||
|
|
|
@ -231,7 +231,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
|
|||
UINT8 xx;
|
||||
|
||||
BTM_TRACE_DEBUG ("btm_acl_created hci_handle=%d link_role=%d transport=%d\n",
|
||||
hci_handle, link_role, transport);
|
||||
hci_handle, link_role, transport);
|
||||
/* Ensure we don't have duplicates */
|
||||
p = btm_bda_to_acl(bda, transport);
|
||||
if (p != (tACL_CONN *)NULL) {
|
||||
|
@ -241,7 +241,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
|
|||
p->transport = transport;
|
||||
#endif
|
||||
BTM_TRACE_DEBUG ("Duplicate btm_acl_created: RemBdAddr: %02x%02x%02x%02x%02x%02x\n",
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
BTM_SetLinkPolicy(p->remote_addr, &btm_cb.btm_def_link_policy);
|
||||
return;
|
||||
}
|
||||
|
@ -269,13 +269,16 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
|
|||
p->conn_addr_type = BLE_ADDR_PUBLIC;
|
||||
memcpy(p->conn_addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN);
|
||||
BTM_TRACE_DEBUG ("conn_addr: RemBdAddr: %02x%02x%02x%02x%02x%02x\n",
|
||||
p->conn_addr[0], p->conn_addr[1], p->conn_addr[2], p->conn_addr[3], p->conn_addr[4], p->conn_addr[5]);
|
||||
p->conn_addr[0], p->conn_addr[1], p->conn_addr[2], p->conn_addr[3], p->conn_addr[4], p->conn_addr[5]);
|
||||
#endif
|
||||
#endif
|
||||
p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
|
||||
|
||||
btm_pm_sm_alloc(xx);
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
btm_sec_update_legacy_auth_state(p, BTM_ACL_LEGACY_AUTH_NONE);
|
||||
#endif
|
||||
|
||||
if (dc) {
|
||||
memcpy (p->remote_dc, dc, DEV_CLASS_LEN);
|
||||
|
@ -299,28 +302,34 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
|
|||
#endif
|
||||
|
||||
if (p_dev_rec && !(transport == BT_TRANSPORT_LE)) {
|
||||
/* If remote features already known, copy them and continue connection setup */
|
||||
if ((p_dev_rec->num_read_pages) &&
|
||||
(p_dev_rec->num_read_pages <= (HCI_EXT_FEATURES_PAGE_MAX + 1))) {
|
||||
memcpy (p->peer_lmp_features, p_dev_rec->features,
|
||||
(HCI_FEATURE_BYTES_PER_PAGE * p_dev_rec->num_read_pages));
|
||||
p->num_read_pages = p_dev_rec->num_read_pages;
|
||||
if (!p_dev_rec->remote_secure_connection_previous_state) {
|
||||
/* If remote features already known, copy them and continue connection setup */
|
||||
if ((p_dev_rec->num_read_pages) &&
|
||||
(p_dev_rec->num_read_pages <= (HCI_EXT_FEATURES_PAGE_MAX + 1))) {
|
||||
memcpy (p->peer_lmp_features, p_dev_rec->features,
|
||||
(HCI_FEATURE_BYTES_PER_PAGE * p_dev_rec->num_read_pages));
|
||||
p->num_read_pages = p_dev_rec->num_read_pages;
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
|
||||
const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
/* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
|
||||
/* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
btm_sec_set_peer_sec_caps(p, p_dev_rec);
|
||||
btm_sec_set_peer_sec_caps(p, p_dev_rec);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend);
|
||||
if (req_pend) {
|
||||
/* Request for remaining Security Features (if any) */
|
||||
l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
|
||||
}
|
||||
BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend);
|
||||
if (req_pend) {
|
||||
/* Request for remaining Security Features (if any) */
|
||||
l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
|
||||
}
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
btm_establish_continue (p);
|
||||
return;
|
||||
btm_establish_continue (p);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/* If remote features indicated secure connection (SC) mode, check the remote feautres again*/
|
||||
/* this is to prevent from BIAS attack where attacker can downgrade SC mode*/
|
||||
btm_read_remote_features (p->hci_handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,13 +338,13 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
|
|||
if (p_dev_rec && transport == BT_TRANSPORT_LE) {
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
btm_ble_get_acl_remote_addr (p_dev_rec, p->active_remote_addr,
|
||||
&p->active_remote_addr_type);
|
||||
&p->active_remote_addr_type);
|
||||
#endif
|
||||
|
||||
if (link_role == HCI_ROLE_MASTER) {
|
||||
btsnd_hcic_ble_read_remote_feat(p->hci_handle);
|
||||
} else if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array)
|
||||
&& link_role == HCI_ROLE_SLAVE) {
|
||||
&& link_role == HCI_ROLE_SLAVE) {
|
||||
btsnd_hcic_rmt_ver_req (p->hci_handle);
|
||||
} else {
|
||||
btm_establish_continue(p);
|
||||
|
@ -785,12 +794,28 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
|
|||
BTM_TRACE_WARNING("btm_acl_encrypt_change -> Issuing delayed HCI_Disconnect!!!\n");
|
||||
btsnd_hcic_disconnect(p_dev_rec->hci_handle, HCI_ERR_PEER_USER);
|
||||
}
|
||||
BTM_TRACE_ERROR("btm_acl_encrypt_change: tBTM_SEC_DEV:0x%x rs_disc_pending=%d\n",
|
||||
BTM_TRACE_WARNING("btm_acl_encrypt_change: tBTM_SEC_DEV:0x%x rs_disc_pending=%d\n",
|
||||
(UINT32)p_dev_rec, p_dev_rec->rs_disc_pending);
|
||||
p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/* If authentication is done through legacy authentication and esp32 has
|
||||
* not authenticated peer deivce yet, do not proceed for encrytion and
|
||||
* first authenticate it. */
|
||||
else if ((BTM_BothEndsSupportSecureConnections(p->remote_addr) == 0) &&
|
||||
((p->legacy_auth_state & BTM_ACL_LEGACY_AUTH_SELF) == 0)) {
|
||||
if ((p_dev_rec = btm_find_dev (p->remote_addr)) != NULL) {
|
||||
if (btm_sec_legacy_authentication_mutual(p_dev_rec)) {
|
||||
btm_sec_update_legacy_auth_state(btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR), BTM_ACL_LEGACY_AUTH_SELF);
|
||||
} else {
|
||||
BTM_TRACE_ERROR("%s failed, Resources not available for Authentication procedure", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -1115,7 +1140,6 @@ void btm_read_remote_ext_features_complete (UINT8 *p)
|
|||
|
||||
if (max_page > HCI_EXT_FEATURES_PAGE_MAX) {
|
||||
BTM_TRACE_ERROR("btm_read_remote_ext_features_complete page=%d unknown", max_page);
|
||||
return;
|
||||
}
|
||||
|
||||
p_acl_cb = &btm_cb.acl_db[acl_idx];
|
||||
|
@ -1212,6 +1236,7 @@ void btm_establish_continue (tACL_CONN *p_acl_cb)
|
|||
evt_data.conn.p_bdn = p_acl_cb->remote_name;
|
||||
evt_data.conn.p_dc = p_acl_cb->remote_dc;
|
||||
evt_data.conn.p_features = p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0];
|
||||
evt_data.conn.sc_downgrade = p_acl_cb->sc_downgrade;
|
||||
#if BLE_INCLUDED == TRUE
|
||||
evt_data.conn.handle = p_acl_cb->hci_handle;
|
||||
evt_data.conn.transport = p_acl_cb->transport;
|
||||
|
|
|
@ -60,7 +60,7 @@ static tBTM_SEC_DEV_REC *btm_find_oldest_dev (void);
|
|||
BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name,
|
||||
UINT8 *features, UINT32 trusted_mask[],
|
||||
LINK_KEY link_key, UINT8 key_type, tBTM_IO_CAP io_cap,
|
||||
UINT8 pin_length)
|
||||
UINT8 pin_length, UINT8 sc_support)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
tBTM_SEC_DEV_REC *p_dev_rec;
|
||||
|
@ -98,6 +98,7 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name,
|
|||
|
||||
p_dev_rec->bond_type = BOND_TYPE_UNKNOWN; /* Default value */
|
||||
p_dev_rec->timestamp = btm_cb.dev_rec_count++;
|
||||
p_dev_rec->remote_secure_connection_previous_state = sc_support;
|
||||
|
||||
if (dev_class) {
|
||||
memcpy (p_dev_rec->dev_class, dev_class, DEV_CLASS_LEN);
|
||||
|
|
|
@ -790,13 +790,24 @@ void btm_vendor_specific_evt (UINT8 *p, UINT8 evt_len)
|
|||
{
|
||||
UINT8 i;
|
||||
|
||||
BTM_TRACE_DEBUG ("BTM Event: Vendor Specific event from controller");
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
UINT8 sub_event;
|
||||
UINT8 *p_evt = p;
|
||||
|
||||
STREAM_TO_UINT8(sub_event, p_evt);
|
||||
/* Check in subevent if authentication is through Legacy Authentication. */
|
||||
if (sub_event == ESP_VS_REM_LEGACY_AUTH_CMP) {
|
||||
UINT16 hci_handle;
|
||||
STREAM_TO_UINT16(hci_handle, p_evt);
|
||||
btm_sec_handle_remote_legacy_auth_cmp(hci_handle);
|
||||
}
|
||||
#endif /// (CLASSIC_BT_INCLUDED == TRUE)
|
||||
for (i = 0; i < BTM_MAX_VSE_CALLBACKS; i++) {
|
||||
if (btm_cb.devcb.p_vend_spec_cb[i]) {
|
||||
(*btm_cb.devcb.p_vend_spec_cb[i])(evt_len, p);
|
||||
}
|
||||
}
|
||||
BTM_TRACE_DEBUG ("BTM Event: Vendor Specific event from controller");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2257,7 +2257,7 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle
|
|||
}
|
||||
} else if (!(BTM_SM4_KNOWN & p_dev_rec->sm4)) {
|
||||
/* the remote features are not known yet */
|
||||
BTM_TRACE_DEBUG("%s: (%s) remote features unknown!!sec_flags:0x%02x\n", __FUNCTION__,
|
||||
BTM_TRACE_ERROR("%s: (%s) remote features unknown!!sec_flags:0x%02x\n", __FUNCTION__,
|
||||
(is_originator) ? "initiator" : "acceptor", p_dev_rec->sec_flags);
|
||||
|
||||
p_dev_rec->sm4 |= BTM_SM4_REQ_PEND;
|
||||
|
@ -3917,10 +3917,11 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
|
|||
(BTM_SEC_AUTHENTICATED | BTM_SEC_ENCRYPTED))) {
|
||||
status = HCI_SUCCESS;
|
||||
}
|
||||
|
||||
/* Currently we do not notify user if it is a keyboard which connects */
|
||||
/* User probably Disabled the keyboard while it was asleap. Let her try */
|
||||
/* User probably Disabled the keyboard while it was asleep. Let her try */
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
/* report the suthentication status */
|
||||
/* report the authentication status */
|
||||
if (old_state != BTM_PAIR_STATE_IDLE) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
|
@ -3930,6 +3931,9 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
|
|||
|
||||
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
btm_sec_update_legacy_auth_state(btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR), BTM_ACL_LEGACY_AUTH_SELF);
|
||||
#endif
|
||||
/* If this is a bonding procedure can disconnect the link now */
|
||||
if (are_bonding) {
|
||||
p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE;
|
||||
|
@ -4657,12 +4661,24 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
|
|||
/* If connection was made to do bonding restore link security if changed */
|
||||
btm_restore_mode();
|
||||
|
||||
/* Store the previous state of secure connection as current state. Since
|
||||
* this is the first encounter with the remote device, whatever the remote
|
||||
* device's SC state is, it cannot lower the SC level from this. */
|
||||
p_dev_rec->remote_secure_connection_previous_state = p_dev_rec->remote_supports_secure_connections;
|
||||
if (p_dev_rec->remote_supports_secure_connections) {
|
||||
BTM_TRACE_EVENT ("Remote device supports Secure Connection");
|
||||
} else {
|
||||
BTM_TRACE_EVENT ("Remote device does not support Secure Connection");
|
||||
}
|
||||
if (key_type != BTM_LKEY_TYPE_CHANGED_COMB) {
|
||||
p_dev_rec->link_key_type = key_type;
|
||||
}
|
||||
|
||||
p_dev_rec->sec_flags |= BTM_SEC_LINK_KEY_KNOWN;
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
btm_sec_update_legacy_auth_state(btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR), BTM_ACL_LEGACY_AUTH_NONE);
|
||||
#endif
|
||||
/*
|
||||
* Until this point in time, we do not know if MITM was enabled, hence we
|
||||
* add the extended security flag here.
|
||||
|
@ -4695,7 +4711,8 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
|
|||
__FUNCTION__, p_dev_rec->link_key_type);
|
||||
(*btm_cb.api.p_link_key_callback) (p_bda, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name,
|
||||
p_link_key, p_dev_rec->link_key_type);
|
||||
p_link_key, p_dev_rec->link_key_type,
|
||||
p_dev_rec->remote_supports_secure_connections);
|
||||
}
|
||||
} else {
|
||||
if ((p_dev_rec->link_key_type == BTM_LKEY_TYPE_UNAUTH_COMB_P_256) ||
|
||||
|
@ -4752,7 +4769,8 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
|
|||
} else {
|
||||
(*btm_cb.api.p_link_key_callback) (p_bda, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name,
|
||||
p_link_key, p_dev_rec->link_key_type);
|
||||
p_link_key, p_dev_rec->link_key_type,
|
||||
p_dev_rec->remote_supports_secure_connections);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5543,7 +5561,9 @@ static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec)
|
|||
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);
|
||||
p_dev_rec->link_key_type,
|
||||
p_dev_rec->remote_supports_secure_connections);
|
||||
|
||||
}
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
@ -5894,6 +5914,29 @@ void btm_sec_set_peer_sec_caps(tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec)
|
|||
BTM_TRACE_API("%s: sm4: 0x%02x, rmt_support_for_secure_connections %d\n", __FUNCTION__,
|
||||
p_dev_rec->sm4, p_dev_rec->remote_supports_secure_connections);
|
||||
|
||||
/* Store previous state of remote device to check if peer device downgraded
|
||||
* it's secure connection state. */
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
if (p_dev_rec->remote_supports_secure_connections >= p_dev_rec->remote_secure_connection_previous_state) {
|
||||
p_dev_rec->remote_secure_connection_previous_state = p_dev_rec->remote_supports_secure_connections;
|
||||
} else {
|
||||
BTM_TRACE_ERROR("Remote Device downgraded security from SC, deleting Link Key");
|
||||
|
||||
/* Mark in ACL packet that secure connection is downgraded. */
|
||||
p_acl_cb->sc_downgrade = 1;
|
||||
p_dev_rec->remote_secure_connection_previous_state = 0;
|
||||
|
||||
/* As peer device downgraded it's security, peer device is a suspicious
|
||||
* device. Hence remove pairing information by removing link key
|
||||
* information. */
|
||||
memset(p_dev_rec->link_key, 0, LINK_KEY_LEN);
|
||||
p_dev_rec->sec_flags &= ~(BTM_SEC_AUTHORIZED | BTM_SEC_AUTHENTICATED
|
||||
| BTM_SEC_ENCRYPTED | BTM_SEC_NAME_KNOWN
|
||||
| BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_LINK_KEY_AUTHED
|
||||
| BTM_SEC_ROLE_SWITCHED | BTM_SEC_16_DIGIT_PIN_AUTHED);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_dev_rec->remote_features_needed) {
|
||||
BTM_TRACE_EVENT("%s: Now device in SC Only mode, waiting for peer remote features!\n",
|
||||
|
@ -6156,5 +6199,62 @@ static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec)
|
|||
tACL_CONN *p = btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR);
|
||||
return (p && (p->link_role == BTM_ROLE_MASTER));
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_sec_legacy_authentication_mutual
|
||||
**
|
||||
** Description This function is called when legacy authentication is used
|
||||
** and only remote device has completed the authentication
|
||||
**
|
||||
** Returns TRUE if aunthentication command sent successfully
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN btm_sec_legacy_authentication_mutual (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
{
|
||||
return (btm_sec_start_authentication (p_dev_rec));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_sec_update_legacy_auth_state
|
||||
**
|
||||
** Description This function updates the legacy authentication state
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_sec_update_legacy_auth_state(tACL_CONN *p_acl_cb, UINT8 legacy_auth_state)
|
||||
{
|
||||
if (p_acl_cb) {
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (p_acl_cb->hci_handle);
|
||||
if (p_dev_rec) {
|
||||
if ((BTM_BothEndsSupportSecureConnections(p_dev_rec->bd_addr) == 0) &&
|
||||
(legacy_auth_state != BTM_ACL_LEGACY_AUTH_NONE)) {
|
||||
p_acl_cb->legacy_auth_state |= legacy_auth_state;
|
||||
} else {
|
||||
p_acl_cb->legacy_auth_state = BTM_ACL_LEGACY_AUTH_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_sec_handle_remote_legacy_auth_cmp
|
||||
**
|
||||
** Description This function updates the legacy authneticaiton state
|
||||
** to indicate that remote device has completed the authentication
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_sec_handle_remote_legacy_auth_cmp(UINT16 handle)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
|
||||
tACL_CONN *p_acl_cb = btm_bda_to_acl(p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR);
|
||||
btm_sec_update_legacy_auth_state(p_acl_cb, BTM_ACL_LEGACY_AUTH_REMOTE);
|
||||
}
|
||||
#endif /// (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define ESP_VS_REM_LEGACY_AUTH_CMP 0x03
|
||||
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
typedef char tBTM_LOC_BD_NAME[BTM_MAX_LOC_BD_NAME_LEN + 1];
|
||||
#endif
|
||||
|
@ -92,6 +94,13 @@ UINT8 lmp_version;
|
|||
BOOLEAN in_use;
|
||||
UINT8 link_role;
|
||||
BOOLEAN link_up_issued; /* True if busy_level link up has been issued */
|
||||
BOOLEAN sc_downgrade; /* Store if security is downgraded or not. */
|
||||
|
||||
#define BTM_ACL_LEGACY_AUTH_NONE (0)
|
||||
#define BTM_ACL_LEGACY_AUTH_SELF (1<<0)
|
||||
#define BTM_ACL_LEGACY_AUTH_REMOTE (1<<1)
|
||||
#define BTM_ACL_LEGACY_AUTH_MUTUAL (1<<2)
|
||||
UINT8 legacy_auth_state;
|
||||
|
||||
#define BTM_ACL_SWKEY_STATE_IDLE 0
|
||||
#define BTM_ACL_SWKEY_STATE_MODE_CHANGE 1
|
||||
|
@ -592,6 +601,8 @@ typedef struct {
|
|||
/* "Secure Connections Only" mode and it receives */
|
||||
/* HCI_IO_CAPABILITY_REQUEST_EVT from the peer before */
|
||||
/* it knows peer's support for Secure Connections */
|
||||
BOOLEAN remote_secure_connection_previous_state; /* Stores if peer ever supported
|
||||
secure connection. This will be helpful to know when peer device downgrades it's security. */
|
||||
|
||||
UINT16 ble_hci_handle; /* use in DUMO connection */
|
||||
UINT8 enc_key_size; /* current link encryption key size */
|
||||
|
@ -1146,6 +1157,10 @@ void btm_sem_free(void);
|
|||
|
||||
void btm_lock_free(void);
|
||||
|
||||
void btm_sec_handle_remote_legacy_auth_cmp(UINT16 handle);
|
||||
void btm_sec_update_legacy_auth_state(tACL_CONN *p_acl_cb, UINT8 legacy_auth_state);
|
||||
BOOLEAN btm_sec_legacy_authentication_mutual (tBTM_SEC_DEV_REC *p_dev_rec);
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -219,6 +219,7 @@ void gatt_act_write (tGATT_CLCB *p_clcb, UINT8 sec_act)
|
|||
if (p_attr) {
|
||||
switch (p_clcb->op_subtype) {
|
||||
case GATT_WRITE_NO_RSP:
|
||||
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTU_NUM, NULL);
|
||||
p_clcb->s_handle = p_attr->handle;
|
||||
op_code = (sec_act == GATT_SEC_SIGN_DATA) ? GATT_SIGN_CMD_WRITE : GATT_CMD_WRITE;
|
||||
rt = gatt_send_write_msg(p_tcb,
|
||||
|
|
|
@ -825,14 +825,15 @@ typedef UINT16 tBTM_BL_EVENT_MASK;
|
|||
|
||||
/* the data type associated with BTM_BL_CONN_EVT */
|
||||
typedef struct {
|
||||
tBTM_BL_EVENT event; /* The event reported. */
|
||||
BD_ADDR_PTR p_bda; /* The address of the newly connected device */
|
||||
DEV_CLASS_PTR p_dc; /* The device class */
|
||||
BD_NAME_PTR p_bdn; /* The device name */
|
||||
UINT8 *p_features; /* pointer to the remote device's features page[0] (supported features page) */
|
||||
tBTM_BL_EVENT event; /* The event reported. */
|
||||
BD_ADDR_PTR p_bda; /* The address of the newly connected device */
|
||||
DEV_CLASS_PTR p_dc; /* The device class */
|
||||
BD_NAME_PTR p_bdn; /* The device name */
|
||||
UINT8 *p_features; /* pointer to the remote device's features page[0] (supported features page) */
|
||||
BOOLEAN sc_downgrade; /* Secure connection downgrade state. */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
UINT16 handle; /* connection handle */
|
||||
tBT_TRANSPORT transport; /* link is LE or not */
|
||||
UINT16 handle; /* connection handle */
|
||||
tBT_TRANSPORT transport; /* link is LE or not */
|
||||
#endif
|
||||
} tBTM_BL_CONN_DATA;
|
||||
|
||||
|
@ -1352,7 +1353,7 @@ typedef UINT8 (tBTM_PIN_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
|
|||
*/
|
||||
typedef UINT8 (tBTM_LINK_KEY_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
|
||||
tBTM_BD_NAME bd_name, UINT8 *key,
|
||||
UINT8 key_type);
|
||||
UINT8 key_type, BOOLEAN sc_support);
|
||||
|
||||
|
||||
/* Remote Name Resolved. Parameters are
|
||||
|
@ -3406,7 +3407,8 @@ UINT8 BTM_SecClrService (UINT8 service_id);
|
|||
BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class,
|
||||
BD_NAME bd_name, UINT8 *features,
|
||||
UINT32 trusted_mask[], LINK_KEY link_key,
|
||||
UINT8 key_type, tBTM_IO_CAP io_cap, UINT8 pin_length);
|
||||
UINT8 key_type, tBTM_IO_CAP io_cap, UINT8 pin_length,
|
||||
UINT8 sc_support);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "common/bt_target.h"
|
||||
#include "stack/l2cdefs.h"
|
||||
#include "stack/hcidefs.h"
|
||||
#include "osi/fixed_queue.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
|
@ -1227,6 +1228,21 @@ extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transp
|
|||
|
||||
extern BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, UINT16 handle);
|
||||
|
||||
#define L2CA_GET_ATT_NUM 0
|
||||
#define L2CA_ADD_BTC_NUM 1
|
||||
#define L2CA_DECREASE_BTC_NUM 2
|
||||
#define L2CA_ADD_BTU_NUM 3
|
||||
#define L2CA_DECREASE_BTU_NUM 4
|
||||
#define L2CA_BUFF_INI 5
|
||||
#define L2CA_BUFF_DEINIT 6
|
||||
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
UINT16 * get_num;
|
||||
} tl2c_buff_param_t;
|
||||
|
||||
|
||||
extern void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param);
|
||||
|
||||
#endif /* (BLE_INCLUDED == TRUE) */
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
#define L2CAP_DEFAULT_RETRANS_TOUT 2000 /* 2000 milliseconds */
|
||||
#define L2CAP_DEFAULT_MONITOR_TOUT 12000 /* 12000 milliseconds */
|
||||
#define L2CAP_FCR_ACK_TOUT 200 /* 200 milliseconds */
|
||||
|
||||
#define L2CAP_CACHE_ATT_ACL_NUM 10
|
||||
/* Define the possible L2CAP channel states. The names of
|
||||
** the states may seem a bit strange, but they are taken from
|
||||
** the Bluetooth specification.
|
||||
|
@ -165,6 +165,10 @@ typedef enum {
|
|||
|
||||
#define L2CAP_MAX_FCR_CFG_TRIES 2 /* Config attempts before disconnecting */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
typedef uint8_t tL2C_BLE_FIXED_CHNLS_MASK;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "stack/btu.h"
|
||||
#include "stack/btm_api.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "gatt_int.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
|
@ -1877,6 +1879,16 @@ UINT16 L2CA_GetFreePktBufferNum_LE(void)
|
|||
{
|
||||
return l2cb.controller_le_xmit_window;
|
||||
}
|
||||
UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id)
|
||||
{
|
||||
uint16_t num = 0;
|
||||
tl2c_buff_param_t param;
|
||||
param.conn_id = conn_id;
|
||||
param.get_num = #
|
||||
l2ble_update_att_acl_pkt_num(L2CA_GET_ATT_NUM, ¶m);
|
||||
return num;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -2265,3 +2277,111 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush)
|
|||
return (num_left);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function update_acl_pkt_num
|
||||
**
|
||||
** Description Update the number of att acl packets to be sent in xmit_hold_q.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param)
|
||||
{
|
||||
static SemaphoreHandle_t buff_semaphore = NULL ;
|
||||
static INT16 btc_buf;
|
||||
static INT16 btu_buf;
|
||||
|
||||
if(buff_semaphore == NULL && type != L2CA_BUFF_INI){
|
||||
L2CAP_TRACE_ERROR("%s buff_semaphore not init", __func__);
|
||||
return;
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case L2CA_ADD_BTC_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btc_buf ++;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_DECREASE_BTC_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btc_buf --;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_ADD_BTU_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btu_buf ++;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_DECREASE_BTU_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btu_buf --;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_GET_ATT_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
INT16 att_acl_pkt_num = 0;
|
||||
INT16 att_max_num = 0;
|
||||
*(param->get_num) = 0;
|
||||
UINT8 tcb_idx = param->conn_id;
|
||||
tGATT_TCB * p_tcb = gatt_get_tcb_by_idx(tcb_idx);
|
||||
if (p_tcb == NULL){
|
||||
L2CAP_TRACE_ERROR("%s not found p_tcb", __func__);
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
tL2C_LCB * p_lcb = l2cu_find_lcb_by_bd_addr (p_tcb->peer_bda, BT_TRANSPORT_LE);
|
||||
if (p_lcb == NULL){
|
||||
L2CAP_TRACE_ERROR("%s not found p_lcb", __func__);
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
fixed_queue_t * queue = p_lcb->p_fixed_ccbs[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q;
|
||||
att_max_num = MIN(p_lcb->link_xmit_quota, L2CAP_CACHE_ATT_ACL_NUM);
|
||||
if (queue == NULL){
|
||||
L2CAP_TRACE_ERROR("%s not found queue", __func__);
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
att_acl_pkt_num = fixed_queue_length(queue);
|
||||
if(att_acl_pkt_num < att_max_num){
|
||||
if(btc_buf + btu_buf < att_max_num - att_acl_pkt_num){
|
||||
*(param->get_num) = att_max_num - att_acl_pkt_num - (btc_buf + btu_buf);
|
||||
}
|
||||
}
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_BUFF_INI:{
|
||||
btc_buf = 0;
|
||||
btu_buf = 0;
|
||||
buff_semaphore = xSemaphoreCreateBinary();
|
||||
if (buff_semaphore == NULL) {
|
||||
L2CAP_TRACE_ERROR("%s NO MEMORY", __func__);
|
||||
break;
|
||||
}
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_BUFF_DEINIT:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btc_buf = 0;
|
||||
btu_buf = 0;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
vSemaphoreDelete(buff_semaphore);
|
||||
buff_semaphore = NULL;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -1127,6 +1127,12 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf)
|
|||
while ((l2cb.controller_xmit_window != 0) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota))
|
||||
#endif
|
||||
{
|
||||
//need check flag: partial_segment_being_sent.
|
||||
if ( (p_lcb->partial_segment_being_sent)
|
||||
|| (p_lcb->link_state != LST_CONNECTED)
|
||||
|| (L2C_LINK_CHECK_POWER_MODE (p_lcb)) ) {
|
||||
break;
|
||||
}
|
||||
//L2CAP_TRACE_DEBUG("l2cu_get_next_buffer_to_send = %p",l2cu_get_next_buffer_to_send(p_lcb));
|
||||
if ((p_buf = l2cu_get_next_buffer_to_send (p_lcb)) == NULL) {
|
||||
break;
|
||||
|
|
|
@ -880,6 +880,10 @@ void l2c_init (void)
|
|||
if (l2cb.rcv_pending_q == NULL) {
|
||||
L2CAP_TRACE_ERROR("%s unable to allocate memory for link layer control block", __func__);
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
l2ble_update_att_acl_pkt_num(L2CA_BUFF_INI, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void l2c_free(void)
|
||||
|
@ -889,6 +893,9 @@ void l2c_free(void)
|
|||
#if L2C_DYNAMIC_MEMORY
|
||||
FREE_AND_RESET(l2c_cb_ptr);
|
||||
#endif
|
||||
#if BLE_INCLUDED == TRUE
|
||||
l2ble_update_att_acl_pkt_num(L2CA_BUFF_DEINIT, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -3657,7 +3657,7 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
|
|||
} else {
|
||||
tL2C_LCB *p_lcb = p_ccb->p_lcb;
|
||||
/* If this channel was not congested but it is congested now, tell the app */
|
||||
if ((q_count > p_ccb->buff_quota) || (p_lcb && (p_ccb->local_cid == L2CAP_ATT_CID) && (p_lcb->link_xmit_quota > 0) && (p_lcb->link_xmit_quota <= p_lcb->sent_not_acked))) {
|
||||
if (q_count > p_ccb->buff_quota || (p_lcb && (p_lcb->link_xmit_data_q) && (list_length(p_lcb->link_xmit_data_q) + q_count) > p_ccb->buff_quota)) {
|
||||
p_ccb->cong_sent = TRUE;
|
||||
if (p_ccb->p_rcb && p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb) {
|
||||
L2CAP_TRACE_DEBUG ("L2CAP - Calling CongestionStatus_Cb (TRUE),CID:0x%04x,XmitQ:%u,Quota:%u",
|
||||
|
|
|
@ -164,6 +164,15 @@ static bt_status_t btc_task_post(btc_msg_t *msg, task_post_t timeout)
|
|||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* transfer an message to another module in the different task.
|
||||
* @param msg message
|
||||
* @param arg paramter
|
||||
* @param arg_len length of paramter
|
||||
* @param copy_func deep copy function
|
||||
* @return BT_STATUS_SUCCESS: success
|
||||
* others: fail
|
||||
*/
|
||||
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func)
|
||||
{
|
||||
btc_msg_t lmsg;
|
||||
|
@ -192,6 +201,32 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
|
|||
return btc_task_post(&lmsg, TASK_POST_BLOCKING);
|
||||
}
|
||||
|
||||
/**
|
||||
* transfer an message to another module in tha same task.
|
||||
* @param msg message
|
||||
* @param arg paramter
|
||||
* @return BT_STATUS_SUCCESS: success
|
||||
* others: fail
|
||||
*/
|
||||
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg)
|
||||
{
|
||||
if (msg == NULL) {
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
|
||||
msg->arg = arg;
|
||||
switch (msg->sig) {
|
||||
case BTC_SIG_API_CALL:
|
||||
profile_tab[msg->pid].btc_call(msg);
|
||||
break;
|
||||
case BTC_SIG_API_CB:
|
||||
profile_tab[msg->pid].btc_cb(msg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int btc_init(void)
|
||||
{
|
||||
|
|
|
@ -92,8 +92,26 @@ typedef struct {
|
|||
|
||||
typedef void (* btc_arg_deep_copy_t)(btc_msg_t *msg, void *dst, void *src);
|
||||
|
||||
/**
|
||||
* transfer an message to another module in the different task.
|
||||
* @param msg message
|
||||
* @param arg paramter
|
||||
* @param arg_len length of paramter
|
||||
* @param copy_func deep copy function
|
||||
* @return BT_STATUS_SUCCESS: success
|
||||
* others: fail
|
||||
*/
|
||||
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func);
|
||||
|
||||
/**
|
||||
* transfer an message to another module in tha same task.
|
||||
* @param msg message
|
||||
* @param arg paramter
|
||||
* @return BT_STATUS_SUCCESS: success
|
||||
* others: fail
|
||||
*/
|
||||
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg);
|
||||
|
||||
int btc_init(void);
|
||||
void btc_deinit(void);
|
||||
bool btc_check_queue_is_congest(void);
|
||||
|
|
|
@ -267,6 +267,7 @@ bool config_remove_key(config_t *config, const char *section, const char *key)
|
|||
assert(config != NULL);
|
||||
assert(section != NULL);
|
||||
assert(key != NULL);
|
||||
bool ret;
|
||||
|
||||
section_t *sec = section_find(config, section);
|
||||
entry_t *entry = entry_find(config, section, key);
|
||||
|
@ -274,7 +275,12 @@ bool config_remove_key(config_t *config, const char *section, const char *key)
|
|||
return false;
|
||||
}
|
||||
|
||||
return list_remove(sec->entries, entry);
|
||||
ret = list_remove(sec->entries, entry);
|
||||
if (list_length(sec->entries) == 0) {
|
||||
OSI_TRACE_DEBUG("%s remove section name:%s",__func__, section);
|
||||
ret &= config_remove_section(config, section);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const config_section_node_t *config_section_begin(const config_t *config)
|
||||
|
|
|
@ -139,6 +139,7 @@ endif
|
|||
|
||||
ifdef CONFIG_BLE_MESH
|
||||
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \
|
||||
esp_ble_mesh/mesh_common/tinycrypt/include \
|
||||
esp_ble_mesh/mesh_core \
|
||||
esp_ble_mesh/mesh_core/include \
|
||||
esp_ble_mesh/mesh_core/storage \
|
||||
|
@ -151,9 +152,11 @@ COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \
|
|||
esp_ble_mesh/api
|
||||
|
||||
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \
|
||||
esp_ble_mesh/mesh_common/tinycrypt/src \
|
||||
esp_ble_mesh/mesh_core \
|
||||
esp_ble_mesh/mesh_core/storage \
|
||||
esp_ble_mesh/btc \
|
||||
esp_ble_mesh/mesh_models/common \
|
||||
esp_ble_mesh/mesh_models/client \
|
||||
esp_ble_mesh/mesh_models/server \
|
||||
esp_ble_mesh/api/core \
|
||||
|
|
|
@ -42,7 +42,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
|
|||
|
||||
// Create a semaphore
|
||||
if ((semaphore = xSemaphoreCreateCounting(1, 0)) == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory for the semaphore", __func__);
|
||||
BT_ERR("Failed to create semaphore");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
|
|||
|
||||
if (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL) != BT_STATUS_SUCCESS) {
|
||||
vSemaphoreDelete(semaphore);
|
||||
BT_ERR("%s, BLE Mesh initialise failed", __func__);
|
||||
BT_ERR("Failed to start mesh init");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void)
|
|||
return btc_ble_mesh_get_primary_addr();
|
||||
}
|
||||
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr)
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
|
||||
uint16_t group_addr)
|
||||
{
|
||||
if (model == NULL) {
|
||||
return NULL;
|
||||
|
@ -54,7 +55,7 @@ uint8_t esp_ble_mesh_get_element_count(void)
|
|||
}
|
||||
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t company_id, uint16_t model_id)
|
||||
uint16_t company_id, uint16_t model_id)
|
||||
{
|
||||
if (element == NULL) {
|
||||
return NULL;
|
||||
|
@ -62,7 +63,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
|
|||
return btc_ble_mesh_model_find_vnd(element, company_id, model_id);
|
||||
}
|
||||
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id)
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t model_id)
|
||||
{
|
||||
if (element == NULL) {
|
||||
return NULL;
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
#define ESP_BLE_MESH_TX_SDU_MAX ((CONFIG_BLE_MESH_ADV_BUF_COUNT - 3) * 12)
|
||||
|
||||
static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
btc_ble_mesh_model_act_t act,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role)
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
btc_ble_mesh_model_act_t act,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role)
|
||||
{
|
||||
btc_ble_mesh_model_args_t arg = {0};
|
||||
uint8_t op_len = 0, mic_len = 0;
|
||||
|
@ -39,12 +39,12 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
|||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_ERR("%s, Invalid destination address 0x0000", __func__);
|
||||
BT_ERR("Invalid destination address 0x0000");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (device_role > ROLE_FAST_PROV) {
|
||||
BT_ERR("%s, Invalid device role 0x%02x", __func__, device_role);
|
||||
BT_ERR("Invalid device role 0x%02x", device_role);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
|||
|
||||
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
|
||||
if (op_len + length > model->pub->msg->size) {
|
||||
BT_ERR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
|
||||
BT_ERR("Too small publication msg size %d", model->pub->msg->size);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
|||
}
|
||||
|
||||
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) {
|
||||
BT_ERR("%s, Data length %d is too large", __func__, length);
|
||||
BT_ERR("Too large data length %d", length);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
@ -176,8 +176,9 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data)
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data)
|
||||
{
|
||||
if (model == NULL || ctx == NULL ||
|
||||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
|
@ -190,9 +191,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data, int32_t msg_timeout,
|
||||
bool need_rsp, esp_ble_mesh_dev_role_t device_role)
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role)
|
||||
{
|
||||
if (model == NULL || ctx == NULL ||
|
||||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
|
@ -218,8 +221,8 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_server_state_type_t type,
|
||||
esp_ble_mesh_server_state_value_t *value)
|
||||
esp_ble_mesh_server_state_type_t type,
|
||||
esp_ble_mesh_server_state_value_t *value)
|
||||
{
|
||||
btc_ble_mesh_model_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -294,7 +297,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name)
|
|||
return bt_mesh_provisioner_get_node_index(name);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length)
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
|
||||
uint8_t *data, uint16_t length)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -334,6 +338,25 @@ esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicas
|
|||
return btc_ble_mesh_provisioner_get_node_with_addr(unicast_addr);
|
||||
}
|
||||
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name)
|
||||
{
|
||||
if (!name || (strlen(name) > ESP_BLE_MESH_NODE_NAME_MAX_LEN)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_provisioner_get_node_with_name(name);
|
||||
}
|
||||
|
||||
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void)
|
||||
{
|
||||
return btc_ble_mesh_provisioner_get_prov_node_count();
|
||||
}
|
||||
|
||||
const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void)
|
||||
{
|
||||
return btc_ble_mesh_provisioner_get_node_table_entry();
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16])
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
|
@ -377,7 +400,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr)
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
|
||||
uint16_t net_idx, uint16_t app_idx)
|
||||
uint16_t net_idx, uint16_t app_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -400,7 +423,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
|
||||
uint16_t net_idx, uint16_t app_idx)
|
||||
uint16_t net_idx, uint16_t app_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -428,7 +451,7 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
|
||||
uint16_t model_id, uint16_t company_id)
|
||||
uint16_t model_id, uint16_t company_id)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -501,12 +524,6 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx)
|
|||
{
|
||||
return bt_mesh_provisioner_local_net_key_get(net_idx);
|
||||
}
|
||||
|
||||
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void)
|
||||
{
|
||||
return btc_ble_mesh_provisioner_get_prov_node_count();
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
|
||||
#if (CONFIG_BLE_MESH_FAST_PROV)
|
||||
|
|
|
@ -35,11 +35,29 @@ bool esp_ble_mesh_node_is_provisioned(void)
|
|||
return bt_mesh_is_provisioned();
|
||||
}
|
||||
|
||||
static bool prov_bearers_valid(esp_ble_mesh_prov_bearer_t bearers)
|
||||
{
|
||||
if ((!(bearers & (ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT))) ||
|
||||
(IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
|
||||
!IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
!(bearers & ESP_BLE_MESH_PROV_ADV)) ||
|
||||
(!IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
!(bearers & ESP_BLE_MESH_PROV_GATT))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (prov_bearers_valid(bearers) == false) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
|
@ -56,6 +74,10 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
|
|||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (prov_bearers_valid(bearers) == false) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
|
@ -68,7 +90,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32],
|
||||
uint8_t private_key[32])
|
||||
uint8_t private_key[32])
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -157,7 +179,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
|
|||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER)
|
||||
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
|
||||
uint8_t pub_key_y[32])
|
||||
uint8_t pub_key_y[32])
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -232,6 +254,10 @@ esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearer
|
|||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (prov_bearers_valid(bearers) == false) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
|
@ -249,6 +275,10 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
|
|||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (prov_bearers_valid(bearers) == false) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
|
@ -262,7 +292,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
|
||||
esp_ble_mesh_dev_add_flag_t flags)
|
||||
esp_ble_mesh_dev_add_flag_t flags)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -288,8 +318,10 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
|
||||
esp_ble_mesh_bd_addr_t addr, esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer, uint16_t oob_info, uint16_t unicast_addr)
|
||||
esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer,
|
||||
uint16_t oob_info, uint16_t unicast_addr)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -347,7 +379,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
|
||||
uint8_t offset, bool prov_after_match)
|
||||
uint8_t offset, bool prov_after_match)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -60,7 +60,8 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx)
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
uint16_t net_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -100,8 +101,8 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle)
|
|||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
||||
uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type)
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
|
||||
esp_ble_mesh_proxy_filter_type_t filter_type)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -124,8 +125,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
|||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
|
||||
uint16_t net_idx, uint16_t *addr, uint16_t addr_num)
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -149,8 +150,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
|
|||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle,
|
||||
uint16_t net_idx, uint16_t *addr, uint16_t addr_num)
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -55,7 +55,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void);
|
|||
* to 0x0000 in order to unsubscribe the model from the group.
|
||||
*
|
||||
*/
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr);
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
|
||||
uint16_t group_addr);
|
||||
|
||||
/**
|
||||
* @brief Find the BLE Mesh element pointer via the element address.
|
||||
|
@ -87,7 +88,7 @@ uint8_t esp_ble_mesh_get_element_count(void);
|
|||
*
|
||||
*/
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t company_id, uint16_t model_id);
|
||||
uint16_t company_id, uint16_t model_id);
|
||||
|
||||
/**
|
||||
* @brief Find the SIG model with the given element and Model id.
|
||||
|
@ -98,7 +99,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
|
|||
* @return Pointer to the SIG Model on success, or NULL on failure which means the SIG Model is not found.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id);
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t model_id);
|
||||
|
||||
/**
|
||||
* @brief Get the Composition data which has been registered.
|
||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
|
||||
/** @brief: event, event code of user-defined model events; param, parameters of user-defined model events */
|
||||
typedef void (* esp_ble_mesh_model_cb_t)(esp_ble_mesh_model_cb_event_t event,
|
||||
esp_ble_mesh_model_cb_param_t *param);
|
||||
esp_ble_mesh_model_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh callback for user-defined models' operations.
|
||||
|
@ -104,8 +104,9 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data);
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Send client model message (such as model get, set, etc).
|
||||
|
@ -123,9 +124,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data, int32_t msg_timeout,
|
||||
bool need_rsp, esp_ble_mesh_dev_role_t device_role);
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role);
|
||||
|
||||
/**
|
||||
* @brief Send a model publication message.
|
||||
|
@ -166,8 +169,8 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_server_state_type_t type,
|
||||
esp_ble_mesh_server_state_value_t *value);
|
||||
esp_ble_mesh_server_state_type_t type,
|
||||
esp_ble_mesh_server_state_value_t *value);
|
||||
|
||||
/**
|
||||
* @brief Reset the provisioning procedure of the local BLE Mesh node.
|
||||
|
@ -226,7 +229,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name);
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length);
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
|
||||
uint8_t *data, uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the provisioned node information
|
||||
|
@ -250,6 +254,48 @@ esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t u
|
|||
*/
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the provisioned node information
|
||||
* with the node name.
|
||||
*
|
||||
* @param[in] name: Name of the node (end by '\0').
|
||||
*
|
||||
* @return Pointer of the node info struct or NULL on failure.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get provisioned node count.
|
||||
*
|
||||
* @return Number of the provisioned nodes.
|
||||
*
|
||||
*/
|
||||
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the entry of the node table.
|
||||
*
|
||||
* @note After invoking the function to get the entry of nodes, users can use the "for"
|
||||
* loop combined with the macro CONFIG_BLE_MESH_MAX_PROV_NODES to get each node's
|
||||
* information. Before trying to read the node's information, users need to check
|
||||
* if the node exists, i.e. if the *(esp_ble_mesh_node_t **node) is NULL.
|
||||
* For example:
|
||||
* ```
|
||||
* const esp_ble_mesh_node_t **entry = esp_ble_mesh_provisioner_get_node_table_entry();
|
||||
* for (int i = 0; i < CONFIG_BLE_MESH_MAX_PROV_NODES; i++) {
|
||||
* const esp_ble_mesh_node_t *node = entry[i];
|
||||
* if (node) {
|
||||
* ......
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @return Pointer to the start of the node table.
|
||||
*
|
||||
*/
|
||||
const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to delete the provisioned node information
|
||||
* with the node device uuid.
|
||||
|
@ -287,7 +333,8 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx);
|
||||
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
|
||||
uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is used to update a local AppKey for Provisioner.
|
||||
|
@ -300,7 +347,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
|
||||
uint16_t net_idx, uint16_t app_idx);
|
||||
uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the local app key value.
|
||||
|
@ -328,7 +375,7 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
|
||||
uint16_t model_id, uint16_t company_id);
|
||||
uint16_t model_id, uint16_t company_id);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to add local network key.
|
||||
|
@ -366,14 +413,6 @@ esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16
|
|||
*/
|
||||
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get provisioned node count.
|
||||
*
|
||||
* @return Number of the provisioned nodes.
|
||||
*
|
||||
*/
|
||||
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get fast provisioning application key.
|
||||
*
|
||||
|
|
|
@ -76,7 +76,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers);
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32],
|
||||
uint8_t private_key[32]);
|
||||
uint8_t private_key[32]);
|
||||
|
||||
/**
|
||||
* @brief Provide provisioning input OOB number.
|
||||
|
@ -128,7 +128,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name);
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
|
||||
uint8_t pub_key_y[32]);
|
||||
uint8_t pub_key_y[32]);
|
||||
|
||||
/**
|
||||
* @brief Provide provisioning input OOB string.
|
||||
|
@ -232,7 +232,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
|
||||
esp_ble_mesh_dev_add_flag_t flags);
|
||||
esp_ble_mesh_dev_add_flag_t flags);
|
||||
|
||||
/** @brief Provision an unprovisioned device with fixed unicast address.
|
||||
*
|
||||
|
@ -257,16 +257,17 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
|
|||
* and "esp_ble_mesh_provisioner_prov_device_with_addr" by a Provisioner.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
|
||||
esp_ble_mesh_bd_addr_t addr, esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer, uint16_t oob_info, uint16_t unicast_addr);
|
||||
esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer,
|
||||
uint16_t oob_info, uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief Delete device from queue, reset current provisioning link and reset the node.
|
||||
* @brief Delete device from queue, and reset current provisioning link with the device.
|
||||
*
|
||||
* @note If the device is in the queue, remove it from the queue; if the device is being
|
||||
* provisioned, terminate the provisioning procedure; if the device has already
|
||||
* been provisioned, reset the device. And either one of the addr or device UUID
|
||||
* can be input.
|
||||
* @note If the device is in the queue, remove it from the queue; if the device is
|
||||
* being provisioned, terminate the provisioning procedure. Either one of the
|
||||
* device address or device UUID can be used as input.
|
||||
*
|
||||
* @param[in] del_dev: Pointer to a struct containing the device information.
|
||||
*
|
||||
|
@ -290,8 +291,8 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
|
|||
*
|
||||
*/
|
||||
typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_ble_mesh_bd_addr_t addr, const esp_ble_mesh_addr_type_t addr_type,
|
||||
const uint8_t adv_type, const uint8_t *dev_uuid,
|
||||
uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer);
|
||||
const uint8_t adv_type, const uint8_t *dev_uuid,
|
||||
uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set the part of the device UUID
|
||||
|
@ -307,7 +308,7 @@ typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_ble_mesh_bd_addr_t addr, co
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
|
||||
uint8_t offset, bool prov_after_match);
|
||||
uint8_t offset, bool prov_after_match);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set provisioning data information
|
||||
|
|
|
@ -65,7 +65,8 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void);
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx);
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client terminates a connection with the Proxy Server.
|
||||
|
@ -87,8 +88,8 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle);
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
||||
uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type);
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
|
||||
esp_ble_mesh_proxy_filter_type_t filter_type);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client adds address to the Proxy Server filter list.
|
||||
|
@ -101,8 +102,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
|
||||
uint16_t net_idx, uint16_t *addr, uint16_t addr_num);
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client removes address from the Proxy Server filter list.
|
||||
|
@ -115,8 +116,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle,
|
||||
uint16_t net_idx, uint16_t *addr, uint16_t addr_num);
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -61,6 +61,12 @@ typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
|
|||
/*!< Invalid Company ID */
|
||||
#define ESP_BLE_MESH_CID_NVAL 0xFFFF
|
||||
|
||||
/*!< Special TTL value to request using configured default TTL */
|
||||
#define ESP_BLE_MESH_TTL_DEFAULT 0xFF
|
||||
|
||||
/*!< Maximum allowed TTL value */
|
||||
#define ESP_BLE_MESH_TTL_MAX 0x7F
|
||||
|
||||
#define ESP_BLE_MESH_ADDR_UNASSIGNED 0x0000
|
||||
#define ESP_BLE_MESH_ADDR_ALL_NODES 0xFFFF
|
||||
#define ESP_BLE_MESH_ADDR_PROXIES 0xFFFC
|
||||
|
@ -265,7 +271,7 @@ typedef enum {
|
|||
#define ESP_BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
|
||||
#define ESP_BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xC00000) | (cid))
|
||||
|
||||
/*!< This macro is associated with BLE_MESH_MODEL in mesh_access.h */
|
||||
/*!< This macro is associated with BLE_MESH_MODEL_CB in mesh_access.h */
|
||||
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
|
||||
{ \
|
||||
.model_id = (_id), \
|
||||
|
@ -278,7 +284,7 @@ typedef enum {
|
|||
.user_data = _user_data, \
|
||||
}
|
||||
|
||||
/*!< This macro is associated with BLE_MESH_MODEL_VND in mesh_access.h */
|
||||
/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
|
||||
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
|
||||
{ \
|
||||
.vnd.company_id = (_company), \
|
||||
|
@ -455,6 +461,17 @@ typedef struct {
|
|||
*/
|
||||
#define ESP_BLE_MESH_MODEL_OP_END {0, 0, 0}
|
||||
|
||||
/** Abstraction that describes a model callback structure.
|
||||
* This structure is associated with struct bt_mesh_model_cb in mesh_access.h.
|
||||
*/
|
||||
typedef struct {
|
||||
/** Callback used during model initialization. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t init_cb;
|
||||
|
||||
/** Callback used during model deinitialization. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t deinit_cb;
|
||||
} esp_ble_mesh_model_cbs_t;
|
||||
|
||||
/** Abstraction that describes a Mesh Model instance.
|
||||
* This structure is associated with struct bt_mesh_model in mesh_access.h
|
||||
*/
|
||||
|
@ -488,6 +505,9 @@ struct esp_ble_mesh_model {
|
|||
/** Model operation context */
|
||||
esp_ble_mesh_model_op_t *op;
|
||||
|
||||
/** Model callback structure */
|
||||
esp_ble_mesh_model_cbs_t *cb;
|
||||
|
||||
/** Model-specific user data */
|
||||
void *user_data;
|
||||
};
|
||||
|
@ -522,7 +542,7 @@ typedef struct {
|
|||
/** Force sending reliably by using segment acknowledgement */
|
||||
uint8_t send_rel: 1;
|
||||
|
||||
/** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */
|
||||
/** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */
|
||||
uint8_t send_ttl;
|
||||
|
||||
/** Opcode of a received message. Not used for sending message. */
|
||||
|
@ -809,7 +829,7 @@ typedef enum {
|
|||
ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT, /*!< Provisioner provisioning done event */
|
||||
ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT, /*!< Provisioner add a device to the list which contains devices that are waiting/going to be provisioned completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT, /*!< Provisioner start to provision an unprovisioned device completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device if it exists and remove the device from network completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT, /*!< Provisioner set the value to be compared with part of the unprovisioned device UUID completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT, /*!< Provisioner set net_idx/flags/iv_index used for provisioning completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT, /*!< Provisioner set static oob value used for provisioning completion event */
|
||||
|
@ -1112,6 +1132,7 @@ typedef union {
|
|||
*/
|
||||
struct ble_mesh_provisioner_add_local_app_key_comp_param {
|
||||
int err_code; /*!< Indicate the result of adding local AppKey by the Provisioner */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
} provisioner_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT */
|
||||
/**
|
||||
|
@ -1156,14 +1177,14 @@ typedef union {
|
|||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_delete_node_with_uuid_comp_data_comp_param {
|
||||
struct ble_mesh_provisioner_delete_node_with_uuid_comp_param {
|
||||
int err_code; /*!< Indicate the result of deleting node with uuid by the Provisioner */
|
||||
uint8_t uuid[16]; /*!< Node device uuid */
|
||||
} provisioner_delete_node_with_uuid_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_delete_node_with_addr_comp_data_comp_param {
|
||||
struct ble_mesh_provisioner_delete_node_with_addr_comp_param {
|
||||
int err_code; /*!< Indicate the result of deleting node with unicast address by the Provisioner */
|
||||
uint16_t unicast_addr; /*!< Node unicast address */
|
||||
} provisioner_delete_node_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */
|
||||
|
@ -1954,8 +1975,8 @@ typedef struct {
|
|||
int64_t timestamp; /*!< Time when the last message is received */
|
||||
} esp_ble_mesh_last_msg_info_t;
|
||||
|
||||
#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response will be sent internally */
|
||||
#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response need to be sent in the application */
|
||||
#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response need to be sent in the application */
|
||||
#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response will be sent internally */
|
||||
|
||||
/** Parameters of the Server Model response control */
|
||||
typedef struct {
|
||||
|
|
|
@ -53,7 +53,7 @@ static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode)
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state)
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_config_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -78,7 +78,7 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state)
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_config_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -40,7 +40,7 @@ static bool generic_client_get_need_param(esp_ble_mesh_opcode_t opcode)
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_generic_client_get_state_t *get_state)
|
||||
esp_ble_mesh_generic_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_generic_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -66,7 +66,7 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_generic_client_set_state_t *set_state)
|
||||
esp_ble_mesh_generic_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_generic_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -34,7 +34,7 @@ esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_serve
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_get_state_t *get_state)
|
||||
esp_ble_mesh_health_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_health_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -60,7 +60,7 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_set_state_t *set_state)
|
||||
esp_ble_mesh_health_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_health_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -27,7 +27,7 @@ esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_light_client_get_state_t *get_state)
|
||||
esp_ble_mesh_light_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_lighting_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -53,7 +53,7 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_light_client_set_state_t *set_state)
|
||||
esp_ble_mesh_light_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_lighting_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -27,7 +27,7 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_get_state_t *get_state)
|
||||
esp_ble_mesh_sensor_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_sensor_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -52,7 +52,7 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_set_state_t *set_state)
|
||||
esp_ble_mesh_sensor_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_sensor_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -27,7 +27,7 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_get_state_t *get_state)
|
||||
esp_ble_mesh_time_scene_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_time_scene_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
@ -53,7 +53,7 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
|
|||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_set_state_t *set_state)
|
||||
esp_ble_mesh_time_scene_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_time_scene_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
|
|
@ -756,7 +756,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t event,
|
||||
esp_ble_mesh_cfg_client_cb_param_t *param);
|
||||
esp_ble_mesh_cfg_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Configuration Server Model callback function type
|
||||
|
@ -764,7 +764,7 @@ typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_cfg_server_cb_t)(esp_ble_mesh_cfg_server_cb_event_t event,
|
||||
esp_ble_mesh_cfg_server_cb_param_t *param);
|
||||
esp_ble_mesh_cfg_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Config Client Model callback.
|
||||
|
@ -800,7 +800,7 @@ esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_c
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state);
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of the Configuration Server Model states using the Config Client Model set messages.
|
||||
|
@ -816,7 +816,7 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state);
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -483,7 +483,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_generic_client_cb_t)(esp_ble_mesh_generic_client_cb_event_t event,
|
||||
esp_ble_mesh_generic_client_cb_param_t *param);
|
||||
esp_ble_mesh_generic_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Generic Client Model callback.
|
||||
|
@ -509,7 +509,7 @@ esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cli
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_generic_client_get_state_t *get_state);
|
||||
esp_ble_mesh_generic_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Generic Server Model states using the Generic Client Model set messages.
|
||||
|
@ -525,7 +525,7 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_generic_client_set_state_t *set_state);
|
||||
esp_ble_mesh_generic_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief Generic Server Models related context.
|
||||
|
@ -1285,7 +1285,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_generic_server_cb_t)(esp_ble_mesh_generic_server_cb_event_t event,
|
||||
esp_ble_mesh_generic_server_cb_param_t *param);
|
||||
esp_ble_mesh_generic_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Generic Server Model callback.
|
||||
|
|
|
@ -335,7 +335,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_event_t event,
|
||||
esp_ble_mesh_health_client_cb_param_t *param);
|
||||
esp_ble_mesh_health_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Health Server Model callback function type
|
||||
|
@ -343,7 +343,7 @@ typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_e
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_health_server_cb_t)(esp_ble_mesh_health_server_cb_event_t event,
|
||||
esp_ble_mesh_health_server_cb_param_t *param);
|
||||
esp_ble_mesh_health_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Health Model callback, the callback will report Health Client & Server Model events.
|
||||
|
@ -379,7 +379,7 @@ esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_serve
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_get_state_t *get_state);
|
||||
esp_ble_mesh_health_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set the Health Server states using the Health Client Model set messages.
|
||||
|
@ -395,7 +395,7 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_set_state_t *set_state);
|
||||
esp_ble_mesh_health_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief This function is called by the Health Server Model to update the context of its Health Current status.
|
||||
|
|
|
@ -539,7 +539,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_light_client_cb_t)(esp_ble_mesh_light_client_cb_event_t event,
|
||||
esp_ble_mesh_light_client_cb_param_t *param);
|
||||
esp_ble_mesh_light_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Light Client Model callback.
|
||||
|
@ -565,7 +565,7 @@ esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_light_client_get_state_t *get_state);
|
||||
esp_ble_mesh_light_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Light Server Model states using the Light Client Model set messages.
|
||||
|
@ -581,7 +581,7 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_light_client_set_state_t *set_state);
|
||||
esp_ble_mesh_light_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief Lighting Server Models related context.
|
||||
|
@ -1663,7 +1663,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_lighting_server_cb_t)(esp_ble_mesh_lighting_server_cb_event_t event,
|
||||
esp_ble_mesh_lighting_server_cb_param_t *param);
|
||||
esp_ble_mesh_lighting_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Lighting Server Model callback.
|
||||
|
|
|
@ -215,7 +215,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_sensor_client_cb_t)(esp_ble_mesh_sensor_client_cb_event_t event,
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param);
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Sensor Client Model callback.
|
||||
|
@ -241,7 +241,7 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_get_state_t *get_state);
|
||||
esp_ble_mesh_sensor_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Sensor Server Model states using the Sensor Client Model set messages.
|
||||
|
@ -257,7 +257,7 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
|
|||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_set_state_t *set_state);
|
||||
esp_ble_mesh_sensor_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Models related context.
|
||||
|
@ -698,7 +698,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_sensor_server_cb_t)(esp_ble_mesh_sensor_server_cb_event_t event,
|
||||
esp_ble_mesh_sensor_server_cb_param_t *param);
|
||||
esp_ble_mesh_sensor_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Sensor Server Model callback.
|
||||
|
|
|
@ -276,7 +276,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_time_scene_client_cb_t)(esp_ble_mesh_time_scene_client_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param);
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Time Scene Client Model callback.
|
||||
|
@ -301,7 +301,7 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_get_state_t *get_state);
|
||||
esp_ble_mesh_time_scene_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages.
|
||||
|
@ -316,7 +316,7 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
|
|||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_set_state_t *set_state);
|
||||
esp_ble_mesh_time_scene_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Models related context.
|
||||
|
@ -900,7 +900,7 @@ typedef enum {
|
|||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_server_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_server_cb_param_t *param);
|
||||
esp_ble_mesh_time_scene_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Time and Scenes Server Model callback.
|
||||
|
|
|
@ -20,12 +20,10 @@
|
|||
#include "cfg_cli.h"
|
||||
#include "esp_ble_mesh_config_model_api.h"
|
||||
|
||||
extern s32_t config_msg_timeout;
|
||||
|
||||
/* Configuration Client Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_config_client_cb_to_app(esp_ble_mesh_cfg_client_cb_event_t event,
|
||||
esp_ble_mesh_cfg_client_cb_param_t *param)
|
||||
esp_ble_mesh_cfg_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_cfg_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_cfg_client_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_CLIENT);
|
||||
|
@ -51,7 +49,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->cfg_client_get_state.params, src->cfg_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->cfg_client_get_state.get_state) {
|
||||
|
@ -60,7 +58,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->cfg_client_get_state.get_state, src->cfg_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_cfg_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -71,7 +69,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->cfg_client_set_state.params, src->cfg_client_set_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->cfg_client_set_state.set_state) {
|
||||
|
@ -80,13 +78,13 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->cfg_client_set_state.set_state, src->cfg_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_cfg_client_set_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +136,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -157,7 +155,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.comp_data_status.composition_data->len;
|
||||
p_dest_data->status_cb.comp_data_status.composition_data = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.comp_data_status.composition_data) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.comp_data_status.composition_data,
|
||||
|
@ -173,7 +171,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.model_sub_list.sub_addr->len;
|
||||
p_dest_data->status_cb.model_sub_list.sub_addr = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.model_sub_list.sub_addr) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.model_sub_list.sub_addr,
|
||||
|
@ -187,7 +185,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.netkey_list.net_idx->len;
|
||||
p_dest_data->status_cb.netkey_list.net_idx = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.netkey_list.net_idx) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.netkey_list.net_idx,
|
||||
|
@ -201,7 +199,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.appkey_list.app_idx->len;
|
||||
p_dest_data->status_cb.appkey_list.app_idx = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.appkey_list.app_idx) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.appkey_list.app_idx,
|
||||
|
@ -217,7 +215,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.model_app_list.app_idx->len;
|
||||
p_dest_data->status_cb.model_app_list.app_idx = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.model_app_list.app_idx) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.model_app_list.app_idx,
|
||||
|
@ -306,18 +304,17 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param
|
|||
msg.pid = BTC_PID_CONFIG_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_config_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_client_cb_param_t),
|
||||
btc_ble_mesh_config_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_cfg_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
|
@ -339,7 +336,7 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
act = ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown config client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Config client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -351,38 +348,38 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_config_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_config_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_get_state_t *get)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -401,7 +398,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
|||
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
|
||||
if (get == NULL) {
|
||||
BT_ERR("%s, Invalid config client get", __func__);
|
||||
BT_ERR("Invalid Configuration Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
|
@ -409,63 +406,65 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
|||
break;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
config_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
|
||||
return bt_mesh_cfg_beacon_get(&ctx);
|
||||
return bt_mesh_cfg_beacon_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET:
|
||||
return bt_mesh_cfg_ttl_get(&ctx);
|
||||
return bt_mesh_cfg_ttl_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_FRIEND_GET:
|
||||
return bt_mesh_cfg_friend_get(&ctx);
|
||||
return bt_mesh_cfg_friend_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET:
|
||||
return bt_mesh_cfg_gatt_proxy_get(&ctx);
|
||||
return bt_mesh_cfg_gatt_proxy_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_RELAY_GET:
|
||||
return bt_mesh_cfg_relay_get(&ctx);
|
||||
return bt_mesh_cfg_relay_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
|
||||
return bt_mesh_cfg_mod_pub_get(&ctx, get->model_pub_get.element_addr,
|
||||
return bt_mesh_cfg_mod_pub_get(¶m, get->model_pub_get.element_addr,
|
||||
get->model_pub_get.model_id,
|
||||
get->model_pub_get.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET:
|
||||
return bt_mesh_cfg_hb_pub_get(&ctx);
|
||||
return bt_mesh_cfg_hb_pub_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET:
|
||||
return bt_mesh_cfg_hb_sub_get(&ctx);
|
||||
return bt_mesh_cfg_hb_sub_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
|
||||
return bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page);
|
||||
return bt_mesh_cfg_comp_data_get(¶m, get->comp_data_get.page);
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
|
||||
return bt_mesh_cfg_mod_sub_get(&ctx, get->sig_model_sub_get.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_get(¶m, get->sig_model_sub_get.element_addr,
|
||||
get->sig_model_sub_get.model_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
|
||||
return bt_mesh_cfg_mod_sub_get_vnd(&ctx, get->vnd_model_sub_get.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_get_vnd(¶m, get->vnd_model_sub_get.element_addr,
|
||||
get->vnd_model_sub_get.model_id,
|
||||
get->vnd_model_sub_get.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET:
|
||||
return bt_mesh_cfg_net_key_get(&ctx);
|
||||
return bt_mesh_cfg_net_key_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
|
||||
return bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx);
|
||||
return bt_mesh_cfg_app_key_get(¶m, get->app_key_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
|
||||
return bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx);
|
||||
return bt_mesh_cfg_node_identity_get(¶m, get->node_identity_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
|
||||
return bt_mesh_cfg_mod_app_get(&ctx, get->sig_model_app_get.element_addr,
|
||||
return bt_mesh_cfg_mod_app_get(¶m, get->sig_model_app_get.element_addr,
|
||||
get->sig_model_app_get.model_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
|
||||
return bt_mesh_cfg_mod_app_get_vnd(&ctx, get->vnd_model_app_get.element_addr,
|
||||
return bt_mesh_cfg_mod_app_get_vnd(¶m, get->vnd_model_app_get.element_addr,
|
||||
get->vnd_model_app_get.model_id,
|
||||
get->vnd_model_app_get.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
|
||||
return bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx);
|
||||
return bt_mesh_cfg_kr_phase_get(¶m, get->kr_phase_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
|
||||
return bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr);
|
||||
return bt_mesh_cfg_lpn_timeout_get(¶m, get->lpn_pollto_get.lpn_addr);
|
||||
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET:
|
||||
return bt_mesh_cfg_net_transmit_get(&ctx);
|
||||
return bt_mesh_cfg_net_transmit_get(¶m);
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
BT_ERR("Invalid Configuration Get opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -475,7 +474,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
|||
static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_set_state_t *set)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -483,39 +482,41 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
|
|||
}
|
||||
|
||||
if (params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set == NULL) {
|
||||
BT_ERR("%s, Invalid config client set", __func__);
|
||||
BT_ERR("Invalid Configuration Set");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = BLE_MESH_KEY_DEV;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
config_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_SET:
|
||||
return bt_mesh_cfg_beacon_set(&ctx, set->beacon_set.beacon);
|
||||
return bt_mesh_cfg_beacon_set(¶m, set->beacon_set.beacon);
|
||||
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET:
|
||||
return bt_mesh_cfg_ttl_set(&ctx, set->default_ttl_set.ttl);
|
||||
return bt_mesh_cfg_ttl_set(¶m, set->default_ttl_set.ttl);
|
||||
case ESP_BLE_MESH_MODEL_OP_FRIEND_SET:
|
||||
return bt_mesh_cfg_friend_set(&ctx, set->friend_set.friend_state);
|
||||
return bt_mesh_cfg_friend_set(¶m, set->friend_set.friend_state);
|
||||
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET:
|
||||
return bt_mesh_cfg_gatt_proxy_set(&ctx, set->gatt_proxy_set.gatt_proxy);
|
||||
return bt_mesh_cfg_gatt_proxy_set(¶m, set->gatt_proxy_set.gatt_proxy);
|
||||
case ESP_BLE_MESH_MODEL_OP_RELAY_SET:
|
||||
return bt_mesh_cfg_relay_set(&ctx, set->relay_set.relay,
|
||||
return bt_mesh_cfg_relay_set(¶m, set->relay_set.relay,
|
||||
set->relay_set.relay_retransmit);
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD:
|
||||
return bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx,
|
||||
return bt_mesh_cfg_net_key_add(¶m, set->net_key_add.net_idx,
|
||||
&set->net_key_add.net_key[0]);
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD:
|
||||
return bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx,
|
||||
return bt_mesh_cfg_app_key_add(¶m, set->app_key_add.net_idx,
|
||||
set->app_key_add.app_idx,
|
||||
&set->app_key_add.app_key[0]);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND:
|
||||
return bt_mesh_cfg_mod_app_bind(&ctx, set->model_app_bind.element_addr,
|
||||
return bt_mesh_cfg_mod_app_bind(¶m, set->model_app_bind.element_addr,
|
||||
set->model_app_bind.model_app_idx,
|
||||
set->model_app_bind.model_id,
|
||||
set->model_app_bind.company_id);
|
||||
|
@ -528,46 +529,46 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
|
|||
.period = set->model_pub_set.publish_period,
|
||||
.transmit = set->model_pub_set.publish_retransmit,
|
||||
};
|
||||
return bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr,
|
||||
return bt_mesh_cfg_mod_pub_set(¶m, set->model_pub_set.element_addr,
|
||||
set->model_pub_set.model_id,
|
||||
set->model_pub_set.company_id, &model_pub);
|
||||
}
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD:
|
||||
return bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_add(¶m, set->model_sub_add.element_addr,
|
||||
set->model_sub_add.sub_addr,
|
||||
set->model_sub_add.model_id,
|
||||
set->model_sub_add.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE:
|
||||
return bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_del(¶m, set->model_sub_delete.element_addr,
|
||||
set->model_sub_delete.sub_addr,
|
||||
set->model_sub_delete.model_id,
|
||||
set->model_sub_delete.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE:
|
||||
return bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_overwrite(¶m, set->model_sub_overwrite.element_addr,
|
||||
set->model_sub_overwrite.sub_addr,
|
||||
set->model_sub_overwrite.model_id,
|
||||
set->model_sub_overwrite.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD:
|
||||
return bt_mesh_cfg_mod_sub_va_add(&ctx, set->model_sub_va_add.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_va_add(¶m, set->model_sub_va_add.element_addr,
|
||||
&set->model_sub_va_add.label_uuid[0],
|
||||
set->model_sub_va_add.model_id,
|
||||
set->model_sub_va_add.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE:
|
||||
return bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set->model_sub_va_overwrite.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_va_overwrite(¶m, set->model_sub_va_overwrite.element_addr,
|
||||
&set->model_sub_va_overwrite.label_uuid[0],
|
||||
set->model_sub_va_overwrite.model_id,
|
||||
set->model_sub_va_overwrite.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE:
|
||||
return bt_mesh_cfg_mod_sub_va_del(&ctx, set->model_sub_va_delete.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_va_del(¶m, set->model_sub_va_delete.element_addr,
|
||||
&set->model_sub_va_delete.label_uuid[0],
|
||||
set->model_sub_va_delete.model_id,
|
||||
set->model_sub_va_delete.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET:
|
||||
return bt_mesh_cfg_hb_sub_set(&ctx, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set);
|
||||
return bt_mesh_cfg_hb_sub_set(¶m, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET:
|
||||
return bt_mesh_cfg_hb_pub_set(&ctx, (const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set);
|
||||
return bt_mesh_cfg_hb_pub_set(¶m, (struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_NODE_RESET:
|
||||
return bt_mesh_cfg_node_reset(&ctx);
|
||||
return bt_mesh_cfg_node_reset(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET: {
|
||||
struct bt_mesh_cfg_mod_pub model_pub = {
|
||||
.app_idx = set->model_pub_va_set.publish_app_idx,
|
||||
|
@ -576,42 +577,42 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
|
|||
.period = set->model_pub_va_set.publish_period,
|
||||
.transmit = set->model_pub_va_set.publish_retransmit,
|
||||
};
|
||||
return bt_mesh_cfg_mod_pub_va_set(&ctx, set->model_pub_va_set.element_addr,
|
||||
return bt_mesh_cfg_mod_pub_va_set(¶m, set->model_pub_va_set.element_addr,
|
||||
set->model_pub_va_set.model_id,
|
||||
set->model_pub_va_set.company_id,
|
||||
set->model_pub_va_set.label_uuid, &model_pub);
|
||||
}
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL:
|
||||
return bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_del_all(¶m, set->model_sub_delete_all.element_addr,
|
||||
set->model_sub_delete_all.model_id,
|
||||
set->model_sub_delete_all.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE:
|
||||
return bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx,
|
||||
return bt_mesh_cfg_net_key_update(¶m, set->net_key_update.net_idx,
|
||||
set->net_key_update.net_key);
|
||||
case ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE:
|
||||
return bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx);
|
||||
return bt_mesh_cfg_net_key_delete(¶m, set->net_key_delete.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE:
|
||||
return bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx,
|
||||
return bt_mesh_cfg_app_key_update(¶m, set->app_key_update.net_idx,
|
||||
set->app_key_update.app_idx,
|
||||
set->app_key_update.app_key);
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE:
|
||||
return bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx,
|
||||
return bt_mesh_cfg_app_key_delete(¶m, set->app_key_delete.net_idx,
|
||||
set->app_key_delete.app_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET:
|
||||
return bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx,
|
||||
return bt_mesh_cfg_node_identity_set(¶m, set->node_identity_set.net_idx,
|
||||
set->node_identity_set.identity);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND:
|
||||
return bt_mesh_cfg_mod_app_unbind(&ctx, set->model_app_unbind.element_addr,
|
||||
return bt_mesh_cfg_mod_app_unbind(¶m, set->model_app_unbind.element_addr,
|
||||
set->model_app_unbind.model_app_idx,
|
||||
set->model_app_unbind.model_id,
|
||||
set->model_app_unbind.company_id);
|
||||
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET:
|
||||
return bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx,
|
||||
return bt_mesh_cfg_kr_phase_set(¶m, set->kr_phase_set.net_idx,
|
||||
set->kr_phase_set.transition);
|
||||
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET:
|
||||
return bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit);
|
||||
return bt_mesh_cfg_net_transmit_set(¶m, set->net_transmit_set.net_transmit);
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
BT_ERR("Invalid Configuration Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -622,7 +623,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
|
|||
{
|
||||
btc_ble_mesh_config_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_cfg_client_cb_param_t cb = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -634,12 +634,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
|
|||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE: {
|
||||
cb.params = arg->cfg_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
cb.error_code = btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
|
||||
arg->cfg_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
|
@ -649,12 +643,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
|
|||
}
|
||||
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE: {
|
||||
cb.params = arg->cfg_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
cb.error_code = btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
|
||||
arg->cfg_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
|
@ -684,7 +672,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_CFG_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_config_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_client_free_req_data(msg);
|
||||
|
@ -694,7 +682,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
|
|||
/* Configuration Server Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_config_server_cb_to_app(esp_ble_mesh_cfg_server_cb_event_t event,
|
||||
esp_ble_mesh_cfg_server_cb_param_t *param)
|
||||
esp_ble_mesh_cfg_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_cfg_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_cfg_server_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_SERVER);
|
||||
|
@ -721,13 +709,11 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param
|
|||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_cfg_server_cb_param_t cb_params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
|
@ -740,7 +726,7 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
|
|||
act = ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown config server event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Config server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -751,10 +737,11 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
|
|||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_server_callback(&cb_params, act);
|
||||
|
@ -775,6 +762,6 @@ void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_CFG_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_config_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
/* Generic Client Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_generic_client_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
|
||||
esp_ble_mesh_generic_client_cb_param_t *param)
|
||||
esp_ble_mesh_generic_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_generic_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT);
|
||||
|
@ -49,7 +49,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
|||
memcpy(dst->generic_client_get_state.params, src->generic_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->generic_client_get_state.get_state) {
|
||||
|
@ -58,7 +58,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
|||
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_generic_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -78,7 +78,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
|||
length = src->generic_client_set_state.set_state->user_property_set.property_value->len;
|
||||
dst->generic_client_set_state.set_state->user_property_set.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!dst->generic_client_set_state.set_state->user_property_set.property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->user_property_set.property_value,
|
||||
|
@ -91,7 +91,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
|||
length = src->generic_client_set_state.set_state->admin_property_set.property_value->len;
|
||||
dst->generic_client_set_state.set_state->admin_property_set.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!dst->generic_client_set_state.set_state->admin_property_set.property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->admin_property_set.property_value,
|
||||
|
@ -103,12 +103,12 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->status_cb.user_properties_status.property_ids->len;
|
||||
p_dest_data->status_cb.user_properties_status.property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.user_properties_status.property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.user_properties_status.property_ids,
|
||||
|
@ -206,7 +206,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->status_cb.user_property_status.property_value->len;
|
||||
p_dest_data->status_cb.user_property_status.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.user_property_status.property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.user_property_status.property_value,
|
||||
|
@ -220,7 +220,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->status_cb.admin_properties_status.property_ids->len;
|
||||
p_dest_data->status_cb.admin_properties_status.property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.admin_properties_status.property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.admin_properties_status.property_ids,
|
||||
|
@ -235,7 +235,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->status_cb.admin_property_status.property_value->len;
|
||||
p_dest_data->status_cb.admin_property_status.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.admin_property_status.property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.admin_property_status.property_value,
|
||||
|
@ -249,7 +249,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->status_cb.manufacturer_properties_status.property_ids->len;
|
||||
p_dest_data->status_cb.manufacturer_properties_status.property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.manufacturer_properties_status.property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_properties_status.property_ids,
|
||||
|
@ -264,7 +264,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->status_cb.manufacturer_property_status.property_value->len;
|
||||
p_dest_data->status_cb.manufacturer_property_status.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.manufacturer_property_status.property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_property_status.property_value,
|
||||
|
@ -278,7 +278,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->status_cb.client_properties_status.property_ids->len;
|
||||
p_dest_data->status_cb.client_properties_status.property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.client_properties_status.property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids,
|
||||
|
@ -374,18 +374,17 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_
|
|||
msg.pid = BTC_PID_GENERIC_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_generic_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_client_cb_param_t),
|
||||
btc_ble_mesh_generic_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_generic_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
|
@ -407,7 +406,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown generic client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Generic client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -419,31 +418,31 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_generic_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_generic_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -453,7 +452,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
|||
btc_ble_mesh_generic_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_generic_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -465,12 +463,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
|||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
|
||||
params = arg->generic_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
|
@ -479,10 +471,10 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
|||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->generic_client_get_state.params;
|
||||
cb.error_code = bt_mesh_generic_client_get_state(&common,
|
||||
(void *)arg->generic_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
cb.error_code = bt_mesh_generic_client_get_state(&common, arg->generic_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
|
||||
|
@ -491,12 +483,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
|||
}
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
|
||||
params = arg->generic_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
|
@ -505,10 +491,10 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
|||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->generic_client_set_state.params;
|
||||
cb.error_code = bt_mesh_generic_client_set_state(&common,
|
||||
(void *)arg->generic_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
cb.error_code = bt_mesh_generic_client_set_state(&common, arg->generic_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
|
||||
|
@ -537,7 +523,7 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_generic_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_client_free_req_data(msg);
|
||||
|
@ -546,9 +532,8 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
|
|||
|
||||
/* Generic Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_generic_server_cb_to_app(
|
||||
esp_ble_mesh_generic_server_cb_event_t event,
|
||||
esp_ble_mesh_generic_server_cb_param_t *param)
|
||||
static inline void btc_ble_mesh_generic_server_cb_to_app(esp_ble_mesh_generic_server_cb_event_t event,
|
||||
esp_ble_mesh_generic_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_generic_server_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_SERVER);
|
||||
|
@ -577,7 +562,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->value.state_change.user_property_set.value->len;
|
||||
p_dest_data->value.state_change.user_property_set.value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.user_property_set.value == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value,
|
||||
|
@ -591,7 +576,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->value.state_change.admin_property_set.value->len;
|
||||
p_dest_data->value.state_change.admin_property_set.value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.admin_property_set.value == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value,
|
||||
|
@ -611,7 +596,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->value.set.user_property.property_value->len;
|
||||
p_dest_data->value.set.user_property.property_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.user_property.property_value == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value,
|
||||
|
@ -625,7 +610,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
|
|||
length = p_src_data->value.set.admin_property.property_value->len;
|
||||
p_dest_data->value.set.admin_property.property_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.admin_property.property_value == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value,
|
||||
|
@ -702,17 +687,15 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_
|
|||
msg.pid = BTC_PID_GENERIC_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_generic_server_cb_param_t), btc_ble_mesh_generic_server_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_server_cb_param_t),
|
||||
btc_ble_mesh_generic_server_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_param_t cb_params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
|
@ -731,7 +714,7 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
|
|||
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown Generic Server event type", __func__);
|
||||
BT_ERR("Unknown Generic Server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -742,10 +725,11 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
|
|||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_callback(&cb_params, act);
|
||||
|
@ -766,7 +750,7 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_generic_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_free_req_data(msg);
|
||||
|
|
|
@ -21,12 +21,10 @@
|
|||
#include "health_cli.h"
|
||||
#include "esp_ble_mesh_health_model_api.h"
|
||||
|
||||
extern s32_t health_msg_timeout;
|
||||
|
||||
/* Health Client Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event,
|
||||
esp_ble_mesh_health_client_cb_param_t *param)
|
||||
esp_ble_mesh_health_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_health_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT);
|
||||
|
@ -52,7 +50,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->health_client_get_state.params, src->health_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->health_client_get_state.get_state) {
|
||||
|
@ -61,7 +59,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_health_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -75,12 +73,12 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
memcpy(dst->health_client_set_state.set_state, src->health_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_health_client_set_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +130,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -150,7 +148,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.current_status.fault_array->len;
|
||||
p_dest_data->status_cb.current_status.fault_array = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.current_status.fault_array) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array,
|
||||
|
@ -166,7 +164,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.fault_status.fault_array->len;
|
||||
p_dest_data->status_cb.fault_status.fault_array = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.fault_status.fault_array) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array,
|
||||
|
@ -240,18 +238,17 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa
|
|||
msg.pid = BTC_PID_HEALTH_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_client_cb_param_t),
|
||||
btc_ble_mesh_health_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len)
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len)
|
||||
{
|
||||
esp_ble_mesh_health_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
|
@ -273,7 +270,7 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown health client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Health client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -285,38 +282,38 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_health_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_health_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_get_state_t *get)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -324,27 +321,29 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
|
|||
}
|
||||
|
||||
if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) {
|
||||
BT_ERR("%s, Invalid health client get", __func__);
|
||||
BT_ERR("Invalid Health Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = params->ctx.app_idx;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = params->ctx.app_idx;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
health_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
|
||||
return bt_mesh_health_attention_get(&ctx);
|
||||
return bt_mesh_health_attention_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
|
||||
return bt_mesh_health_period_get(&ctx);
|
||||
return bt_mesh_health_period_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
|
||||
return bt_mesh_health_fault_get(&ctx, get->fault_get.company_id);
|
||||
return bt_mesh_health_fault_get(¶m, get->fault_get.company_id);
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -354,40 +353,42 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
|
|||
static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_set_state_t *set)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL || set == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = params->ctx.app_idx;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = params->ctx.app_idx;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
health_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
|
||||
return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true);
|
||||
return bt_mesh_health_attention_set(¶m, set->attention_set.attention, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
|
||||
return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false);
|
||||
return bt_mesh_health_attention_set(¶m, set->attention_set.attention, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
|
||||
return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true);
|
||||
return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
|
||||
return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false);
|
||||
return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
|
||||
return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, true);
|
||||
return bt_mesh_health_fault_test(¶m, set->fault_test.company_id, set->fault_test.test_id, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
|
||||
return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, false);
|
||||
return bt_mesh_health_fault_test(¶m, set->fault_test.company_id, set->fault_test.test_id, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
|
||||
return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true);
|
||||
return bt_mesh_health_fault_clear(¶m, set->fault_clear.company_id, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
|
||||
return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false);
|
||||
return bt_mesh_health_fault_clear(¶m, set->fault_clear.company_id, false);
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -398,7 +399,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
|
|||
{
|
||||
btc_ble_mesh_health_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_health_client_cb_param_t cb = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -410,12 +410,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
|
|||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
|
||||
cb.params = arg->health_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
cb.error_code = btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
|
||||
arg->health_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
|
@ -426,12 +420,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
|
|||
}
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
|
||||
cb.params = arg->health_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
cb.error_code = btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
|
||||
arg->health_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
|
@ -462,7 +450,7 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_health_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_client_free_req_data(msg);
|
||||
|
@ -472,7 +460,7 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
|
|||
/* Health Server Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
|
||||
esp_ble_mesh_health_server_cb_param_t *param)
|
||||
esp_ble_mesh_health_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
|
||||
|
@ -556,8 +544,8 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa
|
|||
msg.pid = BTC_PID_HEALTH_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_server_cb_param_t),
|
||||
btc_ble_mesh_health_server_copy_req_data);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
|
||||
|
@ -601,7 +589,7 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_health_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_server_free_req_data(msg);
|
||||
|
@ -618,7 +606,8 @@ void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t c
|
|||
btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id)
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
|
||||
u8_t test_id, u16_t company_id)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
/* Lighting Client Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_lighting_client_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
|
||||
esp_ble_mesh_light_client_cb_param_t *param)
|
||||
esp_ble_mesh_light_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT);
|
||||
|
@ -48,7 +48,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
|
|||
memcpy(dst->light_client_get_state.params, src->light_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->light_client_get_state.get_state) {
|
||||
|
@ -57,7 +57,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
|
|||
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_light_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -71,12 +71,12 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
|
|||
memcpy(dst->light_client_set_state.set_state, src->light_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_light_client_set_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
|
|||
length = p_src_data->status_cb.lc_property_status.property_value->len;
|
||||
p_dest_data->status_cb.lc_property_status.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.lc_property_status.property_value) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value,
|
||||
|
@ -218,18 +218,17 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p
|
|||
msg.pid = BTC_PID_LIGHTING_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_lighting_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_light_client_cb_param_t),
|
||||
btc_ble_mesh_lighting_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
|
@ -251,7 +250,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown lighting client event type", __func__);
|
||||
BT_ERR("Unknown Lighting client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -263,31 +262,31 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_lighting_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_lighting_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -297,7 +296,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
|||
btc_ble_mesh_lighting_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_light_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -309,12 +307,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
|||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
|
||||
params = arg->light_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
|
@ -323,10 +315,10 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
|||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->light_client_get_state.params;
|
||||
cb.error_code = bt_mesh_light_client_get_state(&common,
|
||||
(void *)arg->light_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
cb.error_code = bt_mesh_light_client_get_state(&common, arg->light_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
|
||||
|
@ -335,12 +327,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
|||
}
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
|
||||
params = arg->light_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
|
@ -349,10 +335,10 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
|||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->light_client_set_state.params;
|
||||
cb.error_code = bt_mesh_light_client_set_state(&common,
|
||||
(void *)arg->light_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
cb.error_code = bt_mesh_light_client_set_state(&common, arg->light_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
|
||||
|
@ -381,7 +367,7 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_lighting_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_client_free_req_data(msg);
|
||||
|
@ -390,9 +376,8 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
|
|||
|
||||
/* Lighting Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_lighting_server_cb_to_app(
|
||||
esp_ble_mesh_lighting_server_cb_event_t event,
|
||||
esp_ble_mesh_lighting_server_cb_param_t *param)
|
||||
static inline void btc_ble_mesh_lighting_server_cb_to_app(esp_ble_mesh_lighting_server_cb_event_t event,
|
||||
esp_ble_mesh_lighting_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_lighting_server_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_SERVER);
|
||||
|
@ -420,7 +405,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
|
|||
length = p_src_data->value.state_change.lc_property_set.property_value->len;
|
||||
p_dest_data->value.state_change.lc_property_set.property_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.lc_property_set.property_value == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.lc_property_set.property_value,
|
||||
|
@ -436,7 +421,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
|
|||
length = p_src_data->value.set.lc_property.property_value->len;
|
||||
p_dest_data->value.set.lc_property.property_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.lc_property.property_value == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value,
|
||||
|
@ -451,7 +436,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
|
|||
length = p_src_data->value.status.sensor_status.data->len;
|
||||
p_dest_data->value.status.sensor_status.data = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.status.sensor_status.data == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data,
|
||||
|
@ -514,17 +499,15 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c
|
|||
msg.pid = BTC_PID_LIGHTING_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(
|
||||
&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t), btc_ble_mesh_lighting_server_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t),
|
||||
btc_ble_mesh_lighting_server_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_param_t cb_params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
|
@ -546,7 +529,7 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
|
|||
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown Lighting Server event type", __func__);
|
||||
BT_ERR("Unknown Lighting server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -557,10 +540,11 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
|
|||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_server_callback(&cb_params, act);
|
||||
|
@ -581,7 +565,7 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_lighting_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_server_free_req_data(msg);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,7 +22,7 @@
|
|||
/* Sensor Client Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_sensor_client_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param)
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_sensor_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT);
|
||||
|
@ -58,7 +58,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len;
|
||||
dst->sensor_client_get_state.get_state->column_get.raw_value_x = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_get_state.get_state->column_get.raw_value_x) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->column_get.raw_value_x,
|
||||
|
@ -71,7 +71,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
length = src->sensor_client_get_state.get_state->series_get.raw_value_x1->len;
|
||||
dst->sensor_client_get_state.get_state->series_get.raw_value_x1 = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x1) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x1,
|
||||
|
@ -82,7 +82,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
length = src->sensor_client_get_state.get_state->series_get.raw_value_x2->len;
|
||||
dst->sensor_client_get_state.get_state->series_get.raw_value_x2 = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x2) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x2,
|
||||
|
@ -94,7 +94,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len;
|
||||
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down,
|
||||
|
@ -124,7 +124,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up->len;
|
||||
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up,
|
||||
|
@ -135,7 +135,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_low->len;
|
||||
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low,
|
||||
|
@ -146,7 +146,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_high->len;
|
||||
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high,
|
||||
|
@ -159,7 +159,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
length = src->sensor_client_set_state.set_state->setting_set.sensor_setting_raw->len;
|
||||
dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw,
|
||||
|
@ -171,12 +171,12 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.descriptor_status.descriptor->len;
|
||||
p_dest_data->status_cb.descriptor_status.descriptor = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.descriptor_status.descriptor) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.descriptor_status.descriptor,
|
||||
|
@ -290,7 +290,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.cadence_status.sensor_cadence_value->len;
|
||||
p_dest_data->status_cb.cadence_status.sensor_cadence_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.cadence_status.sensor_cadence_value) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.cadence_status.sensor_cadence_value,
|
||||
|
@ -304,7 +304,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.settings_status.sensor_setting_property_ids->len;
|
||||
p_dest_data->status_cb.settings_status.sensor_setting_property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.settings_status.sensor_setting_property_ids) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.settings_status.sensor_setting_property_ids,
|
||||
|
@ -319,7 +319,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.setting_status.sensor_setting_raw->len;
|
||||
p_dest_data->status_cb.setting_status.sensor_setting_raw = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.setting_status.sensor_setting_raw) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.setting_status.sensor_setting_raw,
|
||||
|
@ -333,7 +333,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.sensor_status.marshalled_sensor_data->len;
|
||||
p_dest_data->status_cb.sensor_status.marshalled_sensor_data = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.sensor_status.marshalled_sensor_data) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.sensor_status.marshalled_sensor_data,
|
||||
|
@ -347,7 +347,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.column_status.sensor_column_value->len;
|
||||
p_dest_data->status_cb.column_status.sensor_column_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.column_status.sensor_column_value) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.column_status.sensor_column_value,
|
||||
|
@ -361,7 +361,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->status_cb.series_status.sensor_series_value->len;
|
||||
p_dest_data->status_cb.series_status.sensor_series_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.series_status.sensor_series_value) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.series_status.sensor_series_value,
|
||||
|
@ -456,18 +456,17 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa
|
|||
msg.pid = BTC_PID_SENSOR_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_sensor_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_client_cb_param_t),
|
||||
btc_ble_mesh_sensor_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_sensor_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
|
@ -489,7 +488,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown sensor client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Sensor client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -501,31 +500,31 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_sensor_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_sensor_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -535,7 +534,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
|||
btc_ble_mesh_sensor_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_sensor_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -547,12 +545,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
|||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
|
||||
params = arg->sensor_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
|
@ -561,10 +553,10 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
|||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->sensor_client_get_state.params;
|
||||
cb.error_code = bt_mesh_sensor_client_get_state(&common,
|
||||
(void *)arg->sensor_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
cb.error_code = bt_mesh_sensor_client_get_state(&common, arg->sensor_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
|
||||
|
@ -573,12 +565,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
|||
}
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
|
||||
params = arg->sensor_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
|
@ -587,10 +573,10 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
|||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->sensor_client_set_state.params;
|
||||
cb.error_code = bt_mesh_sensor_client_set_state(&common,
|
||||
(void *)arg->sensor_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
cb.error_code = bt_mesh_sensor_client_set_state(&common, arg->sensor_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
|
||||
|
@ -619,7 +605,7 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_sensor_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_client_free_req_data(msg);
|
||||
|
@ -628,9 +614,8 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
|
|||
|
||||
/* Sensor Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_sensor_server_cb_to_app(
|
||||
esp_ble_mesh_sensor_server_cb_event_t event,
|
||||
esp_ble_mesh_sensor_server_cb_param_t *param)
|
||||
static inline void btc_ble_mesh_sensor_server_cb_to_app(esp_ble_mesh_sensor_server_cb_event_t event,
|
||||
esp_ble_mesh_sensor_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_sensor_server_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_SERVER);
|
||||
|
@ -658,7 +643,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len;
|
||||
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down,
|
||||
|
@ -669,7 +654,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len;
|
||||
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up,
|
||||
|
@ -680,7 +665,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len;
|
||||
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low,
|
||||
|
@ -691,7 +676,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len;
|
||||
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high,
|
||||
|
@ -704,7 +689,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->value.state_change.sensor_setting_set.setting_value->len;
|
||||
p_dest_data->value.state_change.sensor_setting_set.setting_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_setting_set.setting_value == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_setting_set.setting_value,
|
||||
|
@ -719,7 +704,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->value.get.sensor_column.raw_value_x->len;
|
||||
p_dest_data->value.get.sensor_column.raw_value_x = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.get.sensor_column.raw_value_x == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x,
|
||||
|
@ -731,7 +716,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->value.get.sensor_series.raw_value->len;
|
||||
p_dest_data->value.get.sensor_series.raw_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.get.sensor_series.raw_value == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value,
|
||||
|
@ -747,7 +732,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->value.set.sensor_cadence.cadence->len;
|
||||
p_dest_data->value.set.sensor_cadence.cadence = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.sensor_cadence.cadence == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence,
|
||||
|
@ -760,7 +745,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
|||
length = p_src_data->value.set.sensor_setting.setting_raw->len;
|
||||
p_dest_data->value.set.sensor_setting.setting_raw = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.sensor_setting.setting_raw == NULL) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw,
|
||||
|
@ -834,17 +819,15 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa
|
|||
msg.pid = BTC_PID_SENSOR_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(
|
||||
&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t), btc_ble_mesh_sensor_server_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t),
|
||||
btc_ble_mesh_sensor_server_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_param_t cb_params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
|
@ -863,7 +846,7 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
|
|||
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown Sensor Server event type", __func__);
|
||||
BT_ERR("Unknown Sensor server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -874,10 +857,11 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
|
|||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_server_callback(&cb_params, act);
|
||||
|
@ -898,7 +882,7 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_sensor_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_server_free_req_data(msg);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
/* Time and Scenes Client Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_time_scene_client_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param)
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT);
|
||||
|
@ -48,7 +48,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
|
|||
memcpy(dst->time_scene_client_get_state.params, src->time_scene_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->time_scene_client_get_state.get_state) {
|
||||
|
@ -57,7 +57,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
|
|||
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -71,12 +71,12 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
|
|||
memcpy(dst->time_scene_client_set_state.set_state, src->time_scene_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_time_scene_client_set_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
|
|||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
|
|||
length = p_src_data->status_cb.scene_register_status.scenes->len;
|
||||
p_dest_data->status_cb.scene_register_status.scenes = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.scene_register_status.scenes) {
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.scene_register_status.scenes,
|
||||
|
@ -220,18 +220,17 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie
|
|||
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_time_scene_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_client_cb_param_t),
|
||||
btc_ble_mesh_time_scene_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
|
@ -253,7 +252,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown time scene client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Time Scene client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -265,31 +264,31 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_time_scene_client_cb_evt_to_btc(opcode,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_time_scene_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -299,7 +298,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
|||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -311,12 +309,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
|||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
|
||||
params = arg->time_scene_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
|
@ -325,10 +317,10 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
|||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->time_scene_client_get_state.params;
|
||||
cb.error_code = bt_mesh_time_scene_client_get_state(&common,
|
||||
(void *)arg->time_scene_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
cb.error_code = bt_mesh_time_scene_client_get_state(&common, arg->time_scene_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
|
||||
|
@ -337,12 +329,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
|||
}
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
|
||||
params = arg->time_scene_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
|
@ -351,10 +337,10 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
|||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
cb.params = arg->time_scene_client_set_state.params;
|
||||
cb.error_code = bt_mesh_time_scene_client_set_state(&common,
|
||||
(void *)arg->time_scene_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
cb.error_code = bt_mesh_time_scene_client_set_state(&common, arg->time_scene_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
|
||||
|
@ -383,7 +369,7 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_time_scene_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_client_free_req_data(msg);
|
||||
|
@ -392,9 +378,8 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
|
|||
|
||||
/* Time and Scenes Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_time_scene_server_cb_to_app(
|
||||
esp_ble_mesh_time_scene_server_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_server_cb_param_t *param)
|
||||
static inline void btc_ble_mesh_time_scene_server_cb_to_app(esp_ble_mesh_time_scene_server_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_time_scene_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_time_scene_server_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER);
|
||||
|
@ -418,17 +403,14 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv
|
|||
msg.pid = BTC_PID_TIME_SCENE_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(
|
||||
&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0};
|
||||
size_t length = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
|
@ -450,7 +432,7 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
|
|||
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("%s, Unknown Time Scene Server event type", __func__);
|
||||
BT_ERR("Unknown Time Scene server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -461,10 +443,11 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
|
|||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_server_callback(&cb_params, act);
|
||||
|
@ -485,7 +468,7 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
|
|||
if (msg->act < ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_time_scene_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -53,15 +53,14 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
@ -70,10 +69,9 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX,
|
||||
} btc_ble_mesh_config_server_evt_t;
|
||||
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -53,15 +53,14 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE,
|
||||
|
@ -70,10 +69,9 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX,
|
||||
} btc_ble_mesh_generic_server_evt_t;
|
||||
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
|
|
@ -53,15 +53,14 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len);
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
|
||||
|
@ -82,7 +81,8 @@ void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
|||
|
||||
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id);
|
||||
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id);
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
|
||||
u8_t test_id, u16_t company_id);
|
||||
|
||||
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time);
|
||||
|
||||
|
|
|
@ -53,15 +53,14 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE,
|
||||
|
@ -71,10 +70,9 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX,
|
||||
} btc_ble_mesh_lighting_server_evt_t;
|
||||
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "btc/btc_manage.h"
|
||||
#include "mesh_byteorder.h"
|
||||
#include "mesh_main.h"
|
||||
#include "fast_prov.h"
|
||||
#include "provisioner_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
|
@ -298,6 +299,12 @@ esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_uuid(const uint8_t u
|
|||
|
||||
esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr);
|
||||
|
||||
esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *name);
|
||||
|
||||
u16_t btc_ble_mesh_provisioner_get_prov_node_count(void);
|
||||
|
||||
const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void);
|
||||
|
||||
int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
|
||||
|
||||
int btc_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
|
||||
|
@ -313,15 +320,12 @@ esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr);
|
|||
uint8_t btc_ble_mesh_elem_count(void);
|
||||
|
||||
esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem,
|
||||
uint16_t company, uint16_t id);
|
||||
uint16_t company, uint16_t id);
|
||||
|
||||
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem,
|
||||
uint16_t id);
|
||||
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem, uint16_t id);
|
||||
|
||||
const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void);
|
||||
|
||||
u16_t btc_ble_mesh_provisioner_get_prov_node_count(void);
|
||||
|
||||
void btc_ble_mesh_model_call_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_model_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
|
|
@ -53,15 +53,14 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE,
|
||||
|
@ -70,10 +69,9 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX,
|
||||
} btc_ble_mesh_sensor_server_evt_t;
|
||||
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
|
|
@ -53,15 +53,14 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
|
|||
|
||||
void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE,
|
||||
|
@ -71,10 +70,9 @@ typedef enum {
|
|||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX,
|
||||
} btc_ble_mesh_time_scene_server_evt_t;
|
||||
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "esp_attr.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#include "mesh_byteorder.h"
|
||||
|
@ -34,14 +35,11 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST
|
||||
#define bt_mesh_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
||||
#define bt_mesh_calloc(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
|
||||
#else
|
||||
#define bt_mesh_malloc(size) malloc((size))
|
||||
#define bt_mesh_calloc(size) calloc(1, (size))
|
||||
#endif /* CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST */
|
||||
#define bt_mesh_free(p) free((p))
|
||||
IRAM_ATTR void *bt_mesh_malloc(size_t size);
|
||||
|
||||
IRAM_ATTR void *bt_mesh_calloc(size_t size);
|
||||
|
||||
IRAM_ATTR void bt_mesh_free(void *ptr);
|
||||
|
||||
/**
|
||||
* @brief This function allocates memory to store outgoing message.
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "mesh_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -36,6 +37,8 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#define BLE_MESH_ADV_TASK_STACK_SIZE 3072
|
||||
#define BLE_MESH_ADV_TASK_NAME "mesh_adv_task"
|
||||
#define BLE_MESH_ADV_TASK_PRIO (configMAX_PRIORITIES - 5)
|
||||
|
||||
/**
|
||||
* @brief Put the current thread to sleep.
|
||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
|
||||
typedef struct {
|
||||
SemaphoreHandle_t mutex;
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
StaticQueue_t *buffer;
|
||||
#endif
|
||||
} bt_mesh_mutex_t;
|
||||
|
|
|
@ -28,18 +28,6 @@ typedef unsigned long long u64_t;
|
|||
|
||||
typedef int bt_mesh_atomic_t;
|
||||
|
||||
#ifndef bool
|
||||
#define bool int8_t
|
||||
#endif
|
||||
|
||||
#ifndef false
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
#ifndef true
|
||||
#define true 1
|
||||
#endif
|
||||
|
||||
#ifndef PRIu64
|
||||
#define PRIu64 "llu"
|
||||
#endif
|
||||
|
|
|
@ -186,15 +186,6 @@ const char *bt_hex(const void *buf, size_t len);
|
|||
|
||||
void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len);
|
||||
|
||||
unsigned int _copy(uint8_t *to, unsigned int to_len,
|
||||
const uint8_t *from, unsigned int from_len);
|
||||
|
||||
void _set(void *to, uint8_t val, unsigned int len);
|
||||
|
||||
uint8_t _double_byte(uint8_t a);
|
||||
|
||||
int _compare(const uint8_t *a, const uint8_t *b, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue