Compare commits
No commits in common. "master" and "v3.3.3" have entirely different histories.
418 changed files with 41296 additions and 10120 deletions
|
@ -35,13 +35,6 @@ variables:
|
|||
|
||||
# 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
|
||||
|
@ -370,11 +363,7 @@ build_docker:
|
|||
DOCKER_TMP_IMAGE_NAME: "idf_tmp_image"
|
||||
before_script: []
|
||||
script:
|
||||
- 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}"
|
||||
|
||||
- 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}"
|
||||
# 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.
|
||||
|
@ -803,18 +792,6 @@ 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
|
||||
|
@ -829,11 +806,6 @@ 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
|
||||
|
@ -852,11 +824,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
|
||||
- ./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}
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
# assgin integration test cases
|
||||
- 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
|
||||
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin
|
||||
|
||||
.define_config_file_name: &define_config_file_name |
|
||||
JOB_NAME_PREFIX=$(echo ${CI_JOB_NAME} | awk '{print $1}')
|
||||
|
@ -898,7 +870,7 @@ assign_test:
|
|||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone test env configs
|
||||
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
- cd $TEST_FW_PATH
|
||||
# run test
|
||||
|
@ -952,28 +924,24 @@ 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/auto_test_script/TestCaseFiles"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
|
||||
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
|
||||
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
- cd ci-test-runner-configs
|
||||
# clone test bench
|
||||
- ./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}
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cat ${KNOWN_ISSUE_FILE} >> ${TEST_CASE_FILE_PATH}/KnownIssues
|
||||
- cd auto_test_script
|
||||
# run test
|
||||
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
- python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
|
||||
nvs_compatible_test:
|
||||
<<: *test_template
|
||||
|
@ -991,17 +959,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
|
||||
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
- cd ci-test-runner-configs
|
||||
# clone test bench
|
||||
- ./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
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
- ./tools/prepare_nvs_bin.sh
|
||||
# prepare nvs bins
|
||||
- ./Tools/prepare_nvs_bin.sh
|
||||
# run test
|
||||
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
- python CIRunner.py -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
|
||||
|
@ -1356,7 +1324,7 @@ IT_002:
|
|||
|
||||
IT_003:
|
||||
<<: *test_template
|
||||
parallel: 14
|
||||
parallel: 13
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_5
|
||||
|
@ -1376,7 +1344,7 @@ IT_005:
|
|||
|
||||
IT_006:
|
||||
<<: *test_template
|
||||
parallel: 13
|
||||
parallel: 8
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
|
@ -1400,6 +1368,13 @@ IT_009:
|
|||
- ESP32_IDF
|
||||
- SSC_T1_3
|
||||
|
||||
IT_010:
|
||||
<<: *test_template
|
||||
parallel: 4
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
|
||||
IT_011:
|
||||
<<: *test_template
|
||||
tags:
|
||||
|
@ -1439,7 +1414,6 @@ IT_015:
|
|||
|
||||
IT_016:
|
||||
<<: *test_template
|
||||
allow_failure: true
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T50_MESH1
|
||||
|
@ -1452,6 +1426,7 @@ IT_017:
|
|||
|
||||
IT_018:
|
||||
<<: *test_template
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_9
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#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.
|
||||
|
@ -36,7 +35,7 @@
|
|||
*
|
||||
* @return Number of free pages
|
||||
*/
|
||||
uint32_t bootloader_mmap_get_free_pages(void);
|
||||
uint32_t bootloader_mmap_get_free_pages();
|
||||
|
||||
/**
|
||||
* @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(void);
|
||||
bootloader_sha256_handle_t bootloader_sha256_start();
|
||||
|
||||
void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len);
|
||||
|
||||
|
|
|
@ -62,17 +62,3 @@ __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,8 +26,6 @@
|
|||
#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"
|
||||
|
@ -188,7 +186,22 @@ 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.
|
||||
return bootloader_sha256_flash_contents(address, size, out_sha_256);
|
||||
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;
|
||||
}
|
||||
|
||||
int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata, bool *valid_two_otadata, bool max)
|
||||
|
@ -234,15 +247,13 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
|
|||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
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);
|
||||
const uint8_t *image = bootloader_mmap(partition->offset, partition->size);
|
||||
if (image == NULL) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, mmap_size);
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, partition->size);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
memcpy(app_desc, image + app_desc_offset, sizeof(esp_app_desc_t));
|
||||
memcpy(app_desc, image + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t), 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(void)
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
{
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)malloc(sizeof(mbedtls_sha256_context));
|
||||
if (!ctx) {
|
||||
|
@ -53,7 +53,6 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
|
|||
}
|
||||
mbedtls_sha256_free(ctx);
|
||||
free(handle);
|
||||
handle = NULL;
|
||||
}
|
||||
|
||||
#else // Bootloader version
|
||||
|
@ -71,7 +70,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(void)
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
{
|
||||
// Enable SHA hardware
|
||||
ets_sha_enable();
|
||||
|
|
|
@ -703,39 +703,3 @@ 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;
|
||||
}
|
|
@ -371,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"
|
||||
|
|
|
@ -1738,65 +1738,12 @@ if BLE_MESH
|
|||
option in the Bluetooth Controller section in menuconfig, which is
|
||||
"Scan Duplicate By Device Address and Advertising Data".
|
||||
|
||||
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
|
||||
bool "BLE Mesh will first allocate memory from PSRAM"
|
||||
default n
|
||||
help
|
||||
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
|
||||
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.
|
||||
|
||||
config BLE_MESH_FAST_PROV
|
||||
bool "Enable BLE Mesh Fast Provisioning"
|
||||
|
@ -1972,7 +1919,7 @@ if BLE_MESH
|
|||
advertising bearer.
|
||||
|
||||
config BLE_MESH_NET_BUF_POOL_USAGE
|
||||
bool
|
||||
bool "BLE Mesh net buffer pool usage tracking"
|
||||
default y
|
||||
help
|
||||
Enable BLE Mesh net buffer pool tracking. This option is used to introduce another
|
||||
|
@ -2030,7 +1977,7 @@ if BLE_MESH
|
|||
config BLE_MESH_SEQ_STORE_RATE
|
||||
int "How often the sequence number gets updated in storage"
|
||||
range 0 1000000
|
||||
default 0
|
||||
default 6
|
||||
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
|
||||
|
@ -2045,7 +1992,7 @@ if BLE_MESH
|
|||
config BLE_MESH_RPL_STORE_TIMEOUT
|
||||
int "Minimum frequency that the RPL gets updated in storage"
|
||||
range 0 1000000
|
||||
default 0
|
||||
default 5
|
||||
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_ERR_INVALID_STATE;
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return btc_storage_get_num_bt_bond_devices();
|
||||
}
|
||||
|
@ -221,6 +221,7 @@ 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;
|
||||
|
@ -230,7 +231,12 @@ esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
|
|||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, dev_num);
|
||||
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);
|
||||
|
||||
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
|
|
@ -50,33 +50,9 @@ 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 (void)
|
||||
uint16_t esp_ble_get_sendable_packets_num ()
|
||||
{
|
||||
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,9 +431,6 @@ 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);
|
||||
}
|
||||
|
@ -465,10 +462,6 @@ 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,9 +274,6 @@ 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,17 +154,6 @@ 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, /*!< Not for application use, use inside stack only. */
|
||||
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< dummy command */
|
||||
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,7 +174,6 @@ 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;
|
||||
|
||||
|
@ -272,14 +271,6 @@ 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,7 +46,6 @@ 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,7 +57,6 @@ 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 */
|
||||
|
@ -67,7 +66,6 @@ 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;
|
||||
|
||||
|
||||
|
@ -82,13 +80,6 @@ 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
|
||||
*/
|
||||
|
@ -137,14 +128,6 @@ 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
|
||||
*/
|
||||
|
@ -290,16 +273,6 @@ 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.
|
||||
|
|
|
@ -610,7 +610,7 @@ void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data)
|
|||
}
|
||||
}
|
||||
|
||||
void bta_dm_read_rssi(tBTA_DM_MSG *p_data)
|
||||
void bta_dm_ble_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,13 +756,11 @@ 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)
|
||||
#if BLE_INCLUDED == TRUE
|
||||
&& bta_dm_cb.device_list.peer_device[i].transport == transport
|
||||
#endif
|
||||
) {
|
||||
&& bta_dm_cb.device_list.peer_device[i].transport == transport) {
|
||||
bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING;
|
||||
btm_remove_acl( p_dev->bd_addr, transport);
|
||||
APPL_TRACE_DEBUG("%s:transport = %d", __func__, transport);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,11 +206,11 @@ void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb)
|
|||
}
|
||||
}
|
||||
|
||||
void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb)
|
||||
void BTA_DmBleReadRSSI(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_READ_RSSI_EVT;
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_READ_RSSI_EVT;
|
||||
memcpy(p_msg->remote_addr, remote_addr, sizeof(BD_ADDR));
|
||||
p_msg->transport = transport;
|
||||
p_msg->read_rssi_cb = cmpl_cb;
|
||||
|
|
|
@ -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_read_rssi, /* BTA_DM_API_READ_RSSI_EVT */
|
||||
bta_dm_ble_read_rssi, /* BTA_DM_API_BLE_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_READ_RSSI_EVT,
|
||||
BTA_DM_API_BLE_READ_RSSI_EVT,
|
||||
BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT,
|
||||
BTA_DM_MAX_EVT
|
||||
};
|
||||
|
@ -1226,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_read_rssi(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_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,10 +603,6 @@ 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;
|
||||
|
@ -654,10 +650,6 @@ 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,7 +35,6 @@
|
|||
#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,
|
||||
|
@ -673,7 +672,6 @@ 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,11 +426,6 @@ 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;
|
||||
|
|
|
@ -926,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 up event */
|
||||
tBTA_DM_LINK_UP link_up; /* ACL connection down 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 */
|
||||
|
@ -1457,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_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
|
||||
extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
|
|
@ -129,13 +129,11 @@ 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 */
|
||||
|
@ -146,7 +144,6 @@ 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 */
|
||||
|
@ -158,8 +155,7 @@ 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_FREE_SCN_EVT 35 /* FREE an SCN */
|
||||
#define BTA_JV_MAX_EVT 36 /* max number of JV events */
|
||||
#define BTA_JV_MAX_EVT 35 /* max number of JV events */
|
||||
|
||||
typedef UINT16 tBTA_JV_EVT;
|
||||
|
||||
|
@ -182,7 +178,6 @@ 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. */
|
||||
|
@ -191,6 +186,18 @@ 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. */
|
||||
|
@ -248,22 +255,6 @@ 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 {
|
||||
|
@ -274,7 +265,6 @@ 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 {
|
||||
|
@ -282,7 +272,6 @@ 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. */
|
||||
|
@ -291,6 +280,7 @@ 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. */
|
||||
|
@ -314,13 +304,19 @@ 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. */
|
||||
|
@ -360,23 +356,6 @@ 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 {
|
||||
|
@ -386,7 +365,6 @@ 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 */
|
||||
|
@ -394,7 +372,6 @@ 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 */
|
||||
|
@ -405,12 +382,9 @@ 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_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_LE_OPEN l2c_le_open; /* BTA_JV_L2CAP_OPEN_EVT */
|
||||
tBTA_JV_L2CAP_WRITE_FIXED l2c_write_fixed; /* BTA_JV_L2CAP_WRITE_FIXED_EVT */
|
||||
#endif
|
||||
} tBTA_JV;
|
||||
|
||||
/* JAVA DM Interface callback */
|
||||
|
@ -419,10 +393,8 @@ 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 {
|
||||
|
@ -452,25 +424,12 @@ extern tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback);
|
|||
**
|
||||
** Function BTA_JvDisable
|
||||
**
|
||||
** Description Disable the Java I/F. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_JV_DISABLE_EVT.
|
||||
** Description Disable the Java I/F
|
||||
**
|
||||
** Returns 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);
|
||||
extern void BTA_JvDisable(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -525,17 +484,12 @@ 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, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -578,7 +532,6 @@ 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
|
||||
|
@ -786,7 +739,6 @@ 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 */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -817,7 +769,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
|
|||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -834,8 +786,8 @@ extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_c
|
|||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
|
||||
UINT8 local_scn, UINT8 max_session,
|
||||
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);
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -863,7 +815,8 @@ 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);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -890,6 +843,7 @@ 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);
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -911,7 +865,8 @@ 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,7 +48,6 @@
|
|||
|
||||
|
||||
#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;
|
||||
|
@ -93,10 +92,11 @@ 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,10 +114,6 @@ 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);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -292,12 +288,6 @@ 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;
|
||||
|
@ -373,57 +363,6 @@ 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);
|
||||
|
@ -438,7 +377,6 @@ 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
|
||||
|
@ -464,7 +402,6 @@ 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 */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -519,9 +456,10 @@ 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]);
|
||||
}
|
||||
|
@ -540,15 +478,14 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
else {
|
||||
} 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) {
|
||||
|
@ -558,8 +495,6 @@ 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;
|
||||
|
@ -602,9 +537,7 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
else {
|
||||
} 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) {
|
||||
|
@ -619,7 +552,6 @@ 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);
|
||||
|
@ -702,6 +634,7 @@ BOOLEAN bta_jv_check_psm(UINT16 psm)
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -740,12 +673,7 @@ void bta_jv_enable(tBTA_JV_MSG *p_data)
|
|||
*******************************************************************************/
|
||||
void bta_jv_disable (tBTA_JV_MSG *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);
|
||||
}
|
||||
UNUSED(p_data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -854,16 +782,7 @@ void bta_jv_get_channel_id(tBTA_JV_MSG *p_data)
|
|||
*******************************************************************************/
|
||||
void bta_jv_free_scn(tBTA_JV_MSG *p_data)
|
||||
{
|
||||
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;
|
||||
UINT16 scn = p_data->free_channel.scn;
|
||||
|
||||
switch (p_data->free_channel.type) {
|
||||
case BTA_JV_CONN_TYPE_RFCOMM: {
|
||||
|
@ -883,19 +802,6 @@ 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)
|
||||
{
|
||||
|
@ -1186,7 +1092,6 @@ void bta_jv_delete_record(tBTA_JV_MSG *p_data)
|
|||
}
|
||||
}
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_jv_l2cap_client_cback
|
||||
|
@ -1612,7 +1517,6 @@ 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 */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -1692,7 +1596,6 @@ 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;
|
||||
|
@ -1857,10 +1760,9 @@ 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;
|
||||
tBTA_JV evt_data;
|
||||
APPL_TRACE_DEBUG("%s, rfc handle:%d",__func__, cc->handle);
|
||||
APPL_TRACE_DEBUG("bta_jv_rfcomm_close, rfc handle:%d", cc->handle);
|
||||
if (!cc->handle) {
|
||||
APPL_TRACE_ERROR("%s, rfc handle is null", __func__);
|
||||
APPL_TRACE_ERROR("bta_jv_rfcomm_close, rfc handle is null");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1868,21 +1770,9 @@ 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("%s: sec id in use:%d, rfc_cb in use:%d", __func__, get_sec_id_used(), get_rfc_cb_used());
|
||||
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());
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -2086,8 +1976,6 @@ 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");
|
||||
}
|
||||
}
|
||||
|
@ -2463,7 +2351,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;
|
||||
|
@ -2903,6 +2791,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,16 +69,6 @@ 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 */
|
||||
|
@ -110,39 +100,18 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback)
|
|||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback)
|
||||
void BTA_JvDisable(void)
|
||||
{
|
||||
tBTA_JV_API_DISABLE *p_buf;
|
||||
BT_HDR *p_buf;
|
||||
|
||||
APPL_TRACE_API( "BTA_JvDisable");
|
||||
bta_sys_deregister(BTA_ID_JV);
|
||||
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;
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_JV_API_DISABLE_EVT;
|
||||
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
|
||||
|
@ -230,14 +199,12 @@ 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_RFCOMM_CBACK *p_cback, void *user_data)
|
||||
tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type)
|
||||
{
|
||||
tBTA_JV_STATUS status = BTA_JV_FAILURE;
|
||||
tBTA_JV_API_FREE_CHANNEL *p_msg;
|
||||
|
@ -247,8 +214,6 @@ tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_C
|
|||
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;
|
||||
}
|
||||
|
@ -345,7 +310,6 @@ tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle)
|
|||
return (status);
|
||||
}
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capConnectLE
|
||||
|
@ -859,7 +823,6 @@ tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_i
|
|||
|
||||
return (status);
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -905,20 +868,19 @@ 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, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data)
|
||||
tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, 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( "%s", __func__);
|
||||
APPL_TRACE_API( "BTA_JvRfcommClose");
|
||||
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) {
|
||||
|
@ -926,7 +888,6 @@ tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, v
|
|||
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,14 +52,12 @@ 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 */
|
||||
|
@ -68,13 +66,11 @@ 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,14 +48,12 @@ 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,
|
||||
|
@ -64,13 +62,11 @@ 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
|
||||
};
|
||||
|
||||
|
@ -84,12 +80,6 @@ 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;
|
||||
|
@ -125,8 +115,6 @@ 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 {
|
||||
|
@ -139,7 +127,6 @@ 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
|
||||
|
@ -169,7 +156,6 @@ 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;
|
||||
|
@ -247,7 +233,6 @@ 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 {
|
||||
|
@ -315,7 +300,6 @@ 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;
|
||||
|
||||
|
@ -342,8 +326,6 @@ 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 */
|
||||
|
@ -358,20 +340,16 @@ 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;
|
||||
|
@ -379,6 +357,7 @@ 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 */
|
||||
|
@ -389,9 +368,7 @@ 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, */
|
||||
|
@ -430,14 +407,12 @@ 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);
|
||||
|
@ -446,12 +421,11 @@ 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 "btc_gap_ble.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
#include "btm_int.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
|
@ -304,11 +304,11 @@ static void btc_dm_link_up_evt(tBTA_DM_LINK_UP *p_link_up)
|
|||
BD_ADDR bd_addr;
|
||||
bt_bdaddr_t bt_bdaddr;
|
||||
|
||||
memcpy(bd_addr, p_link_up->bd_addr, sizeof(BD_ADDR));
|
||||
memcpy(bt_bdaddr.address, p_link_up->bd_addr, sizeof(BD_ADDR));
|
||||
|
||||
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 {
|
||||
|
@ -404,10 +404,11 @@ 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_inter_profile_call(&msg, ¶m);
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
|
@ -426,10 +427,11 @@ 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_inter_profile_call(&msg, ¶m);
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
@ -453,10 +455,11 @@ 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_inter_profile_call(&msg, ¶m);
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
@ -473,10 +476,11 @@ 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_inter_profile_call(&msg, ¶m);
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
@ -492,43 +496,16 @@ 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_inter_profile_call(&msg, ¶m);
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context 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;
|
||||
|
@ -666,7 +643,16 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
|
||||
case BTA_DM_DEV_UNPAIRED_EVT: {
|
||||
btc_dm_dev_unpaired_evt(&p_data->link_down);
|
||||
#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) */
|
||||
break;
|
||||
}
|
||||
case BTA_DM_BLE_DEV_UNPAIRED_EVT: {
|
||||
|
@ -699,14 +685,13 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||
break;
|
||||
}
|
||||
#endif /* BTC_GAP_BT_INCLUDED == TRUE */
|
||||
case BTA_DM_LINK_UP_EVT:
|
||||
btc_dm_link_up_evt(&p_data->link_up);
|
||||
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;
|
||||
case BTA_DM_LINK_UP_EVT:
|
||||
btc_dm_link_up_evt(&p_data->link_up);
|
||||
break;
|
||||
#if ((BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
|
||||
#if (defined(BLE_INCLUDED) && (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;
|
||||
|
@ -869,10 +854,11 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
|||
}
|
||||
|
||||
if (rsp_app) {
|
||||
ret = btc_inter_profile_call(&ble_msg, ¶m);
|
||||
ret = btc_transfer_context(&ble_msg, ¶m,
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
btc_dm_sec_arg_deep_free(msg);
|
||||
|
|
|
@ -201,6 +201,7 @@ int btc_storage_get_num_bt_bond_devices(void)
|
|||
}
|
||||
}
|
||||
btc_config_unlock();
|
||||
|
||||
return num_dev;
|
||||
}
|
||||
|
||||
|
@ -214,17 +215,15 @@ 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 (in_dev_num <= 0) {
|
||||
if (dev_num-- <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -237,12 +236,9 @@ bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *d
|
|||
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;
|
||||
|
|
|
@ -89,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,7 +127,6 @@ 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_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) ||
|
||||
|
@ -137,9 +136,6 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
|||
} else {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
}
|
||||
} else {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
}
|
||||
#else /* BTC_AV_SRC_INCLUDED */
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
#endif /* #if BTC_AV_SRC_INCLUDED */
|
||||
|
@ -163,10 +159,6 @@ 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) {
|
||||
|
@ -182,6 +174,7 @@ 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()) {
|
||||
|
@ -191,15 +184,14 @@ 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 if (btc_av_is_connected() == TRUE) {
|
||||
} else {
|
||||
/* 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_DmReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
|
||||
BTA_DmBleReadRSSI(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_DmReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback);
|
||||
BTA_DmBleReadRSSI(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,7 +852,6 @@ 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:
|
||||
|
@ -906,10 +905,6 @@ 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,7 +33,6 @@ 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,7 +35,6 @@ 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,7 +29,6 @@
|
|||
#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)
|
||||
|
||||
|
@ -56,20 +55,13 @@ typedef struct {
|
|||
char service_name[ESP_SPP_SERVER_NAME_MAX + 1];
|
||||
} spp_slot_t;
|
||||
|
||||
typedef struct {
|
||||
spp_slot_t *spp_slots[MAX_RFC_PORTS + 1];
|
||||
static struct spp_local_param_t {
|
||||
spp_slot_t *spp_slots[BTA_JV_MAX_RFC_SR_SESSION + 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_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
|
||||
} spp_local_param;
|
||||
|
||||
static void spp_osi_free(void *p)
|
||||
{
|
||||
|
@ -81,7 +73,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 <= MAX_RFC_PORTS; i++) {
|
||||
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] = (spp_slot_t *)osi_malloc(sizeof(spp_slot_t));
|
||||
if (!spp_local_param.spp_slots[i]) {
|
||||
|
@ -89,9 +81,6 @@ 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);
|
||||
|
@ -112,7 +101,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 <= MAX_RFC_PORTS; i++) {
|
||||
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]->id == id) {
|
||||
return spp_local_param.spp_slots[i];
|
||||
}
|
||||
|
@ -122,7 +111,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 <= MAX_RFC_PORTS; i++) {
|
||||
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]->rfc_handle == handle) {
|
||||
return spp_local_param.spp_slots[i];
|
||||
}
|
||||
|
@ -132,7 +121,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 <= MAX_RFC_PORTS; i++) {
|
||||
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]->fd == fd) {
|
||||
return spp_local_param.spp_slots[i];
|
||||
}
|
||||
|
@ -140,16 +129,6 @@ 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) {
|
||||
|
@ -181,6 +160,15 @@ 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;
|
||||
|
@ -189,38 +177,14 @@ 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_START_EVT:
|
||||
case BTA_JV_RFCOMM_SRV_OPEN_EVT:
|
||||
slot = spp_find_slot_by_id(id);
|
||||
if (!slot) {
|
||||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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__);
|
||||
|
@ -229,13 +193,18 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u
|
|||
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->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);
|
||||
break;
|
||||
case BTA_JV_RFCOMM_OPEN_EVT:
|
||||
slot = spp_find_slot_by_id(id);
|
||||
|
@ -254,26 +223,14 @@ 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 && p_data->rfc_close.port_status != PORT_LOCAL_CLOSED) {
|
||||
BTA_JvRfcommClose(slot->rfc_handle, NULL, (void *)slot->id);
|
||||
if (slot->connected) {
|
||||
BTA_JvRfcommClose(slot->rfc_handle, (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;
|
||||
}
|
||||
|
@ -335,15 +292,8 @@ 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();
|
||||
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);
|
||||
BTA_JvFreeChannel(slot->scn, BTA_JV_CONN_TYPE_RFCOMM);
|
||||
spp_free_slot(slot);
|
||||
}
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
break;
|
||||
|
@ -363,22 +313,6 @@ 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;
|
||||
|
@ -389,66 +323,41 @@ 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) {
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
BTA_JvDisable((tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb);
|
||||
osi_mutex_unlock(&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;
|
||||
}
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) {
|
||||
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_JvDisable();
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
|
@ -467,10 +376,6 @@ 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) {
|
||||
|
@ -478,16 +383,14 @@ 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, (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)slot->id);
|
||||
BTA_JvRfcommClose(arg->disconnect.handle, (void *)slot->id);
|
||||
btc_disconnect_cb(slot->rfc_handle);
|
||||
spp_free_slot(slot);
|
||||
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) {
|
||||
|
@ -505,54 +408,8 @@ 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) {
|
||||
|
@ -566,7 +423,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, BTA_JV_DEF_RFC_MTU);
|
||||
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990);
|
||||
if (item_size != 0){
|
||||
slot->write_data = data;
|
||||
BTA_JvRfcommWrite(arg->write.handle, slot->id, item_size, data);
|
||||
|
@ -647,9 +504,6 @@ 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;
|
||||
|
@ -708,7 +562,6 @@ 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 (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);
|
||||
|
@ -725,7 +578,6 @@ void btc_spp_cb_handler(btc_msg_t *msg)
|
|||
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);
|
||||
|
@ -757,7 +609,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, BTA_JV_DEF_RFC_MTU);
|
||||
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990);
|
||||
if (item_size != 0){
|
||||
slot->write_data = data;
|
||||
BTA_JvRfcommWrite(slot->rfc_handle, slot->id, item_size, data);
|
||||
|
@ -793,7 +645,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, BTA_JV_DEF_RFC_MTU);
|
||||
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990);
|
||||
if (item_size != 0){
|
||||
slot->write_data = data;
|
||||
BTA_JvRfcommWrite(slot->rfc_handle, slot->id, item_size, data);
|
||||
|
@ -816,22 +668,6 @@ 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;
|
||||
|
@ -869,16 +705,12 @@ 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 -1;
|
||||
return 0;
|
||||
}
|
||||
p_data.data_ind.handle = slot->rfc_handle;
|
||||
|
||||
|
@ -919,10 +751,6 @@ 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) {
|
||||
|
@ -942,10 +770,6 @@ 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) {
|
||||
|
@ -974,10 +798,6 @@ 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,12 +96,6 @@
|
|||
|
||||
#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 */
|
||||
|
@ -299,19 +293,6 @@
|
|||
#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
|
||||
|
@ -1360,7 +1341,7 @@
|
|||
|
||||
/* The maximum number of ports supported. */
|
||||
#ifndef MAX_RFC_PORTS
|
||||
#define MAX_RFC_PORTS 8 /*max is 30*/
|
||||
#define MAX_RFC_PORTS 16 /*max is 30*/
|
||||
#endif
|
||||
|
||||
/* The maximum simultaneous links to different devices. */
|
||||
|
@ -1729,6 +1710,15 @@ 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
|
||||
|
|
|
@ -794,7 +794,7 @@ 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_WARNING("btm_acl_encrypt_change: tBTM_SEC_DEV:0x%x rs_disc_pending=%d\n",
|
||||
BTM_TRACE_ERROR("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 */
|
||||
}
|
||||
|
@ -1140,6 +1140,7 @@ 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];
|
||||
|
|
|
@ -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_ERROR("%s: (%s) remote features unknown!!sec_flags:0x%02x\n", __FUNCTION__,
|
||||
BTM_TRACE_DEBUG("%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;
|
||||
|
|
|
@ -219,7 +219,6 @@ 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,
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "common/bt_target.h"
|
||||
#include "stack/l2cdefs.h"
|
||||
#include "stack/hcidefs.h"
|
||||
#include "osi/fixed_queue.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
|
@ -1228,21 +1227,6 @@ 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,10 +165,6 @@ 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,8 +36,6 @@
|
|||
#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)
|
||||
/*******************************************************************************
|
||||
|
@ -1879,16 +1877,6 @@ 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
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -2277,111 +2265,3 @@ 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,12 +1127,6 @@ 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,10 +880,6 @@ 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)
|
||||
|
@ -893,9 +889,6 @@ 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_lcb->link_xmit_data_q) && (list_length(p_lcb->link_xmit_data_q) + q_count) > p_ccb->buff_quota)) {
|
||||
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))) {
|
||||
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,15 +164,6 @@ 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;
|
||||
|
@ -201,32 +192,6 @@ 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,26 +92,8 @@ 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,7 +267,6 @@ 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);
|
||||
|
@ -275,12 +274,7 @@ bool config_remove_key(config_t *config, const char *section, const char *key)
|
|||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
return list_remove(sec->entries, entry);
|
||||
}
|
||||
|
||||
const config_section_node_t *config_section_begin(const config_t *config)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#ifndef __THREAD_H__
|
||||
#define __THREAD_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/FreeRTOSConfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
|
|
@ -156,7 +156,6 @@ COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \
|
|||
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("Failed to create semaphore");
|
||||
BT_ERR("%s, Failed to allocate memory for the semaphore", __func__);
|
||||
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("Failed to start mesh init");
|
||||
BT_ERR("%s, BLE Mesh initialise failed", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,7 @@ 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;
|
||||
|
@ -63,8 +62,7 @@ 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;
|
||||
|
|
|
@ -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("Invalid destination address 0x0000");
|
||||
BT_ERR("%s, Invalid destination address 0x0000", __func__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (device_role > ROLE_FAST_PROV) {
|
||||
BT_ERR("Invalid device role 0x%02x", device_role);
|
||||
BT_ERR("%s, Invalid device role 0x%02x", __func__, 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("Too small publication msg size %d", model->pub->msg->size);
|
||||
BT_ERR("%s, Model publication msg size %d is too small", __func__, 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("Too large data length %d", length);
|
||||
BT_ERR("%s, Data length %d is too large", __func__, length);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
@ -176,8 +176,7 @@ 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,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data)
|
||||
{
|
||||
if (model == NULL || ctx == NULL ||
|
||||
|
@ -191,11 +190,9 @@ 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 ||
|
||||
|
@ -297,8 +294,7 @@ 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};
|
||||
|
|
|
@ -35,29 +35,11 @@ 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;
|
||||
|
@ -74,10 +56,6 @@ 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;
|
||||
|
@ -254,10 +232,6 @@ 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;
|
||||
|
@ -275,10 +249,6 @@ 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;
|
||||
|
@ -318,10 +288,8 @@ 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};
|
||||
|
|
|
@ -60,8 +60,7 @@ 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};
|
||||
|
@ -101,8 +100,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};
|
||||
|
@ -125,8 +124,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_
|
|||
== 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};
|
||||
|
@ -150,8 +149,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_
|
|||
== 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,8 +55,7 @@ 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.
|
||||
|
@ -99,8 +98,7 @@ 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.
|
||||
|
|
|
@ -104,8 +104,7 @@ 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,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data);
|
||||
|
||||
/**
|
||||
|
@ -124,11 +123,9 @@ 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.
|
||||
|
@ -229,8 +226,7 @@ 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
|
||||
|
@ -333,8 +329,7 @@ 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.
|
||||
|
|
|
@ -257,17 +257,16 @@ 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, and reset current provisioning link with the device.
|
||||
* @brief Delete device from queue, reset current provisioning link and reset the node.
|
||||
*
|
||||
* @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.
|
||||
* @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.
|
||||
*
|
||||
* @param[in] del_dev: Pointer to a struct containing the device information.
|
||||
*
|
||||
|
|
|
@ -65,8 +65,7 @@ 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.
|
||||
|
@ -88,8 +87,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.
|
||||
|
@ -102,8 +101,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_
|
|||
* @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.
|
||||
|
@ -116,8 +115,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_
|
|||
* @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,12 +61,6 @@ 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
|
||||
|
@ -271,7 +265,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_CB in mesh_access.h */
|
||||
/*!< This macro is associated with BLE_MESH_MODEL in mesh_access.h */
|
||||
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
|
||||
{ \
|
||||
.model_id = (_id), \
|
||||
|
@ -284,7 +278,7 @@ typedef enum {
|
|||
.user_data = _user_data, \
|
||||
}
|
||||
|
||||
/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
|
||||
/*!< This macro is associated with BLE_MESH_MODEL_VND in mesh_access.h */
|
||||
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
|
||||
{ \
|
||||
.vnd.company_id = (_company), \
|
||||
|
@ -461,17 +455,6 @@ 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
|
||||
*/
|
||||
|
@ -505,9 +488,6 @@ 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;
|
||||
};
|
||||
|
@ -542,7 +522,7 @@ typedef struct {
|
|||
/** Force sending reliably by using segment acknowledgement */
|
||||
uint8_t send_rel: 1;
|
||||
|
||||
/** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */
|
||||
/** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */
|
||||
uint8_t send_ttl;
|
||||
|
||||
/** Opcode of a received message. Not used for sending message. */
|
||||
|
@ -829,7 +809,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 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_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 */
|
||||
|
@ -1132,7 +1112,6 @@ 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 */
|
||||
/**
|
||||
|
@ -1177,14 +1156,14 @@ typedef union {
|
|||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_provisioner_delete_node_with_uuid_comp_param {
|
||||
struct ble_mesh_provisioner_delete_node_with_uuid_comp_data_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_param {
|
||||
struct ble_mesh_provisioner_delete_node_with_addr_comp_data_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 */
|
||||
|
@ -1975,8 +1954,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 need to be sent in the application */
|
||||
#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response will be sent internally */
|
||||
#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 */
|
||||
|
||||
/** Parameters of the Server Model response control */
|
||||
typedef struct {
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#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,
|
||||
|
@ -49,7 +51,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->cfg_client_get_state.get_state) {
|
||||
|
@ -58,7 +60,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -69,7 +71,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->cfg_client_set_state.set_state) {
|
||||
|
@ -78,13 +80,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +138,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -155,7 +157,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.comp_data_status.composition_data,
|
||||
|
@ -171,7 +173,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.model_sub_list.sub_addr,
|
||||
|
@ -185,7 +187,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.netkey_list.net_idx,
|
||||
|
@ -199,7 +201,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.appkey_list.app_idx,
|
||||
|
@ -215,7 +217,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.model_app_list.app_idx,
|
||||
|
@ -304,8 +306,8 @@ 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,
|
||||
|
@ -315,6 +317,7 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
{
|
||||
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) {
|
||||
|
@ -336,7 +339,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("Unknown Config client event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown config client event type %d", __func__, evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -349,20 +352,21 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
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) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
}
|
||||
|
||||
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,
|
||||
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)
|
||||
{
|
||||
|
@ -371,15 +375,15 @@ void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_mo
|
|||
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)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -398,7 +402,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("Invalid Configuration Get");
|
||||
BT_ERR("%s, Invalid config client get", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
|
@ -406,65 +410,63 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
|
|||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
switch (param.opcode) {
|
||||
config_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
|
||||
return bt_mesh_cfg_beacon_get(¶m);
|
||||
return bt_mesh_cfg_beacon_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET:
|
||||
return bt_mesh_cfg_ttl_get(¶m);
|
||||
return bt_mesh_cfg_ttl_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_FRIEND_GET:
|
||||
return bt_mesh_cfg_friend_get(¶m);
|
||||
return bt_mesh_cfg_friend_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET:
|
||||
return bt_mesh_cfg_gatt_proxy_get(¶m);
|
||||
return bt_mesh_cfg_gatt_proxy_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_RELAY_GET:
|
||||
return bt_mesh_cfg_relay_get(¶m);
|
||||
return bt_mesh_cfg_relay_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
|
||||
return bt_mesh_cfg_mod_pub_get(¶m, get->model_pub_get.element_addr,
|
||||
return bt_mesh_cfg_mod_pub_get(&ctx, 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(¶m);
|
||||
return bt_mesh_cfg_hb_pub_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET:
|
||||
return bt_mesh_cfg_hb_sub_get(¶m);
|
||||
return bt_mesh_cfg_hb_sub_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
|
||||
return bt_mesh_cfg_comp_data_get(¶m, get->comp_data_get.page);
|
||||
return bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page);
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
|
||||
return bt_mesh_cfg_mod_sub_get(¶m, get->sig_model_sub_get.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_get(&ctx, 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(¶m, get->vnd_model_sub_get.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_get_vnd(&ctx, 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(¶m);
|
||||
return bt_mesh_cfg_net_key_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
|
||||
return bt_mesh_cfg_app_key_get(¶m, get->app_key_get.net_idx);
|
||||
return bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
|
||||
return bt_mesh_cfg_node_identity_get(¶m, get->node_identity_get.net_idx);
|
||||
return bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
|
||||
return bt_mesh_cfg_mod_app_get(¶m, get->sig_model_app_get.element_addr,
|
||||
return bt_mesh_cfg_mod_app_get(&ctx, 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(¶m, get->vnd_model_app_get.element_addr,
|
||||
return bt_mesh_cfg_mod_app_get_vnd(&ctx, 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(¶m, get->kr_phase_get.net_idx);
|
||||
return bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
|
||||
return bt_mesh_cfg_lpn_timeout_get(¶m, get->lpn_pollto_get.lpn_addr);
|
||||
return bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr);
|
||||
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET:
|
||||
return bt_mesh_cfg_net_transmit_get(¶m);
|
||||
return bt_mesh_cfg_net_transmit_get(&ctx);
|
||||
default:
|
||||
BT_ERR("Invalid Configuration Get opcode 0x%04x", param.opcode);
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -474,7 +476,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)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -482,41 +484,39 @@ 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("Invalid Configuration Set");
|
||||
BT_ERR("%s, Invalid config client set", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
switch (param.opcode) {
|
||||
config_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_BEACON_SET:
|
||||
return bt_mesh_cfg_beacon_set(¶m, set->beacon_set.beacon);
|
||||
return bt_mesh_cfg_beacon_set(&ctx, set->beacon_set.beacon);
|
||||
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET:
|
||||
return bt_mesh_cfg_ttl_set(¶m, set->default_ttl_set.ttl);
|
||||
return bt_mesh_cfg_ttl_set(&ctx, set->default_ttl_set.ttl);
|
||||
case ESP_BLE_MESH_MODEL_OP_FRIEND_SET:
|
||||
return bt_mesh_cfg_friend_set(¶m, set->friend_set.friend_state);
|
||||
return bt_mesh_cfg_friend_set(&ctx, set->friend_set.friend_state);
|
||||
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET:
|
||||
return bt_mesh_cfg_gatt_proxy_set(¶m, set->gatt_proxy_set.gatt_proxy);
|
||||
return bt_mesh_cfg_gatt_proxy_set(&ctx, set->gatt_proxy_set.gatt_proxy);
|
||||
case ESP_BLE_MESH_MODEL_OP_RELAY_SET:
|
||||
return bt_mesh_cfg_relay_set(¶m, set->relay_set.relay,
|
||||
return bt_mesh_cfg_relay_set(&ctx, 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(¶m, set->net_key_add.net_idx,
|
||||
return bt_mesh_cfg_net_key_add(&ctx, 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(¶m, set->app_key_add.net_idx,
|
||||
return bt_mesh_cfg_app_key_add(&ctx, 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(¶m, set->model_app_bind.element_addr,
|
||||
return bt_mesh_cfg_mod_app_bind(&ctx, 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);
|
||||
|
@ -529,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(¶m, set->model_pub_set.element_addr,
|
||||
return bt_mesh_cfg_mod_pub_set(&ctx, 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(¶m, set->model_sub_add.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_add(&ctx, 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(¶m, set->model_sub_delete.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_del(&ctx, 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(¶m, set->model_sub_overwrite.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_overwrite(&ctx, 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(¶m, set->model_sub_va_add.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_va_add(&ctx, 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(¶m, set->model_sub_va_overwrite.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_va_overwrite(&ctx, 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(¶m, set->model_sub_va_delete.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_va_del(&ctx, 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(¶m, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set);
|
||||
return bt_mesh_cfg_hb_sub_set(&ctx, (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(¶m, (struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set);
|
||||
return bt_mesh_cfg_hb_pub_set(&ctx, (const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set);
|
||||
case ESP_BLE_MESH_MODEL_OP_NODE_RESET:
|
||||
return bt_mesh_cfg_node_reset(¶m);
|
||||
return bt_mesh_cfg_node_reset(&ctx);
|
||||
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,
|
||||
|
@ -577,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(¶m, set->model_pub_va_set.element_addr,
|
||||
return bt_mesh_cfg_mod_pub_va_set(&ctx, 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(¶m, set->model_sub_delete_all.element_addr,
|
||||
return bt_mesh_cfg_mod_sub_del_all(&ctx, 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(¶m, set->net_key_update.net_idx,
|
||||
return bt_mesh_cfg_net_key_update(&ctx, 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(¶m, set->net_key_delete.net_idx);
|
||||
return bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx);
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE:
|
||||
return bt_mesh_cfg_app_key_update(¶m, set->app_key_update.net_idx,
|
||||
return bt_mesh_cfg_app_key_update(&ctx, 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(¶m, set->app_key_delete.net_idx,
|
||||
return bt_mesh_cfg_app_key_delete(&ctx, 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(¶m, set->node_identity_set.net_idx,
|
||||
return bt_mesh_cfg_node_identity_set(&ctx, 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(¶m, set->model_app_unbind.element_addr,
|
||||
return bt_mesh_cfg_mod_app_unbind(&ctx, 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(¶m, set->kr_phase_set.net_idx,
|
||||
return bt_mesh_cfg_kr_phase_set(&ctx, 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(¶m, set->net_transmit_set.net_transmit);
|
||||
return bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit);
|
||||
default:
|
||||
BT_ERR("Invalid Configuration Set opcode 0x%04x", param.opcode);
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -623,6 +623,7 @@ 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,6 +635,12 @@ 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) {
|
||||
|
@ -643,6 +650,12 @@ 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) {
|
||||
|
@ -672,7 +685,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_client_free_req_data(msg);
|
||||
|
@ -709,11 +722,13 @@ 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,
|
||||
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) {
|
||||
|
@ -726,7 +741,7 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *mo
|
|||
act = ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Config server event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown config server event type %d", __func__, evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -738,10 +753,10 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *mo
|
|||
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) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
}
|
||||
|
||||
btc_ble_mesh_config_server_callback(&cb_params, act);
|
||||
|
@ -762,6 +777,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown deep copy 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids,
|
||||
|
@ -374,8 +374,8 @@ 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,
|
||||
|
@ -385,6 +385,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
{
|
||||
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) {
|
||||
|
@ -406,7 +407,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("Unknown Generic client event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown generic client event type %d", __func__, evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -419,20 +420,21 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
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) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
}
|
||||
|
||||
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,
|
||||
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)
|
||||
{
|
||||
|
@ -441,8 +443,8 @@ void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_m
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -452,6 +454,7 @@ 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__);
|
||||
|
@ -463,6 +466,12 @@ 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;
|
||||
|
@ -471,10 +480,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, arg->generic_client_get_state.get_state);
|
||||
cb.error_code = bt_mesh_generic_client_get_state(&common,
|
||||
(void *)arg->generic_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
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);
|
||||
|
@ -483,6 +492,12 @@ 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;
|
||||
|
@ -491,10 +506,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, arg->generic_client_set_state.set_state);
|
||||
cb.error_code = bt_mesh_generic_client_set_state(&common,
|
||||
(void *)arg->generic_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
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);
|
||||
|
@ -523,7 +538,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_client_free_req_data(msg);
|
||||
|
@ -532,7 +547,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,
|
||||
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 =
|
||||
|
@ -562,7 +578,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value,
|
||||
|
@ -576,7 +592,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value,
|
||||
|
@ -596,7 +612,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value,
|
||||
|
@ -610,7 +626,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value,
|
||||
|
@ -687,15 +703,17 @@ 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,
|
||||
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) {
|
||||
|
@ -714,7 +732,7 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *m
|
|||
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Generic Server event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown Generic Server event type", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -726,10 +744,10 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *m
|
|||
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) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_callback(&cb_params, act);
|
||||
|
@ -750,7 +768,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_free_req_data(msg);
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#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,
|
||||
|
@ -50,7 +52,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->health_client_get_state.get_state) {
|
||||
|
@ -59,7 +61,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -73,12 +75,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +132,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -148,7 +150,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array,
|
||||
|
@ -164,7 +166,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array,
|
||||
|
@ -238,8 +240,8 @@ 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,
|
||||
|
@ -249,6 +251,7 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
{
|
||||
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) {
|
||||
|
@ -270,7 +273,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("Unknown Health client event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown health client event type %d", __func__, evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -283,20 +286,21 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
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) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
}
|
||||
|
||||
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,
|
||||
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)
|
||||
{
|
||||
|
@ -305,15 +309,15 @@ void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *mo
|
|||
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)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
@ -321,29 +325,27 @@ 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("Invalid Health Get");
|
||||
BT_ERR("%s, Invalid health client get", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
switch (param.opcode) {
|
||||
health_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
|
||||
return bt_mesh_health_attention_get(¶m);
|
||||
return bt_mesh_health_attention_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
|
||||
return bt_mesh_health_period_get(¶m);
|
||||
return bt_mesh_health_period_get(&ctx);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
|
||||
return bt_mesh_health_fault_get(¶m, get->fault_get.company_id);
|
||||
return bt_mesh_health_fault_get(&ctx, get->fault_get.company_id);
|
||||
default:
|
||||
BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode);
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -353,42 +355,40 @@ 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)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
|
||||
if (params == NULL || set == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
switch (param.opcode) {
|
||||
health_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
|
||||
return bt_mesh_health_attention_set(¶m, set->attention_set.attention, true);
|
||||
return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
|
||||
return bt_mesh_health_attention_set(¶m, set->attention_set.attention, false);
|
||||
return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
|
||||
return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, true);
|
||||
return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
|
||||
return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, false);
|
||||
return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
|
||||
return bt_mesh_health_fault_test(¶m, set->fault_test.company_id, set->fault_test.test_id, true);
|
||||
return bt_mesh_health_fault_test(&ctx, 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(¶m, set->fault_test.company_id, set->fault_test.test_id, false);
|
||||
return bt_mesh_health_fault_test(&ctx, 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(¶m, set->fault_clear.company_id, true);
|
||||
return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
|
||||
return bt_mesh_health_fault_clear(¶m, set->fault_clear.company_id, false);
|
||||
return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false);
|
||||
default:
|
||||
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -399,6 +399,7 @@ 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,6 +411,12 @@ 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) {
|
||||
|
@ -420,6 +427,12 @@ 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) {
|
||||
|
@ -450,7 +463,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_client_free_req_data(msg);
|
||||
|
@ -544,8 +557,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)
|
||||
|
@ -589,7 +602,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_server_free_req_data(msg);
|
||||
|
@ -606,8 +619,7 @@ 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};
|
||||
|
||||
|
|
|
@ -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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown deep copy 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value,
|
||||
|
@ -218,8 +218,8 @@ 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,
|
||||
|
@ -229,6 +229,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
{
|
||||
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) {
|
||||
|
@ -250,7 +251,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("Unknown Lighting client event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown lighting client event type", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -263,20 +264,21 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
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) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
}
|
||||
|
||||
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,
|
||||
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)
|
||||
{
|
||||
|
@ -285,8 +287,8 @@ void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -296,6 +298,7 @@ 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__);
|
||||
|
@ -307,6 +310,12 @@ 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;
|
||||
|
@ -315,10 +324,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, arg->light_client_get_state.get_state);
|
||||
cb.error_code = bt_mesh_light_client_get_state(&common,
|
||||
(void *)arg->light_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
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);
|
||||
|
@ -327,6 +336,12 @@ 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;
|
||||
|
@ -335,10 +350,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, arg->light_client_set_state.set_state);
|
||||
cb.error_code = bt_mesh_light_client_set_state(&common,
|
||||
(void *)arg->light_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
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);
|
||||
|
@ -367,7 +382,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_client_free_req_data(msg);
|
||||
|
@ -376,7 +391,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,
|
||||
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 =
|
||||
|
@ -405,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.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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.lc_property_set.property_value,
|
||||
|
@ -421,7 +437,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value,
|
||||
|
@ -436,7 +452,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data,
|
||||
|
@ -499,15 +515,17 @@ 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,
|
||||
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) {
|
||||
|
@ -529,7 +547,7 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *
|
|||
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Lighting server event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown Lighting Server event type", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -541,10 +559,10 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *
|
|||
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) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_server_callback(&cb_params, act);
|
||||
|
@ -565,7 +583,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_server_free_req_data(msg);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown deep copy 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.series_status.sensor_series_value,
|
||||
|
@ -456,8 +456,8 @@ 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,
|
||||
|
@ -467,6 +467,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
{
|
||||
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) {
|
||||
|
@ -488,7 +489,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("Unknown Sensor client event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown sensor client event type %d", __func__, evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -501,20 +502,21 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
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) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
}
|
||||
|
||||
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,
|
||||
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)
|
||||
{
|
||||
|
@ -523,8 +525,8 @@ void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_mo
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -534,6 +536,7 @@ 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__);
|
||||
|
@ -545,6 +548,12 @@ 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;
|
||||
|
@ -553,10 +562,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, arg->sensor_client_get_state.get_state);
|
||||
cb.error_code = bt_mesh_sensor_client_get_state(&common,
|
||||
(void *)arg->sensor_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
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);
|
||||
|
@ -565,6 +574,12 @@ 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;
|
||||
|
@ -573,10 +588,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, arg->sensor_client_set_state.set_state);
|
||||
cb.error_code = bt_mesh_sensor_client_set_state(&common,
|
||||
(void *)arg->sensor_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
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);
|
||||
|
@ -605,7 +620,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_client_free_req_data(msg);
|
||||
|
@ -614,7 +629,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,
|
||||
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 =
|
||||
|
@ -643,7 +659,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down,
|
||||
|
@ -654,7 +670,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up,
|
||||
|
@ -665,7 +681,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low,
|
||||
|
@ -676,7 +692,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high,
|
||||
|
@ -689,7 +705,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_setting_set.setting_value,
|
||||
|
@ -704,7 +720,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x,
|
||||
|
@ -716,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.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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value,
|
||||
|
@ -732,7 +748,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence,
|
||||
|
@ -745,7 +761,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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw,
|
||||
|
@ -819,15 +835,17 @@ 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,
|
||||
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) {
|
||||
|
@ -846,7 +864,7 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *mo
|
|||
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Sensor server event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown Sensor Server event type", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -858,10 +876,10 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *mo
|
|||
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) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_server_callback(&cb_params, act);
|
||||
|
@ -882,7 +900,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_server_free_req_data(msg);
|
||||
|
|
|
@ -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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown deep copy 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate 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, Out of memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.scene_register_status.scenes,
|
||||
|
@ -220,8 +220,8 @@ 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,
|
||||
|
@ -231,6 +231,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
{
|
||||
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) {
|
||||
|
@ -252,7 +253,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("Unknown Time Scene client event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown time scene client event type %d", __func__, evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -265,20 +266,21 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
|||
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) {
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
}
|
||||
|
||||
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,
|
||||
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)
|
||||
{
|
||||
|
@ -287,8 +289,8 @@ void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mes
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -298,6 +300,7 @@ 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__);
|
||||
|
@ -309,6 +312,12 @@ 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;
|
||||
|
@ -317,10 +326,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, arg->time_scene_client_get_state.get_state);
|
||||
cb.error_code = bt_mesh_time_scene_client_get_state(&common,
|
||||
(void *)arg->time_scene_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
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);
|
||||
|
@ -329,6 +338,12 @@ 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;
|
||||
|
@ -337,10 +352,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, arg->time_scene_client_set_state.set_state);
|
||||
cb.error_code = bt_mesh_time_scene_client_set_state(&common,
|
||||
(void *)arg->time_scene_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
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);
|
||||
|
@ -369,7 +384,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_client_free_req_data(msg);
|
||||
|
@ -378,7 +393,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,
|
||||
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 =
|
||||
|
@ -403,14 +419,17 @@ 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,
|
||||
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) {
|
||||
|
@ -432,7 +451,7 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model
|
|||
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Time Scene server event type %d", evt_type);
|
||||
BT_ERR("%s, Unknown Time Scene Server event type", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -444,10 +463,10 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model
|
|||
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) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_server_callback(&cb_params, act);
|
||||
|
@ -468,7 +487,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 act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -53,7 +53,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
@ -69,7 +70,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
@ -69,7 +70,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
@ -81,8 +82,7 @@ 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,7 +53,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
@ -70,7 +71,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
|
|
@ -322,7 +322,8 @@ 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);
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
@ -69,7 +70,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
|
|
@ -53,7 +53,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
@ -70,7 +71,8 @@ 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,
|
||||
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);
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "esp_attr.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#include "mesh_byteorder.h"
|
||||
|
@ -35,11 +34,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
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);
|
||||
#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))
|
||||
|
||||
/**
|
||||
* @brief This function allocates memory to store outgoing message.
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "mesh_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -37,8 +36,6 @@ 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_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
StaticQueue_t *buffer;
|
||||
#endif
|
||||
} bt_mesh_mutex_t;
|
||||
|
|
|
@ -493,7 +493,7 @@ void net_buf_unref(struct net_buf *buf)
|
|||
pool->uninit_count++;
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
|
||||
pool->avail_count++;
|
||||
NET_BUF_DBG("Unref, pool %p, avail_count %d, uninit_count %d",
|
||||
NET_BUF_DBG("%s, pool %p, avail_count %d, uninit_count %d", __func__,
|
||||
pool, pool->avail_count, pool->uninit_count);
|
||||
NET_BUF_ASSERT(pool->avail_count <= pool->buf_count);
|
||||
#endif
|
||||
|
@ -546,7 +546,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
|
|||
|
||||
NET_BUF_ASSERT(pool);
|
||||
|
||||
NET_BUF_DBG("Alloc, pool %p, uninit_count %d, buf_count %d",
|
||||
NET_BUF_DBG("%s, pool %p, uninit_count %d, buf_count %d", __func__,
|
||||
pool, pool->uninit_count, pool->buf_count);
|
||||
|
||||
/* We need to lock interrupts temporarily to prevent race conditions
|
||||
|
@ -570,7 +570,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
|
|||
|
||||
bt_mesh_buf_unlock();
|
||||
|
||||
NET_BUF_ERR("Out of free buffer, pool %p", pool);
|
||||
NET_BUF_ERR("%s, Failed to get free buffer", __func__);
|
||||
return NULL;
|
||||
|
||||
success:
|
||||
|
@ -579,11 +579,11 @@ success:
|
|||
if (size) {
|
||||
buf->__buf = data_alloc(buf, &size, timeout);
|
||||
if (!buf->__buf) {
|
||||
NET_BUF_ERR("Out of data, buf %p", buf);
|
||||
NET_BUF_ERR("%s, Failed to allocate data", __func__);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
NET_BUF_WARN("Zero data size, buf %p", buf);
|
||||
NET_BUF_WARN("%s, Zero data size", __func__);
|
||||
buf->__buf = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,37 +19,6 @@
|
|||
#include "client_common.h"
|
||||
#include "mesh_common.h"
|
||||
|
||||
IRAM_ATTR void *bt_mesh_malloc(size_t size)
|
||||
{
|
||||
#ifdef CONFIG_BLE_MESH_MEM_ALLOC_MODE_INTERNAL
|
||||
return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST
|
||||
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_MEM_ALLOC_MODE_IRAM_8BIT
|
||||
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#else
|
||||
return malloc(size);
|
||||
#endif
|
||||
}
|
||||
|
||||
IRAM_ATTR void *bt_mesh_calloc(size_t size)
|
||||
{
|
||||
#ifdef CONFIG_BLE_MESH_MEM_ALLOC_MODE_INTERNAL
|
||||
return heap_caps_calloc(1, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST
|
||||
return heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_MEM_ALLOC_MODE_IRAM_8BIT
|
||||
return heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#else
|
||||
return calloc(1, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
IRAM_ATTR void bt_mesh_free(void *ptr)
|
||||
{
|
||||
heap_caps_free(ptr);
|
||||
}
|
||||
|
||||
struct net_buf_simple *bt_mesh_alloc_buf(u16_t size)
|
||||
{
|
||||
struct net_buf_simple *buf = NULL;
|
||||
|
@ -57,7 +26,7 @@ struct net_buf_simple *bt_mesh_alloc_buf(u16_t size)
|
|||
|
||||
buf = (struct net_buf_simple *)bt_mesh_calloc(sizeof(struct net_buf_simple) + size);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -83,7 +52,7 @@ u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send)
|
|||
bt_mesh_client_user_data_t *client = NULL;
|
||||
|
||||
if (srv_send) {
|
||||
BT_DBG("Message is sent by a server model");
|
||||
BT_DBG("%s, Message is sent by a server model", __func__);
|
||||
return NODE;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,36 +22,32 @@ static bt_mesh_mutex_t atomic_lock;
|
|||
void bt_mesh_mutex_create(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("Create, invalid mutex");
|
||||
BT_ERR("%s, Invalid mutex", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||
mutex->buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||
mutex->buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#endif
|
||||
__ASSERT(mutex->buffer, "Failed to create mutex buffer");
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
mutex->buffer = heap_caps_calloc(1, sizeof(StaticQueue_t), MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM);
|
||||
__ASSERT(mutex->buffer, "%s, Failed to create queue buffer", __func__);
|
||||
mutex->mutex = xSemaphoreCreateMutexStatic(mutex->buffer);
|
||||
__ASSERT(mutex->mutex, "Failed to create static mutex");
|
||||
#else /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
__ASSERT(mutex->mutex, "%s, Failed to create static mutex", __func__);
|
||||
#else
|
||||
mutex->mutex = xSemaphoreCreateMutex();
|
||||
__ASSERT(mutex->mutex, "Failed to create mutex");
|
||||
#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
__ASSERT(mutex->mutex, "%s, Failed to create mutex", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("Free, invalid mutex");
|
||||
BT_ERR("%s, Invalid mutex", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mutex->mutex) {
|
||||
vSemaphoreDelete(mutex->mutex);
|
||||
mutex->mutex = NULL;
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
heap_caps_free(mutex->buffer);
|
||||
mutex->buffer = NULL;
|
||||
#endif
|
||||
|
@ -61,7 +57,7 @@ void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex)
|
|||
void bt_mesh_mutex_lock(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("Lock, invalid mutex");
|
||||
BT_ERR("%s, Invalid mutex", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -73,7 +69,7 @@ void bt_mesh_mutex_lock(bt_mesh_mutex_t *mutex)
|
|||
void bt_mesh_mutex_unlock(bt_mesh_mutex_t *mutex)
|
||||
{
|
||||
if (!mutex) {
|
||||
BT_ERR("Unlock, invalid mutex");
|
||||
BT_ERR("%s, Invalid mutex", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void bt_mesh_timer_init(void)
|
|||
bm_alarm_hash_map = hash_map_new(BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE,
|
||||
hash_function_pointer, NULL,
|
||||
(data_free_fn)osi_alarm_free, NULL);
|
||||
__ASSERT(bm_alarm_hash_map, "Failed to create hash map");
|
||||
__ASSERT(bm_alarm_hash_map, "%s, Failed to create hash map", __func__);
|
||||
}
|
||||
|
||||
void bt_mesh_timer_deinit(void)
|
||||
|
@ -74,12 +74,12 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
|
|||
if (!hash_map_has_key(bm_alarm_hash_map, (void *)work)) {
|
||||
alarm = osi_alarm_new("bt_mesh", (osi_alarm_callback_t)handler, (void *)&work->work, 0);
|
||||
if (alarm == NULL) {
|
||||
BT_ERR("Alarm not created");
|
||||
BT_ERR("%s, Alarm not created", __func__);
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
if (!hash_map_set(bm_alarm_hash_map, work, (void *)alarm)) {
|
||||
BT_ERR("Alarm not set");
|
||||
BT_ERR("%s, Alarm not set", __func__);
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
|
|||
|
||||
alarm = hash_map_get(bm_alarm_hash_map, work);
|
||||
if (alarm == NULL) {
|
||||
BT_ERR("Init, alarm not found");
|
||||
BT_ERR("%s, Alarm not found", __func__);
|
||||
bt_mesh_alarm_unlock();
|
||||
return -ENODEV;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Submit, alarm not found");
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Submit, alarm not found");
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ int k_delayed_work_cancel(struct k_delayed_work *work)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Cancel, alarm not found");
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ int k_delayed_work_free(struct k_delayed_work *work)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Free, alarm not found");
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
bt_mesh_alarm_unlock();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ s32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
|
|||
bt_mesh_alarm_lock();
|
||||
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
|
||||
if (alarm == NULL) {
|
||||
BT_WARN("Get time, alarm not found");
|
||||
BT_WARN("%s, Alarm not found", __func__);
|
||||
bt_mesh_alarm_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -22,11 +22,221 @@
|
|||
#include "fast_prov.h"
|
||||
#include "provisioner_main.h"
|
||||
|
||||
#include "generic_client.h"
|
||||
#include "sensor_client.h"
|
||||
#include "time_scene_client.h"
|
||||
#include "lighting_client.h"
|
||||
|
||||
#include "generic_server.h"
|
||||
#include "sensor_server.h"
|
||||
#include "time_scene_server.h"
|
||||
#include "lighting_server.h"
|
||||
|
||||
#define BLE_MESH_SDU_MAX_LEN 384
|
||||
|
||||
static const struct bt_mesh_comp *dev_comp;
|
||||
static u16_t dev_primary_addr;
|
||||
|
||||
static const struct {
|
||||
const u16_t id;
|
||||
int (*const init)(struct bt_mesh_model *model, bool primary);
|
||||
} model_init[] = {
|
||||
{ BLE_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_init },
|
||||
#if defined(CONFIG_BLE_MESH_CFG_CLI)
|
||||
{ BLE_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_HEALTH_CLI)
|
||||
{ BLE_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_LEVEL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_BATTERY_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_LOCATION_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_SENSOR_CLI)
|
||||
{ BLE_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_TIME_CLI)
|
||||
{ BLE_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_SCENE_CLI)
|
||||
{ BLE_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_SCHEDULER_CLI)
|
||||
{ BLE_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_CTL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_HSL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_XYL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_LC_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_init },
|
||||
#endif
|
||||
{ BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, bt_mesh_gen_onoff_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, bt_mesh_gen_level_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, bt_mesh_gen_def_trans_time_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, bt_mesh_gen_power_onoff_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, bt_mesh_gen_power_onoff_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, bt_mesh_gen_power_level_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, bt_mesh_gen_power_level_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, bt_mesh_gen_battery_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, bt_mesh_gen_location_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, bt_mesh_gen_location_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, bt_mesh_gen_user_prop_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, bt_mesh_gen_admin_prop_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, bt_mesh_gen_manu_prop_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, bt_mesh_gen_client_prop_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, bt_mesh_light_lightness_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, bt_mesh_light_lightness_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SRV, bt_mesh_light_ctl_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV, bt_mesh_light_ctl_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV, bt_mesh_light_ctl_temp_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SRV, bt_mesh_light_hsl_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV, bt_mesh_light_hsl_hue_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV, bt_mesh_light_hsl_sat_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV, bt_mesh_light_hsl_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SRV, bt_mesh_light_xyl_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV, bt_mesh_light_xyl_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LC_SRV, bt_mesh_light_lc_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV, bt_mesh_light_lc_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_TIME_SRV, bt_mesh_time_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_TIME_SETUP_SRV, bt_mesh_time_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_SCENE_SRV, bt_mesh_scene_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, bt_mesh_scene_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_SCHEDULER_SRV, bt_mesh_scheduler_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, bt_mesh_scheduler_setup_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_SENSOR_SRV, bt_mesh_sensor_srv_init },
|
||||
{ BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, bt_mesh_sensor_setup_srv_init },
|
||||
};
|
||||
|
||||
static const struct {
|
||||
const u16_t id;
|
||||
int (*const deinit)(struct bt_mesh_model *model, bool primary);
|
||||
} model_deinit[] = {
|
||||
{ BLE_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_deinit },
|
||||
#if defined(CONFIG_BLE_MESH_CFG_CLI)
|
||||
{ BLE_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_HEALTH_CLI)
|
||||
{ BLE_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_LEVEL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_BATTERY_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_LOCATION_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
|
||||
{ BLE_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_SENSOR_CLI)
|
||||
{ BLE_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_TIME_CLI)
|
||||
{ BLE_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_SCENE_CLI)
|
||||
{ BLE_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_SCHEDULER_CLI)
|
||||
{ BLE_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_CTL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_HSL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_XYL_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_deinit },
|
||||
#endif
|
||||
#if defined(CONFIG_BLE_MESH_LIGHT_LC_CLI)
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_deinit },
|
||||
#endif
|
||||
{ BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, bt_mesh_gen_onoff_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, bt_mesh_gen_level_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, bt_mesh_gen_def_trans_time_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, bt_mesh_gen_power_onoff_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, bt_mesh_gen_power_onoff_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, bt_mesh_gen_power_level_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, bt_mesh_gen_power_level_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, bt_mesh_gen_battery_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, bt_mesh_gen_location_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, bt_mesh_gen_location_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, bt_mesh_gen_user_prop_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, bt_mesh_gen_admin_prop_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, bt_mesh_gen_manu_prop_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, bt_mesh_gen_client_prop_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, bt_mesh_light_lightness_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, bt_mesh_light_lightness_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SRV, bt_mesh_light_ctl_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV, bt_mesh_light_ctl_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV, bt_mesh_light_ctl_temp_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SRV, bt_mesh_light_hsl_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV, bt_mesh_light_hsl_hue_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV, bt_mesh_light_hsl_sat_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV, bt_mesh_light_hsl_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SRV, bt_mesh_light_xyl_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV, bt_mesh_light_xyl_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LC_SRV, bt_mesh_light_lc_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV, bt_mesh_light_lc_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_TIME_SRV, bt_mesh_time_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_TIME_SETUP_SRV, bt_mesh_time_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_SCENE_SRV, bt_mesh_scene_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, bt_mesh_scene_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_SCHEDULER_SRV, bt_mesh_scheduler_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, bt_mesh_scheduler_setup_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_SENSOR_SRV, bt_mesh_sensor_srv_deinit },
|
||||
{ BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, bt_mesh_sensor_setup_srv_deinit },
|
||||
};
|
||||
|
||||
void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
||||
struct bt_mesh_elem *elem,
|
||||
bool vnd, bool primary,
|
||||
|
@ -35,11 +245,6 @@ void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
|||
{
|
||||
int i, j;
|
||||
|
||||
if (dev_comp == NULL) {
|
||||
BT_ERR("Invalid device composition");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < dev_comp->elem_count; i++) {
|
||||
struct bt_mesh_elem *elem = &dev_comp->elem[i];
|
||||
|
||||
|
@ -62,7 +267,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
|
|||
int period = 0;
|
||||
|
||||
if (!mod->pub) {
|
||||
BT_ERR("Model has no publication support");
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -84,7 +289,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
|
|||
period = K_MINUTES((mod->pub->period & BIT_MASK(6)) * 10U);
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown model publication period");
|
||||
BT_ERR("%s, Unknown model publication period", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -101,7 +306,7 @@ static s32_t next_period(struct bt_mesh_model *mod)
|
|||
u32_t elapsed = 0U, period = 0U;
|
||||
|
||||
if (!pub) {
|
||||
BT_ERR("Model has no publication support");
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -131,7 +336,7 @@ static void publish_sent(int err, void *user_data)
|
|||
BT_DBG("err %d", err);
|
||||
|
||||
if (!mod->pub) {
|
||||
BT_ERR("Model has no publication support");
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -172,7 +377,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
|
|||
{
|
||||
struct bt_mesh_model_pub *pub = mod->pub;
|
||||
if (!pub) {
|
||||
BT_ERR("Model has no publication support");
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -194,13 +399,13 @@ static int publish_retransmit(struct bt_mesh_model *mod)
|
|||
|
||||
key = bt_mesh_tx_appkey_get(pub->dev_role, pub->key);
|
||||
if (!key) {
|
||||
BT_ERR("AppKey 0x%03x not exists", pub->key);
|
||||
BT_ERR("%s, AppKey 0x%03x not exists", __func__, pub->key);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
tx.sub = bt_mesh_tx_netkey_get(pub->dev_role, key->net_idx);
|
||||
if (!tx.sub) {
|
||||
BT_ERR("Subnet 0x%04x not exists", key->net_idx);
|
||||
BT_ERR("%s, Subnet 0x%04x not exists", __func__, key->net_idx);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
|
@ -209,7 +414,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
|
|||
|
||||
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_SHORT);
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -242,12 +447,12 @@ static void mod_publish(struct k_work *work)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
period_ms = bt_mesh_model_pub_period_get(pub->mod);
|
||||
BT_INFO("Publish period %u ms", period_ms);
|
||||
BT_INFO("period %u ms", period_ms);
|
||||
|
||||
if (pub->count) {
|
||||
err = publish_retransmit(pub->mod);
|
||||
if (err) {
|
||||
BT_ERR("Failed to retransmit (err %d)", err);
|
||||
BT_ERR("%s, Failed to retransmit (err %d)", __func__, err);
|
||||
|
||||
pub->count = 0U;
|
||||
|
||||
|
@ -264,11 +469,14 @@ static void mod_publish(struct k_work *work)
|
|||
return;
|
||||
}
|
||||
|
||||
__ASSERT_NO_MSG(pub->update != NULL);
|
||||
|
||||
/* Callback the model publish update event to the application layer.
|
||||
* In the event, users can update the context of the publish message
|
||||
* which will be published in the next period.
|
||||
*/
|
||||
if (pub->update && pub->update(pub->mod)) {
|
||||
err = pub->update(pub->mod);
|
||||
if (err) {
|
||||
/* Cancel this publish attempt. */
|
||||
BT_ERR("Update failed, skipping publish (err %d)", err);
|
||||
pub->period_start = k_uptime_get_32();
|
||||
|
@ -278,7 +486,7 @@ static void mod_publish(struct k_work *work)
|
|||
|
||||
err = bt_mesh_model_publish(pub->mod);
|
||||
if (err) {
|
||||
BT_ERR("Publishing failed (err %d)", err);
|
||||
BT_ERR("%s, Publishing failed (err %d)", __func__, err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,12 +500,12 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
|
|||
struct bt_mesh_elem *elem = NULL;
|
||||
|
||||
if (!dev_comp) {
|
||||
BT_ERR("dev_comp not initialized");
|
||||
BT_ERR("%s, dev_comp is not initialized", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (elem_idx >= dev_comp->elem_count) {
|
||||
BT_ERR("Invalid element index %u", elem_idx);
|
||||
BT_ERR("%s, Invalid element index %u", __func__, elem_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -305,14 +513,14 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
|
|||
|
||||
if (vnd) {
|
||||
if (mod_idx >= elem->vnd_model_count) {
|
||||
BT_ERR("Invalid vendor model index %u", mod_idx);
|
||||
BT_ERR("%s, Invalid vendor model index %u", __func__, mod_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &elem->vnd_models[mod_idx];
|
||||
} else {
|
||||
if (mod_idx >= elem->model_count) {
|
||||
BT_ERR("Invalid SIG model index %u", mod_idx);
|
||||
BT_ERR("%s, Invalid SIG model index %u", __func__, mod_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -323,19 +531,8 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
|
|||
static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
bool vnd, bool primary, void *user_data)
|
||||
{
|
||||
int *err = user_data;
|
||||
int i;
|
||||
|
||||
if (!user_data) {
|
||||
BT_ERR("Invalid model init user data");
|
||||
return;
|
||||
}
|
||||
|
||||
if (*err) {
|
||||
BT_ERR("Model init failed (err %d)", *err);
|
||||
return;
|
||||
}
|
||||
|
||||
mod->elem = elem;
|
||||
|
||||
if (mod->pub) {
|
||||
|
@ -359,27 +556,18 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
|||
return;
|
||||
}
|
||||
|
||||
if (mod->cb && mod->cb->init) {
|
||||
*err = mod->cb->init(mod);
|
||||
for (i = 0; i < ARRAY_SIZE(model_init); i++) {
|
||||
if (model_init[i].id == mod->id) {
|
||||
model_init[i].init(mod, primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
bool vnd, bool primary, void *user_data)
|
||||
{
|
||||
int *err = user_data;
|
||||
int i;
|
||||
|
||||
if (!user_data) {
|
||||
BT_ERR("Invalid model deinit user data");
|
||||
return;
|
||||
}
|
||||
|
||||
if (*err) {
|
||||
BT_ERR("Model deinit failed (err %d)", *err);
|
||||
return;
|
||||
}
|
||||
|
||||
mod->elem = NULL;
|
||||
|
||||
if (mod->pub) {
|
||||
|
@ -399,15 +587,15 @@ static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
|||
return;
|
||||
}
|
||||
|
||||
if (mod->cb && mod->cb->deinit) {
|
||||
*err = mod->cb->deinit(mod);
|
||||
for (i = 0; i < ARRAY_SIZE(model_deinit); i++) {
|
||||
if (model_deinit[i].id == mod->id) {
|
||||
model_deinit[i].deinit(mod, primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
/* There must be at least one element */
|
||||
if (!comp->elem_count) {
|
||||
return -EINVAL;
|
||||
|
@ -415,24 +603,23 @@ int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
|
|||
|
||||
dev_comp = comp;
|
||||
|
||||
bt_mesh_model_foreach(mod_init, &err);
|
||||
bt_mesh_model_foreach(mod_init, NULL);
|
||||
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_comp_deregister(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (dev_comp == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_model_foreach(mod_deinit, &err);
|
||||
bt_mesh_model_foreach(mod_deinit, NULL);
|
||||
|
||||
dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED;
|
||||
dev_comp = NULL;
|
||||
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bt_mesh_comp_provision(u16_t addr)
|
||||
|
@ -458,6 +645,8 @@ void bt_mesh_comp_unprovision(void)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED;
|
||||
|
||||
bt_mesh_model_foreach(mod_init, NULL);
|
||||
}
|
||||
|
||||
u16_t bt_mesh_primary_addr(void)
|
||||
|
@ -587,7 +776,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
|
|||
case 0x00:
|
||||
case 0x01:
|
||||
if (buf->data[0] == 0x7f) {
|
||||
BT_ERR("Ignoring RFU OpCode");
|
||||
BT_ERR("%s, Ignoring RFU OpCode", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -595,7 +784,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
|
|||
return 0;
|
||||
case 0x02:
|
||||
if (buf->len < 2) {
|
||||
BT_ERR("Too short payload for 2-octet OpCode");
|
||||
BT_ERR("%s, Too short payload for 2-octet OpCode", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -603,7 +792,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
|
|||
return 0;
|
||||
case 0x03:
|
||||
if (buf->len < 3) {
|
||||
BT_ERR("Too short payload for 3-octet OpCode");
|
||||
BT_ERR("%s, Too short payload for 3-octet OpCode", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -649,7 +838,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
BT_INFO("recv, len %u: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
if (get_opcode(buf, &opcode) < 0) {
|
||||
BT_WARN("Unable to decode OpCode");
|
||||
BT_WARN("%s, Unable to decode OpCode", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -743,7 +932,7 @@ static bool ready_to_send(u8_t role, u16_t dst)
|
|||
return true;
|
||||
} else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en() && role == PROVISIONER) {
|
||||
if (!bt_mesh_provisioner_check_msg_dst(dst)) {
|
||||
BT_ERR("Failed to find DST 0x%04x", dst);
|
||||
BT_ERR("%s, Failed to find DST 0x%04x", __func__, dst);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -763,7 +952,7 @@ static int model_send(struct bt_mesh_model *model,
|
|||
|
||||
role = bt_mesh_get_device_role(model, tx->ctx->srv_send);
|
||||
if (role == ROLE_NVAL) {
|
||||
BT_ERR("Failed to get model role");
|
||||
BT_ERR("%s, Failed to get model role", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -772,22 +961,22 @@ static int model_send(struct bt_mesh_model *model,
|
|||
BT_INFO("send, len %u: %s", msg->len, bt_hex(msg->data, msg->len));
|
||||
|
||||
if (!ready_to_send(role, tx->ctx->addr)) {
|
||||
BT_ERR("Not ready to send");
|
||||
BT_ERR("%s, Not ready", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (net_buf_simple_tailroom(msg) < BLE_MESH_MIC_SHORT) {
|
||||
BT_ERR("Not enough tailroom for TransMIC");
|
||||
BT_ERR("%s, Not enough tailroom for TransMIC", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msg->len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN) - BLE_MESH_MIC_SHORT) {
|
||||
BT_ERR("Too big message (len %d)", msg->len);
|
||||
BT_ERR("%s, Too big message", __func__);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
if (!implicit_bind && !model_has_key(model, tx->ctx->app_idx)) {
|
||||
BT_ERR("Model not bound to AppKey 0x%04x", tx->ctx->app_idx);
|
||||
BT_ERR("%s, Model not bound to AppKey 0x%04x", __func__, tx->ctx->app_idx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -804,13 +993,13 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
|
|||
|
||||
role = bt_mesh_get_device_role(model, ctx->srv_send);
|
||||
if (role == ROLE_NVAL) {
|
||||
BT_ERR("Failed to get model role");
|
||||
BT_ERR("%s, Failed to get model role", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sub = bt_mesh_tx_netkey_get(role, ctx->net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", ctx->net_idx);
|
||||
BT_ERR("%s, Failed to get subnet", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -846,28 +1035,28 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!pub || !pub->msg) {
|
||||
BT_ERR("Model has no publication support");
|
||||
BT_ERR("%s, Model has no publication support", __func__);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (pub->addr == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_WARN("Unassigned publish address");
|
||||
BT_WARN("%s, Unassigned model publish address", __func__);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
key = bt_mesh_tx_appkey_get(pub->dev_role, pub->key);
|
||||
if (!key) {
|
||||
BT_ERR("Invalid AppKeyIndex 0x%03x", pub->key);
|
||||
BT_ERR("%s, AppKey 0x%03x not exists", __func__, pub->key);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
if (pub->msg->len + BLE_MESH_MIC_SHORT > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN)) {
|
||||
BT_ERR("Message does not fit maximum SDU size");
|
||||
BT_ERR("%s, Message does not fit maximum SDU size", __func__);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
if (pub->count) {
|
||||
BT_WARN("Clearing publish retransmit timer");
|
||||
BT_WARN("%s, Clearing publish retransmit timer", __func__);
|
||||
k_delayed_work_cancel(&pub->timer);
|
||||
}
|
||||
|
||||
|
@ -882,7 +1071,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
|||
|
||||
tx.sub = bt_mesh_tx_netkey_get(pub->dev_role, ctx.net_idx);
|
||||
if (!tx.sub) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", ctx.net_idx);
|
||||
BT_ERR("%s, Subnet 0x%04x not exists", __func__, ctx.net_idx);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
|
@ -893,7 +1082,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
|||
|
||||
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_SHORT);
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -923,7 +1112,8 @@ struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id)
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem,
|
||||
u16_t id)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -29,6 +29,11 @@ u8_t bt_mesh_elem_count(void);
|
|||
/* Find local element based on unicast or group address */
|
||||
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr);
|
||||
|
||||
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
|
||||
u16_t company, u16_t id);
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem,
|
||||
u16_t id);
|
||||
|
||||
u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr);
|
||||
|
||||
bool bt_mesh_fixed_group_match(u16_t addr);
|
||||
|
|
|
@ -41,6 +41,12 @@
|
|||
#define ADV_INT_DEFAULT_MS 100
|
||||
#define ADV_INT_FAST_MS 20
|
||||
|
||||
#if defined(CONFIG_BT_HOST_CRYPTO)
|
||||
#define ADV_STACK_SIZE 1024
|
||||
#else
|
||||
#define ADV_STACK_SIZE 768
|
||||
#endif
|
||||
|
||||
static const bt_mesh_addr_t *dev_addr;
|
||||
|
||||
static const u8_t adv_type[] = {
|
||||
|
@ -56,19 +62,19 @@ NET_BUF_POOL_DEFINE(adv_buf_pool, CONFIG_BLE_MESH_ADV_BUF_COUNT,
|
|||
static struct bt_mesh_adv adv_pool[CONFIG_BLE_MESH_ADV_BUF_COUNT];
|
||||
|
||||
struct bt_mesh_queue {
|
||||
QueueHandle_t handle;
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
QueueHandle_t queue;
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
StaticQueue_t *buffer;
|
||||
u8_t *storage;
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct bt_mesh_queue adv_queue;
|
||||
/* We reserve one queue item for bt_mesh_adv_update() */
|
||||
static struct bt_mesh_queue xBleMeshQueue;
|
||||
/* We reserve one queue for bt_mesh_adv_update() */
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
#define BLE_MESH_ADV_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT + 1)
|
||||
#define BLE_MESH_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT + 1)
|
||||
#else
|
||||
#define BLE_MESH_ADV_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + 1)
|
||||
#define BLE_MESH_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + 1)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
|
@ -77,11 +83,11 @@ NET_BUF_POOL_DEFINE(relay_adv_buf_pool, CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT,
|
|||
|
||||
static struct bt_mesh_adv relay_adv_pool[CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT];
|
||||
|
||||
static struct bt_mesh_queue relay_queue;
|
||||
static struct bt_mesh_queue xBleMeshRelayQueue;
|
||||
#define BLE_MESH_RELAY_QUEUE_SIZE CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT
|
||||
|
||||
static QueueSetHandle_t mesh_queue_set;
|
||||
#define BLE_MESH_QUEUE_SET_SIZE (BLE_MESH_ADV_QUEUE_SIZE + BLE_MESH_RELAY_QUEUE_SIZE)
|
||||
static QueueSetHandle_t xBleMeshQueueSet;
|
||||
#define BLE_MESH_QUEUE_SET_SIZE (BLE_MESH_QUEUE_SIZE + BLE_MESH_RELAY_QUEUE_SIZE)
|
||||
|
||||
#define BLE_MESH_RELAY_TIME_INTERVAL K_SECONDS(6)
|
||||
#define BLE_MESH_MAX_TIME_INTERVAL 0xFFFFFFFF
|
||||
|
@ -115,9 +121,7 @@ static void bt_mesh_ble_adv_deinit(void);
|
|||
|
||||
struct bt_mesh_adv_task {
|
||||
TaskHandle_t handle;
|
||||
#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \
|
||||
CONFIG_SPIRAM_CACHE_WORKAROUND && \
|
||||
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY)
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
StaticTask_t *task;
|
||||
StackType_t *stack;
|
||||
#endif
|
||||
|
@ -190,7 +194,7 @@ static inline int adv_send(struct net_buf *buf)
|
|||
struct ble_adv_tx *tx = cb_data;
|
||||
|
||||
if (tx == NULL) {
|
||||
BT_ERR("Invalid adv user data");
|
||||
BT_ERR("%s, Invalid adv user data", __func__);
|
||||
net_buf_unref(buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -218,7 +222,7 @@ static inline int adv_send(struct net_buf *buf)
|
|||
net_buf_unref(buf);
|
||||
adv_send_start(duration, err, cb, cb_data);
|
||||
if (err) {
|
||||
BT_ERR("Start advertising failed: err %d", err);
|
||||
BT_ERR("%s, Advertising failed: err %d", __func__, err);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -229,7 +233,7 @@ static inline int adv_send(struct net_buf *buf)
|
|||
err = bt_le_adv_stop();
|
||||
adv_send_end(err, cb, cb_data);
|
||||
if (err) {
|
||||
BT_ERR("Stop advertising failed: err %d", err);
|
||||
BT_ERR("%s, Stop advertising failed: err %d", __func__, err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -254,54 +258,54 @@ static void adv_thread(void *p)
|
|||
#if !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||
xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT);
|
||||
while (!(*buf)) {
|
||||
s32_t timeout;
|
||||
BT_DBG("Mesh Proxy Advertising start");
|
||||
timeout = bt_mesh_proxy_server_adv_start();
|
||||
timeout = bt_mesh_proxy_adv_start();
|
||||
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
||||
xQueueReceive(adv_queue.handle, &msg, timeout);
|
||||
xQueueReceive(xBleMeshQueue.queue, &msg, timeout);
|
||||
BT_DBG("Mesh Proxy Advertising stop");
|
||||
bt_mesh_proxy_server_adv_stop();
|
||||
bt_mesh_proxy_adv_stop();
|
||||
}
|
||||
#else
|
||||
xQueueReceive(adv_queue.handle, &msg, portMAX_DELAY);
|
||||
xQueueReceive(xBleMeshQueue.queue, &msg, portMAX_DELAY);
|
||||
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
||||
#else /* !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, K_NO_WAIT);
|
||||
handle = xQueueSelectFromSet(xBleMeshQueueSet, K_NO_WAIT);
|
||||
if (handle) {
|
||||
if (uxQueueMessagesWaiting(adv_queue.handle)) {
|
||||
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||
} else if (uxQueueMessagesWaiting(relay_queue.handle)) {
|
||||
xQueueReceive(relay_queue.handle, &msg, K_NO_WAIT);
|
||||
if (uxQueueMessagesWaiting(xBleMeshQueue.queue)) {
|
||||
xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT);
|
||||
} else if (uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) {
|
||||
xQueueReceive(xBleMeshRelayQueue.queue, &msg, K_NO_WAIT);
|
||||
}
|
||||
} else {
|
||||
while (!(*buf)) {
|
||||
s32_t timeout = 0;
|
||||
BT_DBG("Mesh Proxy Advertising start");
|
||||
timeout = bt_mesh_proxy_server_adv_start();
|
||||
timeout = bt_mesh_proxy_adv_start();
|
||||
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, timeout);
|
||||
handle = xQueueSelectFromSet(xBleMeshQueueSet, timeout);
|
||||
BT_DBG("Mesh Proxy Advertising stop");
|
||||
bt_mesh_proxy_server_adv_stop();
|
||||
bt_mesh_proxy_adv_stop();
|
||||
if (handle) {
|
||||
if (uxQueueMessagesWaiting(adv_queue.handle)) {
|
||||
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||
} else if (uxQueueMessagesWaiting(relay_queue.handle)) {
|
||||
xQueueReceive(relay_queue.handle, &msg, K_NO_WAIT);
|
||||
if (uxQueueMessagesWaiting(xBleMeshQueue.queue)) {
|
||||
xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT);
|
||||
} else if (uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) {
|
||||
xQueueReceive(xBleMeshRelayQueue.queue, &msg, K_NO_WAIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, portMAX_DELAY);
|
||||
handle = xQueueSelectFromSet(xBleMeshQueueSet, portMAX_DELAY);
|
||||
if (handle) {
|
||||
if (uxQueueMessagesWaiting(adv_queue.handle)) {
|
||||
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||
} else if (uxQueueMessagesWaiting(relay_queue.handle)) {
|
||||
xQueueReceive(relay_queue.handle, &msg, K_NO_WAIT);
|
||||
if (uxQueueMessagesWaiting(xBleMeshQueue.queue)) {
|
||||
xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT);
|
||||
} else if (uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) {
|
||||
xQueueReceive(xBleMeshRelayQueue.queue, &msg, K_NO_WAIT);
|
||||
}
|
||||
}
|
||||
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
||||
|
@ -316,18 +320,18 @@ static void adv_thread(void *p)
|
|||
BLE_MESH_ADV(*buf)->busy = 0U;
|
||||
#if !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
if (adv_send(*buf)) {
|
||||
BT_WARN("Failed to send adv packet");
|
||||
BT_WARN("%s, Failed to send adv packet", __func__);
|
||||
}
|
||||
#else /* !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
if (msg.relay && ignore_relay_packet(msg.timestamp)) {
|
||||
/* If the interval between "current time - msg.timestamp" is bigger than
|
||||
* BLE_MESH_RELAY_TIME_INTERVAL, this relay packet will not be sent.
|
||||
*/
|
||||
BT_INFO("Ignore relay packet");
|
||||
BT_INFO("%s, Ignore relay packet", __func__);
|
||||
net_buf_unref(*buf);
|
||||
} else {
|
||||
if (adv_send(*buf)) {
|
||||
BT_WARN("Failed to send adv packet");
|
||||
BT_WARN("%s, Failed to send adv packet", __func__);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -359,7 +363,7 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BT_DBG("pool %p, buf_count %d, uinit_count %d",
|
||||
BT_DBG("%s, pool = %p, buf_count = %d, uinit_count = %d", __func__,
|
||||
buf->pool, pool->buf_count, pool->uninit_count);
|
||||
|
||||
adv = get_id(net_buf_id(buf));
|
||||
|
@ -442,19 +446,19 @@ static void bt_mesh_task_post(bt_mesh_msg_t *msg, uint32_t timeout, bool front)
|
|||
{
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
if (adv_queue.handle == NULL) {
|
||||
BT_ERR("Invalid adv queue");
|
||||
if (xBleMeshQueue.queue == NULL) {
|
||||
BT_ERR("%s, Invalid queue", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (front) {
|
||||
if (xQueueSendToFront(adv_queue.handle, msg, timeout) != pdTRUE) {
|
||||
BT_ERR("Failed to send item to adv queue front");
|
||||
if (xQueueSendToFront(xBleMeshQueue.queue, msg, timeout) != pdTRUE) {
|
||||
BT_ERR("%s, Failed to send item to queue front", __func__);
|
||||
bt_mesh_unref_buf(msg);
|
||||
}
|
||||
} else {
|
||||
if (xQueueSend(adv_queue.handle, msg, timeout) != pdTRUE) {
|
||||
BT_ERR("Failed to send item to adv queue back");
|
||||
if (xQueueSend(xBleMeshQueue.queue, msg, timeout) != pdTRUE) {
|
||||
BT_ERR("%s, Failed to send item to queue back", __func__);
|
||||
bt_mesh_unref_buf(msg);
|
||||
}
|
||||
}
|
||||
|
@ -526,12 +530,12 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
|||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
if (relay_queue.handle == NULL) {
|
||||
BT_ERR("Invalid relay queue");
|
||||
if (xBleMeshRelayQueue.queue == NULL) {
|
||||
BT_ERR("%s, Invalid relay queue", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xQueueSend(relay_queue.handle, msg, timeout) == pdTRUE) {
|
||||
if (xQueueSend(xBleMeshRelayQueue.queue, msg, timeout) == pdTRUE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -539,25 +543,25 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
|||
* If failed to send packet to the relay queue(queue is full), we will
|
||||
* remove the oldest packet in the queue and put the new one into it.
|
||||
*/
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, K_NO_WAIT);
|
||||
if (handle && uxQueueMessagesWaiting(relay_queue.handle)) {
|
||||
BT_INFO("Full queue, remove the oldest relay packet");
|
||||
handle = xQueueSelectFromSet(xBleMeshQueueSet, K_NO_WAIT);
|
||||
if (handle && uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) {
|
||||
BT_INFO("%s, Full queue, remove the oldest relay packet", __func__);
|
||||
/* Remove the oldest relay packet from queue */
|
||||
if (xQueueReceive(relay_queue.handle, &old_msg, K_NO_WAIT) != pdTRUE) {
|
||||
BT_ERR("Failed to remove item from queue");
|
||||
if (xQueueReceive(xBleMeshRelayQueue.queue, &old_msg, K_NO_WAIT) != pdTRUE) {
|
||||
BT_ERR("%s, Failed to remove item from queue", __func__);
|
||||
bt_mesh_unref_buf(msg);
|
||||
return;
|
||||
}
|
||||
/* Unref buf used for the oldest relay packet */
|
||||
bt_mesh_unref_buf(&old_msg);
|
||||
/* Send the latest relay packet to queue */
|
||||
if (xQueueSend(relay_queue.handle, msg, K_NO_WAIT) != pdTRUE) {
|
||||
BT_ERR("Failed to send item to relay queue");
|
||||
if (xQueueSend(xBleMeshRelayQueue.queue, msg, K_NO_WAIT) != pdTRUE) {
|
||||
BT_ERR("%s, Failed to send item to relay queue", __func__);
|
||||
bt_mesh_unref_buf(msg);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
BT_WARN("Empty queue, but failed to send the relay packet");
|
||||
BT_WARN("%s, Empty queue, but failed to send the relay packet", __func__);
|
||||
bt_mesh_unref_buf(msg);
|
||||
}
|
||||
}
|
||||
|
@ -580,29 +584,29 @@ void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *c
|
|||
msg.src = src;
|
||||
msg.dst = dst;
|
||||
msg.timestamp = k_uptime_get_32();
|
||||
/* Use K_NO_WAIT here, if relay_queue is full return immediately */
|
||||
/* Use K_NO_WAIT here, if xBleMeshRelayQueue is full return immediately */
|
||||
ble_mesh_relay_task_post(&msg, K_NO_WAIT);
|
||||
}
|
||||
|
||||
u16_t bt_mesh_get_stored_relay_count(void)
|
||||
{
|
||||
return (u16_t)uxQueueMessagesWaiting(relay_queue.handle);
|
||||
return (u16_t)uxQueueMessagesWaiting(xBleMeshRelayQueue.queue);
|
||||
}
|
||||
#endif /* #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
|
||||
const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void)
|
||||
const bt_mesh_addr_t *bt_mesh_pba_get_addr(void)
|
||||
{
|
||||
return dev_addr;
|
||||
}
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
static bool adv_flags_valid(struct net_buf_simple *buf)
|
||||
static bool bt_mesh_is_adv_flags_valid(struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t flags = 0U;
|
||||
|
||||
if (buf->len != 1U) {
|
||||
BT_DBG("Unexpected adv flags length %d", buf->len);
|
||||
BT_DBG("%s, Unexpected flags length", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -616,7 +620,7 @@ static bool adv_flags_valid(struct net_buf_simple *buf)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool adv_service_uuid_valid(struct net_buf_simple *buf, u16_t *uuid)
|
||||
static bool bt_mesh_is_adv_srv_uuid_valid(struct net_buf_simple *buf, u16_t *uuid)
|
||||
{
|
||||
if (buf->len != 2U) {
|
||||
BT_DBG("Length not match mesh service uuid");
|
||||
|
@ -649,9 +653,7 @@ static bool adv_service_uuid_valid(struct net_buf_simple *buf, u16_t *uuid)
|
|||
#define BLE_MESH_PROXY_SRV_DATA_LEN1 0x09
|
||||
#define BLE_MESH_PROXY_SRV_DATA_LEN2 0x11
|
||||
|
||||
static void handle_adv_service_data(struct net_buf_simple *buf,
|
||||
const bt_mesh_addr_t *addr,
|
||||
u16_t uuid, s8_t rssi)
|
||||
static void bt_mesh_adv_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, u16_t uuid, s8_t rssi)
|
||||
{
|
||||
u16_t type = 0U;
|
||||
|
||||
|
@ -662,7 +664,7 @@ static void handle_adv_service_data(struct net_buf_simple *buf,
|
|||
|
||||
type = net_buf_simple_pull_le16(buf);
|
||||
if (type != uuid) {
|
||||
BT_DBG("Invalid Mesh Service Data UUID 0x%04x", type);
|
||||
BT_DBG("%s, Invalid Mesh Service Data UUID 0x%04x", __func__, type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -671,12 +673,12 @@ static void handle_adv_service_data(struct net_buf_simple *buf,
|
|||
case BLE_MESH_UUID_MESH_PROV_VAL:
|
||||
if (bt_mesh_is_provisioner_en()) {
|
||||
if (buf->len != BLE_MESH_PROV_SRV_DATA_LEN) {
|
||||
BT_WARN("Invalid Mesh Prov Service Data length %d", buf->len);
|
||||
BT_WARN("%s, Invalid Mesh Prov Service Data length %d", __func__, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("Start to handle Mesh Prov Service Data");
|
||||
bt_mesh_provisioner_prov_adv_recv(buf, addr, rssi);
|
||||
bt_mesh_provisioner_prov_adv_ind_recv(buf, addr, rssi);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
@ -684,12 +686,12 @@ static void handle_adv_service_data(struct net_buf_simple *buf,
|
|||
case BLE_MESH_UUID_MESH_PROXY_VAL:
|
||||
if (buf->len != BLE_MESH_PROXY_SRV_DATA_LEN1 &&
|
||||
buf->len != BLE_MESH_PROXY_SRV_DATA_LEN2) {
|
||||
BT_WARN("Invalid Mesh Proxy Service Data length %d", buf->len);
|
||||
BT_WARN("%s, Invalid Mesh Proxy Service Data length %d", __func__, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("Start to handle Mesh Proxy Service Data");
|
||||
bt_mesh_proxy_client_gatt_adv_recv(buf, addr, rssi);
|
||||
bt_mesh_proxy_client_adv_ind_recv(buf, addr, rssi);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -710,7 +712,7 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi,
|
|||
return;
|
||||
}
|
||||
|
||||
BT_DBG("scan, len %u: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
BT_DBG("%s, len %u: %s", __func__, buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
dev_addr = addr;
|
||||
|
||||
|
@ -765,19 +767,19 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi,
|
|||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
case BLE_MESH_DATA_FLAGS:
|
||||
if (!adv_flags_valid(buf)) {
|
||||
if (!bt_mesh_is_adv_flags_valid(buf)) {
|
||||
BT_DBG("Adv Flags mismatch, ignore this adv pkt");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BLE_MESH_DATA_UUID16_ALL:
|
||||
if (!adv_service_uuid_valid(buf, &uuid)) {
|
||||
if (!bt_mesh_is_adv_srv_uuid_valid(buf, &uuid)) {
|
||||
BT_DBG("Adv Service UUID mismatch, ignore this adv pkt");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BLE_MESH_DATA_SVC_DATA16:
|
||||
handle_adv_service_data(buf, addr, uuid, rssi);
|
||||
bt_mesh_adv_srv_data_recv(buf, addr, uuid, rssi);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -793,81 +795,65 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi,
|
|||
|
||||
void bt_mesh_adv_init(void)
|
||||
{
|
||||
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
adv_queue.handle = xQueueCreate(BLE_MESH_ADV_QUEUE_SIZE, sizeof(bt_mesh_msg_t));
|
||||
__ASSERT(adv_queue.handle, "Failed to create queue");
|
||||
#else /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||
adv_queue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||
adv_queue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#if !CONFIG_SPIRAM_USE_MALLOC
|
||||
xBleMeshQueue.queue = xQueueCreate(BLE_MESH_QUEUE_SIZE, sizeof(bt_mesh_msg_t));
|
||||
__ASSERT(xBleMeshQueue.queue, "%s, Failed to create queue", __func__);
|
||||
#else
|
||||
xBleMeshQueue.buffer = heap_caps_calloc(1, sizeof(StaticQueue_t), MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM);
|
||||
__ASSERT(xBleMeshQueue.buffer, "%s, Failed to create queue buffer", __func__);
|
||||
xBleMeshQueue.storage = heap_caps_calloc(1, (BLE_MESH_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM);
|
||||
__ASSERT(xBleMeshQueue.storage, "%s, Failed to create queue storage", __func__);
|
||||
xBleMeshQueue.queue = xQueueCreateStatic(BLE_MESH_QUEUE_SIZE, sizeof(bt_mesh_msg_t), (uint8_t*)xBleMeshQueue.storage, xBleMeshQueue.buffer);
|
||||
__ASSERT(xBleMeshQueue.queue, "%s, Failed to create static queue", __func__);
|
||||
#endif
|
||||
__ASSERT(adv_queue.buffer, "Failed to create queue buffer");
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||
adv_queue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_ADV_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||
adv_queue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_ADV_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#endif
|
||||
__ASSERT(adv_queue.storage, "Failed to create queue storage");
|
||||
adv_queue.handle = xQueueCreateStatic(BLE_MESH_ADV_QUEUE_SIZE, sizeof(bt_mesh_msg_t), (uint8_t*)adv_queue.storage, adv_queue.buffer);
|
||||
__ASSERT(adv_queue.handle, "Failed to create static queue");
|
||||
#endif /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
relay_queue.handle = xQueueCreate(BLE_MESH_RELAY_QUEUE_SIZE, sizeof(bt_mesh_msg_t));
|
||||
__ASSERT(relay_queue.handle, "Failed to create relay queue");
|
||||
#else /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||
relay_queue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||
relay_queue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#if !CONFIG_SPIRAM_USE_MALLOC
|
||||
xBleMeshRelayQueue.queue = xQueueCreate(BLE_MESH_RELAY_QUEUE_SIZE, sizeof(bt_mesh_msg_t));
|
||||
__ASSERT(xBleMeshRelayQueue.queue, "%s, Failed to create relay queue", __func__);
|
||||
#else
|
||||
xBleMeshRelayQueue.buffer = heap_caps_calloc(1, sizeof(StaticQueue_t), MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM);
|
||||
__ASSERT(xBleMeshRelayQueue.buffer, "%s, Failed to create relay queue buffer", __func__);
|
||||
xBleMeshRelayQueue.storage = heap_caps_calloc(1, (BLE_MESH_RELAY_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM);
|
||||
__ASSERT(xBleMeshRelayQueue.storage, "%s, Failed to create relay queue storage", __func__);
|
||||
xBleMeshRelayQueue.queue = xQueueCreateStatic(BLE_MESH_RELAY_QUEUE_SIZE, sizeof(bt_mesh_msg_t), (uint8_t*)xBleMeshRelayQueue.storage, xBleMeshRelayQueue.buffer);
|
||||
__ASSERT(xBleMeshRelayQueue.queue, "%s, Failed to create static relay queue", __func__);
|
||||
#endif
|
||||
__ASSERT(relay_queue.buffer, "Failed to create relay queue buffer");
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||
relay_queue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_RELAY_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||
relay_queue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_RELAY_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#endif
|
||||
__ASSERT(relay_queue.storage, "Failed to create relay queue storage");
|
||||
relay_queue.handle = xQueueCreateStatic(BLE_MESH_RELAY_QUEUE_SIZE, sizeof(bt_mesh_msg_t), (uint8_t*)relay_queue.storage, relay_queue.buffer);
|
||||
__ASSERT(relay_queue.handle, "Failed to create static relay queue");
|
||||
#endif /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||
|
||||
mesh_queue_set = xQueueCreateSet(BLE_MESH_QUEUE_SET_SIZE);
|
||||
__ASSERT(mesh_queue_set, "Failed to create queue set");
|
||||
xQueueAddToSet(adv_queue.handle, mesh_queue_set);
|
||||
xQueueAddToSet(relay_queue.handle, mesh_queue_set);
|
||||
xBleMeshQueueSet = xQueueCreateSet(BLE_MESH_QUEUE_SET_SIZE);
|
||||
__ASSERT(xBleMeshQueueSet, "%s, Failed to create queue set", __func__);
|
||||
xQueueAddToSet(xBleMeshQueue.queue, xBleMeshQueueSet);
|
||||
xQueueAddToSet(xBleMeshRelayQueue.queue, xBleMeshQueueSet);
|
||||
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
|
||||
#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \
|
||||
CONFIG_SPIRAM_CACHE_WORKAROUND && \
|
||||
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY)
|
||||
#if !CONFIG_SPIRAM_USE_MALLOC
|
||||
int ret = xTaskCreatePinnedToCore(adv_thread, "BLE_Mesh_ADV_Task", BLE_MESH_ADV_TASK_STACK_SIZE, NULL,
|
||||
configMAX_PRIORITIES - 5, &adv_task.handle, BLE_MESH_ADV_TASK_CORE);
|
||||
__ASSERT(ret == pdTRUE, "%s, Failed to create adv thread", __func__);
|
||||
#else
|
||||
adv_task.task = heap_caps_calloc(1, sizeof(StaticTask_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
__ASSERT(adv_task.task, "Failed to create adv thread task");
|
||||
adv_task.stack = heap_caps_calloc_prefer(1, BLE_MESH_ADV_TASK_STACK_SIZE * sizeof(StackType_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
__ASSERT(adv_task.stack, "Failed to create adv thread stack");
|
||||
adv_task.handle = xTaskCreateStaticPinnedToCore(adv_thread, BLE_MESH_ADV_TASK_NAME, BLE_MESH_ADV_TASK_STACK_SIZE, NULL,
|
||||
BLE_MESH_ADV_TASK_PRIO, adv_task.stack, adv_task.task, BLE_MESH_ADV_TASK_CORE);
|
||||
__ASSERT(adv_task.handle, "Failed to create static adv thread");
|
||||
#else /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && CONFIG_SPIRAM_CACHE_WORKAROUND && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY */
|
||||
int ret = xTaskCreatePinnedToCore(adv_thread, BLE_MESH_ADV_TASK_NAME, BLE_MESH_ADV_TASK_STACK_SIZE, NULL,
|
||||
BLE_MESH_ADV_TASK_PRIO, &adv_task.handle, BLE_MESH_ADV_TASK_CORE);
|
||||
__ASSERT(ret == pdTRUE, "Failed to create adv thread");
|
||||
#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && CONFIG_SPIRAM_CACHE_WORKAROUND && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY */
|
||||
__ASSERT(adv_task.task, "%s, Failed to create adv thread task", __func__);
|
||||
#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
adv_task.stack = heap_caps_calloc(1, BLE_MESH_ADV_TASK_STACK_SIZE * sizeof(StackType_t), MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM);
|
||||
#else
|
||||
adv_task.stack = heap_caps_calloc(1, BLE_MESH_ADV_TASK_STACK_SIZE * sizeof(StackType_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#endif
|
||||
__ASSERT(adv_task.stack, "%s, Failed to create adv thread stack", __func__);
|
||||
adv_task.handle = xTaskCreateStaticPinnedToCore(adv_thread, "BLE_Mesh_ADV_Task", BLE_MESH_ADV_TASK_STACK_SIZE, NULL,
|
||||
configMAX_PRIORITIES - 5, adv_task.stack, adv_task.task, BLE_MESH_ADV_TASK_CORE);
|
||||
__ASSERT(adv_task.handle, "%s, Failed to create static adv thread", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
void bt_mesh_adv_deinit(void)
|
||||
{
|
||||
if (adv_queue.handle == NULL) {
|
||||
if (xBleMeshQueue.queue == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
vTaskDelete(adv_task.handle);
|
||||
adv_task.handle = NULL;
|
||||
#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \
|
||||
CONFIG_SPIRAM_CACHE_WORKAROUND && \
|
||||
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY)
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
heap_caps_free(adv_task.stack);
|
||||
adv_task.stack = NULL;
|
||||
heap_caps_free(adv_task.task);
|
||||
|
@ -875,32 +861,32 @@ void bt_mesh_adv_deinit(void)
|
|||
#endif
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
xQueueRemoveFromSet(adv_queue.handle, mesh_queue_set);
|
||||
xQueueRemoveFromSet(relay_queue.handle, mesh_queue_set);
|
||||
xQueueRemoveFromSet(xBleMeshQueue.queue, xBleMeshQueueSet);
|
||||
xQueueRemoveFromSet(xBleMeshRelayQueue.queue, xBleMeshQueueSet);
|
||||
|
||||
vQueueDelete(relay_queue.handle);
|
||||
relay_queue.handle = NULL;
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
heap_caps_free(relay_queue.buffer);
|
||||
relay_queue.buffer = NULL;
|
||||
heap_caps_free(relay_queue.storage);
|
||||
relay_queue.storage = NULL;
|
||||
vQueueDelete(xBleMeshRelayQueue.queue);
|
||||
xBleMeshRelayQueue.queue = NULL;
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
heap_caps_free(xBleMeshRelayQueue.buffer);
|
||||
xBleMeshRelayQueue.buffer = NULL;
|
||||
heap_caps_free(xBleMeshRelayQueue.storage);
|
||||
xBleMeshRelayQueue.storage = NULL;
|
||||
#endif
|
||||
|
||||
bt_mesh_unref_buf_from_pool(&relay_adv_buf_pool);
|
||||
memset(relay_adv_pool, 0, sizeof(relay_adv_pool));
|
||||
|
||||
vQueueDelete(mesh_queue_set);
|
||||
mesh_queue_set = NULL;
|
||||
vQueueDelete(xBleMeshQueueSet);
|
||||
xBleMeshQueueSet = NULL;
|
||||
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
|
||||
vQueueDelete(adv_queue.handle);
|
||||
adv_queue.handle = NULL;
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
heap_caps_free(adv_queue.buffer);
|
||||
adv_queue.buffer = NULL;
|
||||
heap_caps_free(adv_queue.storage);
|
||||
adv_queue.storage = NULL;
|
||||
vQueueDelete(xBleMeshQueue.queue);
|
||||
xBleMeshQueue.queue = NULL;
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
heap_caps_free(xBleMeshQueue.buffer);
|
||||
xBleMeshQueue.buffer = NULL;
|
||||
heap_caps_free(xBleMeshQueue.storage);
|
||||
xBleMeshQueue.storage = NULL;
|
||||
#endif
|
||||
|
||||
bt_mesh_unref_buf_from_pool(&adv_buf_pool);
|
||||
|
@ -973,7 +959,7 @@ int bt_mesh_scan_with_wl_enable(void)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
err = bt_le_scan_start(&scan_param, bt_mesh_scan_cb);
|
||||
if (err && err != -EALREADY) {
|
||||
if (err) {
|
||||
BT_ERR("starting scan failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
@ -1111,17 +1097,17 @@ int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
|||
|
||||
if (param->adv_type != BLE_MESH_ADV_DIRECT_IND &&
|
||||
(param->interval < 0x20 || param->interval > 0x4000)) {
|
||||
BT_ERR("Invalid adv interval 0x%04x", param->interval);
|
||||
BT_ERR("%s, Invalid adv interval 0x%04x", __func__, param->interval);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (param->adv_type > BLE_MESH_ADV_DIRECT_IND_LOW_DUTY) {
|
||||
BT_ERR("Invalid adv type 0x%02x", param->adv_type);
|
||||
BT_ERR("%s, Invalid adv type 0x%02x", __func__, param->adv_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (param->own_addr_type > BLE_MESH_ADDR_RANDOM_ID) {
|
||||
BT_ERR("Invalid own addr type 0x%02x", param->own_addr_type);
|
||||
BT_ERR("%s, Invalid own addr type 0x%02x", __func__, param->own_addr_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1130,29 +1116,29 @@ int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
|||
param->adv_type == BLE_MESH_ADV_DIRECT_IND ||
|
||||
param->adv_type == BLE_MESH_ADV_DIRECT_IND_LOW_DUTY) &&
|
||||
param->peer_addr_type > BLE_MESH_ADDR_RANDOM) {
|
||||
BT_ERR("Invalid peer addr type 0x%02x", param->peer_addr_type);
|
||||
BT_ERR("%s, Invalid peer addr type 0x%02x", __func__, param->peer_addr_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (data && (data->adv_data_len > 31 || data->scan_rsp_data_len > 31)) {
|
||||
BT_ERR("Invalid adv data length (adv %d, scan rsp %d)",
|
||||
BT_ERR("%s, Invalid adv data length, %d %d", __func__,
|
||||
data->adv_data_len, data->scan_rsp_data_len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (param->priority > BLE_MESH_BLE_ADV_PRIO_HIGH) {
|
||||
BT_ERR("Invalid adv priority %d", param->priority);
|
||||
BT_ERR("%s, Invalid adv priority %d", __func__, param->priority);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (param->duration < ADV_SCAN_INT(param->interval)) {
|
||||
BT_ERR("Too small duration %dms", param->duration);
|
||||
BT_ERR("%s, Too small duration %dms", __func__, param->duration);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf = bt_mesh_ble_adv_create(BLE_MESH_ADV_BLE, 0U, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("Unable to allocate buffer");
|
||||
BT_ERR("%s, Unable to allocate buffer", __func__);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -1202,14 +1188,14 @@ int bt_mesh_stop_ble_advertising(u8_t index)
|
|||
bool unref = true;
|
||||
|
||||
if (index >= ARRAY_SIZE(ble_adv_tx)) {
|
||||
BT_ERR("Invalid adv index %d", index);
|
||||
BT_ERR("%s, Invalid index %d", __func__, index);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tx = &ble_adv_tx[index];
|
||||
|
||||
if (tx->buf == NULL) {
|
||||
BT_WARN("Already stopped, index %d", index);
|
||||
BT_WARN("%s, Already stopped, index %d", __func__, index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool);
|
|||
void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data);
|
||||
|
||||
const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void);
|
||||
const bt_mesh_addr_t *bt_mesh_pba_get_addr(void);
|
||||
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit,
|
||||
s32_t timeout);
|
||||
|
|
|
@ -177,7 +177,7 @@ static int secure_beacon_send(void)
|
|||
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, PROV_XMIT,
|
||||
K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("Out of beacon buffer");
|
||||
BT_ERR("%s, Unable to allocate beacon buffer", __func__);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ static int unprovisioned_beacon_send(void)
|
|||
|
||||
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, UNPROV_XMIT, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("Out of beacon buffer");
|
||||
BT_ERR("%s, Unable to allocate beacon buffer", __func__);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
|
|||
u8_t flags = 0U;
|
||||
|
||||
if (buf->len < 21) {
|
||||
BT_ERR("Too short secure beacon (len %u)", buf->len);
|
||||
BT_ERR("%s, Too short secure beacon (len %u)", __func__, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -420,7 +420,7 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf, s8_t rssi)
|
|||
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
if (buf->len < 1) {
|
||||
BT_ERR("Too short beacon");
|
||||
BT_ERR("%s, Too short beacon", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -259,8 +259,7 @@ static bool valid_scan_param(const struct bt_mesh_scan_param *param)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window,
|
||||
u8_t filter_dup, u8_t scan_fil_policy)
|
||||
static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window, u8_t filter_dup, u8_t scan_fil_policy)
|
||||
{
|
||||
UINT8 addr_type_own = BLE_MESH_ADDR_PUBLIC; /* Currently only support Public Address */
|
||||
tGATT_IF client_if = 0xFF; /* Default GATT interface id */
|
||||
|
@ -289,7 +288,7 @@ static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARC
|
|||
u8_t adv_type = 0U;
|
||||
s8_t rssi = 0;
|
||||
|
||||
BT_DBG("%s, event %d", __func__, event);
|
||||
BT_DBG("%s, event = %d", __func__, event);
|
||||
|
||||
if (event == BTA_DM_INQ_RES_EVT) {
|
||||
/* TODO: How to process scan response here? */
|
||||
|
@ -301,7 +300,7 @@ static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARC
|
|||
/* scan rsp len: p_data->inq_res.scan_rsp_len */
|
||||
struct net_buf_simple *buf = bt_mesh_alloc_buf(p_data->inq_res.adv_data_len);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(buf, p_data->inq_res.p_eir, p_data->inq_res.adv_data_len);
|
||||
|
@ -311,9 +310,9 @@ static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARC
|
|||
}
|
||||
bt_mesh_free(buf);
|
||||
} else if (event == BTA_DM_INQ_CMPL_EVT) {
|
||||
BT_INFO("Scan completed, number of scan response %d", p_data->inq_cmpl.num_resps);
|
||||
BT_INFO("%s, Scan completed, number of scan response %d", __func__, p_data->inq_cmpl.num_resps);
|
||||
} else {
|
||||
BT_WARN("Unexpected scan result event %d", event);
|
||||
BT_WARN("%s, Unexpected event 0x%x", __func__, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,13 +336,13 @@ int bt_le_adv_start(const struct bt_mesh_adv_param *param,
|
|||
#endif
|
||||
|
||||
if (!valid_adv_param(param)) {
|
||||
BT_ERR("Invalid adv parameters");
|
||||
BT_ERR("%s, Invalid adv parameters", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = set_adv_data(BLE_MESH_HCI_OP_SET_ADV_DATA, ad, ad_len);
|
||||
if (err) {
|
||||
BT_ERR("Failed to set adv data");
|
||||
BT_ERR("%s, Failed to set adv data", __func__);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -359,7 +358,7 @@ int bt_le_adv_start(const struct bt_mesh_adv_param *param,
|
|||
if (sd && (param->options & BLE_MESH_ADV_OPT_CONNECTABLE)) {
|
||||
err = set_adv_data(BLE_MESH_HCI_OP_SET_SCAN_RSP_DATA, sd, sd_len);
|
||||
if (err) {
|
||||
BT_ERR("Failed to set scan rsp data");
|
||||
BT_ERR("%s, Failed to set scan rsp data", __func__);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
@ -460,10 +459,11 @@ int bt_le_scan_start(const struct bt_mesh_scan_param *param, bt_mesh_scan_cb_t c
|
|||
{
|
||||
int err = 0;
|
||||
|
||||
#if BLE_MESH_DEV
|
||||
if (bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) {
|
||||
BT_INFO("Scan is already started");
|
||||
return -EALREADY;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!valid_scan_param(param)) {
|
||||
return -EINVAL;
|
||||
|
@ -477,30 +477,31 @@ int bt_le_scan_start(const struct bt_mesh_scan_param *param, bt_mesh_scan_cb_t c
|
|||
}
|
||||
#endif
|
||||
|
||||
err = start_le_scan(param->type, param->interval, param->window,
|
||||
param->filter_dup, param->scan_fil_policy);
|
||||
err = start_le_scan(param->type, param->interval, param->window, param->filter_dup, param->scan_fil_policy);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
#if BLE_MESH_DEV
|
||||
bt_mesh_atomic_set_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING);
|
||||
bt_mesh_scan_dev_found_cb = cb;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
bt_mesh_scan_dev_found_cb = cb;
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_le_scan_stop(void)
|
||||
{
|
||||
if (!bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) {
|
||||
BT_INFO("Scan is already stopped");
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
BLE_MESH_BTM_CHECK_STATUS(BTM_BleScan(false, 0, NULL, NULL, NULL));
|
||||
|
||||
#if BLE_MESH_DEV
|
||||
if (bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) {
|
||||
bt_mesh_atomic_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING);
|
||||
bt_mesh_scan_dev_found_cb = NULL;
|
||||
BLE_MESH_BTM_CHECK_STATUS(BTM_BleScan(false, 0, NULL, NULL, NULL));
|
||||
}
|
||||
#else
|
||||
BLE_MESH_BTM_CHECK_STATUS(BTM_BleScan(false, 0, NULL, NULL, NULL));
|
||||
#endif
|
||||
|
||||
bt_mesh_scan_dev_found_cb = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -538,7 +539,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
u8_t buf[100] = {0};
|
||||
u16_t len = 0;
|
||||
|
||||
BT_DBG("gatts read, handle %d", p_data->req_data.p_data->read_req.handle);
|
||||
BT_DBG("%s, read: handle = %d", __func__, p_data->req_data.p_data->read_req.handle);
|
||||
|
||||
if (attr != NULL && attr->read != NULL) {
|
||||
if ((len = attr->read(&bt_mesh_gatts_conn[index], attr, buf, 100,
|
||||
|
@ -548,9 +549,9 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
memcpy(&rsp.attr_value.value[0], buf, len);
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, &rsp);
|
||||
BT_DBG("Send gatts read rsp, handle %d", attr->handle);
|
||||
BT_DBG("%s, Send gatts read response, handle = %x", __func__, attr->handle);
|
||||
} else {
|
||||
BT_WARN("Mesh gatts read failed");
|
||||
BT_WARN("%s, BLE Mesh gatts read failed", __func__);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -560,7 +561,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id);
|
||||
u16_t len = 0;
|
||||
|
||||
BT_DBG("gatts write, handle %d, len %d, data %s", p_data->req_data.p_data->write_req.handle,
|
||||
BT_DBG("%s, write: handle = %d, len = %d, data = %s", __func__, p_data->req_data.p_data->write_req.handle,
|
||||
p_data->req_data.p_data->write_req.len,
|
||||
bt_hex(p_data->req_data.p_data->write_req.value, p_data->req_data.p_data->write_req.len));
|
||||
|
||||
|
@ -572,7 +573,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
if (p_data->req_data.p_data->write_req.need_rsp) {
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, NULL);
|
||||
BT_DBG("Send gatts write rsp, handle %d", attr->handle);
|
||||
BT_DBG("%s, send mesh write rsp, handle = %x", __func__, attr->handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -586,7 +587,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||
break;
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
svc_handle = p_data->create.service_id;
|
||||
BT_DBG("svc_handle %d, future_mesh %p", svc_handle, future_mesh);
|
||||
BT_DBG("%s, svc_handle = %d, future_mesh = %p", __func__, svc_handle, future_mesh);
|
||||
if (future_mesh != NULL) {
|
||||
future_ready(future_mesh, FUTURE_SUCCESS);
|
||||
}
|
||||
|
@ -727,8 +728,7 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_attr_next(const struct bt_mesh_ga
|
|||
return next;
|
||||
}
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t buf_len, u16_t offset,
|
||||
const void *value, u16_t value_len)
|
||||
{
|
||||
|
@ -804,8 +804,8 @@ struct gatts_chrc {
|
|||
} __packed;
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset)
|
||||
const struct bt_mesh_gatt_attr *attr, void *buf,
|
||||
u16_t len, u16_t offset)
|
||||
{
|
||||
struct bt_mesh_gatt_char *chrc = attr->user_data;
|
||||
const struct bt_mesh_gatt_attr *next = NULL;
|
||||
|
@ -822,7 +822,7 @@ ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
|||
*/
|
||||
next = bt_mesh_gatts_attr_next(attr);
|
||||
if (!next) {
|
||||
BT_WARN("No value for characteristic, handle 0x%04x", attr->handle);
|
||||
BT_WARN("%s, No value for characteristic at 0x%04x", __func__, attr->handle);
|
||||
pdu.value_handle = 0x0000;
|
||||
} else {
|
||||
pdu.value_handle = sys_cpu_to_le16(next->handle);
|
||||
|
@ -854,7 +854,7 @@ static void bta_uuid_to_bt_mesh_uuid(tBT_UUID *bta_uuid, const struct bt_mesh_uu
|
|||
bta_uuid->len = LEN_UUID_128;
|
||||
memcpy(bta_uuid->uu.uuid128, BLE_MESH_UUID_128(uuid)->val, LEN_UUID_128);
|
||||
} else {
|
||||
BT_ERR("Invalid mesh uuid type %d", uuid->type);
|
||||
BT_ERR("%s, Invalid mesh uuid type = %d", __func__, uuid->type);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -872,7 +872,7 @@ static int gatts_register(struct bt_mesh_gatt_service *svc)
|
|||
|
||||
last = SYS_SLIST_PEEK_TAIL_CONTAINER(&bt_mesh_gatts_db, last, node);
|
||||
handle = last->attrs[last->attr_count - 1].handle;
|
||||
BT_DBG("gatts register, handle %d", handle);
|
||||
BT_DBG("%s, handle = %d", __func__, handle);
|
||||
|
||||
((void) handle);
|
||||
|
||||
|
@ -937,12 +937,11 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
|||
BTA_GATTS_CreateService(bt_mesh_gatts_if,
|
||||
&bta_uuid, 0, svc->attr_count, true);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("Failed to add primary service");
|
||||
BT_ERR("%s, Failed to add primary service", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
svc->attrs[i].handle = svc_handle;
|
||||
BT_DBG("Add primary service, uuid 0x%04x, perm %d, handle %d",
|
||||
bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle);
|
||||
BT_DBG("Add primary service: svc_uuid = %x, perm = %d, svc_handle = %d", bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle);
|
||||
break;
|
||||
}
|
||||
case BLE_MESH_UUID_GATT_SECONDARY_VAL: {
|
||||
|
@ -951,12 +950,11 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
|||
BTA_GATTS_CreateService(bt_mesh_gatts_if,
|
||||
&bta_uuid, 0, svc->attr_count, false);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("Failed to add secondary service");
|
||||
BT_ERR("%s, Failed to add secondary service", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
svc->attrs[i].handle = svc_handle;
|
||||
BT_DBG("Add secondary service, uuid 0x%04x, perm %d, handle %d",
|
||||
bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle);
|
||||
BT_DBG("Add secondary service: svc_uuid = %x, perm = %d, svc_handle = %d", bta_uuid.uu.uuid16, svc->attrs[i].perm, svc_handle);
|
||||
break;
|
||||
}
|
||||
case BLE_MESH_UUID_GATT_INCLUDE_VAL: {
|
||||
|
@ -968,14 +966,13 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
|||
bta_uuid_to_bt_mesh_uuid(&bta_uuid, gatts_chrc->uuid);
|
||||
BTA_GATTS_AddCharacteristic(svc_handle, &bta_uuid, bt_mesh_perm_to_bta_perm(svc->attrs[i + 1].perm), gatts_chrc->properties, NULL, NULL);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("Failed to add characteristic");
|
||||
BT_ERR("%s, Failed to add characteristic", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
/* All the characteristic should have two handles: the declaration handle and the value handle */
|
||||
svc->attrs[i].handle = char_handle - 1;
|
||||
svc->attrs[i + 1].handle = char_handle;
|
||||
BT_DBG("Add characteristic, uuid 0x%04x, handle %d, perm %d, properties %d",
|
||||
BLE_MESH_UUID_16(gatts_chrc->uuid)->val, char_handle, svc->attrs[i + 1].perm, gatts_chrc->properties);
|
||||
BT_DBG("Add characteristic: char_uuid = %x, char_handle = %d, perm = %d, char_pro = %d", BLE_MESH_UUID_16(gatts_chrc->uuid)->val, char_handle, svc->attrs[i + 1].perm, gatts_chrc->properties);
|
||||
break;
|
||||
}
|
||||
case BLE_MESH_UUID_GATT_CEP_VAL:
|
||||
|
@ -993,12 +990,11 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
|||
bta_uuid_to_bt_mesh_uuid(&bta_uuid, svc->attrs[i].uuid);
|
||||
BTA_GATTS_AddCharDescriptor(svc_handle, bt_mesh_perm_to_bta_perm(svc->attrs[i].perm), &bta_uuid, NULL, NULL);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("Failed to add descriptor");
|
||||
BT_ERR("%s, Failed to add descriptor", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
svc->attrs[i].handle = char_handle;
|
||||
BT_DBG("Add descriptor, uuid 0x%04x, perm %d, handle %d",
|
||||
BLE_MESH_UUID_16(svc->attrs[i].uuid)->val, svc->attrs[i].perm, char_handle);
|
||||
BT_DBG("Add descriptor: descr_uuid = %x, perm= %d, descr_handle = %d", BLE_MESH_UUID_16(svc->attrs[i].uuid)->val, svc->attrs[i].perm, char_handle);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1042,8 +1038,7 @@ int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
const void *data, u16_t len)
|
||||
{
|
||||
u16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle);
|
||||
|
@ -1091,7 +1086,7 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
|
|||
uuid = (struct bt_mesh_uuid *)svc->attrs[0].user_data;
|
||||
if (uuid && uuid->type == BLE_MESH_UUID_TYPE_16) {
|
||||
uuid_16 = (struct bt_mesh_uuid_16 *)uuid;
|
||||
BT_DBG("service start, type 0x%02x, val 0x%04x", uuid_16->uuid.type, uuid_16->val);
|
||||
BT_DBG("%s, type 0x%02x, val 0x%04x", __func__, uuid_16->uuid.type, uuid_16->val);
|
||||
if (uuid_16->val == BLE_MESH_UUID_MESH_PROXY_VAL) {
|
||||
BTA_GATTS_SendServiceChangeIndication(bt_mesh_gatts_if, bt_mesh_gatts_addr);
|
||||
}
|
||||
|
@ -1146,7 +1141,7 @@ u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn)
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
BT_ERR("%s, Conn is not found", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1167,21 +1162,21 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
|||
|
||||
if (!addr || !memcmp(addr->val, zero, BLE_MESH_ADDR_LEN) ||
|
||||
(addr->type > BLE_ADDR_RANDOM)) {
|
||||
BT_ERR("Invalid remote address");
|
||||
BT_ERR("%s, Invalid remote address", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (service_uuid != BLE_MESH_UUID_MESH_PROV_VAL &&
|
||||
service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) {
|
||||
BT_ERR("Invalid service uuid 0x%04x", service_uuid);
|
||||
BT_ERR("%s, Invalid service uuid 0x%04x", __func__, service_uuid);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Check if already creating connection with the device */
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
if (!memcmp(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN)) {
|
||||
BT_WARN("Already create connection with %s",
|
||||
bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
BT_WARN("%s, Already create connection with %s",
|
||||
__func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
return -EALREADY;
|
||||
}
|
||||
}
|
||||
|
@ -1199,16 +1194,19 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
|||
}
|
||||
|
||||
if (i == ARRAY_SIZE(bt_mesh_gattc_info)) {
|
||||
BT_WARN("gattc info is full");
|
||||
BT_WARN("%s, gattc info is full", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) {
|
||||
#if BLE_MESH_DEV
|
||||
if (bt_mesh_atomic_test_and_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) {
|
||||
BLE_MESH_BTM_CHECK_STATUS(BTM_BleScan(false, 0, NULL, NULL, NULL));
|
||||
bt_mesh_atomic_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING);
|
||||
}
|
||||
#else
|
||||
BLE_MESH_BTM_CHECK_STATUS(BTM_BleScan(false, 0, NULL, NULL, NULL));
|
||||
#endif /* BLE_MESH_DEV */
|
||||
|
||||
BT_DBG("Create conn with %s", bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
BT_DBG("%s, create conn with %s", __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
|
||||
/* Min_interval: 250ms
|
||||
* Max_interval: 250ms
|
||||
|
@ -1249,8 +1247,7 @@ u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr,
|
||||
const void *data, u16_t len)
|
||||
{
|
||||
u16_t conn_id = 0U;
|
||||
|
@ -1266,7 +1263,7 @@ int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn,
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
BT_ERR("%s, Conn is not found", __func__);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
|
@ -1291,7 +1288,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
|
|||
}
|
||||
}
|
||||
|
||||
BT_ERR("Conn %p not found", conn);
|
||||
BT_ERR("%s, Conn is not found", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1376,7 +1373,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
}
|
||||
|
||||
if (conn == NULL) {
|
||||
BT_ERR("Conn handle 0x%04x not found", handle);
|
||||
BT_ERR("%s, Conn handle is not found", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1516,12 +1513,12 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
}
|
||||
|
||||
if (conn == NULL) {
|
||||
BT_ERR("Conn handle 0x%04x not found", handle);
|
||||
BT_ERR("%s, Conn handle is not found", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bt_mesh_gattc_info[i].ccc_handle != p_data->write.handle) {
|
||||
BT_WARN("gattc ccc_handle not matched");
|
||||
BT_WARN("%s, gattc ccc_handle is not matched", __func__);
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1530,7 +1527,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->prov_write_descr != NULL) {
|
||||
len = bt_mesh_gattc_conn_cb->prov_write_descr(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn);
|
||||
if (len < 0) {
|
||||
BT_ERR("prov_write_descr failed");
|
||||
BT_ERR("%s, prov_write_descr failed", __func__);
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1540,7 +1537,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->proxy_write_descr != NULL) {
|
||||
len = bt_mesh_gattc_conn_cb->proxy_write_descr(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn);
|
||||
if (len < 0) {
|
||||
BT_ERR("proxy_write_descr failed");
|
||||
BT_ERR("%s, proxy_write_descr failed", __func__);
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1568,14 +1565,14 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
}
|
||||
|
||||
if (conn == NULL) {
|
||||
BT_ERR("Conn handle 0x%04x not found", handle);
|
||||
BT_ERR("%s, Conn handle is not found", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (memcmp(bt_mesh_gattc_info[i].addr.val, p_data->notify.bda, BLE_MESH_ADDR_LEN) ||
|
||||
bt_mesh_gattc_info[i].data_out_handle != p_data->notify.handle ||
|
||||
p_data->notify.is_notify == false) {
|
||||
BT_ERR("Notification error");
|
||||
BT_ERR("%s, Notification error", __func__);
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1585,7 +1582,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
len = bt_mesh_gattc_conn_cb->prov_notify(&bt_mesh_gattc_info[i].conn,
|
||||
p_data->notify.value, p_data->notify.len);
|
||||
if (len < 0) {
|
||||
BT_ERR("prov_notify failed");
|
||||
BT_ERR("%s, prov_notify failed", __func__);
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1595,7 +1592,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
len = bt_mesh_gattc_conn_cb->proxy_notify(&bt_mesh_gattc_info[i].conn,
|
||||
p_data->notify.value, p_data->notify.len);
|
||||
if (len < 0) {
|
||||
BT_ERR("proxy_notify failed");
|
||||
BT_ERR("%s, proxy_notify failed", __func__);
|
||||
bt_mesh_gattc_disconnect(conn);
|
||||
return;
|
||||
}
|
||||
|
@ -1611,20 +1608,30 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
break;
|
||||
case BTA_GATTC_EXEC_EVT:
|
||||
break;
|
||||
case BTA_GATTC_OPEN_EVT:
|
||||
case BTA_GATTC_OPEN_EVT: {
|
||||
BT_DBG("BTA_GATTC_OPEN_EVT");
|
||||
/* After current connection is established, Provisioner can
|
||||
* use BTM_BleScan() to re-enable scan.
|
||||
/** After current connection is established, provisioner can
|
||||
* use BTA_DmBleScan() to re-enable scan.
|
||||
*/
|
||||
tBTM_STATUS status;
|
||||
#if BLE_MESH_DEV
|
||||
if (!bt_mesh_atomic_test_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING)) {
|
||||
tBTM_STATUS status = BTM_BleScan(true, 0, bt_mesh_scan_results_cb, NULL, NULL);
|
||||
status = BTM_BleScan(true, 0, bt_mesh_scan_results_cb, NULL, NULL);
|
||||
if (status != BTM_SUCCESS && status != BTM_CMD_STARTED) {
|
||||
BT_ERR("Invalid scan status %d", status);
|
||||
BT_ERR("%s, Invalid status %d", __func__, status);
|
||||
break;
|
||||
}
|
||||
bt_mesh_atomic_set_bit(bt_mesh_dev.flags, BLE_MESH_DEV_SCANNING);
|
||||
}
|
||||
#else
|
||||
status = BTM_BleScan(true, 0, bt_mesh_scan_results_cb, NULL, NULL);
|
||||
if (status != BTM_SUCCESS && status != BTM_CMD_STARTED) {
|
||||
BT_ERR("%s, Invalid status %d", __func__, status);
|
||||
break;
|
||||
}
|
||||
#endif /* BLE_MESH_DEV */
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_CLOSE_EVT:
|
||||
BT_DBG("BTA_GATTC_CLOSE_EVT");
|
||||
break;
|
||||
|
@ -1632,7 +1639,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
BT_DBG("BTA_GATTC_CONNECT_EVT");
|
||||
|
||||
if (bt_mesh_gattc_if != p_data->connect.client_if) {
|
||||
BT_ERR("gattc_if & connect_if mismatch");
|
||||
BT_ERR("%s, gattc_if & connect_if don't match", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1651,7 +1658,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
|||
BT_DBG("BTA_GATTC_DISCONNECT_EVT");
|
||||
|
||||
if (bt_mesh_gattc_if != p_data->disconnect.client_if) {
|
||||
BT_ERR("gattc_if & disconnect_if mismatch");
|
||||
BT_ERR("%s, gattc_if & disconnect_if don't match", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1810,7 +1817,7 @@ int bt_mesh_rand(void *buf, size_t len)
|
|||
memcpy(buf + i * sizeof(u32_t), &rand, sizeof(u32_t));
|
||||
}
|
||||
|
||||
BT_DBG("Rand %s", bt_hex(buf, len));
|
||||
BT_DBG("%s, rand: %s", __func__, bt_hex(buf, len));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2012,13 +2019,13 @@ int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info)
|
|||
|
||||
if (type == BLE_MESH_EXCEP_INFO_MESH_LINK_ID) {
|
||||
if (!info) {
|
||||
BT_ERR("Invalid Provisioning Link ID");
|
||||
BT_ERR("%s, NULL Provisioning Link ID", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
sys_memcpy_swap(value, info, sizeof(u32_t));
|
||||
}
|
||||
|
||||
BT_DBG("%s exceptional list, type 0x%02x", sub_code ? "Remove" : "Add", type);
|
||||
BT_DBG("%s, %s type 0x%x", __func__, sub_code ? "Remove" : "Add", type);
|
||||
|
||||
/* The parameter "device_info" can't be NULL in the API */
|
||||
BLE_MESH_BTM_CHECK_STATUS(BTM_UpdateBleDuplicateExceptionalList(sub_code, type, value, NULL));
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -50,7 +50,7 @@ static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem,
|
|||
|
||||
if (net_buf_simple_tailroom(buf) <
|
||||
4 + (elem->model_count * 2U) + (elem->vnd_model_count * 4U)) {
|
||||
BT_ERR("Too large device composition");
|
||||
BT_ERR("%s, Too large device composition", __func__);
|
||||
return -E2BIG;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ static void dev_comp_data_get(struct bt_mesh_model *model,
|
|||
|
||||
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, COMP_DATA_MAX_LEN));
|
||||
if (!sdu) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -142,13 +142,13 @@ static void dev_comp_data_get(struct bt_mesh_model *model,
|
|||
|
||||
net_buf_simple_add_u8(sdu, page);
|
||||
if (comp_get_page_0(sdu) < 0) {
|
||||
BT_ERR("Unable to get composition page 0");
|
||||
BT_ERR("%s, Unable to get composition page 0", __func__);
|
||||
bt_mesh_free_buf(sdu);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, sdu, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Composition Data Status");
|
||||
BT_ERR("%s, Unable to send Config Composition Data Status", __func__);
|
||||
}
|
||||
|
||||
bt_mesh_free_buf(sdu);
|
||||
|
@ -457,7 +457,7 @@ static void app_key_add(struct bt_mesh_model *model,
|
|||
key_idx_pack(&msg, key_net_idx, key_app_idx);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config AppKey Status");
|
||||
BT_ERR("%s, Unable to send Config AppKey Status", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -492,7 +492,7 @@ static void app_key_update(struct bt_mesh_model *model,
|
|||
key_idx_pack(&msg, key_net_idx, key_app_idx);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config AppKey Status");
|
||||
BT_ERR("%s, Unable to send Config AppKey Status", __func__);
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
|
@ -577,7 +577,7 @@ send_status:
|
|||
key_idx_pack(&msg, key_net_idx, key_app_idx);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config AppKey Status");
|
||||
BT_ERR("%s, Unable to send Config AppKey Status", __func__);
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
|
@ -603,7 +603,7 @@ static void app_key_get(struct bt_mesh_model *model,
|
|||
|
||||
get_idx = net_buf_simple_pull_le16(buf);
|
||||
if (get_idx > 0xfff) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", get_idx);
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, get_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -647,7 +647,7 @@ static void app_key_get(struct bt_mesh_model *model,
|
|||
|
||||
send_status:
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config AppKey List");
|
||||
BT_ERR("%s, Unable to send Config AppKey List", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -665,7 +665,7 @@ static void beacon_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_beacon_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Beacon Status");
|
||||
BT_ERR("%s, Unable to send Config Beacon Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -705,7 +705,7 @@ static void beacon_set(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_beacon_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Beacon Status");
|
||||
BT_ERR("%s, Unable to send Config Beacon Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -723,7 +723,7 @@ static void default_ttl_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_default_ttl_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Default TTL Status");
|
||||
BT_ERR("%s, Unable to send Config Default TTL Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -757,7 +757,7 @@ static void default_ttl_set(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_default_ttl_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Default TTL Status");
|
||||
BT_ERR("%s, Unable to send Config Default TTL Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -770,7 +770,7 @@ static void send_gatt_proxy_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_gatt_proxy_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config GATT Proxy Status");
|
||||
BT_ERR("%s, Unable to send Config GATT Proxy Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -844,7 +844,7 @@ static void net_transmit_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_net_transmit_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Network Transmit Status");
|
||||
BT_ERR("%s, Unable to send Config Network Transmit Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -877,7 +877,7 @@ static void net_transmit_set(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_net_transmit_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Network Transmit Status");
|
||||
BT_ERR("%s, Unable to send Config Network Transmit Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -896,7 +896,7 @@ static void relay_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_relay_retransmit_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Relay Status");
|
||||
BT_ERR("%s, Unable to send Config Relay Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -947,7 +947,7 @@ static void relay_set(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, bt_mesh_relay_retransmit_get());
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Relay Status");
|
||||
BT_ERR("%s, Unable to send Config Relay Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -985,7 +985,7 @@ static void send_mod_pub_status(struct bt_mesh_model *cfg_mod,
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(cfg_mod, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Model Publication Status");
|
||||
BT_ERR("%s, Unable to send Config Model Publication Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1001,7 +1001,7 @@ static void mod_pub_get(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1049,7 +1049,7 @@ static void mod_pub_set(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1060,7 @@ static void mod_pub_set(struct bt_mesh_model *model,
|
|||
|
||||
pub_ttl = net_buf_simple_pull_u8(buf);
|
||||
if (pub_ttl > BLE_MESH_TTL_MAX && pub_ttl != BLE_MESH_TTL_DEFAULT) {
|
||||
BT_ERR("Invalid TTL value 0x%02x", pub_ttl);
|
||||
BT_ERR("%s, Invalid TTL value 0x%02x", __func__, pub_ttl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1232,7 @@ static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
|
|||
if (label_uuid) {
|
||||
va_del(label_uuid, NULL);
|
||||
} else {
|
||||
BT_ERR("Label UUID not found");
|
||||
BT_ERR("%s, Label UUID not found", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1253,7 +1253,7 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1263,7 +1263,7 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
|||
pub_app_idx &= BIT_MASK(12);
|
||||
pub_ttl = net_buf_simple_pull_u8(buf);
|
||||
if (pub_ttl > BLE_MESH_TTL_MAX && pub_ttl != BLE_MESH_TTL_DEFAULT) {
|
||||
BT_ERR("Invalid TTL value 0x%02x", pub_ttl);
|
||||
BT_ERR("%s, Invalid TTL value 0x%02x", __func__, pub_ttl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1333,7 +1333,7 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ static void send_mod_sub_status(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Model Subscription Status");
|
||||
BT_ERR("%s, Unable to send Config Model Subscription Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1411,7 +1411,7 @@ static void mod_sub_add(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1497,7 +1497,7 @@ static void mod_sub_del(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1572,7 +1572,7 @@ static void mod_sub_overwrite(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1641,7 +1641,7 @@ static void mod_sub_del_all(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1693,7 +1693,7 @@ static void mod_sub_get(struct bt_mesh_model *model,
|
|||
|
||||
addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1732,7 +1732,7 @@ static void mod_sub_get(struct bt_mesh_model *model,
|
|||
|
||||
send_list:
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Model Subscription List");
|
||||
BT_ERR("%s, Unable to send Config Model Subscription List", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1749,7 +1749,7 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model,
|
|||
|
||||
addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1792,7 +1792,7 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model,
|
|||
|
||||
send_list:
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Vendor Model Subscription List");
|
||||
BT_ERR("%s, Unable to send Config Vendor Model Subscription List", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1812,7 +1812,7 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1889,7 +1889,7 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1956,7 +1956,7 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2021,7 +2021,7 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2062,7 +2062,7 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2101,7 +2101,7 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2141,7 +2141,7 @@ static void send_net_key_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_le16(&msg, idx);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config NetKey Status");
|
||||
BT_ERR("%s, Unable to send Config NetKey Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2155,7 +2155,7 @@ static void net_key_add(struct bt_mesh_model *model,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2211,7 +2211,7 @@ static void net_key_add(struct bt_mesh_model *model,
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_STOPPED;
|
||||
bt_mesh_proxy_server_beacon_send(sub);
|
||||
bt_mesh_proxy_beacon_send(sub);
|
||||
bt_mesh_adv_update();
|
||||
} else {
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
|
||||
|
@ -2236,7 +2236,7 @@ static void net_key_update(struct bt_mesh_model *model,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2323,7 +2323,7 @@ static void net_key_del(struct bt_mesh_model *model,
|
|||
|
||||
del_idx = net_buf_simple_pull_le16(buf);
|
||||
if (del_idx > 0xfff) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", del_idx);
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, del_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2392,7 +2392,7 @@ static void net_key_get(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config NetKey List");
|
||||
BT_ERR("%s, Unable to send Config NetKey List", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2411,7 +2411,7 @@ static void node_identity_get(struct bt_mesh_model *model,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2430,7 +2430,7 @@ static void node_identity_get(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, node_id);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Node Identity Status");
|
||||
BT_ERR("%s, Unable to send Config Node Identity Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2449,13 +2449,13 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_WARN("Invalid NetKeyIndex 0x%04x", idx);
|
||||
BT_WARN("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
node_id = net_buf_simple_pull_u8(buf);
|
||||
if (node_id != 0x00 && node_id != 0x01) {
|
||||
BT_WARN("Invalid Node ID value 0x%02x", node_id);
|
||||
BT_WARN("%s, Invalid Node ID value 0x%02x", __func__, node_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2472,9 +2472,9 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
if (node_id) {
|
||||
bt_mesh_proxy_server_identity_start(sub);
|
||||
bt_mesh_proxy_identity_start(sub);
|
||||
} else {
|
||||
bt_mesh_proxy_server_identity_stop(sub);
|
||||
bt_mesh_proxy_identity_stop(sub);
|
||||
}
|
||||
bt_mesh_adv_update();
|
||||
}
|
||||
|
@ -2482,7 +2482,7 @@ static void node_identity_set(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Node Identity Status");
|
||||
BT_ERR("%s, Unable to send Config Node Identity Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2517,7 +2517,7 @@ static void mod_app_bind(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2540,7 +2540,7 @@ static void mod_app_bind(struct bt_mesh_model *model,
|
|||
|
||||
/* Configuration Server only allows device key based access */
|
||||
if (model == mod) {
|
||||
BT_ERR("Client tried to bind AppKey to Configuration Model");
|
||||
BT_ERR("%s, Client tried to bind AppKey to Configuration Model", __func__);
|
||||
status = STATUS_CANNOT_BIND;
|
||||
goto send_status;
|
||||
}
|
||||
|
@ -2553,7 +2553,7 @@ send_status:
|
|||
mod_id);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Model App Bind Status");
|
||||
BT_ERR("%s, Unable to send Config Model App Bind Status", __func__);
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
|
@ -2580,7 +2580,7 @@ static void mod_app_unbind(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2609,7 +2609,7 @@ send_status:
|
|||
mod_id);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Model App Unbind Status");
|
||||
BT_ERR("%s, Unable to send Config Model App Unbind Status", __func__);
|
||||
}
|
||||
|
||||
if (status == STATUS_SUCCESS) {
|
||||
|
@ -2642,7 +2642,7 @@ static void mod_app_get(struct bt_mesh_model *model,
|
|||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(elem_addr)) {
|
||||
BT_ERR("Prohibited element address 0x%04x", elem_addr);
|
||||
BT_ERR("%s, Prohibited element address 0x%04x", __func__, elem_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2693,7 +2693,7 @@ send_list:
|
|||
}
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Model Application List");
|
||||
BT_ERR("%s, Unable to send Config Model Application List", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2714,7 +2714,7 @@ static void node_reset(struct bt_mesh_model *model,
|
|||
* send it later.
|
||||
*/
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Node Reset Status");
|
||||
BT_ERR("%s, Unable to send Config Node Reset Status", __func__);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE)) {
|
||||
|
@ -2732,7 +2732,7 @@ static void send_friend_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, cfg->frnd);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Friend Status");
|
||||
BT_ERR("%s, Unable to send Config Friend Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2832,7 +2832,7 @@ send_rsp:
|
|||
net_buf_simple_add_le24(&msg, timeout);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config LPN PollTimeout Status");
|
||||
BT_ERR("%s, Unable to send Config LPN PollTimeout Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2849,7 +2849,7 @@ static void send_krp_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, phase);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Key Refresh Phase Status");
|
||||
BT_ERR("%s, Unable to send Config Key Refresh Phase Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2861,7 +2861,7 @@ static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2887,7 +2887,7 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
phase = net_buf_simple_pull_u8(buf);
|
||||
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2904,7 +2904,7 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
if (phase < BLE_MESH_KR_PHASE_2 || phase > BLE_MESH_KR_PHASE_3 ||
|
||||
(sub->kr_phase == BLE_MESH_KR_NORMAL &&
|
||||
phase == BLE_MESH_KR_PHASE_2)) {
|
||||
BT_WARN("Prohibited transition %u -> %u", sub->kr_phase, phase);
|
||||
BT_WARN("%s, Prohibited transition %u -> %u", __func__, sub->kr_phase, phase);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2912,25 +2912,17 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
phase == BLE_MESH_KR_PHASE_2) {
|
||||
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
||||
sub->kr_flag = 1;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
BT_DBG("Storing kr phase persistently");
|
||||
bt_mesh_store_subnet(sub);
|
||||
}
|
||||
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
} else if ((sub->kr_phase == BLE_MESH_KR_PHASE_1 ||
|
||||
sub->kr_phase == BLE_MESH_KR_PHASE_2) &&
|
||||
phase == BLE_MESH_KR_PHASE_3) {
|
||||
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
||||
sub->kr_flag = 0;
|
||||
bt_mesh_net_revoke_keys(sub);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
||||
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||
friend_cred_refresh(ctx->net_idx);
|
||||
}
|
||||
|
||||
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
||||
sub->kr_flag = 0;
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
}
|
||||
|
||||
|
@ -3015,7 +3007,7 @@ static void hb_pub_send_status(struct bt_mesh_model *model,
|
|||
|
||||
send:
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Heartbeat Publication Status");
|
||||
BT_ERR("%s, Unable to send Config Heartbeat Publication Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3057,7 +3049,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
if (param->ttl > BLE_MESH_TTL_MAX && param->ttl != BLE_MESH_TTL_DEFAULT) {
|
||||
BT_ERR("Invalid TTL value 0x%02x", param->ttl);
|
||||
BT_ERR("%s, Invalid TTL value 0x%02x", __func__, param->ttl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3065,7 +3057,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
|
|||
|
||||
idx = sys_le16_to_cpu(param->net_idx);
|
||||
if (idx > 0xfff) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", idx);
|
||||
BT_ERR("%s, Invalid NetKeyIndex 0x%04x", __func__, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3154,7 +3146,7 @@ static void hb_sub_send_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, cfg->hb_sub.max_hops);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Config Heartbeat Subscription Status");
|
||||
BT_ERR("%s, Unable to send Config Heartbeat Subscription Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3313,8 +3305,8 @@ static void hb_publish(struct k_work *work)
|
|||
|
||||
sub = bt_mesh_subnet_get(cfg->hb_pub.net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("No matching subnet for idx 0x%04x",
|
||||
cfg->hb_pub.net_idx);
|
||||
BT_ERR("%s, No matching subnet for idx 0x%02x",
|
||||
__func__, cfg->hb_pub.net_idx);
|
||||
cfg->hb_pub.dst = BLE_MESH_ADDR_UNASSIGNED;
|
||||
return;
|
||||
}
|
||||
|
@ -3352,22 +3344,17 @@ static bool conf_is_valid(struct bt_mesh_cfg_srv *cfg)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int cfg_srv_init(struct bt_mesh_model *model)
|
||||
int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
||||
|
||||
if (!bt_mesh_model_in_primary(model)) {
|
||||
BT_ERR("Configuration Server only allowed in primary element");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!cfg) {
|
||||
BT_ERR("No Configuration Server context provided");
|
||||
BT_ERR("%s, No Configuration Server context provided", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!conf_is_valid(cfg)) {
|
||||
BT_ERR("Invalid values in configuration");
|
||||
BT_ERR("%s, Invalid values in configuration", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -3397,24 +3384,16 @@ static int cfg_srv_init(struct bt_mesh_model *model)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cfg_srv_deinit(struct bt_mesh_model *model)
|
||||
int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
||||
|
||||
if (!bt_mesh_model_in_primary(model)) {
|
||||
BT_ERR("Configuration Server only allowed in primary element");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!cfg) {
|
||||
BT_ERR("No Configuration Server context provided");
|
||||
BT_ERR("%s, No Configuration Server context provided", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Use "false" here because if cfg needs to be erased,
|
||||
* it will already be erased in the ble_mesh_deinit().
|
||||
*/
|
||||
bt_mesh_cfg_reset(false);
|
||||
bt_mesh_cfg_reset();
|
||||
|
||||
k_delayed_work_free(&cfg->hb_pub.timer);
|
||||
cfg->hb_pub.dst = BLE_MESH_ADDR_UNASSIGNED;
|
||||
|
@ -3424,15 +3403,9 @@ static int cfg_srv_deinit(struct bt_mesh_model *model)
|
|||
return 0;
|
||||
}
|
||||
|
||||
const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb = {
|
||||
.init = cfg_srv_init,
|
||||
.deinit = cfg_srv_deinit,
|
||||
};
|
||||
|
||||
static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
bool vnd, bool primary, void *user_data)
|
||||
{
|
||||
bool store = *(bool *)user_data;
|
||||
size_t clear_count = 0U;
|
||||
|
||||
/* Clear model state that isn't otherwise cleared. E.g. AppKey
|
||||
|
@ -3443,17 +3416,12 @@ static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
|||
|
||||
clear_count = mod_sub_list_clear(mod);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && clear_count && store) {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && clear_count) {
|
||||
bt_mesh_store_mod_sub(mod);
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_mod_sub_reset(bool store)
|
||||
{
|
||||
bt_mesh_model_foreach(mod_reset, &store);
|
||||
}
|
||||
|
||||
void bt_mesh_cfg_reset(bool store)
|
||||
void bt_mesh_cfg_reset(void)
|
||||
{
|
||||
struct bt_mesh_cfg_srv *cfg = conf;
|
||||
int i;
|
||||
|
@ -3477,11 +3445,11 @@ void bt_mesh_cfg_reset(bool store)
|
|||
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];
|
||||
|
||||
if (sub->net_idx != BLE_MESH_KEY_UNUSED) {
|
||||
bt_mesh_subnet_del(sub, store);
|
||||
bt_mesh_subnet_del(sub, true);
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_mod_sub_reset(store);
|
||||
bt_mesh_model_foreach(mod_reset, NULL);
|
||||
|
||||
(void)memset(labels, 0, sizeof(labels));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst)
|
||||
{
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(dst)) {
|
||||
BT_ERR("Invalid unicast address 0x%04x", dst);
|
||||
BT_ERR("%s, Not a unicast address 0x%04x", __func__, dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16])
|
|||
|
||||
err = bt_mesh_provisioner_local_net_key_add(net_key, &net_idx);
|
||||
if (err) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
BT_ERR("%s, Failed to add NetKey 0x%04x", __func__, net_idx);
|
||||
return 0x01; /* status: Add NetKey failed */
|
||||
};
|
||||
|
||||
|
@ -128,7 +128,7 @@ const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx)
|
|||
|
||||
sub = bt_mesh_fast_prov_subnet_get(net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
BT_ERR("%s, NetKey Index 0x%03x not exists", __func__, net_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx)
|
|||
|
||||
key = bt_mesh_fast_prov_app_key_find(app_idx);
|
||||
if (!key) {
|
||||
BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx);
|
||||
BT_ERR("%s, AppKey Index 0x%03x not exists", __func__, app_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ u8_t bt_mesh_set_fast_prov_action(u8_t action)
|
|||
bt_mesh_beacon_disable();
|
||||
}
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
bt_mesh_proxy_client_prov_enable();
|
||||
bt_mesh_provisioner_pb_gatt_enable();
|
||||
}
|
||||
bt_mesh_provisioner_set_primary_elem_addr(bt_mesh_primary_addr());
|
||||
bt_mesh_provisioner_set_prov_bearer(BLE_MESH_PROV_ADV, false);
|
||||
|
@ -173,7 +173,7 @@ u8_t bt_mesh_set_fast_prov_action(u8_t action)
|
|||
bt_mesh_atomic_or(bt_mesh.flags, BIT(BLE_MESH_PROVISIONER) | BIT(BLE_MESH_VALID_PROV));
|
||||
} else {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
|
||||
bt_mesh_proxy_client_prov_disable();
|
||||
bt_mesh_provisioner_pb_gatt_disable();
|
||||
}
|
||||
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) {
|
||||
bt_mesh_beacon_enable();
|
||||
|
|
|
@ -132,9 +132,19 @@ struct label {
|
|||
bt_mesh_atomic_t flags[1];
|
||||
};
|
||||
|
||||
void bt_mesh_mod_sub_reset(bool store);
|
||||
int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary);
|
||||
int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary);
|
||||
|
||||
void bt_mesh_cfg_reset(bool store);
|
||||
int bt_mesh_cfg_srv_deinit(struct bt_mesh_model *model, bool primary);
|
||||
int bt_mesh_health_srv_deinit(struct bt_mesh_model *model, bool primary);
|
||||
|
||||
int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary);
|
||||
int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary);
|
||||
|
||||
int bt_mesh_cfg_cli_deinit(struct bt_mesh_model *model, bool primary);
|
||||
int bt_mesh_health_cli_deinit(struct bt_mesh_model *model, bool primary);
|
||||
|
||||
void bt_mesh_cfg_reset(void);
|
||||
|
||||
void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat);
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
struct bt_mesh_ctl_friend_clear_confirm cfm = {0};
|
||||
|
||||
if (buf->len < sizeof(*msg)) {
|
||||
BT_WARN("Too short Friend Clear (len %d)", buf->len);
|
||||
BT_WARN("%s, Too short Friend Clear", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, lpn_addr, false, false);
|
||||
if (!frnd) {
|
||||
BT_WARN("No matching LPN addr 0x%04x", lpn_addr);
|
||||
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, lpn_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -276,8 +276,8 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
* 65536, is in the range 0 to 255 inclusive.
|
||||
*/
|
||||
if (lpn_counter - frnd->lpn_counter > 255) {
|
||||
BT_WARN("LPN Counter out of range (old %u new %u)",
|
||||
frnd->lpn_counter, lpn_counter);
|
||||
BT_WARN("%s, LPN Counter out of range (old %u new %u)",
|
||||
__func__, frnd->lpn_counter, lpn_counter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ static void friend_sub_add(struct bt_mesh_friend *frnd, u16_t addr)
|
|||
}
|
||||
}
|
||||
|
||||
BT_WARN("No space in friend subscription list");
|
||||
BT_WARN("%s, No space in friend subscription list", __func__);
|
||||
}
|
||||
|
||||
static void friend_sub_rem(struct bt_mesh_friend *frnd, u16_t addr)
|
||||
|
@ -559,10 +559,7 @@ static struct net_buf *encode_update(struct bt_mesh_friend *frnd, u8_t md)
|
|||
NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*upd));
|
||||
struct bt_mesh_subnet *sub = friend_subnet_get(frnd->net_idx);
|
||||
|
||||
if (!sub) {
|
||||
BT_ERR("Friend subnet 0x%04x not found", frnd->net_idx);
|
||||
return NULL;
|
||||
}
|
||||
__ASSERT_NO_MSG(sub != NULL);
|
||||
|
||||
BT_DBG("lpn 0x%04x md 0x%02x", frnd->lpn, md);
|
||||
|
||||
|
@ -591,7 +588,7 @@ static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, u8_t xact)
|
|||
|
||||
buf = encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_SUB_CFM, &sdu);
|
||||
if (!buf) {
|
||||
BT_ERR("Unable to encode Subscription List Confirmation");
|
||||
BT_ERR("%s, Unable to encode Subscription List Confirmation", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -622,18 +619,18 @@ int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx,
|
|||
u8_t xact = 0U;
|
||||
|
||||
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
|
||||
BT_WARN("Too short Friend Subscription Add (len %d)", buf->len);
|
||||
BT_WARN("%s, Too short Friend Subscription Add", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true);
|
||||
if (!frnd) {
|
||||
BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr);
|
||||
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (frnd->pending_buf) {
|
||||
BT_WARN("Previous buffer not yet sent!");
|
||||
BT_WARN("%s, Previous buffer not yet sent!", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -657,18 +654,18 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx,
|
|||
u8_t xact = 0U;
|
||||
|
||||
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
|
||||
BT_WARN("Too short Friend Subscription Remove (len %d)", buf->len);
|
||||
BT_WARN("%s, Too short Friend Subscription Remove", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true);
|
||||
if (!frnd) {
|
||||
BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr);
|
||||
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (frnd->pending_buf) {
|
||||
BT_WARN("Previous buffer not yet sent!");
|
||||
BT_WARN("%s, Previous buffer not yet sent!", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -697,7 +694,7 @@ static void enqueue_update(struct bt_mesh_friend *frnd, u8_t md)
|
|||
|
||||
buf = encode_update(frnd, md);
|
||||
if (!buf) {
|
||||
BT_ERR("Unable to encode Friend Update");
|
||||
BT_ERR("%s, Unable to encode Friend Update", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -711,23 +708,23 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
struct bt_mesh_friend *frnd = NULL;
|
||||
|
||||
if (buf->len < sizeof(*msg)) {
|
||||
BT_WARN("Too short Friend Poll (len %d)", buf->len);
|
||||
BT_WARN("%s, Too short Friend Poll", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false);
|
||||
if (!frnd) {
|
||||
BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr);
|
||||
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (msg->fsn & ~1) {
|
||||
BT_WARN("Prohibited (non-zero) padding bits");
|
||||
BT_WARN("%s, Prohibited (non-zero) padding bits", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (frnd->pending_buf) {
|
||||
BT_WARN("Previous buffer not yet sent!");
|
||||
BT_WARN("%s, Previous buffer not yet sent!", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -859,27 +856,27 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx,
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (buf->len < sizeof(*msg)) {
|
||||
BT_WARN("Too short Friend Clear Confirm (len %d)", buf->len);
|
||||
BT_WARN("%s, Too short Friend Clear Confirm", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
frnd = find_clear(rx->ctx.addr);
|
||||
if (!frnd) {
|
||||
BT_WARN("No pending clear procedure for 0x%02x", rx->ctx.addr);
|
||||
BT_WARN("%s, No pending clear procedure for 0x%02x", __func__, rx->ctx.addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
lpn_addr = sys_be16_to_cpu(msg->lpn_addr);
|
||||
if (lpn_addr != frnd->lpn) {
|
||||
BT_WARN("LPN address mismatch (0x%04x != 0x%04x)",
|
||||
lpn_addr, frnd->lpn);
|
||||
BT_WARN("%s, LPN address mismatch (0x%04x != 0x%04x)",
|
||||
__func__, lpn_addr, frnd->lpn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
lpn_counter = sys_be16_to_cpu(msg->lpn_counter);
|
||||
if (lpn_counter != frnd->lpn_counter) {
|
||||
BT_WARN("LPN counter mismatch (0x%04x != 0x%04x)",
|
||||
lpn_counter, frnd->lpn_counter);
|
||||
BT_WARN("%s, LPN counter mismatch (0x%04x != 0x%04x)",
|
||||
__func__, lpn_counter, frnd->lpn_counter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -909,7 +906,7 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, s8_t rssi)
|
|||
|
||||
buf = encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_OFFER, &sdu);
|
||||
if (!buf) {
|
||||
BT_ERR("Unable to encode Friend Offer");
|
||||
BT_ERR("%s, Unable to encode Friend Offer", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -967,47 +964,47 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
int i;
|
||||
|
||||
if (buf->len < sizeof(*msg)) {
|
||||
BT_WARN("Too short Friend Request (len %d)", buf->len);
|
||||
BT_WARN("%s, Too short Friend Request", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msg->recv_delay <= 0x09) {
|
||||
BT_WARN("Prohibited ReceiveDelay (0x%02x)", msg->recv_delay);
|
||||
BT_WARN("%s, Prohibited ReceiveDelay (0x%02x)", __func__, msg->recv_delay);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
poll_to = sys_get_be24(msg->poll_to);
|
||||
|
||||
if (poll_to <= 0x000009 || poll_to >= 0x34bc00) {
|
||||
BT_WARN("Prohibited PollTimeout (0x%06x)", poll_to);
|
||||
BT_WARN("%s, Prohibited PollTimeout (0x%06x)", __func__, poll_to);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msg->num_elem == 0x00) {
|
||||
BT_WARN("Prohibited NumElements value (0x00)");
|
||||
BT_WARN("%s, Prohibited NumElements value (0x00)", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(rx->ctx.addr + msg->num_elem - 1)) {
|
||||
BT_WARN("LPN elements stretch outside of unicast range");
|
||||
BT_WARN("%s, LPN elements stretch outside of unicast range", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!MIN_QUEUE_SIZE_LOG(msg->criteria)) {
|
||||
BT_WARN("Prohibited Minimum Queue Size in Friend Request");
|
||||
BT_WARN("%s, Prohibited Minimum Queue Size in Friend Request", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE < MIN_QUEUE_SIZE(msg->criteria)) {
|
||||
BT_WARN("We have a too small Friend Queue size (%u < %u)",
|
||||
CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE,
|
||||
BT_WARN("%s, We have a too small Friend Queue size (%u < %u)",
|
||||
__func__, CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE,
|
||||
MIN_QUEUE_SIZE(msg->criteria));
|
||||
return 0;
|
||||
}
|
||||
|
||||
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false);
|
||||
if (frnd) {
|
||||
BT_WARN("Existing LPN re-requesting Friendship");
|
||||
BT_WARN("%s, Existing LPN re-requesting Friendship", __func__);
|
||||
friend_clear(frnd, BLE_MESH_FRIENDSHIP_TERMINATE_RECV_FRND_REQ);
|
||||
goto init_friend;
|
||||
}
|
||||
|
@ -1021,7 +1018,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
|||
}
|
||||
|
||||
if (!frnd) {
|
||||
BT_WARN("No free Friend contexts for new LPN");
|
||||
BT_WARN("%s, No free Friend contexts for new LPN", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -1197,10 +1194,7 @@ static void friend_timeout(struct k_work *work)
|
|||
.end = buf_send_end,
|
||||
};
|
||||
|
||||
if (frnd->pending_buf != 0U) {
|
||||
BT_ERR("Previous buffer not yet sent!");
|
||||
return;
|
||||
}
|
||||
__ASSERT_NO_MSG(frnd->pending_buf == 0U);
|
||||
|
||||
BT_DBG("lpn 0x%04x send_last %u last %p", frnd->lpn,
|
||||
frnd->send_last, frnd->last);
|
||||
|
@ -1212,14 +1206,14 @@ static void friend_timeout(struct k_work *work)
|
|||
}
|
||||
|
||||
if (frnd->established && !frnd->pending_req) {
|
||||
BT_WARN("Friendship lost with 0x%04x", frnd->lpn);
|
||||
BT_WARN("%s, Friendship lost with 0x%04x", __func__, frnd->lpn);
|
||||
friend_clear(frnd, BLE_MESH_FRIENDSHIP_TERMINATE_POLL_TIMEOUT);
|
||||
return;
|
||||
}
|
||||
|
||||
frnd->last = (void *)sys_slist_get(&frnd->queue);
|
||||
if (!frnd->last) {
|
||||
BT_WARN("Friendship not established with 0x%04x", frnd->lpn);
|
||||
BT_WARN("%s, Friendship not established with 0x%04x", __func__, frnd->lpn);
|
||||
friend_clear(frnd, BLE_MESH_FRIENDSHIP_TERMINATE_ESTABLISH_FAIL);
|
||||
return;
|
||||
}
|
||||
|
@ -1406,7 +1400,7 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd,
|
|||
|
||||
buf = create_friend_pdu(frnd, &info, sbuf);
|
||||
if (!buf) {
|
||||
BT_ERR("Failed to encode Friend buffer");
|
||||
BT_ERR("%s, Failed to encode Friend buffer", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1443,7 +1437,7 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd,
|
|||
|
||||
buf = create_friend_pdu(frnd, &info, sbuf);
|
||||
if (!buf) {
|
||||
BT_ERR("Failed to encode Friend buffer");
|
||||
BT_ERR("%s, Failed to encode Friend buffer", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1701,7 +1695,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src,
|
|||
continue;
|
||||
}
|
||||
|
||||
BT_WARN("Clearing incomplete segments for 0x%04x", src);
|
||||
BT_WARN("%s, Clearing incomplete segments for 0x%04x", __func__, src);
|
||||
|
||||
purge_buffers(&seg->queue);
|
||||
seg->seg_count = 0U;
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
#include "mesh_common.h"
|
||||
#include "health_cli.h"
|
||||
|
||||
s32_t health_msg_timeout;
|
||||
|
||||
static bt_mesh_health_client_t *health_cli;
|
||||
|
||||
static const bt_mesh_client_op_pair_t health_op_pair[] = {
|
||||
{ OP_HEALTH_FAULT_GET, OP_HEALTH_FAULT_STATUS },
|
||||
{ OP_HEALTH_FAULT_CLEAR, OP_HEALTH_FAULT_STATUS },
|
||||
|
@ -81,7 +85,7 @@ static void timeout_handler(struct k_work *work)
|
|||
return;
|
||||
}
|
||||
|
||||
static void health_client_recv_status(struct bt_mesh_model *model,
|
||||
static void health_client_cancel(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
void *status, size_t len)
|
||||
{
|
||||
|
@ -102,7 +106,7 @@ static void health_client_recv_status(struct bt_mesh_model *model,
|
|||
|
||||
node = bt_mesh_is_client_recv_publish_msg(model, ctx, &buf, true);
|
||||
if (!node) {
|
||||
BT_DBG("Unexpected Health Status 0x%04x", ctx->recv_op);
|
||||
BT_DBG("Unexpected health status message 0x%x", ctx->recv_op);
|
||||
} else {
|
||||
switch (node->opcode) {
|
||||
case OP_HEALTH_FAULT_GET:
|
||||
|
@ -132,12 +136,8 @@ static void health_client_recv_status(struct bt_mesh_model *model,
|
|||
|
||||
switch (ctx->recv_op) {
|
||||
case OP_HEALTH_FAULT_STATUS: {
|
||||
struct bt_mesh_health_fault_status *val = status;
|
||||
bt_mesh_free_buf(val->fault_array);
|
||||
break;
|
||||
}
|
||||
case OP_HEALTH_CURRENT_STATUS: {
|
||||
struct bt_mesh_health_current_status *val = status;
|
||||
struct bt_mesh_health_fault_status *val;
|
||||
val = (struct bt_mesh_health_fault_status *)status;
|
||||
bt_mesh_free_buf(val->fault_array);
|
||||
break;
|
||||
}
|
||||
|
@ -160,36 +160,40 @@ static void health_fault_status(struct bt_mesh_model *model,
|
|||
status.cid = net_buf_simple_pull_le16(buf);
|
||||
status.fault_array = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status.fault_array) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
net_buf_simple_add_mem(status.fault_array, buf->data, buf->len);
|
||||
|
||||
health_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_health_fault_status));
|
||||
health_client_cancel(model, ctx, &status, sizeof(struct bt_mesh_health_fault_status));
|
||||
}
|
||||
|
||||
static void health_current_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_health_current_status status = {0};
|
||||
bt_mesh_client_node_t *node = NULL;
|
||||
u8_t test_id = 0U;
|
||||
u16_t cid = 0U;
|
||||
|
||||
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
||||
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
||||
bt_hex(buf->data, buf->len));
|
||||
|
||||
status.test_id = net_buf_simple_pull_u8(buf);
|
||||
status.cid = net_buf_simple_pull_le16(buf);
|
||||
status.fault_array = bt_mesh_alloc_buf(buf->len);
|
||||
if (!status.fault_array) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
/* Health current status is a publish message, sent to the user directly. */
|
||||
if (!(node = bt_mesh_is_client_recv_publish_msg(model, ctx, buf, true))) {
|
||||
return;
|
||||
}
|
||||
|
||||
net_buf_simple_add_mem(status.fault_array, buf->data, buf->len);
|
||||
test_id = net_buf_simple_pull_u8(buf);
|
||||
cid = net_buf_simple_pull_le16(buf);
|
||||
|
||||
health_client_recv_status(model, ctx, &status, sizeof(struct bt_mesh_health_current_status));
|
||||
BT_DBG("Test ID 0x%02x Company ID 0x%04x Fault Count %u",
|
||||
test_id, cid, buf->len);
|
||||
|
||||
((void) test_id);
|
||||
((void) cid);
|
||||
}
|
||||
|
||||
static void health_period_status(struct bt_mesh_model *model,
|
||||
|
@ -204,7 +208,7 @@ static void health_period_status(struct bt_mesh_model *model,
|
|||
|
||||
status = net_buf_simple_pull_u8(buf);
|
||||
|
||||
health_client_recv_status(model, ctx, &status, sizeof(u8_t));
|
||||
health_client_cancel(model, ctx, &status, sizeof(u8_t));
|
||||
}
|
||||
|
||||
static void health_attention_status(struct bt_mesh_model *model,
|
||||
|
@ -219,7 +223,7 @@ static void health_attention_status(struct bt_mesh_model *model,
|
|||
|
||||
status = net_buf_simple_pull_u8(buf);
|
||||
|
||||
health_client_recv_status(model, ctx, &status, sizeof(u8_t));
|
||||
health_client_cancel(model, ctx, &status, sizeof(u8_t));
|
||||
}
|
||||
|
||||
const struct bt_mesh_model_op bt_mesh_health_cli_op[] = {
|
||||
|
@ -230,101 +234,231 @@ const struct bt_mesh_model_op bt_mesh_health_cli_op[] = {
|
|||
BLE_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param)
|
||||
int bt_mesh_health_attention_get(struct bt_mesh_msg_ctx *ctx)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_GET, 0);
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_model_msg_init(&msg, OP_ATTENTION_GET);
|
||||
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
err = bt_mesh_client_send_msg(health_cli->model, OP_ATTENTION_GET, ctx,
|
||||
&msg, timeout_handler, health_msg_timeout,
|
||||
true, NULL, NULL);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
|
||||
int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param,
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx,
|
||||
u8_t attention, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_SET, 1);
|
||||
u32_t opcode = 0U;
|
||||
int err = 0;
|
||||
|
||||
bt_mesh_model_msg_init(&msg, need_ack ? OP_ATTENTION_SET : OP_ATTENTION_SET_UNREL);
|
||||
net_buf_simple_add_u8(&msg, attention);
|
||||
|
||||
return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler);
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param)
|
||||
if (need_ack) {
|
||||
opcode = OP_ATTENTION_SET;
|
||||
} else {
|
||||
opcode = OP_ATTENTION_SET_UNREL;
|
||||
}
|
||||
bt_mesh_model_msg_init(&msg, opcode);
|
||||
net_buf_simple_add_u8(&msg, attention);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, opcode, ctx, &msg,
|
||||
timeout_handler, health_msg_timeout,
|
||||
need_ack, NULL, NULL);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_period_get(struct bt_mesh_msg_ctx *ctx)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_PERIOD_GET, 0);
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_model_msg_init(&msg, OP_HEALTH_PERIOD_GET);
|
||||
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
err = bt_mesh_client_send_msg(health_cli->model, OP_HEALTH_PERIOD_GET,
|
||||
ctx, &msg, timeout_handler, health_msg_timeout,
|
||||
true, NULL, NULL);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
|
||||
int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param,
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_period_set(struct bt_mesh_msg_ctx *ctx,
|
||||
u8_t divisor, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_PERIOD_SET, 1);
|
||||
u32_t opcode = 0U;
|
||||
int err = 0;
|
||||
|
||||
bt_mesh_model_msg_init(&msg, need_ack ? OP_HEALTH_PERIOD_SET : OP_HEALTH_PERIOD_SET_UNREL);
|
||||
net_buf_simple_add_u8(&msg, divisor);
|
||||
|
||||
return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler);
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param,
|
||||
if (need_ack) {
|
||||
opcode = OP_HEALTH_PERIOD_SET;
|
||||
} else {
|
||||
opcode = OP_HEALTH_PERIOD_SET_UNREL;
|
||||
}
|
||||
bt_mesh_model_msg_init(&msg, opcode);
|
||||
net_buf_simple_add_u8(&msg, divisor);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, opcode, ctx, &msg,
|
||||
timeout_handler, health_msg_timeout,
|
||||
need_ack, NULL, NULL);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_test(struct bt_mesh_msg_ctx *ctx,
|
||||
u16_t cid, u8_t test_id, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_TEST, 3);
|
||||
u32_t opcode = 0U;
|
||||
int err = 0;
|
||||
|
||||
bt_mesh_model_msg_init(&msg, need_ack ? OP_HEALTH_FAULT_TEST : OP_HEALTH_FAULT_TEST_UNREL);
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (need_ack) {
|
||||
opcode = OP_HEALTH_FAULT_TEST;
|
||||
} else {
|
||||
opcode = OP_HEALTH_FAULT_TEST_UNREL;
|
||||
}
|
||||
bt_mesh_model_msg_init(&msg, opcode);
|
||||
net_buf_simple_add_u8(&msg, test_id);
|
||||
net_buf_simple_add_le16(&msg, cid);
|
||||
|
||||
return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler);
|
||||
err = bt_mesh_client_send_msg(health_cli->model, opcode, ctx, &msg,
|
||||
timeout_handler, health_msg_timeout,
|
||||
need_ack, NULL, NULL);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param,
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx,
|
||||
u16_t cid, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_CLEAR, 2);
|
||||
u32_t opcode = 0U;
|
||||
int err = 0;
|
||||
|
||||
bt_mesh_model_msg_init(&msg, need_ack ? OP_HEALTH_FAULT_CLEAR : OP_HEALTH_FAULT_CLEAR_UNREL);
|
||||
net_buf_simple_add_le16(&msg, cid);
|
||||
|
||||
return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler);
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid)
|
||||
if (need_ack) {
|
||||
opcode = OP_HEALTH_FAULT_CLEAR;
|
||||
} else {
|
||||
opcode = OP_HEALTH_FAULT_CLEAR_UNREL;
|
||||
}
|
||||
bt_mesh_model_msg_init(&msg, opcode);
|
||||
net_buf_simple_add_le16(&msg, cid);
|
||||
|
||||
err = bt_mesh_client_send_msg(health_cli->model, opcode, ctx, &msg,
|
||||
timeout_handler, health_msg_timeout,
|
||||
need_ack, NULL, NULL);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_get(struct bt_mesh_msg_ctx *ctx, u16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_GET, 2);
|
||||
int err = 0;
|
||||
|
||||
if (!ctx || !ctx->addr) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_model_msg_init(&msg, OP_HEALTH_FAULT_GET);
|
||||
net_buf_simple_add_le16(&msg, cid);
|
||||
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
err = bt_mesh_client_send_msg(health_cli->model, OP_HEALTH_FAULT_GET, ctx,
|
||||
&msg, timeout_handler, health_msg_timeout,
|
||||
true, NULL, NULL);
|
||||
if (err) {
|
||||
BT_ERR("%s, send failed (err %d)", __func__, err);
|
||||
}
|
||||
|
||||
static int health_cli_init(struct bt_mesh_model *model)
|
||||
return err;
|
||||
}
|
||||
|
||||
s32_t bt_mesh_health_cli_timeout_get(void)
|
||||
{
|
||||
return health_msg_timeout;
|
||||
}
|
||||
|
||||
void bt_mesh_health_cli_timeout_set(s32_t timeout)
|
||||
{
|
||||
health_msg_timeout = timeout;
|
||||
}
|
||||
|
||||
int bt_mesh_health_cli_set(struct bt_mesh_model *model)
|
||||
{
|
||||
if (!model || !model->user_data) {
|
||||
BT_ERR("%s, No Health Client context for given model", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
health_cli = model->user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
health_internal_data_t *internal = NULL;
|
||||
bt_mesh_health_client_t *client = NULL;
|
||||
|
||||
BT_DBG("primary %u", primary);
|
||||
|
||||
if (!model) {
|
||||
BT_ERR("Invalid Health Client model");
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
BT_DBG("primary %u", bt_mesh_model_in_primary(model));
|
||||
|
||||
client = (bt_mesh_health_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("No Health Client context provided");
|
||||
BT_ERR("%s, No Health Client context provided", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!client->internal_data) {
|
||||
internal = bt_mesh_calloc(sizeof(health_internal_data_t));
|
||||
if (!internal) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -340,23 +474,26 @@ static int health_cli_init(struct bt_mesh_model *model)
|
|||
|
||||
bt_mesh_health_client_mutex_new();
|
||||
|
||||
/* Set the default health client pointer */
|
||||
if (!health_cli) {
|
||||
health_cli = client;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int health_cli_deinit(struct bt_mesh_model *model)
|
||||
int bt_mesh_health_cli_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
bt_mesh_health_client_t *client = NULL;
|
||||
|
||||
if (!model) {
|
||||
BT_ERR("Invalid Health Client model");
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
BT_DBG("primary %u", bt_mesh_model_in_primary(model));
|
||||
|
||||
client = (bt_mesh_health_client_t *)model->user_data;
|
||||
if (!client) {
|
||||
BT_ERR("No Health Client context provided");
|
||||
BT_ERR("%s, No Health Client context provided", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -371,10 +508,9 @@ static int health_cli_deinit(struct bt_mesh_model *model)
|
|||
|
||||
bt_mesh_health_client_mutex_free();
|
||||
|
||||
return 0;
|
||||
if (health_cli) {
|
||||
health_cli = NULL;
|
||||
}
|
||||
|
||||
const struct bt_mesh_model_cb bt_mesh_health_cli_cb = {
|
||||
.init = health_cli_init,
|
||||
.deinit = health_cli_deinit,
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ static int health_send_fault_status(struct bt_mesh_model *model,
|
|||
|
||||
msg = bt_mesh_alloc_buf(4 + ARRAY_SIZE(srv->test.reg_faults) + 4);
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
BT_ERR("%s, Failed to allocate memory", __func__);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ static int health_send_fault_status(struct bt_mesh_model *model,
|
|||
|
||||
err = bt_mesh_model_send(model, ctx, msg, NULL, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to send Health Fault Status response");
|
||||
BT_ERR("%s, Failed to send Health Fault Status response", __func__);
|
||||
}
|
||||
|
||||
bt_mesh_free_buf(msg);
|
||||
|
@ -128,13 +128,13 @@ static void health_fault_get(struct bt_mesh_model *model,
|
|||
u16_t company_id = 0U;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
company_id = net_buf_simple_pull_le16(buf);
|
||||
if (company_id != srv->test.company_id) {
|
||||
BT_ERR("Unknown Company ID 0x%04x", company_id);
|
||||
BT_ERR("%s, Unknown Company ID 0x%04x", __func__, company_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -151,13 +151,13 @@ static void health_fault_clear(struct bt_mesh_model *model,
|
|||
u16_t company_id = 0U;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
company_id = net_buf_simple_pull_le16(buf);
|
||||
if (company_id != srv->test.company_id) {
|
||||
BT_ERR("Unknown Company ID 0x%04x", company_id);
|
||||
BT_ERR("%s, Unknown Company ID 0x%04x", __func__, company_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,19 +185,19 @@ static void health_fault_test(struct bt_mesh_model *model,
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
test_id = net_buf_simple_pull_u8(buf);
|
||||
if (health_is_test_id_exist(model, test_id) == false) {
|
||||
BT_ERR("Unknown Test ID 0x%02x", test_id);
|
||||
BT_ERR("%s, Unknown Test ID 0x%02x", __func__, test_id);
|
||||
return;
|
||||
}
|
||||
|
||||
company_id = net_buf_simple_pull_le16(buf);
|
||||
if (company_id != srv->test.company_id) {
|
||||
BT_ERR("Unknown Company ID 0x%04x", company_id);
|
||||
BT_ERR("%s, Unknown Company ID 0x%04x", __func__, company_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ static void send_attention_status(struct bt_mesh_model *model,
|
|||
u8_t time = 0U;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ static void send_attention_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, time);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Health Attention Status");
|
||||
BT_ERR("%s, Unable to send Health Attention Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ static void send_health_period_status(struct bt_mesh_model *model,
|
|||
net_buf_simple_add_u8(&msg, model->pub->period_div);
|
||||
|
||||
if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) {
|
||||
BT_ERR("Unable to send Health Period Status");
|
||||
BT_ERR("%s, Unable to send Health Period Status", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ static void health_set_period(struct bt_mesh_model *model,
|
|||
|
||||
period = net_buf_simple_pull_u8(buf);
|
||||
if (period > 15) {
|
||||
BT_WARN("Prohibited period value %u", period);
|
||||
BT_WARN("%s, Prohibited period value %u", __func__, period);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -345,12 +345,12 @@ static size_t health_get_current(struct bt_mesh_model *model,
|
|||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (msg->size < 4) {
|
||||
BT_ERR("Too small health publication msg size %d", msg->size);
|
||||
BT_ERR("%s, Too small health publication msg size %d", __func__, msg->size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ static int health_pub_update(struct bt_mesh_model *model)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!pub || !pub->msg) {
|
||||
BT_ERR("Invalid health publication context");
|
||||
BT_ERR("%s, Invalid health publication context", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -390,12 +390,12 @@ int bt_mesh_fault_update(struct bt_mesh_elem *elem)
|
|||
|
||||
model = bt_mesh_model_find(elem, BLE_MESH_MODEL_ID_HEALTH_SRV);
|
||||
if (!model) {
|
||||
BT_ERR("Health Server not exists");
|
||||
BT_ERR("%s, Health Server does not exist", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!model->pub) {
|
||||
BT_ERR("Health Server has no publication support");
|
||||
BT_ERR("%s, Health Server has no publication support", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ static void attention_off(struct k_work *work)
|
|||
BT_DBG("%s", __func__);
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,7 @@ static void attention_off(struct k_work *work)
|
|||
srv->attn_timer_start = false;
|
||||
}
|
||||
|
||||
static int health_srv_init(struct bt_mesh_model *model)
|
||||
int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
|
||||
|
@ -438,17 +438,22 @@ static int health_srv_init(struct bt_mesh_model *model)
|
|||
*/
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
if (!primary) {
|
||||
/* If Health Server is in the secondary element with NULL user_data. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (srv->test.id_count == 0 || !srv->test.test_ids) {
|
||||
BT_ERR("No Health Test ID provided");
|
||||
BT_ERR("%s, No Health Test ID provided", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!model->pub) {
|
||||
BT_ERR("Health Server has no publication support");
|
||||
BT_ERR("%s, Health Server has no publication support", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -462,29 +467,34 @@ static int health_srv_init(struct bt_mesh_model *model)
|
|||
memset(srv->test.curr_faults, HEALTH_NO_FAULT, ARRAY_SIZE(srv->test.curr_faults));
|
||||
memset(srv->test.reg_faults, HEALTH_NO_FAULT, ARRAY_SIZE(srv->test.reg_faults));
|
||||
|
||||
if (bt_mesh_model_in_primary(model)) {
|
||||
if (primary) {
|
||||
health_srv = srv;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int health_srv_deinit(struct bt_mesh_model *model)
|
||||
int bt_mesh_health_srv_deinit(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
if (!primary) {
|
||||
/* If Health Server is in the secondary element with NULL user_data. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
BT_ERR("%s, No Health Server context provided", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (srv->test.id_count == 0 || !srv->test.test_ids) {
|
||||
BT_ERR("No Health Test ID provided");
|
||||
BT_ERR("%s, No Health Test ID provided", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!model->pub) {
|
||||
BT_ERR("Health Server has no publication support");
|
||||
BT_ERR("%s, Health Server has no publication support", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -493,18 +503,13 @@ static int health_srv_deinit(struct bt_mesh_model *model)
|
|||
|
||||
k_delayed_work_free(&srv->attn_timer);
|
||||
|
||||
if (bt_mesh_model_in_primary(model)) {
|
||||
if (primary) {
|
||||
health_srv = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct bt_mesh_model_cb bt_mesh_health_srv_cb = {
|
||||
.init = health_srv_init,
|
||||
.deinit = health_srv_deinit,
|
||||
};
|
||||
|
||||
void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = NULL;
|
||||
|
@ -512,7 +517,7 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
|
|||
if (!model) {
|
||||
srv = health_srv;
|
||||
if (!srv) {
|
||||
BT_WARN("No Health Server context provided");
|
||||
BT_WARN("%s, No Health Server context provided", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -520,7 +525,7 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
|
|||
} else {
|
||||
srv = model->user_data;
|
||||
if (!srv) {
|
||||
BT_WARN("No Health Server context provided");
|
||||
BT_WARN("%s, No Health Server context provided", __func__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,45 +29,41 @@ typedef bt_mesh_client_user_data_t bt_mesh_config_client_t;
|
|||
typedef bt_mesh_client_internal_data_t config_internal_data_t;
|
||||
|
||||
extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb;
|
||||
|
||||
#define BLE_MESH_MODEL_CFG_CLI(cli_data) \
|
||||
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_CLI, \
|
||||
bt_mesh_cfg_cli_op, NULL, cli_data, &bt_mesh_cfg_cli_cb)
|
||||
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_CFG_CLI, \
|
||||
bt_mesh_cfg_cli_op, NULL, cli_data)
|
||||
|
||||
int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, u8_t page);
|
||||
int bt_mesh_cfg_comp_data_get(struct bt_mesh_msg_ctx *ctx, u8_t page);
|
||||
|
||||
int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param);
|
||||
int bt_mesh_cfg_beacon_get(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
int bt_mesh_cfg_beacon_set(struct bt_mesh_msg_ctx *ctx, u8_t val);
|
||||
|
||||
int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param);
|
||||
int bt_mesh_cfg_ttl_get(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
int bt_mesh_cfg_ttl_set(struct bt_mesh_msg_ctx *ctx, u8_t val);
|
||||
|
||||
int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param);
|
||||
int bt_mesh_cfg_friend_get(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
int bt_mesh_cfg_friend_set(struct bt_mesh_msg_ctx *ctx, u8_t val);
|
||||
|
||||
int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param);
|
||||
int bt_mesh_cfg_gatt_proxy_get(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
int bt_mesh_cfg_gatt_proxy_set(struct bt_mesh_msg_ctx *ctx, u8_t val);
|
||||
|
||||
int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param);
|
||||
int bt_mesh_cfg_relay_get(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t relay, u8_t retransmit);
|
||||
int bt_mesh_cfg_relay_set(struct bt_mesh_msg_ctx *ctx, u8_t new_relay, u8_t new_transmit);
|
||||
|
||||
int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, const u8_t net_key[16]);
|
||||
int bt_mesh_cfg_net_key_add(struct bt_mesh_msg_ctx *ctx, u16_t key_net_idx,
|
||||
const u8_t net_key[16]);
|
||||
|
||||
int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx,
|
||||
const u8_t app_key[16]);
|
||||
int bt_mesh_cfg_app_key_add(struct bt_mesh_msg_ctx *ctx, u16_t key_net_idx,
|
||||
u16_t key_app_idx, const u8_t app_key[16]);
|
||||
|
||||
int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t app_idx,
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_app_bind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_app_idx, u16_t mod_id, u16_t cid);
|
||||
|
||||
struct bt_mesh_cfg_mod_pub {
|
||||
u16_t addr;
|
||||
|
@ -78,36 +74,30 @@ struct bt_mesh_cfg_mod_pub {
|
|||
u8_t transmit;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_pub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_pub_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid,
|
||||
int bt_mesh_cfg_mod_pub_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid,
|
||||
struct bt_mesh_cfg_mod_pub *pub);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_add(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t sub_addr, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_del(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_del(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t sub_addr, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_overwrite(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_overwrite(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t sub_addr, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_va_add(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
const u8_t label[16], u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_del(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_va_del(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
const u8_t label[16], u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_overwrite(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_va_overwrite(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
const u8_t label[16], u16_t mod_id, u16_t cid);
|
||||
|
||||
struct bt_mesh_cfg_hb_sub {
|
||||
u16_t src;
|
||||
|
@ -115,10 +105,10 @@ struct bt_mesh_cfg_hb_sub {
|
|||
u8_t period;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param,
|
||||
int bt_mesh_cfg_hb_sub_set(struct bt_mesh_msg_ctx *ctx,
|
||||
struct bt_mesh_cfg_hb_sub *sub);
|
||||
|
||||
int bt_mesh_cfg_hb_sub_get(bt_mesh_client_common_param_t *param);
|
||||
int bt_mesh_cfg_hb_sub_get(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
struct bt_mesh_cfg_hb_pub {
|
||||
u16_t dst;
|
||||
|
@ -129,12 +119,15 @@ struct bt_mesh_cfg_hb_pub {
|
|||
u16_t net_idx;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_hb_pub_set(bt_mesh_client_common_param_t *param,
|
||||
struct bt_mesh_cfg_hb_pub *pub);
|
||||
int bt_mesh_cfg_hb_pub_set(struct bt_mesh_msg_ctx *ctx,
|
||||
const struct bt_mesh_cfg_hb_pub *pub);
|
||||
|
||||
int bt_mesh_cfg_hb_pub_get(bt_mesh_client_common_param_t *param);
|
||||
int bt_mesh_cfg_hb_pub_get(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param);
|
||||
int bt_mesh_cfg_node_reset(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
s32_t bt_mesh_cfg_cli_timeout_get(void);
|
||||
void bt_mesh_cfg_cli_timeout_set(s32_t timeout);
|
||||
|
||||
/* Configuration Client Status Message Context */
|
||||
|
||||
|
@ -251,61 +244,53 @@ struct bt_mesh_cfg_lpn_pollto_status {
|
|||
s32_t timeout;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id,
|
||||
u16_t cid, const u8_t label[16],
|
||||
int bt_mesh_cfg_mod_pub_va_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid, const u8_t label[16],
|
||||
struct bt_mesh_cfg_mod_pub *pub);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, const u8_t net_key[16]);
|
||||
|
||||
int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx,
|
||||
const u8_t app_key[16]);
|
||||
|
||||
int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx);
|
||||
|
||||
int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u8_t identity);
|
||||
|
||||
int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t app_idx,
|
||||
int bt_mesh_cfg_mod_sub_del_all(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_app_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id);
|
||||
int bt_mesh_cfg_mod_sub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, u16_t mod_id);
|
||||
|
||||
int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
int bt_mesh_cfg_mod_sub_get_vnd(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
int bt_mesh_cfg_net_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
|
||||
const u8_t net_key[16]);
|
||||
|
||||
int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u8_t transition);
|
||||
int bt_mesh_cfg_net_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, u16_t lpn_addr);
|
||||
int bt_mesh_cfg_net_key_get(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param);
|
||||
int bt_mesh_cfg_app_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
|
||||
u16_t app_idx, const u8_t app_key[16]);
|
||||
|
||||
int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, u8_t transmit);
|
||||
int bt_mesh_cfg_app_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u16_t app_idx);
|
||||
|
||||
int bt_mesh_cfg_app_key_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_node_identity_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_node_identity_set(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u8_t identity);
|
||||
|
||||
int bt_mesh_cfg_mod_app_unbind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t app_idx, u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_app_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, u16_t mod_id);
|
||||
|
||||
int bt_mesh_cfg_mod_app_get_vnd(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
|
||||
int bt_mesh_cfg_kr_phase_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_kr_phase_set(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u8_t transition);
|
||||
|
||||
int bt_mesh_cfg_lpn_timeout_get(struct bt_mesh_msg_ctx *ctx, u16_t lpn_addr);
|
||||
|
||||
int bt_mesh_cfg_net_transmit_get(struct bt_mesh_msg_ctx *ctx);
|
||||
|
||||
int bt_mesh_cfg_net_transmit_set(struct bt_mesh_msg_ctx *ctx, u8_t transmit);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue